@redneckz/wildless-cms-uni-blocks 0.14.581 → 0.14.583

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/bundle/api/RetailApi/RetailApi.d.ts +9 -0
  2. package/bundle/api/RetailApi/RetailApiTypes.d.ts +83 -0
  3. package/bundle/api/RetailApi/utils/getUpdateUserProfile.d.ts +3 -0
  4. package/bundle/api/RetailApi/utils/getUpdateUserTask.d.ts +2 -0
  5. package/bundle/blocks.schema.json +1 -1
  6. package/bundle/bundle.umd.js +278 -37
  7. package/bundle/bundle.umd.min.js +1 -1
  8. package/bundle/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +2 -0
  9. package/bundle/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +6 -0
  10. package/bundle/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
  11. package/bundle/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
  12. package/dist/api/RetailApi/RetailApi.d.ts +9 -0
  13. package/dist/api/RetailApi/RetailApi.js +29 -0
  14. package/dist/api/RetailApi/RetailApi.js.map +1 -0
  15. package/dist/api/RetailApi/RetailApiTypes.d.ts +83 -0
  16. package/dist/api/RetailApi/RetailApiTypes.js +2 -0
  17. package/dist/api/RetailApi/RetailApiTypes.js.map +1 -0
  18. package/dist/api/RetailApi/utils/getUpdateUserProfile.d.ts +3 -0
  19. package/dist/api/RetailApi/utils/getUpdateUserProfile.js +27 -0
  20. package/dist/api/RetailApi/utils/getUpdateUserProfile.js.map +1 -0
  21. package/dist/api/RetailApi/utils/getUpdateUserTask.d.ts +2 -0
  22. package/dist/api/RetailApi/utils/getUpdateUserTask.js +43 -0
  23. package/dist/api/RetailApi/utils/getUpdateUserTask.js.map +1 -0
  24. package/dist/components/ApplicationLeadForm/ApplicationLeadForm.js +9 -23
  25. package/dist/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  26. package/dist/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +2 -0
  27. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +6 -0
  28. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +70 -0
  29. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -0
  30. package/dist/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
  31. package/dist/components/ApplicationLeadForm/useInitApplicationLead.js +11 -0
  32. package/dist/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -0
  33. package/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
  34. package/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js +20 -11
  35. package/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
  36. package/lib/api/RetailApi/RetailApi.d.ts +9 -0
  37. package/lib/api/RetailApi/RetailApi.js +27 -0
  38. package/lib/api/RetailApi/RetailApi.js.map +1 -0
  39. package/lib/api/RetailApi/RetailApiTypes.d.ts +83 -0
  40. package/lib/api/RetailApi/RetailApiTypes.js +2 -0
  41. package/lib/api/RetailApi/RetailApiTypes.js.map +1 -0
  42. package/lib/api/RetailApi/utils/getUpdateUserProfile.d.ts +3 -0
  43. package/lib/api/RetailApi/utils/getUpdateUserProfile.js +24 -0
  44. package/lib/api/RetailApi/utils/getUpdateUserProfile.js.map +1 -0
  45. package/lib/api/RetailApi/utils/getUpdateUserTask.d.ts +2 -0
  46. package/lib/api/RetailApi/utils/getUpdateUserTask.js +40 -0
  47. package/lib/api/RetailApi/utils/getUpdateUserTask.js.map +1 -0
  48. package/lib/components/ApplicationLeadForm/ApplicationLeadForm.js +10 -24
  49. package/lib/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  50. package/lib/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +2 -0
  51. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +6 -0
  52. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +67 -0
  53. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -0
  54. package/lib/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
  55. package/lib/components/ApplicationLeadForm/useInitApplicationLead.js +8 -0
  56. package/lib/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -0
  57. package/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
  58. package/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js +20 -11
  59. package/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
  60. package/mobile/bundle/api/RetailApi/RetailApi.d.ts +9 -0
  61. package/mobile/bundle/api/RetailApi/RetailApiTypes.d.ts +83 -0
  62. package/mobile/bundle/api/RetailApi/utils/getUpdateUserProfile.d.ts +3 -0
  63. package/mobile/bundle/api/RetailApi/utils/getUpdateUserTask.d.ts +2 -0
  64. package/mobile/bundle/bundle.umd.js +278 -37
  65. package/mobile/bundle/bundle.umd.min.js +1 -1
  66. package/mobile/bundle/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +2 -0
  67. package/mobile/bundle/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +6 -0
  68. package/mobile/bundle/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
  69. package/mobile/bundle/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
  70. package/mobile/dist/api/RetailApi/RetailApi.d.ts +9 -0
  71. package/mobile/dist/api/RetailApi/RetailApi.js +29 -0
  72. package/mobile/dist/api/RetailApi/RetailApi.js.map +1 -0
  73. package/mobile/dist/api/RetailApi/RetailApiTypes.d.ts +83 -0
  74. package/mobile/dist/api/RetailApi/RetailApiTypes.js +2 -0
  75. package/mobile/dist/api/RetailApi/RetailApiTypes.js.map +1 -0
  76. package/mobile/dist/api/RetailApi/utils/getUpdateUserProfile.d.ts +3 -0
  77. package/mobile/dist/api/RetailApi/utils/getUpdateUserProfile.js +27 -0
  78. package/mobile/dist/api/RetailApi/utils/getUpdateUserProfile.js.map +1 -0
  79. package/mobile/dist/api/RetailApi/utils/getUpdateUserTask.d.ts +2 -0
  80. package/mobile/dist/api/RetailApi/utils/getUpdateUserTask.js +43 -0
  81. package/mobile/dist/api/RetailApi/utils/getUpdateUserTask.js.map +1 -0
  82. package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadForm.js +9 -23
  83. package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  84. package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +2 -0
  85. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +6 -0
  86. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +70 -0
  87. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -0
  88. package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
  89. package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.js +11 -0
  90. package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -0
  91. package/mobile/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
  92. package/mobile/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js +20 -11
  93. package/mobile/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
  94. package/mobile/lib/api/RetailApi/RetailApi.d.ts +9 -0
  95. package/mobile/lib/api/RetailApi/RetailApi.js +27 -0
  96. package/mobile/lib/api/RetailApi/RetailApi.js.map +1 -0
  97. package/mobile/lib/api/RetailApi/RetailApiTypes.d.ts +83 -0
  98. package/mobile/lib/api/RetailApi/RetailApiTypes.js +2 -0
  99. package/mobile/lib/api/RetailApi/RetailApiTypes.js.map +1 -0
  100. package/mobile/lib/api/RetailApi/utils/getUpdateUserProfile.d.ts +3 -0
  101. package/mobile/lib/api/RetailApi/utils/getUpdateUserProfile.js +24 -0
  102. package/mobile/lib/api/RetailApi/utils/getUpdateUserProfile.js.map +1 -0
  103. package/mobile/lib/api/RetailApi/utils/getUpdateUserTask.d.ts +2 -0
  104. package/mobile/lib/api/RetailApi/utils/getUpdateUserTask.js +40 -0
  105. package/mobile/lib/api/RetailApi/utils/getUpdateUserTask.js.map +1 -0
  106. package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadForm.js +10 -24
  107. package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  108. package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +2 -0
  109. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +6 -0
  110. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +67 -0
  111. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -0
  112. package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
  113. package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.js +8 -0
  114. package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -0
  115. package/mobile/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
  116. package/mobile/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js +20 -11
  117. package/mobile/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
  118. package/mobile/src/api/RetailApi/RetailApi.ts +51 -0
  119. package/mobile/src/api/RetailApi/RetailApiTypes.ts +91 -0
  120. package/mobile/src/api/RetailApi/utils/getUpdateUserProfile.ts +44 -0
  121. package/mobile/src/api/RetailApi/utils/getUpdateUserTask.ts +46 -0
  122. package/mobile/src/components/ApplicationLeadForm/ApplicationLeadForm.tsx +11 -26
  123. package/mobile/src/components/ApplicationLeadForm/ApplicationLeadFormContent.ts +2 -0
  124. package/mobile/src/components/ApplicationLeadForm/useApplicationLeadApi.ts +75 -0
  125. package/mobile/src/components/ApplicationLeadForm/useInitApplicationLead.ts +8 -0
  126. package/mobile/src/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.tsx +35 -14
  127. package/package.json +2 -2
  128. package/src/api/RetailApi/RetailApi.ts +51 -0
  129. package/src/api/RetailApi/RetailApiTypes.ts +91 -0
  130. package/src/api/RetailApi/utils/getUpdateUserProfile.ts +44 -0
  131. package/src/api/RetailApi/utils/getUpdateUserTask.ts +46 -0
  132. package/src/components/ApplicationLeadForm/ApplicationLeadForm.fixture.tsx +1 -0
  133. package/src/components/ApplicationLeadForm/ApplicationLeadForm.tsx +11 -26
  134. package/src/components/ApplicationLeadForm/ApplicationLeadFormContent.ts +2 -0
  135. package/src/components/ApplicationLeadForm/useApplicationLeadApi.ts +75 -0
  136. package/src/components/ApplicationLeadForm/useInitApplicationLead.ts +8 -0
  137. package/src/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.fixture.tsx +5 -4
  138. package/src/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.tsx +35 -14
  139. package/bundle/components/ApplicationLeadForm/getFormatData.d.ts +0 -2
  140. package/bundle/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +0 -13
  141. package/dist/components/ApplicationLeadForm/getFormatData.d.ts +0 -2
  142. package/dist/components/ApplicationLeadForm/getFormatData.js +0 -13
  143. package/dist/components/ApplicationLeadForm/getFormatData.js.map +0 -1
  144. package/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +0 -13
  145. package/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js +0 -30
  146. package/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js.map +0 -1
  147. package/lib/components/ApplicationLeadForm/getFormatData.d.ts +0 -2
  148. package/lib/components/ApplicationLeadForm/getFormatData.js +0 -10
  149. package/lib/components/ApplicationLeadForm/getFormatData.js.map +0 -1
  150. package/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +0 -13
  151. package/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js +0 -27
  152. package/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js.map +0 -1
  153. package/mobile/bundle/components/ApplicationLeadForm/getFormatData.d.ts +0 -2
  154. package/mobile/bundle/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +0 -13
  155. package/mobile/dist/components/ApplicationLeadForm/getFormatData.d.ts +0 -2
  156. package/mobile/dist/components/ApplicationLeadForm/getFormatData.js +0 -13
  157. package/mobile/dist/components/ApplicationLeadForm/getFormatData.js.map +0 -1
  158. package/mobile/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +0 -13
  159. package/mobile/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js +0 -30
  160. package/mobile/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js.map +0 -1
  161. package/mobile/lib/components/ApplicationLeadForm/getFormatData.d.ts +0 -2
  162. package/mobile/lib/components/ApplicationLeadForm/getFormatData.js +0 -10
  163. package/mobile/lib/components/ApplicationLeadForm/getFormatData.js.map +0 -1
  164. package/mobile/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +0 -13
  165. package/mobile/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js +0 -27
  166. package/mobile/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js.map +0 -1
  167. package/mobile/src/components/ApplicationLeadForm/getFormatData.tsx +0 -17
  168. package/mobile/src/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.tsx +0 -36
  169. package/src/components/ApplicationLeadForm/getFormatData.tsx +0 -17
  170. package/src/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.tsx +0 -36
