Skip to content

Commit

Permalink
Merge pull request #92 from UjjwalSaini07/Minor_Enhancement
Browse files Browse the repository at this point in the history
Finalize the Subscription Section
  • Loading branch information
UjjwalSaini07 authored Oct 16, 2024
2 parents ceda3d4 + fe0ff95 commit b14c626
Show file tree
Hide file tree
Showing 14 changed files with 374 additions and 222 deletions.
79 changes: 79 additions & 0 deletions Backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"author": "Ujjwal Saini",
"license": "ISC",
"dependencies": {
"axios": "^1.7.7",
"body-parser": "^1.20.3",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
Expand Down
97 changes: 66 additions & 31 deletions Backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,50 @@ const express = require('express');
const nodemailer = require('nodemailer');
const cors = require('cors');
const bodyParser = require('body-parser');
require("dotenv").config()
const axios = require('axios'); // Import axios for external requests
require("dotenv").config();

const app = express();
const PORT = 5000; // You can change the port if needed
const PORT = 5000;

app.use(cors());
app.use(bodyParser.json());

// Set up Nodemailer transporter
// Set up Nodemailer
const transporter = nodemailer.createTransport({
service: 'gmail', // You can use another service like SendGrid or SMTP
service: 'gmail',
auth: {
user: process.env.EMAIL_USER,
user: process.env.EMAIL_USER,
pass: process.env.EMAIL_PASS,
},
});

// GET route for /send-email to avoid "Cannot GET" error in the browser
app.get('/send-email', (req, res) => {
res.send('Email API is running. Use POST /send-email to send an email.');
});
// Email sending endpoint
res.send('Email API is running. Use POST /send-email to send an email.');
});

