feat: create kyc page with api

This commit is contained in:
2026-05-12 18:46:05 +03:00
parent 238da1609b
commit 236edbe437
4 changed files with 30 additions and 16 deletions

View File

@@ -1,5 +1,5 @@
import { getCsrfToken } from '@shared/api/csrf'
import { tokenStore } from '@shared/api/tokenStore'
import { tokenStore, refreshAccessToken } from '@shared/api/tokenStore'
export interface KycResponse {
status: boolean
@@ -12,7 +12,11 @@ export interface KycResponse {
const KYC_API_URL = 'https://app.kyc.elcsa.ru'
export async function kycCreate(): Promise<KycResponse> {
export function kycCreate(): Promise<KycResponse> {
return doKycRequest(true)
}
async function doKycRequest(allowRetry: boolean): Promise<KycResponse> {
const csrf = await getCsrfToken()
const bearer = tokenStore.get()
@@ -27,6 +31,16 @@ export async function kycCreate(): Promise<KycResponse> {
body: JSON.stringify({}),
})
if (res.status === 401 && allowRetry) {
try {
await refreshAccessToken()
return doKycRequest(false)
} catch {
tokenStore.clear()
throw new Error('Unauthorized')
}
}
const data = await res.json()
if (!res.ok) throw data
return data as KycResponse

View File

@@ -34,7 +34,7 @@ export function KycWidget() {
</div>
<p className={styles.description}>
Для продолжения работы необходимо пройти KYC верификацию.
Для продолжения работы необходимо пройти KYC верификацию
</p>
<div className={styles.buttonWrapper}>