From e1014626a4dfb2b2cb7d835a476264e4fb769b1f Mon Sep 17 00:00:00 2001 From: Aditya Date: Thu, 14 Nov 2024 10:43:34 +0530 Subject: [PATCH 01/10] Update Contact Us --- package.json | 1 + pages/api/v1/contact/index.js | 61 +++++++++++++++++++++++------- pages/api/v1/contact/nodemailer.js | 34 +++++++++++++++++ yarn.lock | 12 ++++++ 4 files changed, 95 insertions(+), 13 deletions(-) create mode 100644 pages/api/v1/contact/nodemailer.js diff --git a/package.json b/package.json index 2a2ac0d..711e805 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "mongoose": "^8.2.1", "next": "^14.1.0", "next-sitemap": "^4.2.3", + "node-mailer": "^0.1.1", "react": "^18", "react-confetti": "^6.1.0", "react-dom": "^18", diff --git a/pages/api/v1/contact/index.js b/pages/api/v1/contact/index.js index ef5ea1a..a450deb 100644 --- a/pages/api/v1/contact/index.js +++ b/pages/api/v1/contact/index.js @@ -1,30 +1,65 @@ -import Contact from "@/utils/models/contact.model"; -import DBInstance from "@/utils/db"; -DBInstance(); +// import Contact from "@/utils/models/contact.model"; +// import DBInstance from "@/utils/db"; +// DBInstance(); + +// export default async function handler(req, res) { +// if (req.method === "POST") { +// try { +// const { name, email, message } = req.body; + +// const contact = new Contact({ +// name, +// email, +// message +// }); + +// await contact.save(); + +// res.status(200).json({ message: "Message sent successfully" }); +// } catch (error) { +// console.error(error, res, "INTERNAL_SERVER_ERROR"); +// } +// } else { +// console.log("🚫", req.method, "was called and got an error!"); +// res.status(405).json({ +// success: false, +// data: null, +// message: "🚫 HTTP Method not Allowed" +// }); +// } +// } + +import { sendmail } from "./nodemailer"; export default async function handler(req, res) { if (req.method === "POST") { try { const { name, email, message } = req.body; - const contact = new Contact({ + if (!name || !email || !message) { + return res + .status(400) + .json({ message: "All fields are required" }); + } + + console.log("Received contact form data:", { name, email, message }); - await contact.save(); + const emailResponse = await sendmail(name, email, message); - res.status(200).json({ message: "Message sent successfully" }); + if (emailResponse.success) { + return res.status(200).json({ message: emailResponse.message }); + } else { + return res.status(500).json({ message: emailResponse.message }); + } } catch (error) { - console.error(error, res, "INTERNAL_SERVER_ERROR"); + console.error("Error processing request:", error); + return res.status(500).json({ message: "Internal server error" }); } } else { - console.log("🚫", req.method, "was called and got an error!"); - res.status(405).json({ - success: false, - data: null, - message: "🚫 HTTP Method not Allowed" - }); + res.status(405).json({ message: "Method not allowed" }); } } diff --git a/pages/api/v1/contact/nodemailer.js b/pages/api/v1/contact/nodemailer.js new file mode 100644 index 0000000..8530d03 --- /dev/null +++ b/pages/api/v1/contact/nodemailer.js @@ -0,0 +1,34 @@ +import nodemailer from "nodemailer"; + +export const sendmail = async (name, email, query) => { + try { + const transporter = nodemailer.createTransport({ + host: "smtp.zoho.in", + port: 465, + secure: true, + auth: { + user: "aditya0@zohomail.in", // Club Query Zoho email + pass: process.env + } + }); + + const mailOptions = { + from: "aditya0@zohomail.in", + to: "aditya0@zohomail.in", // Club community email address + subject: `Query from ${email}`, + html: `Hello Support Team,

+ Please find below a new inquiry from
Name: ${name}
Email: ${email}.

+ Query:
+ ${query}

