diff --git a/src/app/t/[path]/teams/page.tsx b/src/app/t/[path]/teams/page.tsx index 41a086a..22d17ca 100644 --- a/src/app/t/[path]/teams/page.tsx +++ b/src/app/t/[path]/teams/page.tsx @@ -1,3 +1,6 @@ +import { TeamsList } from "@/components/team/TeamsList"; +import Link from "next/link"; + export default async function TournamentTeamsPage({ params, }: { @@ -5,9 +8,13 @@ export default async function TournamentTeamsPage({ }) { return ( <> -
-

{`Teams`}

+
+

{`Teams`}

+
+ Add +
+ ); } diff --git a/src/components/GenericListItem.tsx b/src/components/GenericListItem.tsx new file mode 100644 index 0000000..1bb1f70 --- /dev/null +++ b/src/components/GenericListItem.tsx @@ -0,0 +1,32 @@ +import Link from "next/link"; +import { JSX } from "react"; + +const GenericListItem = ({ + title, + subtitle, + href, + icon, +}: { + title: string; + subtitle?: string; + href?: string; + icon?: () => JSX.Element; +}) => { + return ( + <> +
+ +
+

{title}

+

+ {subtitle} +

+
+ {icon && icon()} + +
+ + ); +}; + +export { GenericListItem }; diff --git a/src/components/team/TeamsList.tsx b/src/components/team/TeamsList.tsx new file mode 100644 index 0000000..8cfa98d --- /dev/null +++ b/src/components/team/TeamsList.tsx @@ -0,0 +1,51 @@ +import { fetchServerside } from "@/lib/utils"; +import { Team } from "@/types/Team"; +import { cookies } from "next/headers"; +import { GenericListItem } from "../GenericListItem"; + +const TeamsList = async ({ tournament_id }: { tournament_id: string }) => { + let data_team: Team[] = []; + const response = await fetchServerside(`/tournament/${tournament_id}/team`, { + headers: { + Cookie: (await cookies()).toString(), + }, + }); + if (response.ok) { + data_team = await response.json(); + } + + return ( +
+ {data_team.length !== 0 ? ( +
+ {data_team.map((team, i) => { + return ; + })} +
+ ) : ( + <> +

+ {"There are currently no teams in the tournament."} +

+ + )} +
+ ); +}; + +const TeamListItem = ({ + team: team, +}: { + team: Team; + indexForImage: number; +}) => { + return ( + + ); +}; + +export { TeamsList }; diff --git a/src/components/tournament/TournamentList.tsx b/src/components/tournament/TournamentList.tsx index 579cd32..0c38f73 100644 --- a/src/components/tournament/TournamentList.tsx +++ b/src/components/tournament/TournamentList.tsx @@ -7,13 +7,13 @@ import MOW2024OlekRelief from "../../../public/S-MOW2024-olekrelief.jpg"; const TournamentsList = async () => { let data_tournaments: Tournament[] = []; - const res = await fetchServerside("/tournament", { + const response = await fetchServerside("/tournament", { headers: { Cookie: (await cookies()).toString(), }, }); - if (res.ok) { - data_tournaments = await res.json(); + if (response.ok) { + data_tournaments = await response.json(); } return ( diff --git a/src/types/Team.ts b/src/types/Team.ts new file mode 100644 index 0000000..e4518db --- /dev/null +++ b/src/types/Team.ts @@ -0,0 +1,8 @@ +type Team = { + id: string; + full_name: string; + shortened_name: string; + tournament_id: string; +}; + +export type { Team };