feat: implement check-in submission logic with hook and validation
This commit is contained in:
32
client/cms/.sisyphus/drafts/checkin_logic.md
Normal file
32
client/cms/.sisyphus/drafts/checkin_logic.md
Normal 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('签到失败'),
|
||||
});
|
||||
```
|
||||
Reference in New Issue
Block a user