@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
@@ -870,7 +870,7 @@
870
870
  const url = isNaturalPerson ? '/api/v1/lead' : '/api/v1/sendcorporatelead';
871
871
  const submitBody = {
872
872
  typeForm,
873
- ...getRegion$2(region, isNaturalPerson),
873
+ ...getRegion$1(region, isNaturalPerson),
874
874
  ...getEmail(email, isNaturalPerson),
875
875
  ...getPhone(phone),
876
876
  ...getFormatDate(desiredMeetingDate, 'desiredMeetingDate'),
@@ -908,7 +908,7 @@
908
908
  }
909
909
  const getPhone = (phone) => (phone ? { phone: formatPhone(phone) } : {});
910
910
  const getFormatDate = (date, key = 'birthday') => date ? { [key]: formatDate(date) } : {};
911
- const getRegion$2 = (region, isNaturalPerson = true) => ({
911
+ const getRegion$1 = (region, isNaturalPerson = true) => ({
912
912
  [isNaturalPerson ? 'regionBranch' : 'region']: region,
913
913
  });
914
914
  const getEmail = (email, isNaturalPerson = true) => ({
@@ -2219,19 +2219,19 @@
2219
2219
  };
2220
2220
 
2221
2221
  /* eslint-disable @typescript-eslint/no-unused-vars */
2222
- const getFormatData$1 = (data) => {
2222
+ const getFormatData = (data) => {
2223
2223
  const { acquiringType, onlineCheckout, posTerminal, amount, term, annualRevenue, serviceType, vedTypes, region, ...usedData } = data;
2224
2224
  const partnerComments = acquiringType || annualRevenue ? getPartnerComments(data) : null;
2225
2225
  const formatData = {
2226
2226
  ...usedData,
2227
2227
  ...getVedTypes(vedTypes),
2228
- ...getRegion$1(region),
2228
+ ...getRegion(region),
2229
2229
  ...(partnerComments ? { partnerComments } : {}),
2230
2230
  ...(serviceType ? { typeForm: serviceType } : {}),
2231
2231
  };
2232
2232
  return Object.fromEntries(Object.entries(formatData)?.map(([k, v]) => [k, v?.key || v]));
2233
2233
  };
2234
- const getRegion$1 = (region) => region?.key || region?.text ? { region: region?.text || region?.key } : {};
2234
+ const getRegion = (region) => region?.key || region?.text ? { region: region?.text || region?.key } : {};
2235
2235
  const getVedTypes = (vedTypes) => vedTypes
2236
2236
  ? {
2237
2237
  vedTypes: Object.fromEntries(VED_TYPES.map((v) => [v, v === vedTypes])),
@@ -2284,7 +2284,7 @@
2284
2284
 
2285
2285
  const renderContacts = () => (jsxs("div", { className: "space-y-m", children: [jsx(Heading, { headingType: "h6", title: "\u0418\u043B\u0438 \u0441\u0432\u044F\u0436\u0438\u0442\u0435\u0441\u044C \u0441 \u043D\u0430\u043C\u0438 \u0443\u0434\u043E\u0431\u043D\u044B\u043C \u0441\u043F\u043E\u0441\u043E\u0431\u043E\u043C", className: "@xl:text-center" }), jsxs("div", { className: "flex sm:justify-center gap-xl", children: [jsxs("a", { className: "flex gap-s items-center text-primary-text no-underline", href: `tel:8 (800) 200-78-70`, "aria-label": "\u0442\u0435\u043B\u0435\u0444\u043E\u043D 8 (800) 200-78-70", children: [jsx(Img, { image: { icon: 'PhoneIcon' }, width: "24", height: "24" }), jsx("span", { children: "8 (800) 200-78-70" })] }), jsxs("a", { className: "flex gap-s items-center text-primary-text no-underline", "aria-label": "\u043F\u043E\u0447\u0442\u0430 ved@rshb.ru", href: `mailto:ved@rshb.ru`, children: [jsx(Img, { image: { icon: 'MailIcon' }, width: "24", height: "24" }), jsx("span", { children: "ved@rshb.ru" })] })] })] }));
2286
2286
 
2287
- const API$1 = LeadServiceAPI();
2287
+ const API = LeadServiceAPI();
2288
2288
  const ApplicationForm = JSX(
2289
2289
  // eslint-disable-next-line max-lines-per-function
2290
2290
  ({ className, title, typeForm = '', sections = [], button, link, endpoint, additionalParams, isContacts, data, ...rest }) => {
@@ -2297,8 +2297,8 @@
2297
2297
  if (!isValidationSuccess(feedbackValidator(formData))) {
2298
2298
  return 'Fail';
2299
2299
  }
2300
- const formatData = getFormatData$1({ ...formData, ...additionalParams });
2301
- const status = (await API$1.send(formatData, endpoint === 'lead')) ? 'OK' : 'Fail';
2300
+ const formatData = getFormatData({ ...formData, ...additionalParams });
2301
+ const status = (await API.send(formatData, endpoint === 'lead')) ? 'OK' : 'Fail';
2302
2302
  setResponseType(status);
2303
2303
  if (status) {
2304
2304
  const responseTypeDialog = useResponseTypeDialog({ responseType: status, typeForm });
@@ -2341,16 +2341,6 @@
2341
2341
  'consentToReceiveMaterials',
2342
2342
  ];
2343
2343
 
2344
- const getFormatData = (data) => {
2345
- const { region, ...usedData } = data;
2346
- const formatData = {
2347
- ...usedData,
2348
- ...getRegion(region),
2349
- };
2350
- return Object.fromEntries(Object.entries(formatData)?.map(([k, v]) => [k, v?.key || v]));
2351
- };
2352
- const getRegion = (region) => region?.key || region?.text ? { region: region?.text || region?.key } : {};
2353
-
2354
2344
  const initialFormState = {
2355
2345
  typeForm: '',
2356
2346
  region: { key: '', text: '' },
@@ -2450,27 +2440,282 @@
2450
2440
 
2451
2441
  const renderSubmitButton = (button, className) => (jsx(Button, { className: style('w-full @xl:w-auto', className), type: "submit", children: button?.text ? button.text : 'Отправить заявку' }));
2452
2442
 
2453
- const API = LeadServiceAPI();
2454
- const ApplicationLeadForm = JSX(
2455
- // eslint-disable-next-line max-lines-per-function
2456
- ({ className, title, typeForm = '', sections = [], button, endpoint, ...rest }) => {
2457
- const inputs = (sections?.flatMap((_) => _?.inputs) || []);
2458
- const initialFormState = getInitialFormState(inputs, typeForm);
2459
- const [responseType, setResponseType] = useState('');
2443
+ const getAthorizationHeaders = () => {
2444
+ const token = sessionStorage.getItem('accessToken');
2445
+ return token ? { Authorization: `Bearer ${token}` } : null;
2446
+ };
2447
+ const isJSON = (response) => response.headers.get('Content-Type') === 'application/json';
2448
+ const request = async (url, method, body) => await fetch('https://retail-light-api.cprb.dev.rshbdev.ru/api/v1' + url, {
2449
+ method,
2450
+ headers: {
2451
+ 'Content-Type': 'application/json',
2452
+ ...getAthorizationHeaders(),
2453
+ },
2454
+ credentials: 'include',
2455
+ body: body ? JSON.stringify(body) : null,
2456
+ }).then((response) => (isJSON(response) ? response.json() : response));
2457
+ const saveToken = (data) => {
2458
+ sessionStorage.setItem('accessToken', data.access_token);
2459
+ sessionStorage.setItem('refreshToken', data.refresh_token);
2460
+ };
2461
+ const RETAIL_API = {
2462
+ CreateUserProfile: async (body) => await request('/public-data/createUserProfile', 'POST', body),
2463
+ UpdateUserProfile: async (body) => await request('/user-data/updateUserProfile', 'PUT', body),
2464
+ CreateDraftTask: async (body) => await request('/user-data/createDraftTask', 'POST', body),
2465
+ UpdateUserTask: async (body) => await request('/user-data/updateUserTask', 'PUT', body),
2466
+ SendCode: async (body) => await request('/sms/sendCode', 'POST', body),
2467
+ CheckCode: async (body) => await request('/sms/checkCode', 'POST', body).then(saveToken),
2468
+ };
2469
+
2470
+ const getUpdateUserProfileData = (profileId, formData) => {
2471
+ const { name = '', surname = '', middleName = '', birthday = '', phone = '', email = '', processPersonalDataLeadFlg, consentProviderFlg, consentPfrFlg, consentPhotoFlg, consentAssignmentClaimsFlg, consentCollectionFlg, consentInformFlg, } = formData;
2472
+ return {
2473
+ profile: {
2474
+ id: profileId,
2475
+ name,
2476
+ surname,
2477
+ midname: middleName,
2478
+ birthDate: birthday && formatDate(birthday, true),
2479
+ email,
2480
+ phone: formatPhone(phone),
2481
+ processPersonalDataLeadFlg: Boolean(processPersonalDataLeadFlg),
2482
+ consentProviderFlg: Boolean(consentProviderFlg),
2483
+ consentPfrFlg: Boolean(consentPfrFlg),
2484
+ consentPhotoFlg: Boolean(consentPhotoFlg),
2485
+ consentAssignmentClaimsFlg: Boolean(consentAssignmentClaimsFlg),
2486
+ consentCollectionFlg: Boolean(consentCollectionFlg),
2487
+ consentInformFlg: Boolean(consentInformFlg),
2488
+ },
2489
+ };
2490
+ };
2491
+
2492
+ /* eslint-disable max-params */
2493
+ const getUpdateUserTaskData = (participantId, taskId, profileId, formatData) => ({
2494
+ sendToBank: true,
2495
+ taskKind: 'SHORT',
2496
+ task: {
2497
+ taskSource: globalThis.location.origin,
2498
+ id: taskId,
2499
+ participants: [
2500
+ {
2501
+ birthDate: formatData?.birthDate,
2502
+ id: participantId,
2503
+ midname: formatData?.midname,
2504
+ name: formatData?.name,
2505
+ surname: formatData?.surname,
2506
+ profile: {
2507
+ id: profileId,
2508
+ },
2509
+ participantContacts: [
2510
+ {
2511
+ contactTypeCd: {
2512
+ key: 'EMAIL',
2513
+ },
2514
+ value: formatData?.email,
2515
+ },
2516
+ {
2517
+ contactTypeCd: {
2518
+ key: 'MAIN_PHONE',
2519
+ },
2520
+ value: formatData?.phone,
2521
+ },
2522
+ ],
2523
+ roleCd: {
2524
+ key: 'BORROWER',
2525
+ value: 'Заемщик',
2526
+ },
2527
+ },
2528
+ ],
2529
+ },
2530
+ });
2531
+
2532
+ const Loader = JSX(({ color = 'text-primary-main', position = 'absolute', blur = true }) => (jsx("div", { className: style('flex justify-center items-center h-full w-full z-50', position, {
2533
+ 'backdrop-blur': blur,
2534
+ }), children: jsx("div", { className: style('inline-block h-28 w-28', 'animate-spin rounded-full', 'border-8 border-solid border-current', 'border-r-transparent', color), role: "status" }) })));
2535
+
2536
+ const Timer = JSX(({ time, setTime, className }) => {
2537
+ useEffect(() => {
2538
+ const timer = setInterval(() => {
2539
+ setTime(time - 1);
2540
+ }, 1000);
2541
+ if (time === 0) {
2542
+ clearInterval(timer);
2543
+ }
2544
+ return () => {
2545
+ clearInterval(timer);
2546
+ };
2547
+ }, [time]);
2548
+ return jsx("span", { className: className, children: secondsToMinSecPadded(time) });
2549
+ });
2550
+ const secondsToMinSecPadded = (time) => {
2551
+ const minutes = `${Math.floor(time / 60)}`.padStart(2, '0');
2552
+ const seconds = `${time % 60}`.padStart(2, '0');
2553
+ return `${minutes}:${seconds}`;
2554
+ };
2555
+
2556
+ const InputCode = JSX(({ values, setValues, hasError }) => {
2557
+ const [activeIndex, setActiveIndex] = useState(0);
2558
+ const inputRefs = useRef([]);
2559
+ useEffect(() => {
2560
+ inputRefs.current?.[activeIndex]?.focus();
2561
+ }, [activeIndex]);
2562
+ const handleChange = useCallback((index) => (event) => {
2563
+ const { value } = event.currentTarget;
2564
+ const isLastIndex = index === values.length - 1;
2565
+ const isMultipleCharacters = value.length > 1;
2566
+ if (isLastIndex && isMultipleCharacters) {
2567
+ return;
2568
+ }
2569
+ setValues(values.map((_, i) => (i === index ? value : _)));
2570
+ setActiveIndex(index + 1);
2571
+ }, [values]);
2572
+ const handleKeyDown = useCallback((currentIndex) => (event) => {
2573
+ const { key } = event;
2574
+ if (key === 'Backspace' && !values[currentIndex]) {
2575
+ const previousIndex = currentIndex > 0 ? currentIndex - 1 : values.length - 1;
2576
+ const updatedValues = values.map((value, index) => (index === previousIndex ? '' : value));
2577
+ setValues(updatedValues);
2578
+ setActiveIndex(previousIndex);
2579
+ }
2580
+ }, [values]);
2581
+ const handlePaste = useCallback((event) => {
2582
+ event.preventDefault();
2583
+ const pastedData = event.clipboardData.getData('text');
2584
+ const updatedValues = values.map((_, idx) => (idx < pastedData.length ? pastedData[idx] : _));
2585
+ setValues(updatedValues);
2586
+ setActiveIndex(updatedValues.length - 1);
2587
+ }, [values]);
2588
+ return (jsxs("div", { className: "flex flex-col gap-2 text-center", children: [jsx("div", { children: values.map((value, index) => (jsx("input", { type: "number", maxLength: 1, value: value, onChange: handleChange(index), onPaste: handlePaste, ref: (ref) => {
2589
+ if (!inputRefs.current) {
2590
+ inputRefs.current = [];
2591
+ }
2592
+ inputRefs.current[index] = ref;
2593
+ }, onFocus: (event) => event.target.select(), onKeyDown: handleKeyDown(index), className: getInputStyle(index, values, hasError) }, index))) }), hasError ? jsx("div", { className: "text-error", children: "\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043E\u0434" }) : null] }));
2594
+ });
2595
+ const getInputStyle = (index, values, hasError = false) => {
2596
+ const isInputEmpty = !values[index];
2597
+ return `w-16 h-20 text-3xl text-center p-2 m-2 border ${hasError && isInputEmpty ? 'border-error' : 'border-gray'} rounded-md caret-transparent outline-none`;
2598
+ };
2599
+
2600
+ const SubmitButton = JSX(({ isDisabled, onClick, text }) => {
2601
+ return (jsx(Button, { type: "button", onClick: onClick, disabled: isDisabled, children: jsx(Text, { font: "font-medium", children: text }) }));
2602
+ });
2603
+
2604
+ const VerifyPhoneDialog = JSX(({ title, phone, description, __html, code = true, codeLength = 4, textButton = '', onClose, href = '', }) => {
2605
+ const { close } = useDialogManager();
2606
+ const [values, setValues] = useState(Array(codeLength).fill(''));
2607
+ const [hasError, setHasError] = useState(false);
2608
+ const [isLoading, setIsLoading] = useState(false);
2609
+ const [timeNextReq, setTimeNextReq] = useState(180);
2610
+ const isValidCode = useMemo(() => values.every(Boolean), [values]);
2611
+ useEffect(() => {
2612
+ RETAIL_API.SendCode({
2613
+ phoneNumber: phone,
2614
+ smsCodesSetName: { key: 'AUTHENTICATION' },
2615
+ });
2616
+ }, []);
2617
+ const handleSubmit = useCallback(async () => {
2618
+ try {
2619
+ setIsLoading(true);
2620
+ await RETAIL_API.CheckCode({
2621
+ smsText: values.join(''),
2622
+ smsCodesSetName: { key: 'AUTHENTICATION' },
2623
+ });
2624
+ globalThis.location.href = href;
2625
+ close();
2626
+ onClose && onClose();
2627
+ }
2628
+ catch {
2629
+ setIsLoading(false);
2630
+ setHasError(true);
2631
+ }
2632
+ }, [values]);
2633
+ return (jsx(Dialog, { className: "my-6xl max-w-3xl w-full min-h-fit mx-auto rounded-lg", children: jsxs("div", { className: "flex flex-col gap-lg items-center rounded-md", children: [jsx(Headline, { className: "w-full", title: title, description: description, headlineVersion: "S", isEmbedded: true }), code ? jsx(InputCode, { values: values, setValues: setValues, hasError: hasError }) : null, timeNextReq ? (jsxs("div", { className: "flex flex-row text-l font-light text-primary-main", children: ["\u041F\u043E\u043B\u0443\u0447\u0438\u0442\u044C \u043D\u043E\u0432\u044B\u0439 \u043A\u043E\u0434 \u043C\u043E\u0436\u043D\u043E \u0447\u0435\u0440\u0435\u0437", jsx(Timer, { className: "text-primary-main ml-1", time: timeNextReq, setTime: setTimeNextReq })] })) : (jsx(LinkButton, { className: "text-primary-main", children: "\u041F\u043E\u043B\u0443\u0447\u0438\u0442\u044C \u043D\u043E\u0432\u044B\u0439 \u043A\u043E\u0434" })), jsx(RichText, { itemSize: "list-s", __html: __html }), textButton ? (jsx(SubmitButton, { isDisabled: !isValidCode, onClick: handleSubmit, text: textButton })) : null, isLoading ? jsx(Loader, { blur: false }) : null] }) }));
2634
+ });
2635
+
2636
+ const useVerifyPhoneDialog = (props) => {
2637
+ const { open, close } = useDialogManager();
2638
+ return {
2639
+ open: (options = {}) => open(jsx(VerifyPhoneDialog, { ...props }), options),
2640
+ close,
2641
+ };
2642
+ };
2643
+
2644
+ const useApplicationLeadApi = (inputs, programId) => {
2645
+ const [responseStatus, setResponseStatus] = useState('');
2646
+ // eslint-disable-next-line consistent-return
2460
2647
  const handleSubmit = useCallback(async (formData) => {
2461
2648
  const feedbackValidator = objectValidator(getObjectValidator(inputs));
2462
2649
  if (!isValidationSuccess(feedbackValidator(formData))) {
2463
2650
  return 'Fail';
2464
2651
  }
2465
- const formatData = getFormatData(formData);
2466
- const status = (await API.send(formatData, endpoint === 'lead')) ? 'OK' : 'Fail';
2467
- setResponseType(status);
2468
- if (status) {
2469
- const responseTypeDialog = useResponseTypeDialog({ responseType: status, typeForm });
2470
- responseTypeDialog.open();
2652
+ try {
2653
+ const { profile } = await RETAIL_API.CreateUserProfile({
2654
+ profile: { phone: formatPhone(formData.phone) },
2655
+ });
2656
+ const profileId = profile?.id;
2657
+ if (profileId && formData?.phone) {
2658
+ const handleSuccessVerify = async () => {
2659
+ try {
2660
+ await RETAIL_API.UpdateUserProfile(getUpdateUserProfileData(profileId, formData));
2661
+ const { taskId, participantId } = await RETAIL_API.CreateDraftTask({
2662
+ profileId,
2663
+ programId,
2664
+ });
2665
+ await RETAIL_API.UpdateUserTask(getUpdateUserTaskData(participantId, taskId, profileId, formData));
2666
+ setResponseStatus('OK');
2667
+ }
2668
+ catch {
2669
+ setResponseStatus('Fail');
2670
+ }
2671
+ };
2672
+ // eslint-disable-next-line react-hooks/rules-of-hooks
2673
+ const verifyPhoneDialog = useVerifyPhoneDialog({
2674
+ onClose: handleSuccessVerify,
2675
+ ...verifyPhoneContent(formData?.phone),
2676
+ });
2677
+ verifyPhoneDialog.open();
2678
+ }
2679
+ }
2680
+ catch {
2681
+ setResponseStatus('Fail');
2471
2682
  }
2472
- return status;
2473
2683
  }, []);
2684
+ return {
2685
+ handleSubmit,
2686
+ responseStatus,
2687
+ };
2688
+ };
2689
+ const verifyPhoneContent = (phone) => ({
2690
+ title: 'Подтвердите номер телефона',
2691
+ description: `Мы отправили код на ${phone}`,
2692
+ phone: formatPhone(phone),
2693
+ textButton: 'Оформить',
2694
+ __html: `<span>Вводя код, я подтверждаю, что ознакомлен и подписываю:</span>
2695
+ <ul><li>соглашение о порядке использования простой электронной подписи,
2696
+ </li><li>согласие на обработку персональных данных,
2697
+ </li><li>предоставление и подписание прочих согласий Банка,
2698
+ </li><li>согласие на запрос в ПФР</li></ul>`,
2699
+ href: '/credit-lead',
2700
+ });
2701
+
2702
+ const useInitApplicationLead = () => {
2703
+ useEffect(() => {
2704
+ sessionStorage.removeItem('accessToken');
2705
+ sessionStorage.removeItem('refreshToken');
2706
+ }, []);
2707
+ };
2708
+
2709
+ const ApplicationLeadForm = JSX(({ className, title, programId, typeForm = '', sections = [], button, ...rest }) => {
2710
+ const inputs = (sections?.flatMap((_) => _?.inputs) || []);
2711
+ const initialFormState = getInitialFormState(inputs, typeForm);
2712
+ const [responseType, setResponseType] = useState('');
2713
+ useInitApplicationLead();
2714
+ const { handleSubmit, responseStatus } = useApplicationLeadApi(inputs, programId || '');
2715
+ if (responseStatus) {
2716
+ const responseTypeDialog = useResponseTypeDialog({ responseType: responseStatus, typeForm });
2717
+ responseTypeDialog.open();
2718
+ }
2474
2719
  const [, { field, onSubmit, reset }] = useForm(initialFormState, { onSubmit: handleSubmit });
2475
2720
  useEffect(() => {
2476
2721
  if (responseType === 'OK') {
@@ -4927,10 +5172,6 @@
4927
5172
  const isClient = !isSSR();
4928
5173
  const ClientOnly = JSX(({ children }) => (isClient ? children : null));
4929
5174
 
4930
- const Loader = JSX(({ color = 'text-primary-main', position = 'absolute', blur = true }) => (jsx("div", { className: style('flex justify-center items-center h-full w-full z-50', position, {
4931
- 'backdrop-blur': blur,
4932
- }), children: jsx("div", { className: style('inline-block h-28 w-28', 'animate-spin rounded-full', 'border-8 border-solid border-current', 'border-r-transparent', color), role: "status" }) })));
4933
-
4934
5175
  const MapMarkerClusterIcon = '/icons/MapMarkerClusterIcon.svg';
4935
5176
  const MapMarkerClusterYellowIcon = '/icons/MapMarkerClusterYellowIcon.svg';
4936
5177
  function renderClusterer({ yandexMaps, map, points, isLoad, }) {
@@ -6571,7 +6812,7 @@
6571
6812
  slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
6572
6813
  });
6573
6814
 
6574
- const packageVersion = "0.14.580";
6815
+ const packageVersion = "0.14.582";
6575
6816
 
6576
6817
  exports.Blocks = Blocks;
6577
6818
  exports.ContentPage = ContentPage;