+ Kind regards,
+ ${name}` + }; + + const info = await transporter.sendMail(mailOptions); + console.log("Email sent successfully:", info.response); + return { success: true, message: "Email sent successfully" }; + } catch (err) { + console.error("Error sending email:", err.message); + return { success: false, message: err.message }; + } +}; \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 135ac22..889789a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4480,11 +4480,23 @@ next@^14.1.0: "@next/swc-win32-ia32-msvc" "14.2.5" "@next/swc-win32-x64-msvc" "14.2.5" +node-mailer@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/node-mailer/-/node-mailer-0.1.1.tgz#609e14a9b2c34422540b3a66938163d1d2421500" + integrity sha512-L3YwTtPodsYr1sNPW/PxXw0rSOr/ldygaIph2YtXDwLGt9l8km/OjM0Wrr57Yf07JEEnDb3wApjhVdR0k5v0kw== + dependencies: + nodemailer ">= 0.1.15" + node-releases@^2.0.18: version "2.0.18" resolved "https://registry.npmjs.org/node-releases/-/node-releases-2.0.18.tgz" integrity sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g== +"nodemailer@>= 0.1.15": + version "6.9.16" + resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-6.9.16.tgz#3ebdf6c6f477c571c0facb0727b33892635e0b8b" + integrity sha512-psAuZdTIRN08HKVd/E8ObdV6NO7NTBY3KsC30F7M4H1OnmLCUNaS56FpYxyb26zWLSyYF9Ozch9KYHhHegsiOQ== + normalize-path@^3.0.0, normalize-path@~3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz" From ea17511903b8450b4a118e413cac0abbd6899d79 Mon Sep 17 00:00:00 2001 From: Aditya Date: Thu, 14 Nov 2024 11:36:29 +0530 Subject: [PATCH 02/10] Update Contact Us --- pages/api/v1/contact/index.js | 31 ------------------------------ pages/api/v1/contact/nodemailer.js | 8 ++++---- public/sitemap-0.xml | 14 +++++++------- 3 files changed, 11 insertions(+), 42 deletions(-) diff --git a/pages/api/v1/contact/index.js b/pages/api/v1/contact/index.js index a450deb..305ab38 100644 --- a/pages/api/v1/contact/index.js +++ b/pages/api/v1/contact/index.js @@ -1,34 +1,3 @@ -// import Contact from "@/utils/models/contact.model"; -// import DBInstance from "@/utils/db"; -// DBInstance(); - -// export default async function handler(req, res) { -// if (req.method === "POST") { -// try { -// const { name, email, message } = req.body; - -// const contact = new Contact({ -// name, -// email, -// message -// }); - -// await contact.save(); - -// res.status(200).json({ message: "Message sent successfully" }); -// } catch (error) { -// console.error(error, res, "INTERNAL_SERVER_ERROR"); -// } -// } else { -// console.log("🚫", req.method, "was called and got an error!"); -// res.status(405).json({ -// success: false, -// data: null, -// message: "🚫 HTTP Method not Allowed" -// }); -// } -// } - import { sendmail } from "./nodemailer"; export default async function handler(req, res) { diff --git a/pages/api/v1/contact/nodemailer.js b/pages/api/v1/contact/nodemailer.js index 8530d03..c73b2a2 100644 --- a/pages/api/v1/contact/nodemailer.js +++ b/pages/api/v1/contact/nodemailer.js @@ -7,14 +7,14 @@ export const sendmail = async (name, email, query) => { port: 465, secure: true, auth: { - user: "aditya0@zohomail.in", // Club Query Zoho email - pass: process.env + user: process.env.SENDER_EMAIL, // Club Query Zoho email + pass: process.env.SENDER_PASS } }); const mailOptions = { - from: "aditya0@zohomail.in", - to: "aditya0@zohomail.in", // Club community email address + from: process.env.SENDER_EMAIL, + to: process.env.RECIPIENT_EMAIL, // Club community email address subject: `Query from ${email}`, html: `Hello Support Team,

Please find below a new inquiry from
Name: ${name}
Email: ${email}.

