From 6907a6bbc6dc1f1f64127d77f84f07da673f179a Mon Sep 17 00:00:00 2001 From: Anders Date: Mon, 15 Apr 2024 20:17:41 +0200 Subject: [PATCH] Connected to db --- app/hooks/useTournament.ts | 2 ++ app/tournament/{[id] => [pin]}/before.tsx | 0 app/tournament/{[id] => [pin]}/ongoing.tsx | 0 app/tournament/{[id] => [pin]}/page.tsx | 12 ++++++++---- app/tournament/{[id] => [pin]}/results.tsx | 0 5 files changed, 10 insertions(+), 4 deletions(-) rename app/tournament/{[id] => [pin]}/before.tsx (100%) rename app/tournament/{[id] => [pin]}/ongoing.tsx (100%) rename app/tournament/{[id] => [pin]}/page.tsx (65%) rename app/tournament/{[id] => [pin]}/results.tsx (100%) diff --git a/app/hooks/useTournament.ts b/app/hooks/useTournament.ts index d5befee..f325e77 100644 --- a/app/hooks/useTournament.ts +++ b/app/hooks/useTournament.ts @@ -1,3 +1,5 @@ +'use client'; + import { Tournament } from '@/app/api/tournament'; import { PongMatch, diff --git a/app/tournament/[id]/before.tsx b/app/tournament/[pin]/before.tsx similarity index 100% rename from app/tournament/[id]/before.tsx rename to app/tournament/[pin]/before.tsx diff --git a/app/tournament/[id]/ongoing.tsx b/app/tournament/[pin]/ongoing.tsx similarity index 100% rename from app/tournament/[id]/ongoing.tsx rename to app/tournament/[pin]/ongoing.tsx diff --git a/app/tournament/[id]/page.tsx b/app/tournament/[pin]/page.tsx similarity index 65% rename from app/tournament/[id]/page.tsx rename to app/tournament/[pin]/page.tsx index 5a74fb4..de424dd 100644 --- a/app/tournament/[id]/page.tsx +++ b/app/tournament/[pin]/page.tsx @@ -1,20 +1,24 @@ -import { useTournament } from '../../hooks/useTournament'; +'use client'; + +import { useTournament, useTournamentByPin } from '../../hooks/useTournament'; import Before from './before'; import ResultsPage from './results'; interface TournamentPageProps { params: { - id: string; + pin: string; }; } export default function TournamentPage(props: TournamentPageProps) { - const { data: tournament, isLoading } = useTournament(props.params.id); + const { data: tournaments, isLoading } = useTournamentByPin(props.params.pin); - if (isLoading || !tournament) { + if (isLoading || !tournaments.length) { return
Loading...
; } + const tournament = tournaments[0]; + if (tournament.status === 'PENDING') { return ; } else if (tournament.status === 'ACTIVE') { diff --git a/app/tournament/[id]/results.tsx b/app/tournament/[pin]/results.tsx similarity index 100% rename from app/tournament/[id]/results.tsx rename to app/tournament/[pin]/results.tsx