@redneckz/wildless-cms-uni-blocks 0.14.580 → 0.14.582

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 (196) 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 +281 -39
  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/hooks/useLeadFormData.d.ts +4 -1
  12. package/bundle/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +2 -0
  13. package/dist/api/RetailApi/RetailApi.d.ts +9 -0
  14. package/dist/api/RetailApi/RetailApi.js +29 -0
  15. package/dist/api/RetailApi/RetailApi.js.map +1 -0
  16. package/dist/api/RetailApi/RetailApiTypes.d.ts +83 -0
  17. package/dist/api/RetailApi/RetailApiTypes.js +2 -0
  18. package/dist/api/RetailApi/RetailApiTypes.js.map +1 -0
  19. package/dist/api/RetailApi/utils/getUpdateUserProfile.d.ts +3 -0
  20. package/dist/api/RetailApi/utils/getUpdateUserProfile.js +27 -0
  21. package/dist/api/RetailApi/utils/getUpdateUserProfile.js.map +1 -0
  22. package/dist/api/RetailApi/utils/getUpdateUserTask.d.ts +2 -0
  23. package/dist/api/RetailApi/utils/getUpdateUserTask.js +43 -0
  24. package/dist/api/RetailApi/utils/getUpdateUserTask.js.map +1 -0
  25. package/dist/components/ApplicationLeadForm/ApplicationLeadForm.js +9 -23
  26. package/dist/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  27. package/dist/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +2 -0
  28. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +6 -0
  29. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +69 -0
  30. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -0
  31. package/dist/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
  32. package/dist/components/ApplicationLeadForm/useInitApplicationLead.js +11 -0
  33. package/dist/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -0
  34. package/dist/hooks/useLeadFormData.d.ts +4 -1
  35. package/dist/hooks/useLeadFormData.js +4 -1
  36. package/dist/hooks/useLeadFormData.js.map +1 -1
  37. package/dist/ui-kit/FormField/Fields/DesiredMeetingDateField.js +1 -1
  38. package/dist/ui-kit/FormField/Fields/DesiredMeetingDateField.js.map +1 -1
  39. package/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +2 -0
  40. package/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js +19 -11
  41. package/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
  42. package/lib/api/RetailApi/RetailApi.d.ts +9 -0
  43. package/lib/api/RetailApi/RetailApi.js +27 -0
  44. package/lib/api/RetailApi/RetailApi.js.map +1 -0
  45. package/lib/api/RetailApi/RetailApiTypes.d.ts +83 -0
  46. package/lib/api/RetailApi/RetailApiTypes.js +2 -0
  47. package/lib/api/RetailApi/RetailApiTypes.js.map +1 -0
  48. package/lib/api/RetailApi/utils/getUpdateUserProfile.d.ts +3 -0
  49. package/lib/api/RetailApi/utils/getUpdateUserProfile.js +24 -0
  50. package/lib/api/RetailApi/utils/getUpdateUserProfile.js.map +1 -0
  51. package/lib/api/RetailApi/utils/getUpdateUserTask.d.ts +2 -0
  52. package/lib/api/RetailApi/utils/getUpdateUserTask.js +40 -0
  53. package/lib/api/RetailApi/utils/getUpdateUserTask.js.map +1 -0
  54. package/lib/components/ApplicationLeadForm/ApplicationLeadForm.js +10 -24
  55. package/lib/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  56. package/lib/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +2 -0
  57. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +6 -0
  58. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +66 -0
  59. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -0
  60. package/lib/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
  61. package/lib/components/ApplicationLeadForm/useInitApplicationLead.js +8 -0
  62. package/lib/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -0
  63. package/lib/hooks/useLeadFormData.d.ts +4 -1
  64. package/lib/hooks/useLeadFormData.js +4 -1
  65. package/lib/hooks/useLeadFormData.js.map +1 -1
  66. package/lib/ui-kit/FormField/Fields/DesiredMeetingDateField.js +1 -1
  67. package/lib/ui-kit/FormField/Fields/DesiredMeetingDateField.js.map +1 -1
  68. package/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +2 -0
  69. package/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js +19 -11
  70. package/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
  71. package/mobile/bundle/api/RetailApi/RetailApi.d.ts +9 -0
  72. package/mobile/bundle/api/RetailApi/RetailApiTypes.d.ts +83 -0
  73. package/mobile/bundle/api/RetailApi/utils/getUpdateUserProfile.d.ts +3 -0
  74. package/mobile/bundle/api/RetailApi/utils/getUpdateUserTask.d.ts +2 -0
  75. package/mobile/bundle/bundle.umd.js +281 -39
  76. package/mobile/bundle/bundle.umd.min.js +1 -1
  77. package/mobile/bundle/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +2 -0
  78. package/mobile/bundle/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +6 -0
  79. package/mobile/bundle/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
  80. package/mobile/bundle/hooks/useLeadFormData.d.ts +4 -1
  81. package/mobile/bundle/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +2 -0
  82. package/mobile/dist/api/RetailApi/RetailApi.d.ts +9 -0
  83. package/mobile/dist/api/RetailApi/RetailApi.js +29 -0
  84. package/mobile/dist/api/RetailApi/RetailApi.js.map +1 -0
  85. package/mobile/dist/api/RetailApi/RetailApiTypes.d.ts +83 -0
  86. package/mobile/dist/api/RetailApi/RetailApiTypes.js +2 -0
  87. package/mobile/dist/api/RetailApi/RetailApiTypes.js.map +1 -0
  88. package/mobile/dist/api/RetailApi/utils/getUpdateUserProfile.d.ts +3 -0
  89. package/mobile/dist/api/RetailApi/utils/getUpdateUserProfile.js +27 -0
  90. package/mobile/dist/api/RetailApi/utils/getUpdateUserProfile.js.map +1 -0
  91. package/mobile/dist/api/RetailApi/utils/getUpdateUserTask.d.ts +2 -0
  92. package/mobile/dist/api/RetailApi/utils/getUpdateUserTask.js +43 -0
  93. package/mobile/dist/api/RetailApi/utils/getUpdateUserTask.js.map +1 -0
  94. package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadForm.js +9 -23
  95. package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  96. package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +2 -0
  97. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +6 -0
  98. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +69 -0
  99. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -0
  100. package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
  101. package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.js +11 -0
  102. package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -0
  103. package/mobile/dist/hooks/useLeadFormData.d.ts +4 -1
  104. package/mobile/dist/hooks/useLeadFormData.js +4 -1
  105. package/mobile/dist/hooks/useLeadFormData.js.map +1 -1
  106. package/mobile/dist/ui-kit/FormField/Fields/DesiredMeetingDateField.js +1 -1
  107. package/mobile/dist/ui-kit/FormField/Fields/DesiredMeetingDateField.js.map +1 -1
  108. package/mobile/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +2 -0
  109. package/mobile/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js +19 -11
  110. package/mobile/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
  111. package/mobile/lib/api/RetailApi/RetailApi.d.ts +9 -0
  112. package/mobile/lib/api/RetailApi/RetailApi.js +27 -0
  113. package/mobile/lib/api/RetailApi/RetailApi.js.map +1 -0
  114. package/mobile/lib/api/RetailApi/RetailApiTypes.d.ts +83 -0
  115. package/mobile/lib/api/RetailApi/RetailApiTypes.js +2 -0
  116. package/mobile/lib/api/RetailApi/RetailApiTypes.js.map +1 -0
  117. package/mobile/lib/api/RetailApi/utils/getUpdateUserProfile.d.ts +3 -0
  118. package/mobile/lib/api/RetailApi/utils/getUpdateUserProfile.js +24 -0
  119. package/mobile/lib/api/RetailApi/utils/getUpdateUserProfile.js.map +1 -0
  120. package/mobile/lib/api/RetailApi/utils/getUpdateUserTask.d.ts +2 -0
  121. package/mobile/lib/api/RetailApi/utils/getUpdateUserTask.js +40 -0
  122. package/mobile/lib/api/RetailApi/utils/getUpdateUserTask.js.map +1 -0
  123. package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadForm.js +10 -24
  124. package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  125. package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +2 -0
  126. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +6 -0
  127. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +66 -0
  128. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -0
  129. package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
  130. package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.js +8 -0
  131. package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -0
  132. package/mobile/lib/hooks/useLeadFormData.d.ts +4 -1
  133. package/mobile/lib/hooks/useLeadFormData.js +4 -1
  134. package/mobile/lib/hooks/useLeadFormData.js.map +1 -1
  135. package/mobile/lib/ui-kit/FormField/Fields/DesiredMeetingDateField.js +1 -1
  136. package/mobile/lib/ui-kit/FormField/Fields/DesiredMeetingDateField.js.map +1 -1
  137. package/mobile/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +2 -0
  138. package/mobile/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js +19 -11
  139. package/mobile/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
  140. package/mobile/src/api/RetailApi/RetailApi.ts +51 -0
  141. package/mobile/src/api/RetailApi/RetailApiTypes.ts +91 -0
  142. package/mobile/src/api/RetailApi/utils/getUpdateUserProfile.ts +44 -0
  143. package/mobile/src/api/RetailApi/utils/getUpdateUserTask.ts +46 -0
  144. package/mobile/src/components/ApplicationLeadForm/ApplicationLeadForm.tsx +11 -26
  145. package/mobile/src/components/ApplicationLeadForm/ApplicationLeadFormContent.ts +2 -0
  146. package/mobile/src/components/ApplicationLeadForm/useApplicationLeadApi.ts +74 -0
  147. package/mobile/src/components/ApplicationLeadForm/useInitApplicationLead.ts +8 -0
  148. package/mobile/src/hooks/useLeadFormData.ts +10 -3
  149. package/mobile/src/ui-kit/FormField/Fields/DesiredMeetingDateField.tsx +2 -2
  150. package/mobile/src/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.tsx +32 -14
  151. package/package.json +2 -2
  152. package/src/api/RetailApi/RetailApi.ts +51 -0
  153. package/src/api/RetailApi/RetailApiTypes.ts +91 -0
  154. package/src/api/RetailApi/utils/getUpdateUserProfile.ts +44 -0
  155. package/src/api/RetailApi/utils/getUpdateUserTask.ts +46 -0
  156. package/src/components/ApplicationLeadForm/ApplicationLeadForm.fixture.tsx +1 -0
  157. package/src/components/ApplicationLeadForm/ApplicationLeadForm.tsx +11 -26
  158. package/src/components/ApplicationLeadForm/ApplicationLeadFormContent.ts +2 -0
  159. package/src/components/ApplicationLeadForm/useApplicationLeadApi.ts +74 -0
  160. package/src/components/ApplicationLeadForm/useInitApplicationLead.ts +8 -0
  161. package/src/hooks/useLeadFormData.ts +10 -3
  162. package/src/ui-kit/FormField/Fields/DesiredMeetingDateField.tsx +2 -2
  163. package/src/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.fixture.tsx +5 -4
  164. package/src/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.tsx +32 -14
  165. package/bundle/components/ApplicationLeadForm/getFormatData.d.ts +0 -2
  166. package/bundle/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +0 -13
  167. package/dist/components/ApplicationLeadForm/getFormatData.d.ts +0 -2
  168. package/dist/components/ApplicationLeadForm/getFormatData.js +0 -13
  169. package/dist/components/ApplicationLeadForm/getFormatData.js.map +0 -1
  170. package/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +0 -13
  171. package/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js +0 -30
  172. package/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js.map +0 -1
  173. package/lib/components/ApplicationLeadForm/getFormatData.d.ts +0 -2
  174. package/lib/components/ApplicationLeadForm/getFormatData.js +0 -10
  175. package/lib/components/ApplicationLeadForm/getFormatData.js.map +0 -1
  176. package/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +0 -13
  177. package/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js +0 -27
  178. package/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js.map +0 -1
  179. package/mobile/bundle/components/ApplicationLeadForm/getFormatData.d.ts +0 -2
  180. package/mobile/bundle/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +0 -13
  181. package/mobile/dist/components/ApplicationLeadForm/getFormatData.d.ts +0 -2
  182. package/mobile/dist/components/ApplicationLeadForm/getFormatData.js +0 -13
  183. package/mobile/dist/components/ApplicationLeadForm/getFormatData.js.map +0 -1
  184. package/mobile/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +0 -13
  185. package/mobile/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js +0 -30
  186. package/mobile/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js.map +0 -1
  187. package/mobile/lib/components/ApplicationLeadForm/getFormatData.d.ts +0 -2
  188. package/mobile/lib/components/ApplicationLeadForm/getFormatData.js +0 -10
  189. package/mobile/lib/components/ApplicationLeadForm/getFormatData.js.map +0 -1
  190. package/mobile/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +0 -13
  191. package/mobile/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js +0 -27
  192. package/mobile/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js.map +0 -1
  193. package/mobile/src/components/ApplicationLeadForm/getFormatData.tsx +0 -17
  194. package/mobile/src/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.tsx +0 -36
  195. package/src/components/ApplicationLeadForm/getFormatData.tsx +0 -17
  196. package/src/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.tsx +0 -36
