From 8973d518a24d35780dbc7058ed9b8e27e44999bd Mon Sep 17 00:00:00 2001 From: Noa Virellia Date: Thu, 1 Jan 2026 11:21:08 +0800 Subject: [PATCH] refactor(client): qr dialog skeleton Signed-off-by: Noa Virellia --- client/src/components/checkin/qr-dialog.tsx | 33 +++++++++++++++++---- client/src/hooks/data/useGetCheckInCode.ts | 7 +++-- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/client/src/components/checkin/qr-dialog.tsx b/client/src/components/checkin/qr-dialog.tsx index dbc7424..dd6af35 100644 --- a/client/src/components/checkin/qr-dialog.tsx +++ b/client/src/components/checkin/qr-dialog.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { Dialog, DialogContent, @@ -14,9 +15,9 @@ import { Button } from '../ui/button'; export function QrDialog( { eventId }: { eventId: string }, ) { - const { data } = useCheckinCode(eventId); + const [open, setOpen] = useState(false); return ( - + @@ -27,21 +28,41 @@ export function QrDialog( 请工作人员扫描下面的二维码为你签到。 - + ); } -function QrDialogContent({ checkinCode }: { checkinCode: string }) { +function QrSection({ eventId, enabled }: { eventId: string; enabled: boolean }) { + const { data } = useCheckinCode(eventId, enabled); + return data + ? ( + <> +
+ +
+ +
+ {data.data.checkin_code} +
+
+ + ) + : ( + + ); +} + +function QrSectionSkeleton() { return ( <>
- +
- {checkinCode} + Loading...
diff --git a/client/src/hooks/data/useGetCheckInCode.ts b/client/src/hooks/data/useGetCheckInCode.ts index d0acd35..e4d5f05 100644 --- a/client/src/hooks/data/useGetCheckInCode.ts +++ b/client/src/hooks/data/useGetCheckInCode.ts @@ -1,8 +1,8 @@ -import { useSuspenseQuery } from '@tanstack/react-query'; +import { useQuery } from '@tanstack/react-query'; import { axiosClient } from '@/lib/axios'; -export function useCheckinCode(eventId: string) { - return useSuspenseQuery({ +export function useCheckinCode(eventId: string, enabled: boolean) { + return useQuery({ queryKey: ['getCheckinCode', eventId], queryFn: async () => { return axiosClient.get<{ @@ -13,5 +13,6 @@ export function useCheckinCode(eventId: string) { }, }); }, + enabled, }); }