admin fix
This commit is contained in:
parent
7786904d9d
commit
e1d2a1f050
3 changed files with 9 additions and 7589 deletions
7582
admin/package-lock.json
generated
7582
admin/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -4,7 +4,8 @@ import type { AxiosError } from 'axios'
|
|||
|
||||
export const authApi = {
|
||||
// Request authentication code (creates web code)
|
||||
requestCode: async (): Promise<RequestCodeResponse> => {
|
||||
// Backend returns { code: string }, not full RequestCodeResponse
|
||||
requestCode: async (): Promise<{ code: string }> => {
|
||||
const response = await adminApiClient.post('/api/admin/auth/request-code')
|
||||
return response.data
|
||||
},
|
||||
|
|
|
|||
|
|
@ -31,14 +31,15 @@ export default function LoginPage() {
|
|||
const requestCodeMutation = useMutation({
|
||||
mutationFn: () => authApi.requestCode(),
|
||||
onSuccess: (data) => {
|
||||
if (data.success && data.code) {
|
||||
// Backend returns { code: string }, not RequestCodeResponse
|
||||
if (data.code) {
|
||||
setCode(data.code)
|
||||
setCodeStatus({
|
||||
success: true,
|
||||
code: data.code,
|
||||
status: data.status || 'pending',
|
||||
expiresAt: data.expiresAt,
|
||||
remainingSeconds: data.remainingSeconds || 600,
|
||||
status: 'pending',
|
||||
expiresAt: undefined,
|
||||
remainingSeconds: 600, // 10 minutes default
|
||||
isClaimed: false,
|
||||
isUsed: false,
|
||||
})
|
||||
|
|
@ -49,9 +50,9 @@ export default function LoginPage() {
|
|||
|
||||
// Start polling for status
|
||||
startStatusPolling(data.code)
|
||||
startCountdown(data.remainingSeconds || 600)
|
||||
startCountdown(600) // 10 minutes
|
||||
} else {
|
||||
toast.error(data.message || 'Failed to generate code')
|
||||
toast.error('Failed to generate code')
|
||||
}
|
||||
},
|
||||
onError: (error: unknown) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue