Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User view events #39

Merged
merged 23 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5f5efed
Add page scaffold and backend fetching
kevinxiao27 Aug 18, 2024
cbc4b6e
Feat: set up backend connections and props
kevinxiao27 Aug 19, 2024
87e77fb
Feat: working filters and some outlined backend connections
kevinxiao27 Aug 20, 2024
b1bc44a
Rename imports
kevinxiao27 Aug 20, 2024
adc4964
Feat: modify useMemo dependncies + remove console.logs
kevinxiao27 Aug 20, 2024
dfde164
Fix mobile styling + font sizes
kevinxiao27 Aug 20, 2024
8844e4b
Feat: fix multiple empty keys bug
kevinxiao27 Aug 20, 2024
ecf28e9
Small code refactors + animation unmounting bug fix
kevinxiao27 Aug 20, 2024
6613638
attempt to resolve prettier formatting conflicts
kevinxiao27 Aug 20, 2024
597a408
Added artificial delay to UI clicks to prevent buggy framer-motion un…
kevinxiao27 Aug 20, 2024
4778236
renamed folder to EventsDashboard
kevinxiao27 Aug 21, 2024
9db49ff
add link to event page from cards
kevinxiao27 Aug 21, 2024
1a3e597
Simplified UI + backend integration
kevinxiao27 Aug 24, 2024
34816ea
Extract Component Refactoring + Tailwind Breakpoints
kevinxiao27 Aug 26, 2024
94ca5ee
Mobile fixes with refactors + guest banner
kevinxiao27 Aug 27, 2024
8c7c205
Conditonal filter tabs for guest view
kevinxiao27 Aug 29, 2024
afc187f
extract refactor event pricing + comment out saved events requirement
kevinxiao27 Aug 29, 2024
bc23510
apostrophe escape fix
kevinxiao27 Aug 29, 2024
53a4fd7
Comment out save logic
kevinxiao27 Sep 22, 2024
a1dc464
Fix buggy event cards
kevinxiao27 Sep 22, 2024
603c565
Update node dependencies
kevinxiao27 Sep 22, 2024
0e78fd6
remove log
kevinxiao27 Sep 22, 2024
9cfb9b7
Merge branch 'dev' into events-view
kevinxiao27 Sep 22, 2024
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
35 changes: 26 additions & 9 deletions src/components/EventsDashboard/EventCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import Link from "next/link";
interface EventCardProps {
event: BiztechEvent;
user: string;
registered: string[];
saved: string[];
setSaved: Dispatch<SetStateAction<string[]>>;
}

const months = ["Jan.", "Feb.", "Mar.", "Apr.", "May", "Jun.", "Jul.", "Aug.", "Sep.", "Oct.", "Nov.", "Dec."];

