Skip to content

Commit 6af71aa

Browse files
authored
Merge pull request #140 from SRM-IST-KTR/staging
Participation certificates done
2 parents fb0f432 + b5f2b23 commit 6af71aa

4 files changed

Lines changed: 101 additions & 60 deletions

File tree

components/Events/EmailDialogue/EmailDialogue.jsx

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@ import { toast, ToastContainer } from "react-toastify";
44
import "react-toastify/dist/ReactToastify.css";
55

66
const EmailDialogBox = ({ CertiOBJ, title, handelCloseModel }) => {
7+
// const [formData, setFormData] = useState({
8+
// email: "",
9+
// type: "",
10+
// event: title
11+
// });
12+
13+
//only for ossome hacks 2
714
const [formData, setFormData] = useState({
8-
email: "",
15+
name: "",
916
type: "",
1017
event: title
1118
});
@@ -22,7 +29,7 @@ const EmailDialogBox = ({ CertiOBJ, title, handelCloseModel }) => {
2229
};
2330

2431
const handleEmailChange = (event) => {
25-
setFormData({ ...formData, email: event.target.value });
32+
setFormData({ ...formData, name: event.target.value });
2633
};
2734

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

3239
const handleGetCertificate = async (e) => {
3340
e.preventDefault();
34-
if (!validateEmail(formData.email)) {
35-
setEmailError("Please enter a valid SRMIST email address.");
36-
return;
37-
}
41+
// if (!validateEmail(formData.email)) {
42+
// setEmailError("Please enter a valid SRMIST email address.");
43+
// return;
44+
// }
3845
setEmailError("");
3946
setIsButtonDisabled(true);
4047
try {
@@ -110,15 +117,15 @@ const EmailDialogBox = ({ CertiOBJ, title, handelCloseModel }) => {
110117
<div className="rounded-md">
111118
<div>
112119
<label htmlFor="email" className="text-gray-800">
113-
Email address
120+
Name
114121
</label>
115122
<input
116-
placeholder="Enter SRMIST email"
123+
placeholder="Enter Name"
117124
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"
118125
required
119-
type="email"
120-
name="email"
121-
value={formData.email}
126+
type="text"
127+
name="text"
128+
value={formData.name}
122129
id="email"
123130
onChange={handleEmailChange}
124131
/>
@@ -157,11 +164,10 @@ const EmailDialogBox = ({ CertiOBJ, title, handelCloseModel }) => {
157164
type="button"
158165
onClick={handleDownload}
159166
disabled={!certificate || isLoading}
160-
className={`${
161-
certificate
162-
? "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"
163-
: "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"
164-
}`}
167+
className={`${certificate
168+
? "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"
169+
: "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"
170+
}`}
165171
>
166172
Download Certificate
167173
</button>

pages/api/v1/certificates/index.js

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,19 @@ DBInstance();
77

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

12-
if (!email || !event || !type) {
12+
//only for ossome hacks 2
13+
const { name, event, type } = req.body;
14+
15+
// if (!email || !event || !type) {
16+
// return res
17+
// .status(400)
18+
// .json({ success: false, error: "All fields are required." });
19+
// }
20+
21+
//only for ossome hacks 2
22+
if (!name || !event || !type) {
1323
return res
1424
.status(400)
1525
.json({ success: false, error: "All fields are required." });
@@ -59,12 +69,26 @@ export default async function handler(req, res) {
5969
});
6070

6171
const User = db.model(eventData.collection[type], userSchema);
62-
const userData = await User.findOne({ email });
72+
// const userData = await User.findOne({ email });
73+
74+
//only for ossome hacks 2
75+
const userData = await User.findOne({
76+
name: { $regex: new RegExp(`^${name}$`, 'i') }
77+
});
78+
79+
// if (!userData || !userData.checkin) {
80+
// return res.status(404).json({
81+
// success: false,
82+
// error: `No certificate found for email: ${email}`
83+
// });
84+
// }
85+
86+
//only for ossome hacks 2
6387

64-
if (!userData || !userData.checkin) {
88+
if (!userData) {
6589
return res.status(404).json({
6690
success: false,
67-
error: `No certificate found for email: ${email}`
91+
error: `No certificate found for name: ${name}`
6892
});
6993
}
7094
// console.log("User data:", userData);

pages/events/index.js

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@ const Events = () => {
4040
throw new Error("Failed to fetch data");
4141
}
4242
const data = await response.json();
43-
setEventData(data.data);
43+
44+
// Sort events by date (most recent first)
45+
const sortedEvents = data.data.sort((a, b) => {
46+
const dateA = new Date(a.event_date);
47+
const dateB = new Date(b.event_date);
48+
return dateB - dateA; // Sort in descending order (newest first)
49+
});
50+
51+
setEventData(sortedEvents);
4452
setFetched(true);
4553
} catch (error) {
4654
console.error(error);
@@ -52,6 +60,10 @@ const Events = () => {
5260

5361
const allEvents = eventData || [];
5462

63+
const activeEvents = allEvents.filter(event => event.is_active);
64+
65+
const pastEvents = allEvents.filter(event => !event.is_active);
66+
5567
return (
5668
<div className="bg-bg_black">
5769
<Head>
@@ -65,8 +77,8 @@ const Events = () => {
6577
content={`events, Community SRM, hackathons, workshops, ${allEvents
6678
.map((event) => event.event_name)
6779
.join(", ")}, ${allEvents
68-
.map((event) => event.venue)
69-
.join(", ")}, tech events, student events`}
80+
.map((event) => event.venue)
81+
.join(", ")}, tech events, student events`}
7082
/>
7183

7284
<meta
@@ -151,7 +163,7 @@ const Events = () => {
151163
<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">
152164
<div className="mt-10 relative z-10">
153165
{eventData &&
154-
eventData.filter((event) => event.is_active).length >
166+
eventData.filter((event) => event.is_active).length >
155167
0 ? (
156168
eventData.map(
157169
(event, index) =>
@@ -193,36 +205,36 @@ const Events = () => {
193205
<div className="flex flex-wrap justify-center gap-4 items-center pb-16 md:pb-28">
194206
{!fetched
195207
? Array.from({ length: 4 }, (_, index) => (
196-
<div
197-
key={index}
198-
className="w-96 sm:w-1/2 md:w-1/3 lg:w-1/2 xl:w-1/3 pr-4 lg:pl-10"
199-
>
200-
<PastEventsSkeleton />
201-
</div>
202-
))
208+
<div
209+
key={index}
210+
className="w-96 sm:w-1/2 md:w-1/3 lg:w-1/2 xl:w-1/3 pr-4 lg:pl-10"
211+
>
212+
<PastEventsSkeleton />
213+
</div>
214+
))
203215
: allEvents.map(
204-
(event, index) =>
205-
!event.is_active && (
206-
<div
207-
key={index}
208-
className="w-full sm:w-1/2 md:w-1/3 lg:w-1/2 xl:w-1/3 p-4"
209-
>
210-
<PastEvents
211-
poster={event.poster_url}
212-
title={event.event_name}
213-
certificateLink={event.certificate}
214-
onButtonClick={handleButtonClick}
215-
openModal={(certificateLink) =>
216-
setIsModalOpen({
217-
open: true,
218-
certificate: certificateLink,
219-
slug: event.slug
220-
})
221-
}
222-
/>
223-
</div>
224-
)
225-
)}
216+
(event, index) =>
217+
!event.is_active && (
218+
<div
219+
key={index}
220+
className="w-full sm:w-1/2 md:w-1/3 lg:w-1/2 xl:w-1/3 p-4"
221+
>
222+
<PastEvents
223+
poster={event.poster_url}
224+
title={event.event_name}
225+
certificateLink={event.certificate}
226+
onButtonClick={handleButtonClick}
227+
openModal={(certificateLink) =>
228+
setIsModalOpen({
229+
open: true,
230+
certificate: certificateLink,
231+
slug: event.slug
232+
})
233+
}
234+
/>
235+
</div>
236+
)
237+
)}
226238
</div>
227239

228240
{isModalOpen && (

public/sitemap-0.xml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<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">
3-
<url><loc>https://githubsrmist.tech</loc><lastmod>2025-03-12T16:01:30.825Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
4-
<url><loc>https://githubsrmist.tech/ODPage</loc><lastmod>2025-03-12T16:01:30.826Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
5-
<url><loc>https://githubsrmist.tech/about</loc><lastmod>2025-03-12T16:01:30.826Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
6-
<url><loc>https://githubsrmist.tech/contact</loc><lastmod>2025-03-12T16:01:30.826Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
7-
<url><loc>https://githubsrmist.tech/events</loc><lastmod>2025-03-12T16:01:30.826Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
8-
<url><loc>https://githubsrmist.tech/team</loc><lastmod>2025-03-12T16:01:30.826Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
3+
<url><loc>https://githubsrmist.tech</loc><lastmod>2025-03-13T07:22:50.228Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
4+
<url><loc>https://githubsrmist.tech/about</loc><lastmod>2025-03-13T07:22:50.229Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
5+
<url><loc>https://githubsrmist.tech/contact</loc><lastmod>2025-03-13T07:22:50.229Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
6+
<url><loc>https://githubsrmist.tech/events</loc><lastmod>2025-03-13T07:22:50.229Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
7+
<url><loc>https://githubsrmist.tech/team</loc><lastmod>2025-03-13T07:22:50.229Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
98
</urlset>

0 commit comments

Comments
 (0)