33 lines
1.2 KiB
Markdown
33 lines
1.2 KiB
Markdown
# 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('签到失败'),
|
|
});
|
|
```
|