Files
shumai/packages/webui/routes/projects/$projectId/index.tsx
T

21 lines
762 B
TypeScript

import { client } from '@/ui/api/client'
import { ProjectFolderSkeleton } from '@/ui/components/loading-skeletons'
import { createFileRoute } from '@tanstack/react-router'
export const projectInfoQueryOptions = (projectId: string) => ({
queryKey: ['projects', projectId],
queryFn: async () => {
const res = await client.api.projects[':projectId'].$get({
param: { projectId: projectId },
})
if (!res.ok) throw new Error('failed to fetch project')
return await res.json()
},
})
export const Route = createFileRoute('/projects/$projectId/')({
loader: ({ context: { queryClient }, params: { projectId } }) =>
queryClient.ensureQueryData(projectInfoQueryOptions(projectId)),
pendingComponent: () => <ProjectFolderSkeleton />,
})