skeletons, tournament stats, polish, bug fixes
This commit is contained in:
@@ -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