wip upcoming tournament page
This commit is contained in:
@@ -1,11 +1,21 @@
|
|||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
import { useCurrentTournament } from "@/features/tournaments/queries";
|
import { tournamentQueries, useCurrentTournament } from "@/features/tournaments/queries";
|
||||||
import UpcomingTournament from "@/features/tournaments/components/upcoming-tournament";
|
import UpcomingTournament from "@/features/tournaments/components/upcoming-tournament";
|
||||||
|
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_authed/")({
|
export const Route = createFileRoute("/_authed/")({
|
||||||
component: Home,
|
component: Home,
|
||||||
loader: () => ({
|
beforeLoad: async ({ context }) => {
|
||||||
|
const queryClient = context.queryClient;
|
||||||
|
const tournament = await ensureServerQueryData(queryClient, tournamentQueries.current())
|
||||||
|
|
||||||
|
return { tournament }
|
||||||
|
},
|
||||||
|
loader: ({ context }) => ({
|
||||||
withPadding: true,
|
withPadding: true,
|
||||||
|
header: {
|
||||||
|
title: context.tournament.name || "FLXN"
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
Stack,
|
Stack,
|
||||||
Title,
|
Title,
|
||||||
Text,
|
Text,
|
||||||
|
ThemeIcon,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import Avatar from "@/components/avatar";
|
import Avatar from "@/components/avatar";
|
||||||
import Countdown from "@/components/countdown";
|
import Countdown from "@/components/countdown";
|
||||||
@@ -46,10 +47,12 @@ const UpcomingTournament: React.FC<{ tournament: Tournament }> = ({
|
|||||||
const tournamentStart = new Date(tournament.start_time);
|
const tournamentStart = new Date(tournament.start_time);
|
||||||
const isEnrollmentOpen = enrollmentDeadline > new Date();
|
const isEnrollmentOpen = enrollmentDeadline > new Date();
|
||||||
|
|
||||||
|
const enrolledTeamsCount = tournament.teams?.length || 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack gap="lg">
|
<Stack gap="lg">
|
||||||
<Group justify="space-between" align="flex-start">
|
<Group justify="space-around" align="flex-start" w='100%'>
|
||||||
<Group align="flex-start" gap="lg">
|
<Group align="center" gap="lg">
|
||||||
<Avatar
|
<Avatar
|
||||||
name={tournament.name}
|
name={tournament.name}
|
||||||
src={
|
src={
|
||||||
@@ -58,42 +61,55 @@ const UpcomingTournament: React.FC<{ tournament: Tournament }> = ({
|
|||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
radius="md"
|
radius="md"
|
||||||
size={80}
|
size={120}
|
||||||
|
px='md'
|
||||||
withBorder={false}
|
withBorder={false}
|
||||||
>
|
>
|
||||||
<TrophyIcon size={32} />
|
<TrophyIcon size={32} />
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<Stack gap="xs">
|
<Stack gap="xs">
|
||||||
<Group gap="sm">
|
|
||||||
<Title order={2}>{tournament.name}</Title>
|
|
||||||
</Group>
|
|
||||||
{tournament.location && (
|
{tournament.location && (
|
||||||
<Group gap="xs">
|
<Group gap="xs">
|
||||||
<MapPinIcon size={16} />
|
<ThemeIcon size="sm" variant="light" radius="sm">
|
||||||
|
<MapPinIcon size={14} />
|
||||||
|
</ThemeIcon>
|
||||||
<Text size="sm" c="dimmed">
|
<Text size="sm" c="dimmed">
|
||||||
{tournament.location}
|
{tournament.location}
|
||||||
</Text>
|
</Text>
|
||||||
</Group>
|
</Group>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Group gap="xs">
|
<Group gap="xs">
|
||||||
<CalendarIcon size={16} />
|
<ThemeIcon size="sm" variant="light" radius="sm">
|
||||||
|
<CalendarIcon size={14} />
|
||||||
|
</ThemeIcon>
|
||||||
<Text size="sm" c="dimmed">
|
<Text size="sm" c="dimmed">
|
||||||
{tournamentStart.toLocaleDateString()} at{" "}
|
{tournamentStart.toLocaleDateString(undefined, {
|
||||||
|
weekday: "short",
|
||||||
|
month: "short",
|
||||||
|
day: "numeric",
|
||||||
|
})}{" "}
|
||||||
|
at{" "}
|
||||||
{tournamentStart.toLocaleTimeString([], {
|
{tournamentStart.toLocaleTimeString([], {
|
||||||
hour: "2-digit",
|
hour: "2-digit",
|
||||||
minute: "2-digit",
|
minute: "2-digit",
|
||||||
})}
|
})}
|
||||||
</Text>
|
</Text>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
|
<Group gap="xs">
|
||||||
|
<ThemeIcon size="sm" variant="light" radius="sm">
|
||||||
|
<UsersIcon size={14} />
|
||||||
|
</ThemeIcon>
|
||||||
|
<Text size="sm" c="dimmed">
|
||||||
|
{enrolledTeamsCount} teams enrolled
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
{tournament.desc && (
|
{tournament.desc && <Text size="sm">{tournament.desc}</Text>}
|
||||||
<Text size="sm">
|
|
||||||
{tournament.desc}
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Card withBorder radius="md" p="lg">
|
<Card withBorder radius="md" p="lg">
|
||||||
<Stack gap="md">
|
<Stack gap="md">
|
||||||
@@ -134,7 +150,7 @@ const UpcomingTournament: React.FC<{ tournament: Tournament }> = ({
|
|||||||
)}
|
)}
|
||||||
<ListButton label="View Rules" Icon={ListIcon} onClick={() => {}} />
|
<ListButton label="View Rules" Icon={ListIcon} onClick={() => {}} />
|
||||||
<ListButton
|
<ListButton
|
||||||
label={`View Teams (${tournament.teams?.length || 0})`}
|
label={`View Teams (${enrolledTeamsCount})`}
|
||||||
Icon={UsersIcon}
|
Icon={UsersIcon}
|
||||||
onClick={() => {}}
|
onClick={() => {}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user