diff --git a/public/sitemap-0.xml b/public/sitemap-0.xml index 317416c..be145a7 100644 --- a/public/sitemap-0.xml +++ b/public/sitemap-0.xml @@ -1,10 +1,10 @@ -https://githubsrmist.tech2024-10-24T16:07:15.206Zdaily0.7 -https://githubsrmist.tech/about2024-10-24T16:07:15.207Zdaily0.7 -https://githubsrmist.tech/contact2024-10-24T16:07:15.207Zdaily0.7 -https://githubsrmist.tech/events2024-10-24T16:07:15.207Zdaily0.7 -https://githubsrmist.tech/recruitment2024-10-24T16:07:15.207Zdaily0.7 -https://githubsrmist.tech/recruitment/dashboard2024-10-24T16:07:15.207Zdaily0.7 -https://githubsrmist.tech/team2024-10-24T16:07:15.207Zdaily0.7 +https://githubsrmist.tech2024-11-14T05:15:34.518Zdaily0.7 +https://githubsrmist.tech/about2024-11-14T05:15:34.519Zdaily0.7 +https://githubsrmist.tech/contact2024-11-14T05:15:34.519Zdaily0.7 +https://githubsrmist.tech/events2024-11-14T05:15:34.519Zdaily0.7 +https://githubsrmist.tech/recruitment2024-11-14T05:15:34.519Zdaily0.7 +https://githubsrmist.tech/recruitment/dashboard2024-11-14T05:15:34.519Zdaily0.7 +https://githubsrmist.tech/team2024-11-14T05:15:34.519Zdaily0.7 \ No newline at end of file From 4e937e521a7ac3b7280fe9f12f704fc411cd43f6 Mon Sep 17 00:00:00 2001 From: Aditya Date: Thu, 14 Nov 2024 12:07:17 +0530 Subject: [PATCH 03/10] Update Contact Us --- public/sitemap-0.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/public/sitemap-0.xml b/public/sitemap-0.xml index bc9279c..879f5c0 100644 --- a/public/sitemap-0.xml +++ b/public/sitemap-0.xml @@ -1,10 +1,10 @@ -https://githubsrmist.tech2024-11-08T19:21:29.955Zdaily0.7 -https://githubsrmist.tech/about2024-11-08T19:21:29.955Zdaily0.7 -https://githubsrmist.tech/contact2024-11-08T19:21:29.955Zdaily0.7 -https://githubsrmist.tech/events2024-11-08T19:21:29.955Zdaily0.7 -https://githubsrmist.tech/recruitment2024-11-08T19:21:29.955Zdaily0.7 -https://githubsrmist.tech/recruitment/dashboard2024-11-08T19:21:29.955Zdaily0.7 -https://githubsrmist.tech/team2024-11-08T19:21:29.955Zdaily0.7 +https://githubsrmist.tech2024-11-14T06:24:31.549Zdaily0.7 +https://githubsrmist.tech/about2024-11-14T06:24:31.551Zdaily0.7 +https://githubsrmist.tech/contact2024-11-14T06:24:31.551Zdaily0.7 +https://githubsrmist.tech/events2024-11-14T06:24:31.551Zdaily0.7 +https://githubsrmist.tech/recruitment2024-11-14T06:24:31.551Zdaily0.7 +https://githubsrmist.tech/recruitment/dashboard2024-11-14T06:24:31.551Zdaily0.7 +https://githubsrmist.tech/team2024-11-14T06:24:31.551Zdaily0.7 \ No newline at end of file From 66fec4fb4ebde8c9ae2f8771b7ea030913251848 Mon Sep 17 00:00:00 2001 From: Aditya Date: Thu, 14 Nov 2024 12:59:14 +0530 Subject: [PATCH 04/10] Update escapeHTML --- pages/api/v1/contact/index.js | 18 +++++++++++++++++- public/sitemap-0.xml | 14 +++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/pages/api/v1/contact/index.js b/pages/api/v1/contact/index.js index 305ab38..f23d663 100644 --- a/pages/api/v1/contact/index.js +++ b/pages/api/v1/contact/index.js @@ -1,15 +1,31 @@ import { sendmail } from "./nodemailer"; +const escapeHTML = (str) => { + return str.replace(/[&<>"']/g, (char) => { + return { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + }[char]; + }); +}; + export default async function handler(req, res) { if (req.method === "POST") { try { - const { name, email, message } = req.body; + let { name, email, message } = req.body; if (!name || !email || !message) { return res .status(400) .json({ message: "All fields are required" }); } + + name = escapeHTML(name); + email = escapeHTML(email); + message = escapeHTML(message); console.log("Received contact form data:", { name, diff --git a/public/sitemap-0.xml b/public/sitemap-0.xml index 879f5c0..93ee0a2 100644 --- a/public/sitemap-0.xml +++ b/public/sitemap-0.xml @@ -1,10 +1,10 @@ -https://githubsrmist.tech2024-11-14T06:24:31.549Zdaily0.7 -https://githubsrmist.tech/about2024-11-14T06:24:31.551Zdaily0.7 -https://githubsrmist.tech/contact2024-11-14T06:24:31.551Zdaily0.7 -https://githubsrmist.tech/events2024-11-14T06:24:31.551Zdaily0.7 -https://githubsrmist.tech/recruitment2024-11-14T06:24:31.551Zdaily0.7 -https://githubsrmist.tech/recruitment/dashboard2024-11-14T06:24:31.551Zdaily0.7 -https://githubsrmist.tech/team2024-11-14T06:24:31.551Zdaily0.7 +https://githubsrmist.tech2024-11-14T06:38:04.705Zdaily0.7 +https://githubsrmist.tech/about2024-11-14T06:38:04.707Zdaily0.7 +https://githubsrmist.tech/contact2024-11-14T06:38:04.707Zdaily0.7 +https://githubsrmist.tech/events2024-11-14T06:38:04.707Zdaily0.7 +https://githubsrmist.tech/recruitment2024-11-14T06:38:04.707Zdaily0.7 +https://githubsrmist.tech/recruitment/dashboard2024-11-14T06:38:04.707Zdaily0.7 +https://githubsrmist.tech/team2024-11-14T06:38:04.707Zdaily0.7 \ No newline at end of file From 85a53ad8767b5813cd5c6ef0e33be01da4d1bcb1 Mon Sep 17 00:00:00 2001 From: GitHub Community SRM - Bot Date: Tue, 1 Apr 2025 22:52:14 +0530 Subject: [PATCH 05/10] Update yarn.lock --- yarn.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 52e9632..1815b36 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4878,7 +4878,7 @@ node-mailer@^0.1.1: integrity sha512-L3YwTtPodsYr1sNPW/PxXw0rSOr/ldygaIph2YtXDwLGt9l8km/OjM0Wrr57Yf07JEEnDb3wApjhVdR0k5v0kw== dependencies: nodemailer ">= 0.1.15" -======= + node-abi@^3.3.0: version "3.74.0" resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-3.74.0.tgz#5bfb4424264eaeb91432d2adb9da23c63a301ed0" From cfe2db0fe343f0ef75051876c967a44f90fdbe6e Mon Sep 17 00:00:00 2001 From: keshitrivedi Date: Sun, 6 Apr 2025 02:02:14 +0530 Subject: [PATCH 06/10] Add new images to Gallery, fix pagination --- components/Home/Gallery.jsx | 8 ++++++-- components/Shared/Scroll.jsx | 2 +- public/Home/12.JPG | Bin 0 -> 6709914 bytes public/Home/13.JPG | Bin 0 -> 6665079 bytes styles/globals.css | 31 +++++++++++++++++++++++++++++++ 5 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 public/Home/12.JPG create mode 100644 public/Home/13.JPG diff --git a/components/Home/Gallery.jsx b/components/Home/Gallery.jsx index a9fbeed..f86f5b7 100644 --- a/components/Home/Gallery.jsx +++ b/components/Home/Gallery.jsx @@ -20,6 +20,8 @@ import img8 from "../../public/Home/8.JPG"; import img9 from "../../public/Home/9.JPG"; import img10 from "../../public/Home/10.JPG"; import img11 from "../../public/Home/11.jpg"; +import img12 from "../../public/Home/12.JPG"; +import img13 from "../../public/Home/13.JPG"; const serviceData = [ img1, @@ -32,7 +34,9 @@ const serviceData = [ img8, img9, img10, - img11 + img11, + img12, + img13 ]; const ServiceSlider = () => { @@ -83,7 +87,7 @@ const ServiceSlider = () => { // slideShadows: false // }} pagination={{ - dynamicBullets: true + clickable: true }} autoplay={{ delay: 2000, diff --git a/components/Shared/Scroll.jsx b/components/Shared/Scroll.jsx index 1d34774..5ce18cd 100644 --- a/components/Shared/Scroll.jsx +++ b/components/Shared/Scroll.jsx @@ -26,7 +26,7 @@ const ScrollToTopButton = () => { }, []); return ( -
+
{isVisible && (