Skip to content

Commit f5e7ea3

Browse files
committed
1st version
1 parent 254d5d4 commit f5e7ea3

4 files changed

Lines changed: 42 additions & 5 deletions

File tree

1.44 MB
Loading

client/src/components/ui/eventCarousel.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,32 @@ type EventCarouselProps = {
1111

1212
const GAP = 40;
1313

14+
function formatEventDateDisplay(dateString: string): string {
15+
try {
16+
const date = new Date(dateString);
17+
const weekday = new Intl.DateTimeFormat("en-US", {
18+
weekday: "long",
19+
}).format(date);
20+
const day = new Intl.DateTimeFormat("en-US", { day: "numeric" }).format(
21+
date,
22+
);
23+
const month = new Intl.DateTimeFormat("en-US", { month: "short" }).format(
24+
date,
25+
);
26+
const time = new Intl.DateTimeFormat("en-US", {
27+
hour: "2-digit",
28+
minute: "2-digit",
29+
hour12: true,
30+
})
31+
.format(date)
32+
.replace("AM", "am")
33+
.replace("PM", "pm");
34+
return `${weekday} ${day} ${month} ${time}`;
35+
} catch {
36+
return "";
37+
}
38+
}
39+
1440
export default function EventCarousel({ items }: EventCarouselProps) {
1541
const viewportRef = useRef<HTMLDivElement>(null);
1642
const firstItemRef = useRef<HTMLDivElement>(null);
@@ -111,7 +137,7 @@ export default function EventCarousel({ items }: EventCarouselProps) {
111137

112138
{/* Needs proper processing and laying out */}
113139
<p className="text-sm tracking-wide text-white/70">
114-
{event.startTime}
140+
{formatEventDateDisplay(event.date)}
115141
</p>
116142

117143
<div className="mt-3 w-full border-b border-white/20" />

client/src/hooks/useEvents.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ export type UiEvent = Omit<ApiEvent, "cover_image"> & {
1818
coverImage: string;
1919
};
2020

21+
// TODO: replace "/game_event_poster.png" with "/game_dev_club_logo.svg" after tests
2122
function transformApiEventToUiEvent(data: ApiEvent): UiEvent {
2223
return {
2324
...data,
24-
coverImage: data.cover_image ?? "/game_dev_club_logo.svg",
25+
coverImage: data.cover_image ?? "/game_event_poster.png",
2526
};
2627
}
2728

client/src/pages/index.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,21 @@ import {
66
EventHighlightCard,
77
eventHighlightCardType,
88
} from "@/components/ui/eventHighlightCard";
9-
import { placeholderEvents, placeholderGames } from "@/placeholderData";
9+
import { UiEvent, useEvents } from "@/hooks/useEvents";
10+
import { placeholderGames } from "@/placeholderData";
1011

1112
import { Button } from "../components/ui/button";
1213

1314
export default function Landing() {
15+
const { data, isPending, isError } = useEvents({
16+
type: "upcoming",
17+
pageSize: 100,
18+
});
19+
// TODO: remove this after testing
20+
console.log("data =", data);
21+
22+
const events: UiEvent[] | undefined = data?.items;
23+
1424
const gameLogoImages = [
1525
{ url: "/godot.png", alt: "Godot Logo", position: "start" },
1626
{ url: "/unity-logo.png", alt: "Unity Logo", position: "end" },
@@ -137,7 +147,7 @@ export default function Landing() {
137147
</section>
138148

139149
<section className="bg-background px-10 py-20">
140-
<EventCarousel items={placeholderEvents} />
150+
{!isPending && !isError && <EventCarousel items={events ?? []} />}
141151
</section>
142152
{/* Leaving commented out until styling/design is confirmed. */}
143153
{/* <section className="bg-background px-4 py-10 md:px-10">
@@ -146,7 +156,7 @@ export default function Landing() {
146156
title="So... How do I get involved?"
147157
text="The easiest way to get involved is to come along to one of our events!"
148158
/>
149-
</div>
159+
</div>1
150160
</section> */}
151161

152162
<section className="relative w-full overflow-hidden bg-dark_3 px-6 py-20 lg:px-12">

0 commit comments

Comments
 (0)