skeletons, tournament stats, polish, bug fixes
This commit is contained in:
@@ -18,7 +18,7 @@ export const Route = createFileRoute("/_authed/admin/tournaments/$id/teams")({
|
||||
loader: ({ context }) => ({
|
||||
header: {
|
||||
withBackButton: true,
|
||||
title: `Manage Teams - ${context.tournament.name}`,
|
||||
title: `${context.tournament.name} Teams`,
|
||||
},
|
||||
withPadding: false,
|
||||
}),
|
||||
|
||||
@@ -27,7 +27,6 @@ export const Route = createFileRoute("/_authed/")({
|
||||
|
||||
function Home() {
|
||||
const { data: tournament } = useCurrentTournament();
|
||||
|
||||
if (!tournament.matches || tournament.matches.length === 0) {
|
||||
return <UpcomingTournament tournament={tournament} />;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import TeamProfile from "@/features/teams/components/team-profile";
|
||||
import ProfileSkeleton from "@/features/teams/components/team-profile/skeleton";
|
||||
import { teamKeys, teamQueries } from "@/features/teams/queries";
|
||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { Suspense } from "react";
|
||||
import { z } from "zod";
|
||||
|
||||
const searchSchema = z.object({
|
||||
@@ -24,6 +26,8 @@ export const Route = createFileRoute("/_authed/teams/$teamId")({
|
||||
}),
|
||||
component: () => {
|
||||
const { teamId } = Route.useParams();
|
||||
return <TeamProfile id={teamId} />;
|
||||
return <Suspense fallback={<ProfileSkeleton />}>
|
||||
<TeamProfile id={teamId} />
|
||||
</Suspense>;
|
||||
},
|
||||
});
|
||||
|
||||
@@ -3,6 +3,8 @@ import { tournamentQueries } from '@/features/tournaments/queries';
|
||||
import Profile from '@/features/tournaments/components/profile';
|
||||
import { z } from "zod";
|
||||
import { prefetchServerQuery } from '@/lib/tanstack-query/utils/prefetch';
|
||||
import { Suspense } from 'react';
|
||||
import ProfileSkeleton from '@/features/tournaments/components/profile/skeleton';
|
||||
|
||||
const searchSchema = z.object({
|
||||
tab: z.string().optional(),
|
||||
@@ -10,9 +12,9 @@ const searchSchema = z.object({
|
||||
|
||||
export const Route = createFileRoute('/_authed/tournaments/$tournamentId')({
|
||||
validateSearch: searchSchema,
|
||||
beforeLoad: async ({ context, params }) => {
|
||||
beforeLoad: ({ context, params }) => {
|
||||
const { queryClient } = context;
|
||||
await prefetchServerQuery(queryClient, tournamentQueries.details(params.tournamentId))
|
||||
prefetchServerQuery(queryClient, tournamentQueries.details(params.tournamentId))
|
||||
},
|
||||
loader: ({ params, context }) => ({
|
||||
header: {
|
||||
@@ -28,5 +30,7 @@ export const Route = createFileRoute('/_authed/tournaments/$tournamentId')({
|
||||
|
||||
function RouteComponent() {
|
||||
const tournamentId = Route.useParams().tournamentId;
|
||||
return <Profile id={tournamentId} />
|
||||
return <Suspense fallback={<ProfileSkeleton />}>
|
||||
<Profile id={tournamentId} />
|
||||
</Suspense>
|
||||
}
|
||||
|
||||
@@ -1,20 +1,14 @@
|
||||
import Page from '@/components/page'
|
||||
import { Stack } from '@mantine/core'
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { TournamentCard } from '@/features/tournaments/components/tournament-card'
|
||||
import { tournamentQueries, useTournaments } from '@/features/tournaments/queries'
|
||||
import { useAuth } from '@/contexts/auth-context'
|
||||
import { useSheet } from '@/hooks/use-sheet'
|
||||
import Sheet from '@/components/sheet/sheet'
|
||||
import TournamentForm from '@/features/tournaments/components/tournament-form'
|
||||
import { PlusIcon } from '@phosphor-icons/react'
|
||||
import Button from '@/components/button'
|
||||
import { tournamentQueries } from '@/features/tournaments/queries'
|
||||
import { prefetchServerQuery } from '@/lib/tanstack-query/utils/prefetch'
|
||||
import { Suspense } from 'react'
|
||||
import TournamentCardList from '@/features/tournaments/components/tournament-card-list'
|
||||
import { Skeleton, Stack } from '@mantine/core'
|
||||
|
||||
export const Route = createFileRoute('/_authed/tournaments/')({
|
||||
beforeLoad: async ({ context }) => {
|
||||
const { queryClient } = context;
|
||||
await prefetchServerQuery(queryClient, tournamentQueries.list())
|
||||
prefetchServerQuery(queryClient, tournamentQueries.list())
|
||||
},
|
||||
loader: () => ({
|
||||
header: {
|
||||
@@ -27,27 +21,11 @@ export const Route = createFileRoute('/_authed/tournaments/')({
|
||||
})
|
||||
|
||||
function RouteComponent() {
|
||||
const { data: tournaments } = useTournaments();
|
||||
const { roles } = useAuth();
|
||||
const sheet = useSheet();
|
||||
|
||||
return (
|
||||
<Stack>
|
||||
{
|
||||
roles?.includes("Admin") ? (
|
||||
<>
|
||||
<Button leftSection={<PlusIcon />} variant='subtle' onClick={sheet.open}>Create Tournament</Button>
|
||||
<Sheet {...sheet.props} title='Create Tournament'>
|
||||
<TournamentForm close={sheet.close} />
|
||||
</Sheet>
|
||||
</>
|
||||
) : null
|
||||
}
|
||||
{
|
||||
tournaments?.map((tournament: any) => (
|
||||
<TournamentCard key={tournament.id} tournament={tournament} />
|
||||
))
|
||||
}
|
||||
</Stack>
|
||||
)
|
||||
return <Suspense fallback={<Stack gap="md">
|
||||
{Array(10).fill(null).map((_, index) => (
|
||||
<Skeleton height="120px" w="100%" />
|
||||
))}
|
||||
</Stack>}>
|
||||
<TournamentCardList />
|
||||
</Suspense>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user