diff --git a/components/Events/EmailDialogue/EmailDialogue.jsx b/components/Events/EmailDialogue/EmailDialogue.jsx index 0acc070..f2adcf7 100644 --- a/components/Events/EmailDialogue/EmailDialogue.jsx +++ b/components/Events/EmailDialogue/EmailDialogue.jsx @@ -1,5 +1,6 @@ import React, { useState, useEffect } from "react"; import axios from "axios"; +import { API_ENDPOINTS } from "@/utils/config"; import { toast, ToastContainer } from "react-toastify"; import "react-toastify/dist/ReactToastify.css"; @@ -46,20 +47,27 @@ const EmailDialogBox = ({ CertiOBJ, title, handelCloseModel }) => { setIsButtonDisabled(true); try { setIsLoading(true); - const response = await axios.post("/api/v1/certificates", formData); + const response = await axios.post(API_ENDPOINTS.CERTIFICATES.GENERATE, { + ...formData, + format: "pdf" + }, { + responseType: 'blob' + }); - if (response.data && response.data.success) { - setCertificate(response.data.certificate); + if (response.status === 200) { + // The API returns the PDF binary directly. + // We create a Blob URL from the response data. + const file = new Blob([response.data], { type: 'application/pdf' }); + const fileURL = URL.createObjectURL(file); + setCertificate(fileURL); toast.success("Certificate generated successfully!"); } else { - toast.error( - response.data.error || "Failed to generate certificate" - ); + toast.error("Failed to generate certificate"); setIsButtonDisabled(false); } } catch (error) { - const errorMessage = - error.response?.data?.error || "Error getting certificate"; + console.error(error); + const errorMessage = "Error getting certificate"; toast.error(errorMessage); setIsButtonDisabled(false); } finally { @@ -71,7 +79,8 @@ const EmailDialogBox = ({ CertiOBJ, title, handelCloseModel }) => { if (certificate) { const link = document.createElement("a"); link.href = certificate; - link.download = `${title}_certificate.png`; + link.download = `${title}_certificate.pdf`; + link.target = "_blank"; document.body.appendChild(link); link.click(); document.body.removeChild(link); diff --git a/components/Events/Register_dialogue/Registerdialogue.jsx b/components/Events/Register_dialogue/Registerdialogue.jsx index e4c090d..c410443 100644 --- a/components/Events/Register_dialogue/Registerdialogue.jsx +++ b/components/Events/Register_dialogue/Registerdialogue.jsx @@ -1,6 +1,9 @@ import React, { useState } from "react"; import axios from "axios"; import Confetti from "react-confetti"; +import { API_ENDPOINTS } from "../../../utils/config"; +import { toast, ToastContainer } from "react-toastify"; +import "react-toastify/dist/ReactToastify.css"; const RegisterDialogue = ({ slug, onRegistrationClose }) => { const [formData, setFormData] = useState({ @@ -52,7 +55,7 @@ const RegisterDialogue = ({ slug, onRegistrationClose }) => { try { console.log("Registering for event:", slug); console.log("Form data:", formData); - const response = await axios.post("/api/v1/events/register", { + const response = await axios.post(API_ENDPOINTS.EVENTS.REGISTER, { ...formData, slug }); @@ -60,21 +63,22 @@ const RegisterDialogue = ({ slug, onRegistrationClose }) => { if (response.status === 200) { setSuccess(true); + toast.success("Registration successful!"); console.log("Registration successful:", response.data); } } catch (err) { setLoading(false); - if ( - err.response?.data?.error === - "Email already registered for this event." - ) { - setError("Email already registered"); - } else { - setError( - err.response?.data?.message || - "An error occurred during registration." - ); + let errorMessage = "An error occurred during registration."; + + // Prioritize the 'error' field from the response as per user report + if (err.response?.data?.error) { + errorMessage = err.response.data.error; + } else if (err.response?.data?.message) { + errorMessage = err.response.data.message; } + + setError(errorMessage); + toast.error(errorMessage); console.error("Registration error:", err); } }; @@ -179,10 +183,9 @@ const RegisterDialogue = ({ slug, onRegistrationClose }) => { type="submit" disabled={loading || success} className={`w-full px-4 py-2 font-bold rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 - ${ - loading - ? "bg-gray-400" - : success + ${loading + ? "bg-gray-400" + : success ? " bg-green-800 text-white" : "bg-bright_green text-black" }`} @@ -190,11 +193,22 @@ const RegisterDialogue = ({ slug, onRegistrationClose }) => { {loading ? "Registering..." : success - ? "Registered" - : "Register"} + ? "Registered" + : "Register"} + ); }; diff --git a/pages/api/v1/certificates/index.js b/pages/api/v1/certificates/index.js deleted file mode 100644 index 8f75d23..0000000 --- a/pages/api/v1/certificates/index.js +++ /dev/null @@ -1,145 +0,0 @@ -import DBInstance from "@/utils/db"; -import Event from "@/utils/models/event.models"; -import textOverlay from "@/utils/certificates/jimpOverlay"; -import mongoose from "mongoose"; - -DBInstance(); - -export default async function handler(req, res) { - if (req.method === "POST") { - const { email, event, type } = req.body; - - //only for ossome hacks 2 - // const { name, event, type } = req.body; - - if (!email || !event || !type) { - return res - .status(400) - .json({ success: false, error: "All fields are required." }); - } - - //only for ossome hacks 2 - // if (!name || !event || !type) { - // return res - // .status(400) - // .json({ success: false, error: "All fields are required." }); - // } - - try { - const eventData = await Event.findOne({ slug: event }); - - if (!eventData) { - // console.log("Event not found for slug:", event); - return res.status(404).json({ - success: false, - error: `Event not found with slug: ${event}` - }); - } - // console.log("eventData:", eventData); - - // console.log("eventData.jimp_config:", eventData.jimp_config); - if (!eventData.jimp_config) { - // console.log("jimp_config is missing from eventData"); - return res.status(500).json({ - success: false, - error: "jimp_config is missing from eventData" - }); - } - - // console.log("Type received:", type); - const normalizedType = type.toLowerCase(); - const certificateURL = eventData.certificate[normalizedType]; - - if (!certificateURL) { - // console.log( - // "Certificate URL not found for type:", - // normalizedType - // ); - return res.status(404).json({ - success: false, - error: `Certificate not found for type: ${normalizedType}` - }); - } - - const db = mongoose.connection.useDb(eventData.database); - const userSchema = new mongoose.Schema({ - name: { type: String, required: true }, - email: { type: String, required: true }, - checkin: { type: Boolean, default: false } - }); - - const User = db.model(eventData.collection[type], userSchema); - const userData = await User.findOne({ email }); - - //only for ossome hacks 2 - // const userData = await User.findOne({ - // name: { $regex: new RegExp(`^${name}$`, 'i') } - // }); - - if (!userData) { - return res.status(404).json({ - success: false, - error: `No certificate found for email: ${email}` - }); - } - - //only for ossome hacks 2 - - // if (!userData) { - // return res.status(404).json({ - // success: false, - // error: `No certificate found for name: ${name}` - // }); - // } - // console.log("User data:", userData); - - const color = - typeof eventData.jimp_config.color === "string" - ? eventData.jimp_config.color.toUpperCase() - : "WHITE"; - - const fontSize = eventData.jimp_config.font_size || "64"; - const yOffset = eventData.jimp_config.yOffset || "380"; - const jimpOptions = { - FONT_64_WHITE: - "https://ik.imagekit.io/githubsrm/fonts/open-sans-64-white/open-sans-64-white.fnt?updatedAt=1726944338422", - FONT_64_BLACK: - "https://ik.imagekit.io/githubsrm/fonts/open-sans-64-black/open-sans-64-black.fnt?updatedAt=1726944338432", - FONT_32_WHITE: - "https://ik.imagekit.io/githubsrm/fonts/open-sans-32-white/open-sans-32-white.fnt?updatedAt=1726944338436", - FONT_32_BLACK: - "https://ik.imagekit.io/githubsrm/fonts/open-sans-32-black/open-sans-32-black.fnt?updatedAt=1726944338420" - }; - const { buffer, error, error_message } = await textOverlay( - userData.name, - certificateURL, - color, - fontSize, - yOffset, - jimpOptions - ); - - if (error) { - console.error("Error from textOverlay:", error_message); - return res.status(500).json({ - success: false, - error: error_message - }); - } - - return res.status(200).json({ - success: true, - certificate: buffer, - name: userData.name - }); - } catch (err) { - console.error("Error during processing:", err.message); - return res.status(500).json({ - success: false, - error: "Internal Server Error" - }); - } - } else { - res.status(405).json({ success: false, error: "Method Not Allowed" }); - } -} diff --git a/pages/api/v1/contact/index.js b/pages/api/v1/contact/index.js deleted file mode 100644 index 3d98510..0000000 --- a/pages/api/v1/contact/index.js +++ /dev/null @@ -1,115 +0,0 @@ -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 { - // Log the incoming request body for debugging - console.log("📥 Received contact form data:", { - body: req.body, - bodyKeys: Object.keys(req.body || {}), - contentType: req.headers['content-type'] - }); - - let { name, email, message } = req.body; - - if (!name || !email || !message) { - console.log("❌ Missing required fields:", { - name: !!name, - email: !!email, - message: !!message - }); - return res - .status(400) - .json({ - success: false, - message: "All fields are required", - received: { - name: !!name, - email: !!email, - message: !!message - } - }); - } - - name = escapeHTML(name); - email = escapeHTML(email); - message = escapeHTML(message); - - // Enhanced validation - const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; - if (!emailRegex.test(email)) { - console.log("❌ Invalid email format:", email); - return res.status(400).json({ - success: false, - message: "Please provide a valid email address", - field: "email" - }); - } - - if (name.length < 2 || name.length > 100) { - console.log("❌ Invalid name length:", name.length); - return res.status(400).json({ - success: false, - message: "Name must be between 2 and 100 characters", - field: "name" - }); - } - - if (message.length < 10 || message.length > 2000) { - console.log("❌ Invalid message length:", message.length); - return res.status(400).json({ - success: false, - message: "Message must be between 10 and 2000 characters", - field: "message" - }); - } - - console.log("📧 Processing contact form submission:", { - name, - email: email.replace(/(.{3}).*(@.*)/, "$1***$2"), // Mask email for logging - messageLength: message.length, - timestamp: new Date().toISOString() - }); - - const emailResponse = await sendmail(name, email, message); - - if (emailResponse.success) { - console.log("✅ Contact form emails sent successfully"); - return res.status(200).json({ - success: true, - message: "Thank you! Your message has been sent successfully. We'll get back to you within 24-48 hours.", - details: emailResponse.details - }); - } else { - console.error("❌ Failed to send contact form emails:", emailResponse.message); - return res.status(500).json({ - success: false, - message: "Sorry, there was an error sending your message. Please try again later or contact us directly." - }); - } - } catch (error) { - console.error("❌ Error processing contact request:", error); - return res.status(500).json({ - success: false, - message: "Internal server error. Please try again later." - }); - } - } else { - res.status(405).json({ - success: false, - message: "Method not allowed. Please use POST." - }); - } -} diff --git a/pages/api/v1/contact/nodemailer.js b/pages/api/v1/contact/nodemailer.js deleted file mode 100644 index 0524eb2..0000000 --- a/pages/api/v1/contact/nodemailer.js +++ /dev/null @@ -1,309 +0,0 @@ -import nodemailer from "nodemailer"; - -// Professional HTML email template with GitHub elements -const createEmailTemplate = (name, email, query) => { - const currentDate = new Date().toLocaleString('en-US', { - year: 'numeric', - month: 'long', - day: 'numeric', - hour: '2-digit', - minute: '2-digit', - timeZone: 'Asia/Kolkata' - }); - - return ` - - - - - - New Contact Form Submission - - -
- - -
-
- - - -

- New Contact Form Submission -

-
-

- GitHub Community SRM • ${currentDate} (IST) -

-
- - -
- - -
-

- Contact Information -

- - - - - - - - - - -
- Name: - - ${name} -
- Email: - - - ${email} - -
-
- - -
-

- Message -

- -
-

- ${query} -

-
-
- - -
-

- Quick Actions -

- -
- - Reply to ${name} - - - Compose Email - -
-
-
- - -
-

- This email was automatically generated from the GitHub Community SRM contact form. -

-

- Please do not reply to this email directly. Use the action buttons above to respond. -

-
-
- - - `; -}; - -// Professional confirmation email template -const createConfirmationTemplate = (name) => { - return ` - - - - - - Thank you for contacting GitHub Community SRM - - -
- - -
-
- - - -
-

- GitHub Community SRM -

-

- Message received successfully -

-
-
-
- - -
-

- Hello ${name}, -

- -

- Thank you for reaching out to GitHub Community SRM. We have received your message and our team will respond within 24-48 hours. -

- -
-
- - - -
-

- What happens next? -

-

- Our team will review your message and respond with relevant information or next steps. -

-
-
-
- -
-

- Connect with us -

-
- - - - - GitHub - - - - - - Website - - - - - - LinkedIn - - - - - - Instagram - - - - - - Discord - -
-
-
- - -
-

- © 2025 GitHub Community SRM. All rights reserved. -

-

- This is an automated confirmation email. Please do not reply directly to this message. -

-
-
- - - `; -}; - -export const sendmail = async (name, email, query) => { - try { - const transporter = nodemailer.createTransport({ - host: "smtp.zoho.in", - port: 465, - secure: true, - auth: { - user: process.env.SENDER_EMAIL, - pass: process.env.SENDER_PASS - } - }); - - // Enhanced mail options for the team - const teamMailOptions = { - from: process.env.SENDER_EMAIL, - to: process.env.RECIPIENT_EMAIL, - replyTo: email, // Enable direct reply to the sender - subject: `🔔 New Contact Form Submission from ${name}`, - html: createEmailTemplate(name, email, query), - // Add plain text version for better compatibility - text: ` -New Contact Form Submission - -From: ${name} (${email}) -Date: ${new Date().toLocaleString('en-US', { timeZone: 'Asia/Kolkata' })} IST - -Message: -${query} - -Reply to this person: ${email} - ` - }; - - // Confirmation email for the sender - const confirmationMailOptions = { - from: process.env.SENDER_EMAIL, - to: email, - subject: "✅ Thank you for contacting GitHub Community SRM", - html: createConfirmationTemplate(name), - text: ` -Hi ${name}! - -Thank you for reaching out to GitHub Community SRM! We've received your message and our team will get back to you within 24-48 hours. - -What happens next? -Our team will review your message and respond with relevant information, resources, or next steps. - -Best regards, -GitHub Community SRM Team - ` - }; - - // Send both emails - const [teamEmailResult, confirmationResult] = await Promise.all([ - transporter.sendMail(teamMailOptions), - transporter.sendMail(confirmationMailOptions) - ]); - - console.log("Team email sent successfully:", teamEmailResult.response); - console.log("Confirmation email sent successfully:", confirmationResult.response); - - return { - success: true, - message: "Emails sent successfully", - details: { - teamEmail: teamEmailResult.messageId, - confirmationEmail: confirmationResult.messageId - } - }; - } catch (err) { - console.error("Error sending emails:", err.message); - return { - success: false, - message: `Failed to send email: ${err.message}` - }; - } -}; \ No newline at end of file diff --git a/pages/api/v1/events/index.js b/pages/api/v1/events/index.js deleted file mode 100644 index d0b6590..0000000 --- a/pages/api/v1/events/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import Event from "@/utils/models/event.models"; -import DBInstance from "@/utils/db"; -DBInstance(); - -export default async function handler(req, res) { - if (req.method === "GET") { - try { - // Retrieve all events from the database - const events = await Event.find(); - - // Send the response with the retrieved events - res.status(200).json({ success: true, data: events }); - } catch (error) { - console.error(error); - res.status(500).json({ success: false, error: "Internal Server Error" }); - } - } else { - // Handle unsupported HTTP methods - res.status(405).json({ success: false, error: "Method Not Allowed" }); - } -} \ No newline at end of file diff --git a/pages/api/v1/events/register/index.js b/pages/api/v1/events/register/index.js deleted file mode 100644 index bf736be..0000000 --- a/pages/api/v1/events/register/index.js +++ /dev/null @@ -1,80 +0,0 @@ -import DBInstance from "@/utils/db"; -import Event from "@/utils/models/event.models"; -import mongoose from "mongoose"; -import { sendRegistrationEmail } from "@/utils/email/registration"; - -DBInstance(); - -export default async function handler(req, res) { - if (req.method === "POST") { - const { name, regNo, email, phn, dept, slug } = req.body; - - if (!name || !regNo || !email || !phn || !dept || !slug) { - return res - .status(400) - .json({ success: false, error: "All fields are required." }); - } - - try { - const event = await Event.findOne({ slug }); - - if (!event) { - return res - .status(404) - .json({ success: false, error: "Event not found." }); - } - - const { database, collection } = event; - const participantsCollection = collection.participants; - const db = mongoose.connection.useDb(database); - const participantSchema = new mongoose.Schema({ - name: { type: String, required: true }, - regNo: { type: String, required: true }, - email: { type: String, required: true }, - phn: { type: String, required: true }, - dept: { type: String, required: true }, - rsvp: { type: Boolean, default: false }, - checkin: { type: Boolean, default: false }, - snacks: { type: Boolean, default: false } - }); - - const Participant = db.model( - participantsCollection, - participantSchema - ); - - const existingParticipant = await Participant.findOne({ email: { $eq: email } }); - - if (existingParticipant) { - return res.status(400).json({ - success: false, - error: "Email already registered for this event." - }); - } - - const newParticipant = new Participant({ - name, - regNo, - email, - phn, - dept - }); - - await newParticipant.save(); - await sendRegistrationEmail(newParticipant, event); - - res.status(200).json({ - success: true, - message: "Participant registered successfully." - }); - } catch (error) { - console.error(error); - res.status(500).json({ - success: false, - error: "Internal Server Error" - }); - } - } else { - res.status(405).json({ success: false, error: "Method Not Allowed" }); - } -} diff --git a/pages/api/v1/healthcheck.js b/pages/api/v1/healthcheck.js deleted file mode 100644 index 118138c..0000000 --- a/pages/api/v1/healthcheck.js +++ /dev/null @@ -1,44 +0,0 @@ -import os from "os"; -import DBInstance from "@/utils/db"; - -const formatTime = (seconds) => { - function pad(s) { - return (s < 10 ? "0" : "") + s; - } - let hours = Math.floor(seconds / (60 * 60)); - let minutes = Math.floor((seconds % (60 * 60)) / 60); - let secs = Math.floor(seconds % 60); - - return pad(hours) + ":" + pad(minutes) + ":" + pad(secs); -}; - -export default async function handler(req, res) { - let healthcheckData = { - message: "🛠️ API v1 working!", - timestamp: new Date().toUTCString(), - cpus: os.cpus(), - architecture: os.arch(), - networkInterfaces: os.networkInterfaces(), - totalMemory: os.totalmem(), - freeMemory: os.freemem(), - platform: os.platform(), - osType: os.type(), - osRelease: os.release(), - osVersion: os.version(), - hostname: os.hostname(), - userInfo: os.userInfo(), - serverUptime: formatTime(process.uptime()), - osUptime: formatTime(os.uptime()), - reqIP: req.headers["x-real-ip"] || req.connection.remoteAddress - }; - - try { - await DBInstance(); - healthcheckData.mongoDBStatus = "✅ Connected to MongoDB"; - } catch (error) { - console.error("❌ Could not connect to MongoDB\n", error.message); - healthcheckData.mongoDBStatus = "❌ MongoDB connection failed"; - } - - res.status(200).json({ status: true, message: healthcheckData }); -} diff --git a/pages/api/v1/recruitment/index.js b/pages/api/v1/recruitment/index.js deleted file mode 100644 index 5f1cb27..0000000 --- a/pages/api/v1/recruitment/index.js +++ /dev/null @@ -1,92 +0,0 @@ -import DBInstance from "@/utils/db"; -import Participant from "@/utils/models/recruitment.model.js"; - -DBInstance(); - -export default async function handler(req, res) { - if (req.method === "POST") { - const { - name, - registrationNo, - email, - phone, - branch, - year, - position, - subDomain1, - subDomain2 - } = req.body; - - // Validate required fields - if ( - !name || - !registrationNo || - !email || - !phone || - !branch || - !year || - !position - ) { - return res - .status(400) - .json({ success: false, error: "All fields are required." }); - } - - try { - // Check if the participant already exists based on email or registration number - const existingParticipant = await Participant.findOne({ - $or: [{ email }, { regNo: registrationNo }] - }); - - if (existingParticipant) { - return res.status(401).json({ - success: false, - error: "Email or Registration Number already registered." - }); - } - - // Structure the domain object based on the position and subdomains - const domain = { - [position]: [subDomain1] - }; - - if (subDomain2) { - domain[position].push(subDomain2); // Add subDomain2 only if provided - } - - // Create a new participant - const newParticipant = new Participant({ - name, - regNo: registrationNo, - email, - phoneNo: phone, - dept: branch, - year, - domain, - status: "registered" - }); - - // Save the new participant to the database - await newParticipant.save(); - - // Respond with success and the new participant data - return res.status(201).json({ - success: true, - data: newParticipant - }); - } catch (error) { - // Handle any errors that occur during the process - console.error("Error during registration:", error); - return res.status(500).json({ - success: false, - error: "Internal Server Error" - }); - } - } else { - // Handle non-POST requests - return res.status(405).json({ - success: false, - error: "Method Not Allowed" - }); - } -} diff --git a/pages/api/v1/recruitment/task/index.js b/pages/api/v1/recruitment/task/index.js deleted file mode 100644 index 8377fdc..0000000 --- a/pages/api/v1/recruitment/task/index.js +++ /dev/null @@ -1,99 +0,0 @@ -import DBInstance from "@/utils/db"; -import ParticipantUser from "@/utils/models/recruitment.model"; -import Task from "@/utils/models/tasks.model"; - -DBInstance(); - -// Utility function to clean up the reference link and any other fields if necessary -const cleanTaskData = (task) => { - // Ensure the reference-link is cleaned from any extra quotes and whitespace - if (task["link"]) { - task["link"] = task["link"].replace(/^\s*"+|"+\s*$/g, ''); // Remove leading/trailing quotes and whitespace - } - return task; -}; - -export default async function handler(req, res) { - const { method } = req; - - if (method === "GET") { - try { - const { email } = req.query; - - if (!email) { - return res.status(400).json({ message: "Email is required" }); - } - - const participant = await ParticipantUser.findOne({ email }); - if (!participant) { - return res.status(404).json({ message: "Participant not found" }); - } - - // Extract participant details - const { name, regNo, email: participantEmail, phoneNo, year, dept, domain, status } = participant; - let taskQueries = []; - let subdomainsList = []; - - // Extract the domain keys only - const domainKeys = Array.from(domain.keys())[0]; // Take the first key - - // Handle different domains (Technical, Creatives, Corporate, etc.) - for (let [domainKey, subdomains] of domain.entries()) { - if (domainKey === "Corporate") { - taskQueries.push({ domain: domainKey, year: year }); - } else { - if (subdomains && subdomains.length > 0) { - taskQueries.push({ - domain: domainKey, - subdomain: { $in: subdomains }, - year: year - }); - subdomainsList = subdomainsList.concat(subdomains); - } - } - } - - if (taskQueries.length === 0) { - return res.status(200).json({ - name, - regNo, - email: participantEmail, - year, - dept, - phoneNo, - domain: domainKeys, // Return only the domain keys - subdomains: subdomainsList, - status, - tasks: [] - }); - } - - // Fetch tasks based on the query - let tasks = await Task.find({ - $or: taskQueries - }); - - // Clean each task before sending it to the client - tasks = tasks.map(cleanTaskData); - - return res.status(200).json({ - name, - regNo, - email: participantEmail, - year, - dept, - phoneNo, - domain: domainKeys, // Return only the domain keys - subdomains: subdomainsList, - status, - tasks // This will include the reference link along with other task details - }); - } catch (error) { - console.error("Error fetching participant data:", error); - return res.status(500).json({ message: "Internal server error" }); - } - } else { - res.setHeader("Allow", ["GET"]); - return res.status(405).end(`Method ${method} Not Allowed`); - } -} \ No newline at end of file diff --git a/pages/api/v1/sponsers/index.js b/pages/api/v1/sponsers/index.js deleted file mode 100644 index a999a90..0000000 --- a/pages/api/v1/sponsers/index.js +++ /dev/null @@ -1,23 +0,0 @@ -import DBInstance from "@/utils/db"; -import Sponsor from "@/utils/models/sponser.model"; -DBInstance(); - -export default async function handler(req, res) { - if (req.method === "GET") { - try { - const sponsers = await Sponsor.find(); - console.log("hello2s") - res.status(200).json({ success: true, data: sponsers }); - } catch (error) { - console.error(error); - res.status(500).json({ success: false, error: "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" - }); - } -} diff --git a/pages/api/v1/team/index.js b/pages/api/v1/team/index.js deleted file mode 100644 index 49bc841..0000000 --- a/pages/api/v1/team/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import Team from "@/utils/models/team.model"; -import DBInstance from "@/utils/db"; -DBInstance(); - -export default async function handler(req, res) { - if (req.method === "GET") { - try { - // Retrieve all current team members from the database and sort by index - const team = await Team.find({ isCurrent: true }).sort({ - index: 1 - }); - - // Send the response with the retrieved team members - res.status(200).json({ success: true, data: team }); - } catch (error) { - console.error(error); - res.status(500).json({ - success: false, - error: "Internal Server Error" - }); - } - } else { - // Handle unsupported HTTP methods - res.status(405).json({ success: false, error: "Method Not Allowed" }); - } -} diff --git a/public/sitemap-0.xml b/public/sitemap-0.xml index b7dadf0..265a92b 100644 --- a/public/sitemap-0.xml +++ b/public/sitemap-0.xml @@ -1,8 +1,8 @@ -https://githubsrmist.in2025-10-18T07:30:38.900Zdaily0.7 -https://githubsrmist.in/about2025-10-18T07:30:38.901Zdaily0.7 -https://githubsrmist.in/contact2025-10-18T07:30:38.901Zdaily0.7 -https://githubsrmist.in/events2025-10-18T07:30:38.901Zdaily0.7 -https://githubsrmist.in/team2025-10-18T07:30:38.901Zdaily0.7 +https://githubsrmist.in2025-12-02T08:58:50.626Zdaily0.7 +https://githubsrmist.in/about2025-12-02T08:58:50.627Zdaily0.7 +https://githubsrmist.in/contact2025-12-02T08:58:50.627Zdaily0.7 +https://githubsrmist.in/events2025-12-02T08:58:50.627Zdaily0.7 +https://githubsrmist.in/team2025-12-02T08:58:50.627Zdaily0.7 \ No newline at end of file diff --git a/utils/certificates/jimpOverlay.js b/utils/certificates/jimpOverlay.js deleted file mode 100644 index 1860409..0000000 --- a/utils/certificates/jimpOverlay.js +++ /dev/null @@ -1,66 +0,0 @@ -import Jimp from "jimp-compact"; - -const textOverlay = async ( - name, - url, - color, - font_size, - yOffset, - jimpOptions -) => { - // console.log("textOverlay function called"); - - try { - // console.log("Received color:", color); - // console.log("Received font_size:", font_size); - // console.log("Received yOffset:", yOffset); - - if (!color || !font_size || !yOffset) { - return { - buffer: null, - error: true, - error_message: "Missing required image config values." - }; - } - - const fontKey = `FONT_${font_size}_${color.toUpperCase()}`; - // console.log("Constructed fontKey:", fontKey); - - if (!jimpOptions[fontKey]) { - return { - buffer: null, - error: true, - error_message: `Invalid font combination: ${fontKey}` - }; - } - - const font = await Jimp.loadFont(jimpOptions[fontKey]); - const image = await Jimp.read(url); - image.scaleToFit(1300, Jimp.AUTO, Jimp.RESIZE_BEZIER); - - image.print( - font, - 0, - parseInt(yOffset), - { - text: name, - alignmentX: Jimp.HORIZONTAL_ALIGN_CENTER, - alignmentY: Jimp.VERTICAL_ALIGN_MIDDLE - }, - 1300, - 900 - ); - - const bufferImage = await image.getBase64Async(Jimp.MIME_PNG); - return { buffer: bufferImage, error: false, error_message: "Success" }; - } catch (error) { - // console.log("Error in textOverlay:", error.message); - return { - buffer: null, - error: true, - error_message: error.message || "Failed" - }; - } -}; - -export default textOverlay; diff --git a/utils/config.js b/utils/config.js index e0667e0..5185838 100644 --- a/utils/config.js +++ b/utils/config.js @@ -13,7 +13,9 @@ export const API_ENDPOINTS = { }, EVENTS: { GET_ALL: `${API_BASE_URL}/api/events`, // GET - Retrieve all events - GET_BY_ID: (id) => `${API_BASE_URL}/api/event/${id}`, // GET - Retrieve a single event by ID + GET_BY_ID: (id) => `${API_BASE_URL}/api/events/${id}`, // GET - Retrieve a single event by ID + GET_BY_SLUG: (slug) => `${API_BASE_URL}/api/events/slug/${slug}`, // GET - Retrieve a single event by slug + REGISTER: `${API_BASE_URL}/api/events/register`, // POST - Register for an event }, SPONSORS: { GET_ALL: `${API_BASE_URL}/api/sponsors`, // GET - Retrieve all sponsors @@ -23,8 +25,7 @@ export const API_ENDPOINTS = { }, CERTIFICATES: { GENERATE: `${API_BASE_URL}/api/certificate/generate`, // POST - Generate a certificate for an event participant - VERIFY: (certificateId) => `${API_BASE_URL}/api/certificate/verify/${certificateId}`, // GET - Verify the authenticity of a certificate - DOWNLOAD: (certificateId) => `${API_BASE_URL}/api/certificate/download/${certificateId}`, // GET - Download a verified certificate + DOWNLOAD: (certificateId) => `${API_BASE_URL}/api/certificate/download/${certificateId}?format=pdf`, // GET - Download a verified certificate (External) }, }; export const API_CONFIG = { diff --git a/utils/db/index.js b/utils/db/index.js deleted file mode 100644 index 6054ca9..0000000 --- a/utils/db/index.js +++ /dev/null @@ -1,23 +0,0 @@ -import mongoose from "mongoose"; -import dotenv from "dotenv"; - -dotenv.config(); - -const { MONGO_URI, DB_NAME } = process.env; - -const DBInstance = async () => { - try { - await mongoose.connect(MONGO_URI, { - useNewUrlParser: true, - useUnifiedTopology: true, - dbName: DB_NAME - }); - - // console.log(`✅ Connected to MongoDB: ${NEXT_PUBLIC_DB_NAME}`); - } catch (err) { - // console.error("❌ Could not connect to MongoDB\n", err.message); - throw err; - } -}; - -export default DBInstance; diff --git a/utils/email/registration.js b/utils/email/registration.js deleted file mode 100644 index f0fb183..0000000 --- a/utils/email/registration.js +++ /dev/null @@ -1,64 +0,0 @@ -import { SESClient, SendEmailCommand } from "@aws-sdk/client-ses"; -import fs from "fs"; -import path from "path"; -import dotenv from "dotenv"; -dotenv.config(); - -const sesClient = new SESClient({ - region: process.env.AWS_REGION, - credentials: { - accessKeyId: process.env.AWS_ACCESS_KEY_ID, - secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY - } -}); - -export async function sendRegistrationEmail(participant, event) { - try { - const filePath = path.resolve( - process.cwd(), - "utils/email/registrationMail.html" - ); - - const emailContent = fs.readFileSync(filePath, "utf8"); - - const customizedContent = emailContent - .replaceAll("{{name}}", participant.name) - .replaceAll("{{email}}", participant.email) - .replaceAll("{{phn}}", participant.phn) - .replaceAll("{{event}}", event.event_name) - .replaceAll("{{department}}", participant.dept) - .replaceAll("{{registrationNumber}}", participant.regNo) - .replaceAll("{{event_description}}", event.event_description) - .replaceAll("{{date}}", event.event_date) - // .replaceAll("{{time}}", event.event_time) - .replaceAll("{{venue}}", event.venue) - .replaceAll("{{prerequisites}}", event.prerequisites) - .replaceAll("{{event_banner}}", event.poster_url); - - const params = { - Destination: { - ToAddresses: [participant.email] - }, - Message: { - Body: { - Html: { - Charset: "UTF-8", - Data: customizedContent - } - }, - Subject: { - Charset: "UTF-8", - Data: `Registration Confirmation for ${event.event_name}` - } - }, - Source: `"GitHub Community SRM | Events" `, - ReplyToAddresses: ["community@githubsrmist.in"] - }; - - const command = new SendEmailCommand(params); - await sesClient.send(command); - console.log("Registration email sent successfully."); - } catch (error) { - console.error("Error sending email:", error); - } -} diff --git a/utils/email/registrationMail.html b/utils/email/registrationMail.html deleted file mode 100644 index 4ac9ba5..0000000 --- a/utils/email/registrationMail.html +++ /dev/null @@ -1,1365 +0,0 @@ - - - - - - - - - Empty template - - - - - - - -
- - - - - -
- - - - -
- - - - -
- - - - - - - - - -
- - - - -
- Left Image -
-
- - - - -
- Right Image -
-
- -
-
- - - - -
- - - - -
- - - - -
- - - - -
- - Registration - Confirmation - -
-

- Registration - Confirmation -

-
-

- Dear - {{name}}, -

-
-

- Thank - you - for - registering - for - the - event - "{{event}}", - hosted - by - GitHub - Community - SRM. - Your - registration - is - confirmed! -

-
-

- Event - Details: -

-
    -
  • - - Event - Name: - - {{event}} -
  • -
  • - Event - Description: - {{event_description}} -
  • -
  • - Date/Time: - {{date}} -
  • - -
  • - Venue: - {{venue}} -
  • -
  • - Prerequisites: - {{prerequisites}} -
  • -
-

- Be - sure - to - bring - your - laptop, - charger, - and - any - other - necessary - items - to - fully - participate - in - the - event. -

-
-

- We - are - excited - to - have - you - join - us! -

-
-

- If - you - have - any - questions, - feel - free - to - contact - us - at - community@githubsrmist.in. -

- -
-
-
-
-
- - - - - -
-
- - diff --git a/utils/models/contact.model.js b/utils/models/contact.model.js deleted file mode 100644 index 74f79e4..0000000 --- a/utils/models/contact.model.js +++ /dev/null @@ -1,20 +0,0 @@ -import mongoose from "mongoose"; - -const contactSchema = new mongoose.Schema({ - name: { - type: String, - required: true - }, - email: { - type: String, - required: true - }, - message: { - type: String, - required: true - } -}); - -const Contact = mongoose.models.Contacts || mongoose.model("Contacts", contactSchema); - -export default Contact; diff --git a/utils/models/event.models.js b/utils/models/event.models.js deleted file mode 100644 index 264ef64..0000000 --- a/utils/models/event.models.js +++ /dev/null @@ -1,124 +0,0 @@ -const mongoose = require("mongoose"); - -const eventSchema = new mongoose.Schema({ - slug: { - type: String, - required: true, - unique: true - }, - event_name: { - type: String, - required: true - }, - event_description: { - type: String, - required: true - }, - speakers_details: [ - { - name: { - type: String - }, - designation: { - type: String - }, - details: String - } - ], - event_date: { - type: Date, - required: true - }, - is_active: { - type: Boolean, - default: true - }, - venue: { - type: String, - required: true - }, - sponsors_details: [ - { - name: String, - place: String, - details: String - } - ], - duration: { - type: Number, - required: true - }, - prerequisites: [String], - certificateLink: { - type: String, - required: true - }, - cost: { - type: Number, - default: 0 - }, - poster_url: { - type: String, - required: true - }, - registration_url: { - type: String, - required: true - }, - gallery: [String], - database: { - type: String, - required: true - }, - collection: { - participants: { - type: String, - required: true - }, - organizers: { - type: String, - required: true - }, - volunteers: { - type: String, - required: true - } - }, - certificate: { - organizers: { - type: String, - required: true - }, - participants: { - type: String, - required: true - }, - volunteers: { - type: String, - required: true - } - }, - jimp_config: { - yOffset: { - type: String - }, - color: { - type: String - }, - font_size: { - type: String - } - }, - teamEvent: { - type: Boolean, - default: false - }, - teamSize: { - type: Number, - default: 1 - } -}); - -const Event = mongoose.models.events || mongoose.model("events", eventSchema); - -export default Event; diff --git a/utils/models/recruitment.model.js b/utils/models/recruitment.model.js deleted file mode 100644 index 3cfa528..0000000 --- a/utils/models/recruitment.model.js +++ /dev/null @@ -1,61 +0,0 @@ -const mongoose = require("mongoose"); - -const participantSchema = new mongoose.Schema({ - name: { - type: String, - required: true - }, - email: { - type: String, - required: true, - unique: true - }, - regNo: { - type: String, - required: true, - unique: true - }, - phoneNo: { - type: Number, - required: true - }, - year: { - type: String, - required: true - }, - dept: { - type: String, - required: true - }, - domain: { - type: Map, - of: { - type: [String], - maxlength: 2 - }, - required: true - }, - links: { - github: { - type: String, - default: null - }, - demo: { - type: String, - default: null - }, - deployment: { - type: String, - default: null - } - }, - status: { - type: String, - enum: ["registered", "taskSubmitted", "interviewShortlisted", "onboarding"], - default: "registered" - } -}); - -const ParticipantUser = mongoose.models.Recruitment24 || mongoose.model("Recruitment24", participantSchema); - -module.exports = ParticipantUser; diff --git a/utils/models/sponser.model.js b/utils/models/sponser.model.js deleted file mode 100644 index c734af4..0000000 --- a/utils/models/sponser.model.js +++ /dev/null @@ -1,16 +0,0 @@ -import mongoose from "mongoose"; - -const sponsorSchema = new mongoose.Schema({ - name: { - type: String, - required: true - }, - logo: { - type: String, - required: true - } -}); - -const Sponsor = mongoose.models.sponsors || mongoose.model("sponsors", sponsorSchema); - -export default Sponsor; \ No newline at end of file diff --git a/utils/models/tasks.model.js b/utils/models/tasks.model.js deleted file mode 100644 index 67c6dd1..0000000 --- a/utils/models/tasks.model.js +++ /dev/null @@ -1,50 +0,0 @@ -const mongoose = require("mongoose"); - -const taskSchema = new mongoose.Schema({ - title: { - type: String, - required: true - }, - description: { - type: String, - required: true - }, - guidelines: { - type: String, - required: true - }, - link: { - type: String, - }, - domain: { - type: String, - enum: ["Technical", "Creatives", "Corporate"], - required: true - }, - subdomain: { - type: String, - enum: [ - "AIML", "Web-Dev", "CP", "App-dev", "Frontend", "Backend", "Full-stack", - "GD", "VFX", " " - ], - required: true - }, - taskType: { - type: String, - enum: ["Frontend", "Backend", "Full-stack", "AIML", "CP", "App-dev", "GD", "VFX"], - required: true - }, - year: { - type: String, - enum: ["1st", "2nd"], - required: true - }, - deadline: { - type: Date, - required: false - }, -}); - -const Task = mongoose.models.tasks || mongoose.model("tasks", taskSchema); - -module.exports = Task; diff --git a/utils/models/team.model.js b/utils/models/team.model.js deleted file mode 100644 index 30a5a0f..0000000 --- a/utils/models/team.model.js +++ /dev/null @@ -1,23 +0,0 @@ -const mongoose = require("mongoose"); - -const teamSchema = new mongoose.Schema({ - index: Number, - name: String, - domain: String, - position: String, - caption: String, - joined: Number, - pictureUrl: String, - isCurrent: Boolean, - socials: { - github: String, - website: String, - linkedin: String, - twitter: String, - instagram: String - } -}); - -const Team = mongoose.models.teams || mongoose.model("teams", teamSchema); - -export default Team;