export const EventCard: React.FC<EventCardProps> = ({ event, user, saved, setSaved }) => {
export const EventCard: React.FC<EventCardProps> = ({ event, user, registered, saved, setSaved }) => {
const [fill, setFill] = useState(false);
let dateString = new Date(event.startDate);

Expand All @@ -36,6 +37,11 @@ export const EventCard: React.FC<EventCardProps> = ({ event, user, saved, setSav
isFavourite = true;
setFill(true);
}
setSaved(newSaved);

if (!user) {
return;
}

const body = {
eventID: id,
Expand All @@ -48,19 +54,18 @@ export const EventCard: React.FC<EventCardProps> = ({ event, user, saved, setSav
} catch (err) {
console.error(err);
}
setSaved(newSaved);
};

const timeStateIndicator = (event: BiztechEvent) => {
const startDate = new Date(event.startDate);
const deadline = new Date(event.deadline);
const timeStateIndicator = (ev: BiztechEvent) => {
const startDate = new Date(ev.startDate);
const deadline = new Date(ev.deadline);
if (new Date() >= deadline && startDate >= new Date()) {
return (
<div className="rounded-full font-poppin font-[700] px-3 py-1 text-white bg-secondary-color text-[8px] lg:text-[12px] flex items-center">
COMING UP
</div>
);
} else if (startDate > new Date()) {
} else if (startDate > new Date() && !registered.includes(`${ev.id};${ev.year}`)) {
return (
<div className="rounded-full px-3 py-1 font-poppins font-[700] text-white bg-events-coming-up text-[8px] lg:text-[12px] flex items-center">
REGISTER BY {`${deadline.getMonth() + 1}/${deadline.getDate()}`}
Expand All @@ -71,10 +76,19 @@ export const EventCard: React.FC<EventCardProps> = ({ event, user, saved, setSav
}
};

const registeredIndicator = (ev: BiztechEvent) => {
if (registered.includes(`${ev.id};${ev.year}`)) {
return <div className="rounded-full font-poppin font-[700] px-3 py-1 text-white bg-black text-[8px] lg:text-[12px] flex items-center">REGISTERED</div>;
} else {
return <></>;
}
};

return (
<>
<Link href={`/events/${event.id}/${event.year}`}>
<Link href={`/event/${event.id}/${event.year}`}>
<motion.div
key={`${event.id + event.year + event.createdAt}`}
layout
initial={{ y: -10, opacity: 0 }}
animate={{ y: 0, opacity: 1 }}
Expand All @@ -94,8 +108,10 @@ export const EventCard: React.FC<EventCardProps> = ({ event, user, saved, setSav
<div className="flex flex-col space-y-1 grow">
<div className="font-600 text-sm lg:text-[24px] py-0.5 lg:py-2 flex flex-row space-x-3 items-center w-full">
<div>{event.ename}</div>
<div className="grow"></div>
<div className="hidden lg:block">{registeredIndicator(event)}</div>
<div className="hidden lg:block">{timeStateIndicator(event)}</div>
<div className="grow flex justify-end">
<div className="">
<Bookmark
height={30}
width={30}
Expand All @@ -112,7 +128,8 @@ export const EventCard: React.FC<EventCardProps> = ({ event, user, saved, setSav
{`${event.pricing ? "$" + event.pricing.members.toFixed(2) : "Free!"}`}{" "}
{event.pricing.nonMembers ? `(Non-members ${event.pricing?.nonMembers.toFixed(2)})` : "(Members only)"}
</p>
<div className="lg:hidden">{timeStateIndicator(event)}</div>
<div className="lg:hidden flex grow justify-end">{registeredIndicator(event)}</div>
<div className="lg:hidden ml-0.5">{timeStateIndicator(event)}</div>
</div>
</div>
</div>
Expand Down
7 changes: 4 additions & 3 deletions src/components/EventsDashboard/EventDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import { EventCard } from "./EventCard";
interface EventDashboardProps {
events: BiztechEvent[];
user: string;
registered: string[];
saved: string[];
setSaved: Dispatch<SetStateAction<string[]>>;
}

export const EventDashboard: React.FC<EventDashboardProps> = ({ events, user, saved, setSaved }) => {
export const EventDashboard: React.FC<EventDashboardProps> = ({ events, user, registered, saved, setSaved }) => {
const currentEvents = events.filter((event) => {
const time = new Date(event.startDate);
return new Date() < time;
Expand Down Expand Up @@ -48,7 +49,7 @@ export const EventDashboard: React.FC<EventDashboardProps> = ({ events, user, sa
currentEvents.map((event, i) => {
return (
<div key={`${event.id + event.year + event.createdAt}`}>
<EventCard event={event} user={user} saved={saved} setSaved={setSaved} />
<EventCard event={event} user={user} registered={registered} saved={saved} setSaved={setSaved} />
</div>
);
})}
Expand Down Expand Up @@ -79,7 +80,7 @@ export const EventDashboard: React.FC<EventDashboardProps> = ({ events, user, sa
pastEvents.map((event) => {
return (
<div key={`${event.id + event.year}`}>
<EventCard event={event} user={user} saved={saved} setSaved={setSaved} />
<EventCard event={event} user={user} registered={registered} saved={saved} setSaved={setSaved} />
</div>
);
})}
Expand Down
Loading