feat: create kyc page with api

This commit is contained in:
2026-05-12 18:04:33 +03:00
parent f52365c293
commit ed9d33e386
6 changed files with 39 additions and 18 deletions

View File

@@ -9,5 +9,7 @@ export function useAuth() {
queryFn: refreshAccessToken,
retry: false,
staleTime: Infinity,
gcTime: Infinity,
refetchOnWindowFocus: false,
})
}

View File

@@ -1,4 +1,6 @@
import { api } from '@shared/api/base'
import { KYC_API_URL } from '@shared/config/env'
import { getCsrfToken } from '@shared/api/csrf'
import { tokenStore } from '@shared/api/tokenStore'
export interface KycResponse {
status: boolean
@@ -9,6 +11,22 @@ export interface KycResponse {
qr_code: string
}
export function kycCreate(): Promise<KycResponse> {
return api.post<KycResponse>('/kyc/create', {})
export async function kycCreate(): Promise<KycResponse> {
const csrf = await getCsrfToken()
const bearer = tokenStore.get()
const res = await fetch(`${KYC_API_URL}/kyc/create`, {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': csrf,
...(bearer ? { Authorization: `Bearer ${bearer}` } : {}),
},
body: JSON.stringify({}),
})
const data = await res.json()
if (!res.ok) throw data
return data as KycResponse
}