Skip to content

Commit 18aaa76

Browse files
Implement event registration logic for SCEvents (#2073)
1 parent 0116cb0 commit 18aaa76

5 files changed

Lines changed: 298 additions & 15 deletions

File tree

package-lock.json

Lines changed: 30 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/APIFunctions/SCEvents.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,29 @@ export async function getAllSCEvents() {
2727

2828
return status;
2929
}
30+
31+
export async function getEventByID(id) {
32+
let status = new ApiResponse();
33+
34+
try {
35+
const url = new URL(`/events/${id}`, SCEVENTS_API_URL);
36+
const res = await fetch(url.href, {
37+
method: 'GET',
38+
headers: {
39+
'Content-Type': 'application/json',
40+
},
41+
});
42+
43+
if (res.ok) {
44+
const result = await res.json();
45+
status.responseData = result;
46+
} else {
47+
status.error = true;
48+
}
49+
} catch (err) {
50+
status.error = true;
51+
status.responseData = err;
52+
}
53+
54+
return status;
55+
}

src/Pages/Events/Events.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useEffect, useState } from 'react';
22
import config from '../../config/config.json';
3-
import { Redirect } from 'react-router-dom';
3+
import { Link, Redirect } from 'react-router-dom';
44
import { getAllSCEvents } from '../../APIFunctions/SCEvents';
55

66
function CalendarIcon() {
@@ -41,7 +41,7 @@ function PinIcon() {
4141

4242
function EventCard({ event }) {
4343
return (
44-
<div className="group rounded-2xl border border-white/10 bg-white/5 p-6 shadow-md backdrop-blur-sm transition duration-300 hover:-translate-y-1 hover:border-white/20 hover:bg-white/[0.07]">
44+
<div className="group flex flex-col rounded-2xl border border-white/10 bg-white/5 p-6 shadow-md backdrop-blur-sm transition duration-300 hover:-translate-y-1 hover:border-white/20 hover:bg-white/[0.07]">
4545
<h2 className="mb-4 text-2xl font-bold text-white">
4646
{event.name || 'Untitled Event'}
4747
</h2>
@@ -71,6 +71,15 @@ function EventCard({ event }) {
7171
{event.description}
7272
</p>
7373
)}
74+
75+
<div className="mt-auto pt-6">
76+
<Link
77+
to={`/events/${event.id}/register`}
78+
className="inline-flex w-full items-center justify-center rounded-xl bg-gradient-to-r from-sky-500 to-indigo-500 px-6 py-3 text-sm font-semibold text-white shadow-lg transition-all duration-300 hover:from-sky-400 hover:to-indigo-400 focus:outline-none focus:ring-2 focus:ring-sky-500 focus:ring-offset-2 focus:ring-offset-gray-900"
79+
>
80+
Register
81+
</Link>
82+
</div>
7483
</div>
7584
);
7685
}

0 commit comments

Comments
 (0)