feat: create kyc page with api
This commit is contained in:
File diff suppressed because one or more lines are too long
2
dist/index.html
vendored
2
dist/index.html
vendored
@@ -5,7 +5,7 @@
|
|||||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>ЭКСА — Ваш мост в мир цифровых активов</title>
|
<title>ЭКСА — Ваш мост в мир цифровых активов</title>
|
||||||
<script type="module" crossorigin src="/assets/index-DnBv2hbv.js"></script>
|
<script type="module" crossorigin src="/assets/index-D7QcZmDu.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-3J8Zo9Sf.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-3J8Zo9Sf.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { getCsrfToken } from '@shared/api/csrf'
|
import { getCsrfToken } from '@shared/api/csrf'
|
||||||
import { tokenStore } from '@shared/api/tokenStore'
|
import { tokenStore, refreshAccessToken } from '@shared/api/tokenStore'
|
||||||
|
|
||||||
export interface KycResponse {
|
export interface KycResponse {
|
||||||
status: boolean
|
status: boolean
|
||||||
@@ -12,7 +12,11 @@ export interface KycResponse {
|
|||||||
|
|
||||||
const KYC_API_URL = 'https://app.kyc.elcsa.ru'
|
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 csrf = await getCsrfToken()
|
||||||
const bearer = tokenStore.get()
|
const bearer = tokenStore.get()
|
||||||
|
|
||||||
@@ -27,6 +31,16 @@ export async function kycCreate(): Promise<KycResponse> {
|
|||||||
body: JSON.stringify({}),
|
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()
|
const data = await res.json()
|
||||||
if (!res.ok) throw data
|
if (!res.ok) throw data
|
||||||
return data as KycResponse
|
return data as KycResponse
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export function KycWidget() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p className={styles.description}>
|
<p className={styles.description}>
|
||||||
Для продолжения работы необходимо пройти KYC верификацию.
|
Для продолжения работы необходимо пройти KYC верификацию
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div className={styles.buttonWrapper}>
|
<div className={styles.buttonWrapper}>
|
||||||
|
|||||||
Reference in New Issue
Block a user