parent
370c165905
commit
3c7e8c3a75
@ -0,0 +1,20 @@ |
|||||||
|
import styled, { css } from 'styled-components/macro' |
||||||
|
|
||||||
|
import { isMobileDevice } from 'config/userAgent' |
||||||
|
|
||||||
|
export const Main = styled.main` |
||||||
|
width: 100%; |
||||||
|
height: 100vh; |
||||||
|
overflow-y: auto; |
||||||
|
|
||||||
|
::-webkit-scrollbar { |
||||||
|
display: none; |
||||||
|
} |
||||||
|
|
||||||
|
${isMobileDevice |
||||||
|
? css` |
||||||
|
padding: 0 12px; |
||||||
|
max-height: 100vh; |
||||||
|
` |
||||||
|
: ''}; |
||||||
|
` |
||||||
@ -0,0 +1,57 @@ |
|||||||
|
import type { ClientIds } from 'config/clients/types' |
||||||
|
|
||||||
|
import { getApiUrl } from 'features/AuthServiceApp/config/routes' |
||||||
|
|
||||||
|
const errorLexics = { |
||||||
|
8: 'error_failed_to_send_email', |
||||||
|
15: 'error_email_field_required', |
||||||
|
18: 'error_user_is_already_verified', |
||||||
|
19: 'error_no_more_than_one_email_per_minute', |
||||||
|
} |
||||||
|
|
||||||
|
type FailedResponse = { |
||||||
|
error: { |
||||||
|
code: keyof typeof errorLexics, |
||||||
|
message?: string, |
||||||
|
}, |
||||||
|
ok: false, |
||||||
|
} |
||||||
|
|
||||||
|
type SuccessResponse = { |
||||||
|
ok: true, |
||||||
|
} |
||||||
|
|
||||||
|
export type UrlParams = { |
||||||
|
client_id: ClientIds, |
||||||
|
lang?: string, |
||||||
|
nonce?: string, |
||||||
|
redirect_uri: string, |
||||||
|
response_mode: string, |
||||||
|
response_type: string, |
||||||
|
scope?: string, |
||||||
|
state?: string, |
||||||
|
} |
||||||
|
|
||||||
|
type TResendConfirmation = { |
||||||
|
email: string, |
||||||
|
urlParams: UrlParams, |
||||||
|
} |
||||||
|
|
||||||
|
export const resendConfirmation = async ({ |
||||||
|
email, |
||||||
|
urlParams, |
||||||
|
} : TResendConfirmation) => { |
||||||
|
const url = getApiUrl('/repeat_confirm_email') |
||||||
|
const init: RequestInit = { |
||||||
|
body: new URLSearchParams({ |
||||||
|
email, |
||||||
|
...urlParams, |
||||||
|
}), |
||||||
|
method: 'POST', |
||||||
|
} |
||||||
|
const response = await fetch(url, init) |
||||||
|
const body: SuccessResponse | FailedResponse = await response.json() |
||||||
|
if (body.ok) return Promise.resolve() |
||||||
|
|
||||||
|
return Promise.reject(errorLexics[body.error.code]) |
||||||
|
} |
||||||
Loading…
Reference in new issue