mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-26 05:18:24 +00:00
21 lines
762 B
TypeScript
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 />,
|
|
})
|