Skip to content

Commit cd60f0b

Browse files
participants can be printed
1 parent aebd54a commit cd60f0b

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

client/src/pages/events/[id].tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useRouter } from "next/router";
44

55
import { Button } from "@/components/ui/button";
66
import TagList from "@/components/ui/tag-list";
7-
import { useEvent } from "@/hooks/event";
7+
import { useEvent } from "@/hooks/events";
88

99
import ActionLayout from "../layouts/actionlayout";
1010

client/src/pages/events/[id]/participants.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ import Link from "next/link";
22
import { useRouter } from "next/router";
33

44
import { Button } from "@/components/ui/button";
5+
import { useEvent } from "@/hooks/events";
56
import ActionLayout from "@/pages/layouts/actionlayout";
67

78
export default function ParticipantsPage() {
89
const router = useRouter();
910
const { id } = router.query;
11+
const eventId = Number(id);
12+
13+
const { data: event, isLoading } = useEvent(eventId);
1014

1115
return (
1216
<>
@@ -21,12 +25,25 @@ export default function ParticipantsPage() {
2125
</Button>
2226
}
2327
primaryAction={
24-
<Link href={"/events/" + id + "/participants"} className="flex-1">
28+
<Link
29+
href={"/events/" + eventId + "/participants"}
30+
className="flex-1"
31+
>
2532
<Button className="w-full rounded-full">Unused Button</Button>
2633
</Link>
2734
}
2835
>
29-
<div>Participants for event {id}</div>
36+
{!isLoading && event?.participants && event.participants.length > 0 && (
37+
<div>
38+
{event.participants.map((p) => (
39+
<p key={p.id}>{p.username}</p>
40+
))}
41+
</div>
42+
)}
43+
44+
{!isLoading && event?.participants?.length === 0 && (
45+
<p>No participants yet.</p>
46+
)}
3047
</ActionLayout>
3148
</>
3249
);

0 commit comments

Comments
 (0)