feat: implement check-in submission logic with hook and validation

This commit is contained in:
2026-02-13 14:06:30 +08:00
parent 170afb4a3b
commit b4e32d5a6d
6 changed files with 281 additions and 3 deletions

View File

@@ -0,0 +1,32 @@
# 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
1. [Resolved] API Client: `postEventCheckinSubmit` exists.
2. [Pending] API Parameters: Need to verify `PostEventCheckinSubmitData`.
3. [Resolved] Toaster Library: `sonner` (`toast.success`, `toast.error`).
## Technical Decisions
- **Logic Placement**: `CheckinScannerNavContainer`.
- **State Management**: `useMutation` from `@tanstack/react-query`.
- **Validation**: Regex `^\d{6}$` for 6-digit number.
- **Error Handling**: `onError` in mutation -> `toast.error`.
- **Success Handling**: `onSuccess` in mutation -> `toast.success`.
## Code Snippets
```typescript
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('签到失败'),
});
```