Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions components/Events/EmailDialogue/EmailDialogue.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ import { toast, ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";

const EmailDialogBox = ({ CertiOBJ, title, handelCloseModel }) => {
// const [formData, setFormData] = useState({
// email: "",
// type: "",
// event: title
// });

//only for ossome hacks 2
const [formData, setFormData] = useState({
email: "",
name: "",
type: "",
event: title
});
Expand All @@ -22,7 +29,7 @@ const EmailDialogBox = ({ CertiOBJ, title, handelCloseModel }) => {
};

const handleEmailChange = (event) => {
setFormData({ ...formData, email: event.target.value });
setFormData({ ...formData, name: event.target.value });
};

const handleRoleChange = (event) => {
Expand All @@ -31,10 +38,10 @@ const EmailDialogBox = ({ CertiOBJ, title, handelCloseModel }) => {

const handleGetCertificate = async (e) => {
e.preventDefault();
if (!validateEmail(formData.email)) {
setEmailError("Please enter a valid SRMIST email address.");
return;
}
// if (!validateEmail(formData.email)) {
// setEmailError("Please enter a valid SRMIST email address.");
// return;
// }
setEmailError("");
setIsButtonDisabled(true);
try {
Expand Down Expand Up @@ -110,15 +117,15 @@ const EmailDialogBox = ({ CertiOBJ, title, handelCloseModel }) => {
<div className="rounded-md">
<div>
<label htmlFor="email" className="text-gray-800">
Email address
Name
</label>
<input
placeholder="Enter SRMIST email"
placeholder="Enter Name"
className="appearance-none relative block w-full px-3 py-3 border border-gray-100 bg-gray-100 rounded-md focus:outline-none focus:ring-bright_green focus:border-bright_green focus:z-10 text-black mb-8 mt-2 font-semibold"
required
type="email"
name="email"
value={formData.email}
type="text"
name="text"
value={formData.name}
id="email"
onChange={handleEmailChange}
/>
Expand Down Expand Up @@ -157,11 +164,10 @@ const EmailDialogBox = ({ CertiOBJ, title, handelCloseModel }) => {
type="button"
onClick={handleDownload}
disabled={!certificate || isLoading}
className={`${
certificate
? "group relative w-full flex justify-center py-3 px-4 border border-transparent font-bold rounded-md text-gray-900 bg-bright_green hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 mt-4"
: "mt-4 group relative w-full flex justify-center py-3 px-4 border border-transparent font-bold rounded-md text-gray-900 bg-gray-300 focus:outline-none focus:ring-2 focus:ring-offset-2 cursor-not-allowed"
}`}
className={`${certificate
? "group relative w-full flex justify-center py-3 px-4 border border-transparent font-bold rounded-md text-gray-900 bg-bright_green hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 mt-4"
: "mt-4 group relative w-full flex justify-center py-3 px-4 border border-transparent font-bold rounded-md text-gray-900 bg-gray-300 focus:outline-none focus:ring-2 focus:ring-offset-2 cursor-not-allowed"
}`}
>
Download Certificate
</button>
Expand Down
34 changes: 29 additions & 5 deletions pages/api/v1/certificates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@ DBInstance();

export default async function handler(req, res) {
if (req.method === "POST") {
const { email, event, type } = req.body;
// const { email, event, type } = req.body;

if (!email || !event || !type) {
//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." });
Expand Down Expand Up @@ -59,12 +69,26 @@ export default async function handler(req, res) {
});

const User = db.model(eventData.collection[type], userSchema);
const userData = await User.findOne({ email });
// const userData = await User.findOne({ email });

//only for ossome hacks 2
const userData = await User.findOne({
name: { $regex: new RegExp(`^${name}$`, 'i') }
});

// if (!userData || !userData.checkin) {
// return res.status(404).json({
// success: false,
// error: `No certificate found for email: ${email}`
// });
// }

//only for ossome hacks 2

if (!userData || !userData.checkin) {
if (!userData) {
return res.status(404).json({
success: false,
error: `No certificate found for email: ${email}`
error: `No certificate found for name: ${name}`
});
}
// console.log("User data:", userData);
Expand Down
78 changes: 45 additions & 33 deletions pages/events/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ const Events = () => {
throw new Error("Failed to fetch data");
}
const data = await response.json();
setEventData(data.data);

// Sort events by date (most recent first)
const sortedEvents = data.data.sort((a, b) => {
const dateA = new Date(a.event_date);
const dateB = new Date(b.event_date);
return dateB - dateA; // Sort in descending order (newest first)
});

setEventData(sortedEvents);
setFetched(true);
} catch (error) {
console.error(error);
Expand All @@ -52,6 +60,10 @@ const Events = () => {

const allEvents = eventData || [];

const activeEvents = allEvents.filter(event => event.is_active);

const pastEvents = allEvents.filter(event => !event.is_active);

return (
<div className="bg-bg_black">
<Head>
Expand All @@ -65,8 +77,8 @@ const Events = () => {
content={`events, Community SRM, hackathons, workshops, ${allEvents
.map((event) => event.event_name)
.join(", ")}, ${allEvents
.map((event) => event.venue)
.join(", ")}, tech events, student events`}
.map((event) => event.venue)
.join(", ")}, tech events, student events`}
/>

<meta
Expand Down Expand Up @@ -151,7 +163,7 @@ const Events = () => {
<div className="bg-black/40 -top-8 lg:top-0 lg:p-8 md:p-12 lg:px-16 lg:py-24 flex justify-center items-center">
<div className="mt-10 relative z-10">
{eventData &&
eventData.filter((event) => event.is_active).length >
eventData.filter((event) => event.is_active).length >
0 ? (
eventData.map(
(event, index) =>
Expand Down Expand Up @@ -193,36 +205,36 @@ const Events = () => {
<div className="flex flex-wrap justify-center gap-4 items-center pb-16 md:pb-28">
{!fetched
? Array.from({ length: 4 }, (_, index) => (
<div
key={index}
className="w-96 sm:w-1/2 md:w-1/3 lg:w-1/2 xl:w-1/3 pr-4 lg:pl-10"
>
<PastEventsSkeleton />
</div>
))
<div
key={index}
className="w-96 sm:w-1/2 md:w-1/3 lg:w-1/2 xl:w-1/3 pr-4 lg:pl-10"
>
<PastEventsSkeleton />
</div>
))
: allEvents.map(
(event, index) =>
!event.is_active && (
<div
key={index}
className="w-full sm:w-1/2 md:w-1/3 lg:w-1/2 xl:w-1/3 p-4"
>
<PastEvents
poster={event.poster_url}
title={event.event_name}
certificateLink={event.certificate}
onButtonClick={handleButtonClick}
openModal={(certificateLink) =>
setIsModalOpen({
open: true,
certificate: certificateLink,
slug: event.slug
})
}
/>
</div>
)
)}
(event, index) =>
!event.is_active && (
<div
key={index}
className="w-full sm:w-1/2 md:w-1/3 lg:w-1/2 xl:w-1/3 p-4"
>
<PastEvents
poster={event.poster_url}
title={event.event_name}
certificateLink={event.certificate}
onButtonClick={handleButtonClick}
openModal={(certificateLink) =>
setIsModalOpen({
open: true,
certificate: certificateLink,
slug: event.slug
})
}
/>
</div>
)
)}
</div>

{isModalOpen && (
Expand Down
11 changes: 5 additions & 6 deletions public/sitemap-0.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<url><loc>https://githubsrmist.tech</loc><lastmod>2025-03-12T16:01:30.825Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://githubsrmist.tech/ODPage</loc><lastmod>2025-03-12T16:01:30.826Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://githubsrmist.tech/about</loc><lastmod>2025-03-12T16:01:30.826Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://githubsrmist.tech/contact</loc><lastmod>2025-03-12T16:01:30.826Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://githubsrmist.tech/events</loc><lastmod>2025-03-12T16:01:30.826Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://githubsrmist.tech/team</loc><lastmod>2025-03-12T16:01:30.826Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://githubsrmist.tech</loc><lastmod>2025-03-13T07:22:50.228Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://githubsrmist.tech/about</loc><lastmod>2025-03-13T07:22:50.229Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://githubsrmist.tech/contact</loc><lastmod>2025-03-13T07:22:50.229Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://githubsrmist.tech/events</loc><lastmod>2025-03-13T07:22:50.229Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://githubsrmist.tech/team</loc><lastmod>2025-03-13T07:22:50.229Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
</urlset>