@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
@@ -862,7 +862,7 @@
862
862
  const url = isNaturalPerson ? '/api/v1/lead' : '/api/v1/sendcorporatelead';
863
863
  const submitBody = {
864
864
  typeForm,
865
- ...getRegion$2(region, isNaturalPerson),
865
+ ...getRegion$1(region, isNaturalPerson),
866
866
  ...getEmail(email, isNaturalPerson),
867
867
  ...getPhone(phone),
868
868
  ...getFormatDate(desiredMeetingDate, 'desiredMeetingDate'),
@@ -900,7 +900,7 @@
900
900
  }
901
901
  const getPhone = (phone) => (phone ? { phone: formatPhone(phone) } : {});
902
902
  const getFormatDate = (date, key = 'birthday') => date ? { [key]: formatDate(date) } : {};
903
- const getRegion$2 = (region, isNaturalPerson = true) => ({
903
+ const getRegion$1 = (region, isNaturalPerson = true) => ({
904
904
  [isNaturalPerson ? 'regionBranch' : 'region']: region,
905
905
  });
906
906
  const getEmail = (email, isNaturalPerson = true) => ({
@@ -2211,19 +2211,19 @@
2211
2211
  };
2212
2212
 
2213
2213
  /* eslint-disable @typescript-eslint/no-unused-vars */
2214
- const getFormatData$1 = (data) => {
2214
+ const getFormatData = (data) => {
2215
2215
  const { acquiringType, onlineCheckout, posTerminal, amount, term, annualRevenue, serviceType, vedTypes, region, ...usedData } = data;
2216
2216
  const partnerComments = acquiringType || annualRevenue ? getPartnerComments(data) : null;
2217
2217
  const formatData = {
2218
2218
  ...usedData,
2219
2219
  ...getVedTypes(vedTypes),
2220
- ...getRegion$1(region),
2220
+ ...getRegion(region),
2221
2221
  ...(partnerComments ? { partnerComments } : {}),
2222
2222
  ...(serviceType ? { typeForm: serviceType } : {}),
2223
2223
  };
2224
2224
  return Object.fromEntries(Object.entries(formatData)?.map(([k, v]) => [k, v?.key || v]));
2225
2225
  };
2226
- const getRegion$1 = (region) => region?.key || region?.text ? { region: region?.text || region?.key } : {};
2226
+ const getRegion = (region) => region?.key || region?.text ? { region: region?.text || region?.key } : {};
2227
2227
  const getVedTypes = (vedTypes) => vedTypes
2228
2228
  ? {
2229
2229
  vedTypes: Object.fromEntries(VED_TYPES.map((v) => [v, v === vedTypes])),
@@ -2276,7 +2276,7 @@
2276
2276
 
2277
2277
  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" })] })] })] }));
2278
2278
 
2279
- const API$1 = LeadServiceAPI();
2279
+ const API = LeadServiceAPI();
2280
2280
  const ApplicationForm = JSX(
2281
2281
  // eslint-disable-next-line max-lines-per-function
2282
2282
  ({ className, title, typeForm = '', sections = [], button, link, endpoint, additionalParams, isContacts, data, ...rest }) => {
@@ -2289,8 +2289,8 @@
2289
2289
  if (!isValidationSuccess(feedbackValidator(formData))) {
2290
2290
  return 'Fail';
2291
2291
  }
2292
- const formatData = getFormatData$1({ ...formData, ...additionalParams });
2293
- const status = (await API$1.send(formatData, endpoint === 'lead')) ? 'OK' : 'Fail';
2292
+ const formatData = getFormatData({ ...formData, ...additionalParams });
2293
+ const status = (await API.send(formatData, endpoint === 'lead')) ? 'OK' : 'Fail';
2294
2294
  setResponseType(status);
2295
2295
  if (status) {
2296
2296
  const responseTypeDialog = useResponseTypeDialog({ responseType: status, typeForm });
@@ -2333,16 +2333,6 @@
2333
2333
  'consentToReceiveMaterials',
2334
2334
  ];
2335
2335
 
2336
- const getFormatData = (data) => {
2337
- const { region, ...usedData } = data;
2338
- const formatData = {
2339
- ...usedData,
2340
- ...getRegion(region),
2341
- };
2342
- return Object.fromEntries(Object.entries(formatData)?.map(([k, v]) => [k, v?.key || v]));
2343
- };
2344
- const getRegion = (region) => region?.key || region?.text ? { region: region?.text || region?.key } : {};
2345
-
2346
2336
  const initialFormState = {
2347
2337
  typeForm: '',
2348
2338
  region: { key: '', text: '' },
@@ -2442,27 +2432,282 @@
2442
2432
 
2443
2433
  const renderSubmitButton = (button, className) => (jsx(Button, { className: style('w-full @xl:w-auto', className), type: "submit", children: button?.text ? button.text : 'Отправить заявку' }));
2444
2434
 
2445
- const API = LeadServiceAPI();
2446
- const ApplicationLeadForm = JSX(
2447
- // eslint-disable-next-line max-lines-per-function
2448
- ({ className, title, typeForm = '', sections = [], button, endpoint, ...rest }) => {
2449
- const inputs = (sections?.flatMap((_) => _?.inputs) || []);
2450
- const initialFormState = getInitialFormState(inputs, typeForm);
2451
- const [responseType, setResponseType] = useState('');
2435
+ const getAthorizationHeaders = () => {
2436
+ const token = sessionStorage.getItem('accessToken');
2437
+ return token ? { Authorization: `Bearer ${token}` } : null;
2438
+ };
2439
+ const isJSON = (response) => response.headers.get('Content-Type') === 'application/json';
2440
+ const request = async (url, method, body) => await fetch('https://retail-light-api.cprb.dev.rshbdev.ru/api/v1' + url, {
2441
+ method,
2442
+ headers: {
2443
+ 'Content-Type': 'application/json',
2444
+ ...getAthorizationHeaders(),
2445
+ },
2446
+ credentials: 'include',
2447
+ body: body ? JSON.stringify(body) : null,
2448
+ }).then((response) => (isJSON(response) ? response.json() : response));
2449
+ const saveToken = (data) => {
2450
+ sessionStorage.setItem('accessToken', data.access_token);
2451
+ sessionStorage.setItem('refreshToken', data.refresh_token);
2452
+ };
2453
+ const RETAIL_API = {
2454
+ CreateUserProfile: async (body) => await request('/public-data/createUserProfile', 'POST', body),
2455
+ UpdateUserProfile: async (body) => await request('/user-data/updateUserProfile', 'PUT', body),
2456
+ CreateDraftTask: async (body) => await request('/user-data/createDraftTask', 'POST', body),
2457
+ UpdateUserTask: async (body) => await request('/user-data/updateUserTask', 'PUT', body),
2458
+ SendCode: async (body) => await request('/sms/sendCode', 'POST', body),
2459
+ CheckCode: async (body) => await request('/sms/checkCode', 'POST', body).then(saveToken),
2460
+ };
2461
+
2462
+ const getUpdateUserProfileData = (profileId, formData) => {
2463
+ const { name = '', surname = '', middleName = '', birthday = '', phone = '', email = '', processPersonalDataLeadFlg, consentProviderFlg, consentPfrFlg, consentPhotoFlg, consentAssignmentClaimsFlg, consentCollectionFlg, consentInformFlg, } = formData;
2464
+ return {
2465
+ profile: {
2466
+ id: profileId,
2467
+ name,
2468
+ surname,
2469
+ midname: middleName,
2470
+ birthDate: birthday && formatDate(birthday, true),
2471
+ email,
2472
+ phone: formatPhone(phone),
2473
+ processPersonalDataLeadFlg: Boolean(processPersonalDataLeadFlg),
2474
+ consentProviderFlg: Boolean(consentProviderFlg),
2475
+ consentPfrFlg: Boolean(consentPfrFlg),
2476
+ consentPhotoFlg: Boolean(consentPhotoFlg),
2477
+ consentAssignmentClaimsFlg: Boolean(consentAssignmentClaimsFlg),
2478
+ consentCollectionFlg: Boolean(consentCollectionFlg),
2479
+ consentInformFlg: Boolean(consentInformFlg),
2480
+ },
2481
+ };
2482
+ };
2483
+
2484
+ /* eslint-disable max-params */
2485
+ const getUpdateUserTaskData = (participantId, taskId, profileId, formatData) => ({
2486
+ sendToBank: true,
2487
+ taskKind: 'SHORT',
2488
+ task: {
2489
+ taskSource: globalThis.location.origin,
2490
+ id: taskId,
2491
+ participants: [
2492
+ {
2493
+ birthDate: formatData?.birthDate,
2494
+ id: participantId,
2495
+ midname: formatData?.midname,
2496
+ name: formatData?.name,
2497
+ surname: formatData?.surname,
2498
+ profile: {
2499
+ id: profileId,
2500
+ },
2501
+ participantContacts: [
2502
+ {
2503
+ contactTypeCd: {
2504
+ key: 'EMAIL',
2505
+ },
2506
+ value: formatData?.email,
2507
+ },
2508
+ {
2509
+ contactTypeCd: {
2510
+ key: 'MAIN_PHONE',
2511
+ },
2512
+ value: formatData?.phone,
2513
+ },
2514
+ ],
2515
+ roleCd: {
2516
+ key: 'BORROWER',
2517
+ value: 'Заемщик',
2518
+ },
2519
+ },
2520
+ ],
2521
+ },
2522
+ });
2523
+
2524
+ 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, {
2525
+ 'backdrop-blur': blur,
2526
+ }), 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" }) })));
2527
+
2528
+ const Timer = JSX(({ time, setTime, className }) => {
2529
+ useEffect(() => {
2530
+ const timer = setInterval(() => {
2531
+ setTime(time - 1);
2532
+ }, 1000);
2533
+ if (time === 0) {
2534
+ clearInterval(timer);
2535
+ }
2536
+ return () => {
2537
+ clearInterval(timer);
2538
+ };
2539
+ }, [time]);
2540
+ return jsx("span", { className: className, children: secondsToMinSecPadded(time) });
2541
+ });
2542
+ const secondsToMinSecPadded = (time) => {
2543
+ const minutes = `${Math.floor(time / 60)}`.padStart(2, '0');
2544
+ const seconds = `${time % 60}`.padStart(2, '0');
2545
+ return `${minutes}:${seconds}`;
2546
+ };
2547
+
2548
+ const InputCode = JSX(({ values, setValues, hasError }) => {
2549
+ const [activeIndex, setActiveIndex] = useState(0);
2550
+ const inputRefs = useRef([]);
2551
+ useEffect(() => {
2552
+ inputRefs.current?.[activeIndex]?.focus();
2553
+ }, [activeIndex]);
2554
+ const handleChange = useCallback((index) => (event) => {
2555
+ const { value } = event.currentTarget;
2556
+ const isLastIndex = index === values.length - 1;
2557
+ const isMultipleCharacters = value.length > 1;
2558
+ if (isLastIndex && isMultipleCharacters) {
2559
+ return;
2560
+ }
2561
+ setValues(values.map((_, i) => (i === index ? value : _)));
2562
+ setActiveIndex(index + 1);
2563
+ }, [values]);
2564
+ const handleKeyDown = useCallback((currentIndex) => (event) => {
2565
+ const { key } = event;
2566
+ if (key === 'Backspace' && !values[currentIndex]) {
2567
+ const previousIndex = currentIndex > 0 ? currentIndex - 1 : values.length - 1;
2568
+ const updatedValues = values.map((value, index) => (index === previousIndex ? '' : value));
2569
+ setValues(updatedValues);
2570
+ setActiveIndex(previousIndex);
2571
+ }
2572
+ }, [values]);
2573
+ const handlePaste = useCallback((event) => {
2574
+ event.preventDefault();
2575
+ const pastedData = event.clipboardData.getData('text');
2576
+ const updatedValues = values.map((_, idx) => (idx < pastedData.length ? pastedData[idx] : _));
2577
+ setValues(updatedValues);
2578
+ setActiveIndex(updatedValues.length - 1);
2579
+ }, [values]);
2580
+ 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) => {
2581
+ if (!inputRefs.current) {
2582
+ inputRefs.current = [];
2583
+ }
2584
+ inputRefs.current[index] = ref;
2585
+ }, 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] }));
2586
+ });
2587
+ const getInputStyle = (index, values, hasError = false) => {
2588
+ const isInputEmpty = !values[index];
2589
+ 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`;
2590
+ };
2591
+
2592
+ const SubmitButton = JSX(({ isDisabled, onClick, text }) => {
2593
+ return (jsx(Button, { type: "button", onClick: onClick, disabled: isDisabled, children: jsx(Text, { font: "font-medium", children: text }) }));
2594
+ });
2595
+
2596
+ const VerifyPhoneDialog = JSX(({ title, phone, description, __html, code = true, codeLength = 4, textButton = '', onClose, href = '', }) => {
2597
+ const { close } = useDialogManager();
2598
+ const [values, setValues] = useState(Array(codeLength).fill(''));
2599
+ const [hasError, setHasError] = useState(false);
2600
+ const [isLoading, setIsLoading] = useState(false);
2601
+ const [timeNextReq, setTimeNextReq] = useState(180);
2602
+ const isValidCode = useMemo(() => values.every(Boolean), [values]);
2603
+ useEffect(() => {
2604
+ RETAIL_API.SendCode({
2605
+ phoneNumber: phone,
2606
+ smsCodesSetName: { key: 'AUTHENTICATION' },
2607
+ });
2608
+ }, []);
2609
+ const handleSubmit = useCallback(async () => {
2610
+ try {
2611
+ setIsLoading(true);
2612
+ await RETAIL_API.CheckCode({
2613
+ smsText: values.join(''),
2614
+ smsCodesSetName: { key: 'AUTHENTICATION' },
2615
+ });
2616
+ globalThis.location.href = href;
2617
+ close();
2618
+ onClose && onClose();
2619
+ }
2620
+ catch {
2621
+ setIsLoading(false);
2622
+ setHasError(true);
2623
+ }
2624
+ }, [values]);
2625
+ 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] }) }));
2626
+ });
2627
+
2628
+ const useVerifyPhoneDialog = (props) => {
2629
+ const { open, close } = useDialogManager();
2630
+ return {
2631
+ open: (options = {}) => open(jsx(VerifyPhoneDialog, { ...props }), options),
2632
+ close,
2633
+ };
2634
+ };
2635
+
2636
+ const useApplicationLeadApi = (inputs, programId) => {
2637
+ const [responseStatus, setResponseStatus] = useState('');
2638
+ // eslint-disable-next-line consistent-return
2452
2639
  const handleSubmit = useCallback(async (formData) => {
2453
2640
  const feedbackValidator = objectValidator(getObjectValidator(inputs));
2454
2641
  if (!isValidationSuccess(feedbackValidator(formData))) {
2455
2642
  return 'Fail';
2456
2643
  }
2457
- const formatData = getFormatData(formData);
2458
- const status = (await API.send(formatData, endpoint === 'lead')) ? 'OK' : 'Fail';
2459
- setResponseType(status);
2460
- if (status) {
2461
- const responseTypeDialog = useResponseTypeDialog({ responseType: status, typeForm });
2462
- responseTypeDialog.open();
2644
+ try {
2645
+ const { profile } = await RETAIL_API.CreateUserProfile({
2646
+ profile: { phone: formatPhone(formData.phone) },
2647
+ });
2648
+ const profileId = profile?.id;
2649
+ if (profileId && formData?.phone) {
2650
+ const handleSuccessVerify = async () => {
2651
+ try {
2652
+ await RETAIL_API.UpdateUserProfile(getUpdateUserProfileData(profileId, formData));
2653
+ const { taskId, participantId } = await RETAIL_API.CreateDraftTask({
2654
+ profileId,
2655
+ programId,
2656
+ });
2657
+ await RETAIL_API.UpdateUserTask(getUpdateUserTaskData(participantId, taskId, profileId, formData));
2658
+ setResponseStatus('OK');
2659
+ }
2660
+ catch {
2661
+ setResponseStatus('Fail');
2662
+ }
2663
+ };
2664
+ // eslint-disable-next-line react-hooks/rules-of-hooks
2665
+ const verifyPhoneDialog = useVerifyPhoneDialog({
2666
+ onClose: handleSuccessVerify,
2667
+ ...verifyPhoneContent(formData?.phone),
2668
+ });
2669
+ verifyPhoneDialog.open();
2670
+ }
2671
+ }
2672
+ catch {
2673
+ setResponseStatus('Fail');
2463
2674
  }
2464
- return status;
2465
2675
  }, []);
2676
+ return {
2677
+ handleSubmit,
2678
+ responseStatus,
2679
+ };
2680
+ };
2681
+ const verifyPhoneContent = (phone) => ({
2682
+ title: 'Подтвердите номер телефона',
2683
+ description: `Мы отправили код на ${phone}`,
2684
+ phone: formatPhone(phone),
2685
+ textButton: 'Оформить',
2686
+ __html: `<span>Вводя код, я подтверждаю, что ознакомлен и подписываю:</span>
2687
+ <ul><li>соглашение о порядке использования простой электронной подписи,
2688
+ </li><li>согласие на обработку персональных данных,
2689
+ </li><li>предоставление и подписание прочих согласий Банка,
2690
+ </li><li>согласие на запрос в ПФР</li></ul>`,
2691
+ href: '/credit-lead',
2692
+ });
2693
+
2694
+ const useInitApplicationLead = () => {
2695
+ useEffect(() => {
2696
+ sessionStorage.removeItem('accessToken');
2697
+ sessionStorage.removeItem('refreshToken');
2698
+ }, []);
2699
+ };
2700
+
2701
+ const ApplicationLeadForm = JSX(({ className, title, programId, typeForm = '', sections = [], button, ...rest }) => {
2702
+ const inputs = (sections?.flatMap((_) => _?.inputs) || []);
2703
+ const initialFormState = getInitialFormState(inputs, typeForm);
2704
+ const [responseType, setResponseType] = useState('');
2705
+ useInitApplicationLead();
2706
+ const { handleSubmit, responseStatus } = useApplicationLeadApi(inputs, programId || '');
2707
+ if (responseStatus) {
2708
+ const responseTypeDialog = useResponseTypeDialog({ responseType: responseStatus, typeForm });
2709
+ responseTypeDialog.open();
2710
+ }
2466
2711
  const [, { field, onSubmit, reset }] = useForm(initialFormState, { onSubmit: handleSubmit });
2467
2712
  useEffect(() => {
2468
2713
  if (responseType === 'OK') {
@@ -5568,10 +5813,6 @@
5568
5813
  const isClient = !isSSR();
5569
5814
  const ClientOnly = JSX(({ children }) => (isClient ? children : null));
5570
5815
 
5571
- 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, {
5572
- 'backdrop-blur': blur,
5573
- }), 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" }) })));
5574
-
5575
5816
  const MapMarkerClusterIcon = '/icons/MapMarkerClusterIcon.svg';
5576
5817
  const MapMarkerClusterYellowIcon = '/icons/MapMarkerClusterYellowIcon.svg';
5577
5818
  function renderClusterer({ yandexMaps, map, points, isLoad, }) {
@@ -6944,7 +7185,7 @@
6944
7185
  slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
6945
7186
  });
6946
7187
 
6947
- const packageVersion = "0.14.580";
7188
+ const packageVersion = "0.14.582";
6948
7189
 
6949
7190
  exports.Blocks = Blocks;
6950
7191
  exports.ContentPage = ContentPage;