@@ -0,0 +1,75 @@
1
+ import { useCallback, useState } from '@redneckz/uni-jsx/lib/hooks';
2
+ import { RETAIL_API } from '../../api/RetailApi/RetailApi';
3
+ import { getUpdateUserProfileData } from '../../api/RetailApi/utils/getUpdateUserProfile';
4
+ import { getUpdateUserTaskData } from '../../api/RetailApi/utils/getUpdateUserTask';
5
+ import { getObjectValidator } from '../../ui-kit/FormField/getObjectValidator';
6
+ import { useVerifyPhoneDialog } from '../../ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog';
7
+ import { formatPhone } from '../../utils/formatPhone';
8
+ import { objectValidator } from '../../validation/objectValidator';
9
+ import { isValidationSuccess } from '../../validation/validator';
10
+ import { type FieldDef } from './ApplicationLeadFormContent';
11
+ import { type FormState } from './getInitialFormState';
12
+
13
+ export const useApplicationLeadApi = (inputs: FieldDef[], programId: string) => {
14
+ const [responseStatus, setResponseStatus] = useState<'OK' | 'Fail' | ''>('');
15
+
16
+ // eslint-disable-next-line consistent-return
17
+ const handleSubmit = useCallback(async (formData: FormState) => {
18
+ const feedbackValidator = objectValidator(getObjectValidator(inputs));
19
+ if (!isValidationSuccess(feedbackValidator(formData))) {
20
+ return 'Fail';
21
+ }
22
+
23
+ try {
24
+ const { profile } = await RETAIL_API.CreateUserProfile({
25
+ profile: { phone: formatPhone(formData.phone as string) },
26
+ });
27
+ const profileId = profile?.id;
28
+
29
+ if (profileId && formData?.phone) {
30
+ const handleSuccessVerify = async () => {
31
+ try {
32
+ await RETAIL_API.UpdateUserProfile(getUpdateUserProfileData(profileId, formData));
33
+ const { taskId, participantId } = await RETAIL_API.CreateDraftTask({
34
+ profileId,
35
+ programId,
36
+ });
37
+
38
+ await RETAIL_API.UpdateUserTask(
39
+ getUpdateUserTaskData(participantId, taskId, profileId, formData),
40
+ );
41
+ setResponseStatus('OK');
42
+ } catch {
43
+ setResponseStatus('Fail');
44
+ }
45
+ };
46
+ // eslint-disable-next-line react-hooks/rules-of-hooks
47
+ const verifyPhoneDialog = useVerifyPhoneDialog({
48
+ onClose: handleSuccessVerify,
49
+ ...verifyPhoneContent(formData?.phone),
50
+ });
51
+ verifyPhoneDialog.open();
52
+ }
53
+ } catch {
54
+ setResponseStatus('Fail');
55
+ }
56
+ }, []);
57
+
58
+ return {
59
+ handleSubmit,
60
+ responseStatus,
61
+ };
62
+ };
63
+
64
+ const verifyPhoneContent = (phone: string) => ({
65
+ title: 'Подтвердите номер телефона',
66
+ description: `Мы отправили код на ${phone}`,
67
+ phone: formatPhone(phone),
68
+ textButton: 'Оформить',
69
+ __html: `<span>Вводя код, я подтверждаю, что ознакомлен и подписываю:</span>
70
+ <ul><li>соглашение о порядке использования простой электронной подписи,
71
+ </li><li>согласие на обработку персональных данных,
72
+ </li><li>предоставление и подписание прочих согласий Банка,
73
+ </li><li>согласие на запрос в ПФР</li></ul>`,
74
+ href: '/credit-lead',
75
+ });
@@ -0,0 +1,8 @@
1
+ import { useEffect } from '@redneckz/uni-jsx/lib/hooks';
2
+
3
+ export const useInitApplicationLead = () => {
4
+ useEffect(() => {
5
+ sessionStorage.removeItem('accessToken');
6
+ sessionStorage.removeItem('refreshToken');
7
+ }, []);
8
+ };
@@ -7,16 +7,17 @@ const title = 'Подтвердите номер телефона';
7
7
  const description = 'Мы отправили код на +7 (999) 999-99-99';
