diff --git a/client/src/components/section-cards.tsx b/client/src/components/section-cards.tsx index 2b96ddf..bb71e4c 100644 --- a/client/src/components/section-cards.tsx +++ b/client/src/components/section-cards.tsx @@ -1,31 +1,9 @@ -import { Badge } from '@/components/ui/badge'; -import { - Card, - CardAction, - CardDescription, - CardFooter, - CardHeader, - CardTitle, -} from '@/components/ui/card'; -import { Button } from './ui/button'; +import { CheckinCard } from './workbenchCards/checkin'; export function SectionCards() { return (
- - - 签到状态 - - 未签到 - - - Day 1 - - - - - - +
); } diff --git a/client/src/components/workbenchCards/checkin.tsx b/client/src/components/workbenchCards/checkin.tsx new file mode 100644 index 0000000..a10f8a8 --- /dev/null +++ b/client/src/components/workbenchCards/checkin.tsx @@ -0,0 +1,38 @@ +import { toast } from 'sonner'; +import { Badge } from '@/components/ui/badge'; +import { Button } from '@/components/ui/button'; +import { Card, CardAction, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card'; +import { useCheckin } from '@/hooks/data/useCheckin'; + +export function CheckinCard() { + const { mutateAsync, isPending } = useCheckin(); + return ( + + + 签到状态 + + 未签到 + + + Day 1 + + + + + + + ); +} diff --git a/client/src/hooks/data/useCheckin.ts b/client/src/hooks/data/useCheckin.ts new file mode 100644 index 0000000..3bde16f --- /dev/null +++ b/client/src/hooks/data/useCheckin.ts @@ -0,0 +1,10 @@ +import { useMutation } from '@tanstack/react-query'; +import { axiosClient } from '@/lib/axios'; + +export function useCheckin() { + return useMutation({ + mutationFn: async () => { + return axiosClient.post('/checkin'); + }, + }); +} diff --git a/client/src/lib/axios.ts b/client/src/lib/axios.ts index 3791c5b..82b38c2 100644 --- a/client/src/lib/axios.ts +++ b/client/src/lib/axios.ts @@ -22,9 +22,7 @@ axiosClient.interceptors.response.use(undefined, async (error: AxiosError) => { await router.navigate({ to: '/login' }); return; } - if (error.config) { - return axiosClient(error.config); - } + else { return Promise.reject(error); } } return Promise.reject(error); }); diff --git a/client/src/routes/_sidebarLayout/index.tsx b/client/src/routes/_sidebarLayout/index.tsx index 7ba6097..dbc029f 100644 --- a/client/src/routes/_sidebarLayout/index.tsx +++ b/client/src/routes/_sidebarLayout/index.tsx @@ -4,13 +4,10 @@ import { hasToken } from '@/lib/token'; export const Route = createFileRoute('/_sidebarLayout/')({ component: Index, - beforeLoad: async ({ location }) => { + beforeLoad: async () => { if (!hasToken()) { throw redirect({ to: '/login', - search: { - redirect: location.href, - }, }); } },