// Email endpoint -1
app.post('/send-email', (req, res) => {
const { email } = req.body;

if (!email) {
return res.status(400).json({ success: false, message: 'Email is required' });
}

const mailOptions = {
from: '[email protected]', // Your email
to: email,
subject: 'Congratulations! You’ve Successfully Subscribed to Daily Bhagavad Gita Shlokas!',
text: `You have successfully subscribed to daily Bhagavad Gita Shlokas! Congratulations! 🎉
Get ready to dive deep into the profound wisdom and teachings of the Bhagavad Gita. Each day, you will receive a meaningful Shloka delivered straight to your inbox. These sacred verses will guide you on a spiritual journey, offering insights into life, duty, and inner peace.
Enjoy the daily dose of timeless philosophy and find inspiration from the divine teachings of Lord Krishna. 🌿
We are excited to have you with us on this path of spiritual growth!`
const mailOptions = {
from: '[email protected]',
to: email,
subject: 'Congratulations! You’ve Successfully Subscribed to Daily Bhagavad Gita Shlokas!',
text: `🎉 Hurray! You've officially subscribed to daily Bhagavad Gita Shlokas! 🌟✨
Get ready to dive deep into the profound wisdom and teachings of the Bhagavad Gita. Each day, you will receive a meaningful Shloka delivered straight to your inbox. These sacred verses will guide you on a spiritual journey, offering insights into life, duty, and inner peace.
Enjoy the daily dose of timeless philosophy and find inspiration from the divine teachings of Lord Krishna. 🌿
We are excited to have you with us on this path of spiritual growth!`,
};

transporter.sendMail(mailOptions, (error, info) => {
if (error) {
console.error('Error sending email:', error);
Expand All @@ -55,19 +56,48 @@ We are excited to have you with us on this path of spiritual growth!`
});
});

// New route to handle Google Apps Script API endpoint -2
app.post('/submit-to-google', async (req, res) => {
const { email } = req.body;

if (!email) {
return res.status(400).json({ success: false, message: 'Email is required' });
}

try {
const googleFormData = new URLSearchParams();
googleFormData.append('email', email);

const googleApiResponse = await axios.post('https://script.google.com/macros/s/AKfycbxBtwPmMCVNgydtEF3GWwgKQUC0R3Fmzn9k5ecg5OC8Nj5IOll6OKvYACixwhDwVizN/exec', googleFormData, {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});

if (googleApiResponse.status !== 200) {
console.error("Google API Error: ", googleApiResponse.data);
return res.status(500).json({ success: false, message: 'Failed to submit to Google API' });
}

res.status(200).json({ success: true, message: googleApiResponse.data.message });
} catch (error) {
console.error("Error submitting to Google API:", error);
res.status(500).json({ success: false, message: 'Google API request failed' });
}
});

// Start the server
app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`);
});

export default app;
module.exports = app;


// TOdo: Basic Code with only post request not having Get Request
// Todo: Code without Google API - Previous Vercel Prod
// const express = require('express');
// const nodemailer = require('nodemailer');
// const cors = require('cors');
// const bodyParser = require('body-parser');
// require("dotenv").config()

// const app = express();
// const PORT = 5000; // You can change the port if needed
Expand All @@ -79,21 +109,23 @@ export default app;
// const transporter = nodemailer.createTransport({
// service: 'gmail', // You can use another service like SendGrid or SMTP
// auth: {
// user: '[email protected]',
// pass: 'pnot bnpc cfwp wnyx',
// user: process.env.EMAIL_USER,
// pass: process.env.EMAIL_PASS,
// },
// });

// // GET route for /send-email to avoid "Cannot GET" error in the browser
// app.get('/send-email', (req, res) => {
// res.send('Email API is running. Use POST /send-email to send an email.');
// });

// // Email sending endpoint
// app.post('/send-email', (req, res) => {
// const { email } = req.body;

// // const mailOptions = {
// // from: '[email protected]', // Your email
// // to: email,
// // // subject: 'Subscription Confirmation',
// // text: '',
// // };
// if (!email) {
// return res.status(400).json({ success: false, message: 'Email is required' });
// }

// const mailOptions = {
// from: '[email protected]', // Your email
Expand All @@ -113,6 +145,7 @@ export default app;
// console.error('Error sending email:', error);
// return res.status(500).json({ success: false, message: 'Failed to send email' });
// }
// console.log('Email sent:', info.response);
// res.status(200).json({ success: true, message: 'Email sent successfully!' });
// });
// });
Expand All @@ -122,3 +155,5 @@ export default app;
// console.log(`Server is running on http://localhost:${PORT}`);
// });

// export default app;

27 changes: 1 addition & 26 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,6 @@
content="Web site created using create-react-app"
/>
<script src="https://cdn.tailwindcss.com"></script>
<!-- <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> -->
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>VedicVani</title>
</head>
<body>
Expand All @@ -33,17 +18,7 @@
class="bg-gradient-to-t from-[#FF9900] to-[#FF6600] min-h-[100vh] text-gray-800 overflow-y-auto"
id="root"
></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">

<script src="https://cdn.jsdelivr.net/npm/tsparticles-engine@2/tsparticles.engine.min.js"></script>
Expand Down
25 changes: 0 additions & 25 deletions public/manifest.json

This file was deleted.

3 changes: 2 additions & 1 deletion src/components/AboutUs.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const textVariantdistort = (delay) => ({
},
});


function AboutUs() {
const [isHovered, setIsHovered] = useState(false);
const [isMobile, setIsMobile] = useState(false);
Expand All @@ -36,6 +35,8 @@ function AboutUs() {
const handleResize = () => {
setIsMobile(window.innerWidth <= 768);
};

window.scrollTo({ top: 0, behavior: 'smooth' });

handleResize();
window.addEventListener('resize', handleResize);
Expand Down
4 changes: 4 additions & 0 deletions src/components/BhaktiGeet.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,10 @@ const App = () => {
fontWeight: "450",
};

useEffect(() => {
window.scrollTo({ top: 0, behavior: 'smooth' });
}, []);

return (
<div style={appStyle}>
<div style={headerStyle}>
Expand Down
Loading

0 comments on commit b14c626

Please sign in to comment.