@@ -0,0 +1,91 @@
1
+ export type CreateUserProfileBody = {
2
+ profile: {
3
+ phone: string;
4
+ };
5
+ };
6
+
7
+ export type CreateUserProfileResponse = {
8
+ profile: {
9
+ id: number;
10
+ };
11
+ };
12
+
13
+ export type UpdateUserProfileBody = {
14
+ profile: {
15
+ id: number;
16
+ phone: string;
17
+ email: string;
18
+ name: string;
19
+ surname: string;
20
+ midname: string;
21
+ birthDate: string;
22
+ processPersonalDataLeadFlg: boolean;
23
+ consentProviderFlg: boolean;
24
+ consentPfrFlg: boolean;
25
+ consentPhotoFlg: boolean;
26
+ consentAssignmentClaimsFlg: boolean;
27
+ consentCollectionFlg: boolean;
28
+ consentInformFlg: boolean;
29
+ };
30
+ };
31
+
32
+ export type CreateDraftTaskBody = {
33
+ profileId: number;
34
+ programId: string;
35
+ };
36
+
37
+ export type CreateDraftTaskResponse = {
38
+ taskId: number;
39
+ participantId: number;
40
+ };
41
+
42
+ export type UpdateUserTaskBody = {
43
+ sendToBank: boolean;
44
+ taskKind: 'SHORT' | 'FULL' | 'UNITED';
45
+ task: {
46
+ taskSource: string;
47
+ id: number;
48
+ participants: [
49
+ {
50
+ birthDate: string;
51
+ id: number;
52
+ midname: string;
53
+ name: string;
54
+ surname: string;
55
+ profile: {
56
+ id: number;
57
+ };
58
+ participantContacts: Array<{
59
+ contactTypeCd: {
60
+ key: 'EMAIL' | 'MAIN_PHONE';
61
+ };
62
+ value: string;
63
+ }>;
64
+ roleCd: {
65
+ key: string;
66
+ value: string;
67
+ };
68
+ },
69
+ ];
70
+ };
71
+ };
72
+
73
+ export type SendCodeBody = {
74
+ phoneNumber: string;
75
+ smsCodesSetName: {
76
+ key: 'AUTHENTICATION' | 'SEND_TASK';
77
+ };
78
+ };
79
+
80
+ export type CheckCodeBody = {
81
+ smsText: string;
82
+ smsCodesSetName: {
83
+ key: 'AUTHENTICATION' | 'SEND_TASK';
84
+ };
85
+ };
86
+
87
+ export type CheckCodeResponse = {
88
+ access_token: string;
89
+ expires_in: number;
90
+ refresh_token: string;
91
+ };
@@ -0,0 +1,44 @@
1
+ import { type FormState } from '../../../components/ApplicationLeadForm/getInitialFormState';
2
+ import { formatDate } from '../../../utils/formatDate';
3
+ import { formatPhone } from '../../../utils/formatPhone';
4
+ import { type UpdateUserProfileBody } from '../RetailApiTypes';
5
+
6
+ export const getUpdateUserProfileData = (
7
+ profileId: number,
8
+ formData: FormState,
9
+ ): UpdateUserProfileBody => {
10
+ const {
11
+ name = '',
12
+ surname = '',
13
+ middleName = '',
14
+ birthday = '',
15
+ phone = '',
16
+ email = '',
17
+ processPersonalDataLeadFlg,
18
+ consentProviderFlg,
19
+ consentPfrFlg,
20
+ consentPhotoFlg,
21
+ consentAssignmentClaimsFlg,
22
+ consentCollectionFlg,
23
+ consentInformFlg,
24
+ } = formData;
25
+
26
+ return {
27
+ profile: {
28
+ id: profileId,
29
+ name,
30
+ surname,
31
+ midname: middleName,
32
+ birthDate: birthday && formatDate(birthday, true),
33
+ email,
34
+ phone: formatPhone(phone),
35
+ processPersonalDataLeadFlg: Boolean(processPersonalDataLeadFlg),
36
+ consentProviderFlg: Boolean(consentProviderFlg),
37
+ consentPfrFlg: Boolean(consentPfrFlg),
38
+ consentPhotoFlg: Boolean(consentPhotoFlg),
39
+ consentAssignmentClaimsFlg: Boolean(consentAssignmentClaimsFlg),
40
+ consentCollectionFlg: Boolean(consentCollectionFlg),
41
+ consentInformFlg: Boolean(consentInformFlg),
42
+ },
43
+ };
44
+ };
@@ -0,0 +1,46 @@
1
+ import { type UpdateUserTaskBody } from '../RetailApiTypes';
2
+
3
+ /* eslint-disable max-params */
4
+ export const getUpdateUserTaskData = (
5
+ participantId: number,
6
+ taskId: number,
7
+ profileId: number,
8
+ formatData?: Record<string, any>,
9
+ ): UpdateUserTaskBody => ({
10
+ sendToBank: true,
11
+ taskKind: 'SHORT',
12
+ task: {
13
+ taskSource: globalThis.location.origin,
14
+ id: taskId,
15
+ participants: [
16
+ {
17
+ birthDate: formatData?.birthDate,
18
+ id: participantId,
19
+ midname: formatData?.midname,
20
+ name: formatData?.name,
21
+ surname: formatData?.surname,
22
+ profile: {
23
+ id: profileId,
24
+ },
25
+ participantContacts: [
26
+ {
27
+ contactTypeCd: {
28
+ key: 'EMAIL',
29
+ },
30
+ value: formatData?.email,
31
+ },
32
+ {
33
+ contactTypeCd: {
34
+ key: 'MAIN_PHONE',
35
+ },
36
+ value: formatData?.phone,
37
+ },
38
+ ],
39
+ roleCd: {
40
+ key: 'BORROWER',
41
+ value: 'Заемщик',
42
+ },
43
+ },
44
+ ],
45
+ },
46
+ });
@@ -1,54 +1,39 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import { useCallback, useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
3
- import { LeadServiceAPI } from '../../api/LeadServiceAPI';
2
+ import { useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
4
3
  import { useForm } from '../../hooks/useForm';
5
4
  import { ApplicationFormLayout } from '../../ui-kit/ApplicationFormLayout/ApplicationFormLayout';
6
5
  import { getField } from '../../ui-kit/FormField/getField';
7
- import { getObjectValidator } from '../../ui-kit/FormField/getObjectValidator';
8
6
  import { inputColumnStyles } from '../../ui-kit/FormField/inputColumnStyle';
9
7
  import { renderTitle } from '../../ui-kit/FormField/renderTitle';
10
8
  import { useResponseTypeDialog } from '../../ui-kit/ResponseTypeDialog/useResponseTypeDialog';
11
9
  import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
12
10
  import { style } from '../../utils/style';
13
- import { objectValidator } from '../../validation/objectValidator';
14
- import { isValidationSuccess } from '../../validation/validator';
15
11
  import {
16
12
  type ApplicationLeadFormContent,
17
13
  type FieldDef,
18
14
  type GroupedConsentsProps,
19
15
  } from './ApplicationLeadFormContent';
20
16
  import { CONSENTS } from './consents';
21
- import { getFormatData } from './getFormatData';
22
- import { getInitialFormState, type FormState } from './getInitialFormState';
17
+ import { getInitialFormState } from './getInitialFormState';
23
18
  import { GroupedConsents } from './GroupedConsents';
24
19
  import { renderSubmitButton } from './renderSubmitButton';
20
+ import { useApplicationLeadApi } from './useApplicationLeadApi';
21
+ import { useInitApplicationLead } from './useInitApplicationLead';
25
22
 
26
23
  interface ApplicationLeadFormProps extends ApplicationLeadFormContent, UniBlockProps {}
27
24
 
28
- const API = LeadServiceAPI();
29
-
30
25
  export const ApplicationLeadForm = JSX<ApplicationLeadFormProps>(
31
- // eslint-disable-next-line max-lines-per-function
32
- ({ className, title, typeForm = '', sections = [], button, endpoint, ...rest }) => {
26
+ ({ className, title, programId, typeForm = '', sections = [], button, ...rest }) => {
33
27
  const inputs = (sections?.flatMap((_) => _?.inputs) || []) as FieldDef[];
34
28
  const initialFormState = getInitialFormState(inputs, typeForm);
35
29
  const [responseType, setResponseType] = useState<'OK' | 'Fail' | ''>('');
36
- const handleSubmit = useCallback(async (formData: FormState) => {
37
- const feedbackValidator = objectValidator(getObjectValidator(inputs));
38
- if (!isValidationSuccess(feedbackValidator(formData))) {
39
- return 'Fail';
40
- }
41
- const formatData = getFormatData(formData);
42
- const status = (await API.send(formatData, endpoint === 'lead')) ? 'OK' : 'Fail';
43
- setResponseType(status);
44
-
45
- if (status) {
46
- const responseTypeDialog = useResponseTypeDialog({ responseType: status, typeForm });
47
- responseTypeDialog.open();
48
- }
30
+ useInitApplicationLead();
31
+ const { handleSubmit, responseStatus } = useApplicationLeadApi(inputs, programId || '');
49
32
 
50
- return status;
51
- }, []);
33
+ if (responseStatus) {
34
+ const responseTypeDialog = useResponseTypeDialog({ responseType: responseStatus, typeForm });
35
+ responseTypeDialog.open();
36
+ }
52
37
 
53
38
  const [, { field, onSubmit, reset }] = useForm(initialFormState, { onSubmit: handleSubmit });
54
39
 
@@ -179,6 +179,8 @@ export type ApplicationLeadFormContent = UniBlockContent &
179
179
  /** @default "" */
180
180
  target?: Target;
181
181
  };
182
+ /** @title Номер кредитной программы */
183
+ programId?: string;
182
184
  typeForm?: TypeFormFieldDef;
183
185
  /** @hidden */
184
186
  sections?: SectionsProps[];
@@ -0,0 +1,74 @@
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
+ });
@@ -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
+ };
@@ -2,17 +2,24 @@ import { useAsyncData } from '@redneckz/uni-jsx/lib/hooks/useAsyncData';
2
2
  import { type LeadProps } from '../ui-kit/FormField/SelectField';
3
3
  import { fetchJSON } from '../utils/fetchJSON';
4
4
 
5
+ type ErrorProps = {
6
+ errorMessage?: string;
7
+ };
8
+
5
9
  export const useLeadFormData = (typeField: string) => {
6
10
  const { data, error } = useAsyncData(
7
11
  `https://portal-ui-cc.cprb.dev.rshbdev.ru/light-api-cash/v1/dictionary?dictionaryType=${typeField}`,
8
12
  fetchData,
9
13
  );
14
+ if (data && 'errorMessage' in data) {
15
+ return { error };
16
+ }
10
17
 
11
- return { data, error };
18
+ return { data: data as LeadProps[], error };
12
19
  };
13
20
 
14
- const fetchData = async (url: string): Promise<LeadProps[]> => {
15
- const result = await fetchJSON<LeadProps[]>(url, { method: 'POST' });
21
+ const fetchData = async (url: string): Promise<LeadProps[] | ErrorProps> => {
22
+ const result = await fetchJSON<LeadProps[] | ErrorProps>(url, { method: 'POST' });
16
23
 
17
24
  return result || [];
18
25
  };
@@ -6,7 +6,7 @@ import { getValidation } from '../getValidation';
6
6
 
7
7
  export const DesiredMeetingDateField = JSX<CustomFieldProps>(({ field, input }) => (
8
8
  <DatePickerControl
9
- label="Дата рождения"
10
- {...getValidation(field('birthday'), validatorObj.birthday, input?.required)}
9
+ label="Желаемая дата встречи"
10
+ {...getValidation(field('desiredMeetingDate'), validatorObj.meetingDay, input?.required)}
11
11
  />
12
12
  ));
@@ -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,56 @@ 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>;
22
23
  }
23
24
 
24
25
  export const VerifyPhoneDialog = JSX<VerifyPhoneDialogProps>(
25
- ({ title, description, __html, code = true, codeLength = 4, textButton = '' }) => {
26
+ ({
27
+ title,
28
+ phone,
29
+ description,
30
+ __html,
31
+ code = true,
32
+ codeLength = 4,
33
+ textButton = '',
34
+ onClose,
35
+ }) => {
26
36
  const { close } = useDialogManager();
27
37
 
28
- const [values, setValues] = useState(Array(codeLength).fill(''));
38
+ const [values, setValues] = useState<string[]>(Array(codeLength).fill('') as string[]);
29
39
  const [hasError, setHasError] = useState(false);
30
40
  const [isLoading, setIsLoading] = useState(false);
31
- const [timeNextReq, setTimeNextReq] = useState<number>(0);
41
+ const [timeNextReq, setTimeNextReq] = useState<number>(180);
32
42
 
33
43
  const isValidCode = useMemo(() => values.every(Boolean), [values]);
34
44
 
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);
45
+ useEffect(() => {
46
+ RETAIL_API.SendCode({
47
+ phoneNumber: phone,
48
+ smsCodesSetName: { key: 'AUTHENTICATION' },
49
+ });
50
+ }, []);
41
51
 
42
- if (success) {
52
+ const handleSubmit = useCallback(async () => {
53
+ try {
54
+ setIsLoading(true);
55
+ await RETAIL_API.CheckCode({
56
+ smsText: values.join(''),
57
+ smsCodesSetName: { key: 'AUTHENTICATION' },
58
+ });
43
59
  close();
44
- } else {
60
+ onClose && onClose();
61
+ } catch {
62
+ setIsLoading(false);
45
63
  setHasError(true);
46
64
  }
47
65
  }, [values]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.14.580",
3
+ "version": "0.14.582",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -210,7 +210,7 @@
210
210
  "path": "lib/common.css"
211
211
  },
212
212
  {
213
- "limit": "71 kB",
213
+ "limit": "73 kB",
214
214
  "path": "bundle/bundle.umd.min.js"
215
215
  }
216
216
  ],
@@ -0,0 +1,51 @@
1
+ import {
2
+ type CheckCodeBody,
3
+ type CheckCodeResponse,
4
+ type CreateDraftTaskBody,
5
+ type CreateDraftTaskResponse,
6
+ type CreateUserProfileBody,
7
+ type CreateUserProfileResponse,
8
+ type SendCodeBody,
9
+ type UpdateUserProfileBody,
10
+ type UpdateUserTaskBody,
11
+ } from './RetailApiTypes';
12
+
13
+ type RequsetMethod = 'POST' | 'GET' | 'PUT';
14
+
15
+ const getAthorizationHeaders = () => {
16
+ const token = sessionStorage.getItem('accessToken');
17
+
18
+ return token ? { Authorization: `Bearer ${token}` } : null;
19
+ };
20
+
21
+ const isJSON = (response: Response) => response.headers.get('Content-Type') === 'application/json';
22
+
23
+ const request = async <T>(url: string, method: RequsetMethod, body?: any): Promise<T> =>
24
+ await fetch('https://retail-light-api.cprb.dev.rshbdev.ru/api/v1' + url, {
25
+ method,
26
+ headers: {
27
+ 'Content-Type': 'application/json',
28
+ ...getAthorizationHeaders(),
29
+ },
30
+ credentials: 'include',
31
+ body: body ? JSON.stringify(body) : null,
32
+ }).then((response) => (isJSON(response) ? response.json() : response));
33
+
34
+ const saveToken = (data: CheckCodeResponse) => {
35
+ sessionStorage.setItem('accessToken', data.access_token as string);
36
+ sessionStorage.setItem('refreshToken', data.refresh_token as string);
37
+ };
38
+
39
+ export const RETAIL_API = {
40
+ CreateUserProfile: async (body: CreateUserProfileBody) =>
41
+ await request<CreateUserProfileResponse>('/public-data/createUserProfile', 'POST', body),
42
+ UpdateUserProfile: async (body: UpdateUserProfileBody) =>
43
+ await request('/user-data/updateUserProfile', 'PUT', body),
44
+ CreateDraftTask: async (body: CreateDraftTaskBody) =>
45
+ await request<CreateDraftTaskResponse>('/user-data/createDraftTask', 'POST', body),
46
+ UpdateUserTask: async (body: UpdateUserTaskBody) =>
47
+ await request('/user-data/updateUserTask', 'PUT', body),
48
+ SendCode: async (body: SendCodeBody) => await request('/sms/sendCode', 'POST', body),
49
+ CheckCode: async (body: CheckCodeBody) =>
50
+ await request<CheckCodeResponse>('/sms/checkCode', 'POST', body).then(saveToken),
51
+ };
@@ -0,0 +1,91 @@
1
+ export type CreateUserProfileBody = {
2
+ profile: {
3
+ phone: string;
4
+ };
5
+ };
6
+
7
+ export type CreateUserProfileResponse = {
8
+ profile: {
9
+ id: number;
10
+ };
11
+ };
12
+
13
+ export type UpdateUserProfileBody = {
14
+ profile: {
15
+ id: number;
16
+ phone: string;
17
+ email: string;
18
+ name: string;
19
+ surname: string;
20
+ midname: string;
21
+ birthDate: string;
22
+ processPersonalDataLeadFlg: boolean;
23
+ consentProviderFlg: boolean;
24
+ consentPfrFlg: boolean;
25
+ consentPhotoFlg: boolean;
26
+ consentAssignmentClaimsFlg: boolean;
27
+ consentCollectionFlg: boolean;
28
+ consentInformFlg: boolean;
29
+ };
30
+ };
31
+
32
+ export type CreateDraftTaskBody = {
33
+ profileId: number;
34
+ programId: string;
35
+ };
36
+
37
+ export type CreateDraftTaskResponse = {
38
+ taskId: number;
39
+ participantId: number;
40
+ };
41
+
42
+ export type UpdateUserTaskBody = {
43
+ sendToBank: boolean;
44
+ taskKind: 'SHORT' | 'FULL' | 'UNITED';
45
+ task: {
46
+ taskSource: string;
47
+ id: number;
48
+ participants: [
49
+ {
50
+ birthDate: string;
51
+ id: number;
52
+ midname: string;
53
+ name: string;
54
+ surname: string;
55
+ profile: {
56
+ id: number;
57
+ };
58
+ participantContacts: Array<{
59
+ contactTypeCd: {
60
+ key: 'EMAIL' | 'MAIN_PHONE';
61
+ };
62
+ value: string;
63
+ }>;
64
+ roleCd: {
65
+ key: string;
66
+ value: string;
67
+ };
68
+ },
69
+ ];
70
+ };
71
+ };
72
+
73
+ export type SendCodeBody = {
74
+ phoneNumber: string;
75
+ smsCodesSetName: {
76
+ key: 'AUTHENTICATION' | 'SEND_TASK';
77
+ };
78
+ };
79
+
80
+ export type CheckCodeBody = {
81
+ smsText: string;
82
+ smsCodesSetName: {
83
+ key: 'AUTHENTICATION' | 'SEND_TASK';
84
+ };
85
+ };
86
+
87
+ export type CheckCodeResponse = {
88
+ access_token: string;
89
+ expires_in: number;
90
+ refresh_token: string;
91
+ };
@@ -0,0 +1,44 @@
1
+ import { type FormState } from '../../../components/ApplicationLeadForm/getInitialFormState';
2
+ import { formatDate } from '../../../utils/formatDate';
3
+ import { formatPhone } from '../../../utils/formatPhone';
4
+ import { type UpdateUserProfileBody } from '../RetailApiTypes';
5
+
6
+ export const getUpdateUserProfileData = (
7
+ profileId: number,
8
+ formData: FormState,
9
+ ): UpdateUserProfileBody => {
10
+ const {
11
+ name = '',
12
+ surname = '',
13
+ middleName = '',
14
+ birthday = '',
15
+ phone = '',
16
+ email = '',
17
+ processPersonalDataLeadFlg,
18
+ consentProviderFlg,
19
+ consentPfrFlg,
20
+ consentPhotoFlg,
21
+ consentAssignmentClaimsFlg,
22
+ consentCollectionFlg,
23
+ consentInformFlg,
24
+ } = formData;
25
+
26
+ return {
27
+ profile: {
28
+ id: profileId,
29
+ name,
30
+ surname,
31
+ midname: middleName,
32
+ birthDate: birthday && formatDate(birthday, true),
33
+ email,
34
+ phone: formatPhone(phone),
35
+ processPersonalDataLeadFlg: Boolean(processPersonalDataLeadFlg),
36
+ consentProviderFlg: Boolean(consentProviderFlg),
37
+ consentPfrFlg: Boolean(consentPfrFlg),
38
+ consentPhotoFlg: Boolean(consentPhotoFlg),
39
+ consentAssignmentClaimsFlg: Boolean(consentAssignmentClaimsFlg),
40
+ consentCollectionFlg: Boolean(consentCollectionFlg),
41
+ consentInformFlg: Boolean(consentInformFlg),
42
+ },
43
+ };
44
+ };