8
8
 
9
9
  const __html = `Вводя код, я подтверждаю, что ознакомлен и подписываю:
10
- <ul> <li>соглашение о порядке использования простой электронной подписи,
11
- </li> <li>согласие на обработку персональных данных,
12
- </li> <li>предоставление и подписание прочих согласий Банка,
13
- </li><li>согласие на запрос в ПФР</li> </ul>`;
10
+ <ul><li>соглашение о порядке использования простой электронной подписи,
11
+ </li><li>согласие на обработку персональных данных,
12
+ </li><li>предоставление и подписание прочих согласий Банка,
13
+ </li><li>согласие на запрос в ПФР</li></ul>`;
14
14
 
15
15
  export default {
16
16
  default: (
17
17
  <VerifyPhoneDialog
18
18
  title={title}
19
19
  description={description}
20
+ phone="+79999999999"
20
21
  __html={__html}
21
22
  textButton="Отправить"
22
23
  />
@@ -1,6 +1,6 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import { useCallback, useState } from '@redneckz/uni-jsx/lib/hooks';
3
- import { useMemo } from 'react';
2
+ import { useCallback, useEffect, useMemo, useState } from '@redneckz/uni-jsx/lib/hooks';
3
+ import { RETAIL_API } from '../../api/RetailApi/RetailApi';
4
4
  import { Headline } from '../../components/Headline/Headline';
5
5
  import { Dialog } from '../DialogManager/Dialog';
6
6
  import { useDialogManager } from '../DialogManager/useDialogManager';
@@ -10,38 +10,59 @@ import { RichText } from '../RichText/RichText';
10
10
  import { Timer } from '../TimerCircle/Timer';
11
11
  import { InputCode } from './InputCode';
12
12
  import { SubmitButton } from './SubmitButton';
13
- import { submitVerifyPhoneForm } from './submitVerifyPhoneForm';
14
13
 
15
14
  export interface VerifyPhoneDialogProps {
15
+ phone: string;
16
16
  title?: string;
17
17
  description?: string;
18
18
  code?: boolean;
19
19
  __html?: string;
20
20
  codeLength?: number;
21
21
  textButton?: string;
22
+ onClose?: () => Promise<void>;
23
+ href?: string;
22
24
  }
23
25
 
24
26
  export const VerifyPhoneDialog = JSX<VerifyPhoneDialogProps>(
25
- ({ title, description, __html, code = true, codeLength = 4, textButton = '' }) => {
27
+ ({
28
+ title,
29
+ phone,
30
+ description,
31
+ __html,
32
+ code = true,
33
+ codeLength = 4,
34
+ textButton = '',
35
+ onClose,
36
+ href = '',
37
+ }) => {
26
38
  const { close } = useDialogManager();
27
39
 
28
- const [values, setValues] = useState(Array(codeLength).fill(''));
40
+ const [values, setValues] = useState<string[]>(Array(codeLength).fill('') as string[]);
29
41
  const [hasError, setHasError] = useState(false);
30
42
  const [isLoading, setIsLoading] = useState(false);
31
- const [timeNextReq, setTimeNextReq] = useState<number>(0);
43
+ const [timeNextReq, setTimeNextReq] = useState<number>(180);
32
44
 
33
45
  const isValidCode = useMemo(() => values.every(Boolean), [values]);
34
46
 
35
- const handleSubmit = useCallback(async () => {
36
- setIsLoading(true);
37
- const { success, expiresIn } = await submitVerifyPhoneForm(values.join(''));
38
- setIsLoading(false);
39
-
40
- setTimeNextReq(expiresIn as number);
47
+ useEffect(() => {
48
+ RETAIL_API.SendCode({
49
+ phoneNumber: phone,
50
+ smsCodesSetName: { key: 'AUTHENTICATION' },
51
+ });
52
+ }, []);
41
53
 
42
- if (success) {
54
+ const handleSubmit = useCallback(async () => {
55
+ try {
56
+ setIsLoading(true);
57
+ await RETAIL_API.CheckCode({
58
+ smsText: values.join(''),
59
+ smsCodesSetName: { key: 'AUTHENTICATION' },
60
+ });
61
+ globalThis.location.href = href;
43
62
  close();
44
- } else {
63
+ onClose && onClose();
64
+ } catch {
65
+ setIsLoading(false);
45
66
  setHasError(true);
46
67
  }
47
68
  }, [values]);
@@ -1,2 +0,0 @@
1
- import { type FormState } from './getInitialFormState';
2
- export declare const getFormatData: (data: FormState) => Record<string, any>;
@@ -1,13 +0,0 @@
1
- export interface VerifyPhoneFormData {
2
- smsText: string;
3
- smsCodesSetName: {
4
- key: string;
5
- };
6
- }
7
- export declare const submitVerifyPhoneForm: (code: string) => Promise<{
8
- success: boolean;
9
- expiresIn: any;
10
- } | {
11
- success: boolean;
12
- expiresIn?: undefined;
13
- }>;
@@ -1,2 +0,0 @@
1
- import { type FormState } from './getInitialFormState';
2
- export declare const getFormatData: (data: FormState) => Record<string, any>;
@@ -1,13 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.getFormatData = void 0;
3
- const getFormatData = (data) => {
4
- const { region, ...usedData } = data;
5
- const formatData = {
6
- ...usedData,
7
- ...getRegion(region),
8
- };
9
- return Object.fromEntries(Object.entries(formatData)?.map(([k, v]) => [k, v?.key || v]));
10
- };
11
- exports.getFormatData = getFormatData;
12
- const getRegion = (region) => region?.key || region?.text ? { region: region?.text || region?.key } : {};
13
- //# sourceMappingURL=getFormatData.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFormatData.js","sourceRoot":"","sources":["../../../src/components/ApplicationLeadForm/getFormatData.tsx"],"names":[],"mappings":";;AAGO,MAAM,aAAa,GAAG,CAAC,IAAe,EAAuB,EAAE;IACpE,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAC;IACrC,MAAM,UAAU,GAAG;QACjB,GAAG,QAAQ;QACX,GAAG,SAAS,CAAC,MAAM,CAAC;KACrB,CAAC;IAEF,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,UAAuB,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAC3E,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,aAAa,iBAUxB;AAEF,MAAM,SAAS,GAAG,CAAC,MAAe,EAA0B,EAAE,CAC5D,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,IAAI,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC"}
@@ -1,13 +0,0 @@
1
- export interface VerifyPhoneFormData {
2
- smsText: string;
3
- smsCodesSetName: {
4
- key: string;
5
- };
6
- }
7
- export declare const submitVerifyPhoneForm: (code: string) => Promise<{
8
- success: boolean;
9
- expiresIn: any;
10
- } | {
11
- success: boolean;
12
- expiresIn?: undefined;
13
- }>;
@@ -1,30 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.submitVerifyPhoneForm = void 0;
3
- const SEND_CODE_URL = '/api/v1/sms/checkCode';
4
- const submitVerifyPhoneForm = async (code) => {
5
- const codeData = {
6
- smsText: code,
7
- smsCodesSetName: { key: 'AUTHENTICATION' },
8
- };
9
- const response = await fetch(SEND_CODE_URL, {
10
- method: 'POST',
11
- headers: {
12
- 'Content-Type': 'application/json',
13
- },
14
- body: JSON.stringify(codeData),
15
- });
16
- if (response.ok) {
17
- const data = await response.json();
18
- return {
19
- success: true,
20
- expiresIn: data.expires_in,
21
- };
22
- }
23
- else {
24
- return {
25
- success: false,
26
- };
27
- }
28
- };
29
- exports.submitVerifyPhoneForm = submitVerifyPhoneForm;
30
- //# sourceMappingURL=submitVerifyPhoneForm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"submitVerifyPhoneForm.js","sourceRoot":"","sources":["../../../src/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.tsx"],"names":[],"mappings":";;AAOA,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAEvC,MAAM,qBAAqB,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;IAC1D,MAAM,QAAQ,GAAwB;QACpC,OAAO,EAAE,IAAI;QACb,eAAe,EAAE,EAAE,GAAG,EAAE,gBAAgB,EAAE;KAC3C,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,aAAa,EAAE;QAC1C,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;KAC/B,CAAC,CAAC;IAEH,IAAI,QAAQ,CAAC,EAAE,EAAE;QACf,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAEnC,OAAO;YACL,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,IAAI,CAAC,UAAU;SAC3B,CAAC;KACH;SAAM;QACL,OAAO;YACL,OAAO,EAAE,KAAK;SACf,CAAC;KACH;AACH,CAAC,CAAC;AA1BW,QAAA,qBAAqB,yBA0BhC"}
@@ -1,2 +0,0 @@
1
- import { type FormState } from './getInitialFormState';
2
- export declare const getFormatData: (data: FormState) => Record<string, any>;
@@ -1,10 +0,0 @@
1
- export const getFormatData = (data) => {
2
- const { region, ...usedData } = data;
3
- const formatData = {
4
- ...usedData,
5
- ...getRegion(region),
6
- };
7
- return Object.fromEntries(Object.entries(formatData)?.map(([k, v]) => [k, v?.key || v]));
8
- };
9
- const getRegion = (region) => region?.key || region?.text ? { region: region?.text || region?.key } : {};
10
- //# sourceMappingURL=getFormatData.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFormatData.js","sourceRoot":"","sources":["../../../src/components/ApplicationLeadForm/getFormatData.tsx"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAe,EAAuB,EAAE;IACpE,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAC;IACrC,MAAM,UAAU,GAAG;QACjB,GAAG,QAAQ;QACX,GAAG,SAAS,CAAC,MAAM,CAAC;KACrB,CAAC;IAEF,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,UAAuB,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAC3E,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,MAAe,EAA0B,EAAE,CAC5D,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,IAAI,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC"}
@@ -1,13 +0,0 @@
1
- export interface VerifyPhoneFormData {
2
- smsText: string;
3
- smsCodesSetName: {
4
- key: string;
5
- };
6
- }
7
- export declare const submitVerifyPhoneForm: (code: string) => Promise<{
8
- success: boolean;
9
- expiresIn: any;
10
- } | {
11
- success: boolean;
12
- expiresIn?: undefined;
13
- }>;
@@ -1,27 +0,0 @@
1
- const SEND_CODE_URL = '/api/v1/sms/checkCode';
2
- export const submitVerifyPhoneForm = async (code) => {
3
- const codeData = {
4
- smsText: code,
5
- smsCodesSetName: { key: 'AUTHENTICATION' },
6
- };
7
- const response = await fetch(SEND_CODE_URL, {
8
- method: 'POST',
9
- headers: {
10
- 'Content-Type': 'application/json',
11
- },
12
- body: JSON.stringify(codeData),
13
- });
14
- if (response.ok) {
15
- const data = await response.json();
16
- return {
17
- success: true,
18
- expiresIn: data.expires_in,
19
- };
20
- }
21
- else {
22
- return {
23
- success: false,
24
- };
25
- }
26
- };
27
- //# sourceMappingURL=submitVerifyPhoneForm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"submitVerifyPhoneForm.js","sourceRoot":"","sources":["../../../src/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.tsx"],"names":[],"mappings":"AAOA,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAE9C,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;IAC1D,MAAM,QAAQ,GAAwB;QACpC,OAAO,EAAE,IAAI;QACb,eAAe,EAAE,EAAE,GAAG,EAAE,gBAAgB,EAAE;KAC3C,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,aAAa,EAAE;QAC1C,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;KAC/B,CAAC,CAAC;IAEH,IAAI,QAAQ,CAAC,EAAE,EAAE;QACf,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAEnC,OAAO;YACL,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,IAAI,CAAC,UAAU;SAC3B,CAAC;KACH;SAAM;QACL,OAAO;YACL,OAAO,EAAE,KAAK;SACf,CAAC;KACH;AACH,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- import { type FormState } from './getInitialFormState';
2
- export declare const getFormatData: (data: FormState) => Record<string, any>;
@@ -1,13 +0,0 @@
1
- export interface VerifyPhoneFormData {
2
- smsText: string;
3
- smsCodesSetName: {
4
- key: string;
5
- };
6
- }
7
- export declare const submitVerifyPhoneForm: (code: string) => Promise<{
8
- success: boolean;
9
- expiresIn: any;
10
- } | {
11
- success: boolean;
12
- expiresIn?: undefined;
13
- }>;
@@ -1,2 +0,0 @@
1
- import { type FormState } from './getInitialFormState';
2
- export declare const getFormatData: (data: FormState) => Record<string, any>;
@@ -1,13 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.getFormatData = void 0;
3
- const getFormatData = (data) => {
4
- const { region, ...usedData } = data;
5
- const formatData = {
6
- ...usedData,
7
- ...getRegion(region),
8
- };
9
- return Object.fromEntries(Object.entries(formatData)?.map(([k, v]) => [k, v?.key || v]));
10
- };
11
- exports.getFormatData = getFormatData;
12
- const getRegion = (region) => region?.key || region?.text ? { region: region?.text || region?.key } : {};
13
- //# sourceMappingURL=getFormatData.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFormatData.js","sourceRoot":"","sources":["../../../src/components/ApplicationLeadForm/getFormatData.tsx"],"names":[],"mappings":";;AAGO,MAAM,aAAa,GAAG,CAAC,IAAe,EAAuB,EAAE;IACpE,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAC;IACrC,MAAM,UAAU,GAAG;QACjB,GAAG,QAAQ;QACX,GAAG,SAAS,CAAC,MAAM,CAAC;KACrB,CAAC;IAEF,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,UAAuB,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAC3E,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,aAAa,iBAUxB;AAEF,MAAM,SAAS,GAAG,CAAC,MAAe,EAA0B,EAAE,CAC5D,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,IAAI,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC"}
@@ -1,13 +0,0 @@
1
- export interface VerifyPhoneFormData {
2
- smsText: string;
3
- smsCodesSetName: {
4
- key: string;
5
- };
6
- }
7
- export declare const submitVerifyPhoneForm: (code: string) => Promise<{
8
- success: boolean;
9
- expiresIn: any;
10
- } | {
11
- success: boolean;
12
- expiresIn?: undefined;
13
- }>;
@@ -1,30 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.submitVerifyPhoneForm = void 0;
3
- const SEND_CODE_URL = '/api/v1/sms/checkCode';
4
- const submitVerifyPhoneForm = async (code) => {
5
- const codeData = {
6
- smsText: code,
7
- smsCodesSetName: { key: 'AUTHENTICATION' },
8
- };
9
- const response = await fetch(SEND_CODE_URL, {
10
- method: 'POST',
11
- headers: {
12
- 'Content-Type': 'application/json',
13
- },
14
- body: JSON.stringify(codeData),
15
- });
16
- if (response.ok) {
17
- const data = await response.json();
18
- return {
19
- success: true,
20
- expiresIn: data.expires_in,
21
- };
22
- }
23
- else {
24
- return {
25
- success: false,
26
- };
27
- }
28
- };
29
- exports.submitVerifyPhoneForm = submitVerifyPhoneForm;
30
- //# sourceMappingURL=submitVerifyPhoneForm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"submitVerifyPhoneForm.js","sourceRoot":"","sources":["../../../src/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.tsx"],"names":[],"mappings":";;AAOA,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAEvC,MAAM,qBAAqB,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;IAC1D,MAAM,QAAQ,GAAwB;QACpC,OAAO,EAAE,IAAI;QACb,eAAe,EAAE,EAAE,GAAG,EAAE,gBAAgB,EAAE;KAC3C,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,aAAa,EAAE;QAC1C,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;KAC/B,CAAC,CAAC;IAEH,IAAI,QAAQ,CAAC,EAAE,EAAE;QACf,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAEnC,OAAO;YACL,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,IAAI,CAAC,UAAU;SAC3B,CAAC;KACH;SAAM;QACL,OAAO;YACL,OAAO,EAAE,KAAK;SACf,CAAC;KACH;AACH,CAAC,CAAC;AA1BW,QAAA,qBAAqB,yBA0BhC"}
@@ -1,2 +0,0 @@
1
- import { type FormState } from './getInitialFormState';
2
- export declare const getFormatData: (data: FormState) => Record<string, any>;
@@ -1,10 +0,0 @@
1
- export const getFormatData = (data) => {
2
- const { region, ...usedData } = data;
3
- const formatData = {
4
- ...usedData,
5
- ...getRegion(region),
6
- };
7
- return Object.fromEntries(Object.entries(formatData)?.map(([k, v]) => [k, v?.key || v]));
8
- };
9
- const getRegion = (region) => region?.key || region?.text ? { region: region?.text || region?.key } : {};
10
- //# sourceMappingURL=getFormatData.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFormatData.js","sourceRoot":"","sources":["../../../src/components/ApplicationLeadForm/getFormatData.tsx"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAe,EAAuB,EAAE;IACpE,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAC;IACrC,MAAM,UAAU,GAAG;QACjB,GAAG,QAAQ;QACX,GAAG,SAAS,CAAC,MAAM,CAAC;KACrB,CAAC;IAEF,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,UAAuB,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAC3E,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,MAAe,EAA0B,EAAE,CAC5D,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,IAAI,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC"}
@@ -1,13 +0,0 @@
1
- export interface VerifyPhoneFormData {
2
- smsText: string;
3
- smsCodesSetName: {
4
- key: string;
5
- };
6
- }
7
- export declare const submitVerifyPhoneForm: (code: string) => Promise<{
8
- success: boolean;
9
- expiresIn: any;
10
- } | {
11
- success: boolean;
12
- expiresIn?: undefined;
13
- }>;
@@ -1,27 +0,0 @@
1
- const SEND_CODE_URL = '/api/v1/sms/checkCode';
2
- export const submitVerifyPhoneForm = async (code) => {
3
- const codeData = {
4
- smsText: code,
5
- smsCodesSetName: { key: 'AUTHENTICATION' },
6
- };
7
- const response = await fetch(SEND_CODE_URL, {
8
- method: 'POST',
9
- headers: {
10
- 'Content-Type': 'application/json',
11
- },
12
- body: JSON.stringify(codeData),
13
- });
14
- if (response.ok) {
15
- const data = await response.json();
16
- return {
17
- success: true,
18
- expiresIn: data.expires_in,
19
- };
20
- }
21
- else {
22
- return {
23
- success: false,
24
- };
25
- }
26
- };
27
- //# sourceMappingURL=submitVerifyPhoneForm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"submitVerifyPhoneForm.js","sourceRoot":"","sources":["../../../src/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.tsx"],"names":[],"mappings":"AAOA,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAE9C,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;IAC1D,MAAM,QAAQ,GAAwB;QACpC,OAAO,EAAE,IAAI;QACb,eAAe,EAAE,EAAE,GAAG,EAAE,gBAAgB,EAAE;KAC3C,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,aAAa,EAAE;QAC1C,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;KAC/B,CAAC,CAAC;IAEH,IAAI,QAAQ,CAAC,EAAE,EAAE;QACf,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAEnC,OAAO;YACL,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,IAAI,CAAC,UAAU;SAC3B,CAAC;KACH;SAAM;QACL,OAAO;YACL,OAAO,EAAE,KAAK;SACf,CAAC;KACH;AACH,CAAC,CAAC"}
@@ -1,17 +0,0 @@
1
- import { type Option } from '../../ui-kit/Select/Option';
2
- import { type FormState } from './getInitialFormState';
3
-
4
- export const getFormatData = (data: FormState): Record<string, any> => {
5
- const { region, ...usedData } = data;
6
- const formatData = {
7
- ...usedData,
8
- ...getRegion(region),
9
- };
10
-
11
- return Object.fromEntries(
12
- Object.entries(formatData as FormState)?.map(([k, v]) => [k, v?.key || v]),
13
- );
14
- };
15
-
16
- const getRegion = (region?: Option): Record<string, string> =>
17
- region?.key || region?.text ? { region: region?.text || region?.key } : {};
@@ -1,36 +0,0 @@
1
- export interface VerifyPhoneFormData {
2
- smsText: string;
3
- smsCodesSetName: {
4
- key: string;
5
- };
6
- }
7
-
8
- const SEND_CODE_URL = '/api/v1/sms/checkCode';
9
-
10
- export const submitVerifyPhoneForm = async (code: string) => {
11
- const codeData: VerifyPhoneFormData = {
12
- smsText: code,
13
- smsCodesSetName: { key: 'AUTHENTICATION' },
14
- };
15
-
16
- const response = await fetch(SEND_CODE_URL, {
17
- method: 'POST',
18
- headers: {
19
- 'Content-Type': 'application/json',
20
- },
21
- body: JSON.stringify(codeData),
22
- });
23
-
24
- if (response.ok) {
25
- const data = await response.json();
26
-
27
- return {
28
- success: true,
29
- expiresIn: data.expires_in,
30
- };
31
- } else {
32
- return {
33
- success: false,
34
- };
35
- }
36
- };
@@ -1,17 +0,0 @@
1
- import { type Option } from '../../ui-kit/Select/Option';
2
- import { type FormState } from './getInitialFormState';
3
-
4
- export const getFormatData = (data: FormState): Record<string, any> => {
5
- const { region, ...usedData } = data;
6
- const formatData = {
7
- ...usedData,
8
- ...getRegion(region),
9
- };
10
-
11
- return Object.fromEntries(
12
- Object.entries(formatData as FormState)?.map(([k, v]) => [k, v?.key || v]),
13
- );
14
- };
15
-
16
- const getRegion = (region?: Option): Record<string, string> =>
17
- region?.key || region?.text ? { region: region?.text || region?.key } : {};
@@ -1,36 +0,0 @@
1
- export interface VerifyPhoneFormData {
2
- smsText: string;
3
- smsCodesSetName: {
4
- key: string;
5
- };
6
- }
7
-
8
- const SEND_CODE_URL = '/api/v1/sms/checkCode';
9
-
10
- export const submitVerifyPhoneForm = async (code: string) => {
11
- const codeData: VerifyPhoneFormData = {
12
- smsText: code,
13
- smsCodesSetName: { key: 'AUTHENTICATION' },
14
- };
15
-
16
- const response = await fetch(SEND_CODE_URL, {
17
- method: 'POST',
18
- headers: {
19
- 'Content-Type': 'application/json',
20
- },
21
- body: JSON.stringify(codeData),
22
- });
23
-
24
- if (response.ok) {
25
- const data = await response.json();
26
-
27
- return {
28
- success: true,
29
- expiresIn: data.expires_in,
30
- };
31
- } else {
32
- return {
33
- success: false,
34
- };
35
- }
36
- };