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 = {
|
export const authApi = {
|
||||||
// Request authentication code (creates web code)
|
// 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')
|
const response = await adminApiClient.post('/api/admin/auth/request-code')
|
||||||
return response.data
|
return response.data
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -31,14 +31,15 @@ export default function LoginPage() {
|
||||||
const requestCodeMutation = useMutation({
|
const requestCodeMutation = useMutation({
|
||||||
mutationFn: () => authApi.requestCode(),
|
mutationFn: () => authApi.requestCode(),
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
if (data.success && data.code) {
|
// Backend returns { code: string }, not RequestCodeResponse
|
||||||
|
if (data.code) {
|
||||||
setCode(data.code)
|
setCode(data.code)
|
||||||
setCodeStatus({
|
setCodeStatus({
|
||||||
success: true,
|
success: true,
|
||||||
code: data.code,
|
code: data.code,
|
||||||
status: data.status || 'pending',
|
status: 'pending',
|
||||||
expiresAt: data.expiresAt,
|
expiresAt: undefined,
|
||||||
remainingSeconds: data.remainingSeconds || 600,
|
remainingSeconds: 600, // 10 minutes default
|
||||||
isClaimed: false,
|
isClaimed: false,
|
||||||
isUsed: false,
|
isUsed: false,
|
||||||
})
|
})
|
||||||
|
|
@ -49,9 +50,9 @@ export default function LoginPage() {
|
||||||
|
|
||||||
// Start polling for status
|
// Start polling for status
|
||||||
startStatusPolling(data.code)
|
startStatusPolling(data.code)
|
||||||
startCountdown(data.remainingSeconds || 600)
|
startCountdown(600) // 10 minutes
|
||||||
} else {
|
} else {
|
||||||
toast.error(data.message || 'Failed to generate code')
|
toast.error('Failed to generate code')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError: (error: unknown) => {
|
onError: (error: unknown) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue