1.2 KiB
1.2 KiB
Draft: Implement Check-in Logic
Requirements (User)
- Input: 6-digit number from scanner.
- Action: Call
/event/checkin/submit(postEventCheckinSubmit). - Feedback: Toaster (success/failure) using
sonner.
Research Questions
- [Resolved] API Client:
postEventCheckinSubmitexists. - [Pending] API Parameters: Need to verify
PostEventCheckinSubmitData. - [Resolved] Toaster Library:
sonner(toast.success,toast.error).
Technical Decisions
- Logic Placement:
CheckinScannerNavContainer. - State Management:
useMutationfrom@tanstack/react-query. - Validation: Regex
^\d{6}$for 6-digit number. - Error Handling:
onErrorin mutation ->toast.error. - Success Handling:
onSuccessin mutation ->toast.success.
Code Snippets
import { useMutation } from '@tanstack/react-query';
import { postEventCheckinSubmit } from '@/client/sdk.gen';
import { toast } from 'sonner';
// In container
const { mutate } = useMutation({
mutationFn: (code: string) => postEventCheckinSubmit({ body: { code } }),
onSuccess: () => toast.success('签到成功'),
onError: () => toast.error('签到失败'),
});