@redneckz/wildless-cms-uni-blocks 0.14.597 → 0.14.599

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 (67) hide show
  1. package/bundle/bundle.umd.js +37 -10
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/bundle/components/ApplicationLeadForm/getInitialFormState.d.ts +1 -1
  4. package/bundle/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +7 -1
  5. package/dist/components/ApplicationLeadForm/ApplicationLeadForm.js +9 -3
  6. package/dist/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  7. package/dist/components/ApplicationLeadForm/getInitialFormState.d.ts +1 -1
  8. package/dist/components/ApplicationLeadForm/getInitialFormState.js +6 -1
  9. package/dist/components/ApplicationLeadForm/getInitialFormState.js.map +1 -1
  10. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +7 -1
  11. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +12 -1
  12. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  13. package/dist/components/DepositFiltration/DepositFiltration.js +1 -1
  14. package/dist/components/DepositFiltration/DepositFiltration.js.map +1 -1
  15. package/dist/ui-kit/FormField/Fields/SexField.js +1 -3
  16. package/dist/ui-kit/FormField/Fields/SexField.js.map +1 -1
  17. package/lib/components/ApplicationLeadForm/ApplicationLeadForm.js +9 -3
  18. package/lib/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  19. package/lib/components/ApplicationLeadForm/getInitialFormState.d.ts +1 -1
  20. package/lib/components/ApplicationLeadForm/getInitialFormState.js +6 -1
  21. package/lib/components/ApplicationLeadForm/getInitialFormState.js.map +1 -1
  22. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +7 -1
  23. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +12 -1
  24. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  25. package/lib/components/DepositFiltration/DepositFiltration.js +1 -1
  26. package/lib/components/DepositFiltration/DepositFiltration.js.map +1 -1
  27. package/lib/ui-kit/FormField/Fields/SexField.js +1 -3
  28. package/lib/ui-kit/FormField/Fields/SexField.js.map +1 -1
  29. package/mobile/bundle/bundle.umd.js +37 -10
  30. package/mobile/bundle/bundle.umd.min.js +1 -1
  31. package/mobile/bundle/components/ApplicationLeadForm/getInitialFormState.d.ts +1 -1
  32. package/mobile/bundle/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +7 -1
  33. package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadForm.js +9 -3
  34. package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  35. package/mobile/dist/components/ApplicationLeadForm/getInitialFormState.d.ts +1 -1
  36. package/mobile/dist/components/ApplicationLeadForm/getInitialFormState.js +6 -1
  37. package/mobile/dist/components/ApplicationLeadForm/getInitialFormState.js.map +1 -1
  38. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +7 -1
  39. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +12 -1
  40. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  41. package/mobile/dist/components/DepositFiltration/DepositFiltration.js +1 -1
  42. package/mobile/dist/components/DepositFiltration/DepositFiltration.js.map +1 -1
  43. package/mobile/dist/ui-kit/FormField/Fields/SexField.js +1 -3
  44. package/mobile/dist/ui-kit/FormField/Fields/SexField.js.map +1 -1
  45. package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadForm.js +9 -3
  46. package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  47. package/mobile/lib/components/ApplicationLeadForm/getInitialFormState.d.ts +1 -1
  48. package/mobile/lib/components/ApplicationLeadForm/getInitialFormState.js +6 -1
  49. package/mobile/lib/components/ApplicationLeadForm/getInitialFormState.js.map +1 -1
  50. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +7 -1
  51. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +12 -1
  52. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  53. package/mobile/lib/components/DepositFiltration/DepositFiltration.js +1 -1
  54. package/mobile/lib/components/DepositFiltration/DepositFiltration.js.map +1 -1
  55. package/mobile/lib/ui-kit/FormField/Fields/SexField.js +1 -3
  56. package/mobile/lib/ui-kit/FormField/Fields/SexField.js.map +1 -1
  57. package/mobile/src/components/ApplicationLeadForm/ApplicationLeadForm.tsx +9 -3
  58. package/mobile/src/components/ApplicationLeadForm/getInitialFormState.tsx +12 -1
  59. package/mobile/src/components/ApplicationLeadForm/useApplicationLeadApi.ts +19 -1
  60. package/mobile/src/components/DepositFiltration/DepositFiltration.tsx +1 -1
  61. package/mobile/src/ui-kit/FormField/Fields/SexField.tsx +8 -12
  62. package/package.json +1 -1
  63. package/src/components/ApplicationLeadForm/ApplicationLeadForm.tsx +9 -3
  64. package/src/components/ApplicationLeadForm/getInitialFormState.tsx +12 -1
  65. package/src/components/ApplicationLeadForm/useApplicationLeadApi.ts +19 -1
  66. package/src/components/DepositFiltration/DepositFiltration.tsx +1 -1
  67. package/src/ui-kit/FormField/Fields/SexField.tsx +8 -12
@@ -2215,9 +2215,7 @@
2215
2215
  { id: 'male', text: 'Мужской' },
2216
2216
  { id: 'female', text: 'Женский' },
2217
2217
  ];
2218
- const SexField = JSX(({ field, input }) => {
2219
- return (jsx("div", { children: jsx(RadioButtonGroupControl, { label: "\u041F\u043E\u043B", orientation: "horizontal", items: SEX_TYPES, ...getValidation(field('sex'), validatorObj.sex, input?.required) }) }));
2220
- });
2218
+ const SexField = JSX(({ field, input }) => (jsx(RadioButtonGroupControl, { label: "\u041F\u043E\u043B", orientation: "horizontal", items: SEX_TYPES, ...getValidation(field('sex'), validatorObj.sex, input?.required) })));
2221
2219
 
2222
2220
  const isPlaceholder = (_) => _ === '_';
2223
2221
  const isDigit = (_) => /\d/.test(_);
@@ -2570,6 +2568,15 @@
2570
2568
  : _ === (dataValue?.key ?? dataValue);
2571
2569
  }));
2572
2570
 
2571
+ function useLocalStorage(key) {
2572
+ const [storedValue, setStoredValue] = useState(JSON.parse(globalThis.localStorage?.getItem(key) || 'null'));
2573
+ const setValue = useCallback((value) => {
2574
+ globalThis.localStorage?.setItem(key, JSON.stringify(value));
2575
+ setStoredValue(value);
2576
+ }, [key, globalThis.localStorage]);
2577
+ return [storedValue, setValue];
2578
+ }
2579
+
2573
2580
  const CONSENTS = [
2574
2581
  'processPersonalDataLeadFlg',
2575
2582
  'consentProviderFlg',
@@ -2615,7 +2622,12 @@
2615
2622
  participantAddress: '',
2616
2623
  participantDateRegistration: undefined,
2617
2624
  };
2618
- const getInitialFormState = (inputs, typeForm = '') => {
2625
+ const getInitialFormState = (inputs, savedForm, typeForm = '') => {
2626
+ if (savedForm) {
2627
+ const formState = JSON.parse(savedForm);
2628
+ formState.birthday = new Date(formState?.birthday || 0);
2629
+ return formState;
2630
+ }
2619
2631
  const formState = Object.fromEntries(inputs.map((_) => [
2620
2632
  _.name,
2621
2633
  (_.fieldType === 'ved' && _?.defaultValue) || initialFormState[_.name],
@@ -3030,8 +3042,16 @@
3030
3042
  };
3031
3043
  };
3032
3044
 
3033
- const useApplicationLeadApi = (inputs, programId) => {
3045
+ const useApplicationLeadApi = ({ inputs, programId, saveForm }) => {
3034
3046
  const [responseStatus, setResponseStatus] = useState('');
3047
+ const [, setTaskId] = useLocalStorage('taskId');
3048
+ const [, setProfileId] = useLocalStorage('profileId');
3049
+ const [, setParticipantId] = useLocalStorage('participantId');
3050
+ const saveUserData = useCallback((participantId, taskId, profileId) => {
3051
+ setParticipantId(participantId);
3052
+ setTaskId(taskId);
3053
+ setProfileId(profileId);
3054
+ }, []);
3035
3055
  // eslint-disable-next-line consistent-return
3036
3056
  const handleSubmit = useCallback(async (formData) => {
3037
3057
  const feedbackValidator = objectValidator(getObjectValidator(inputs));
@@ -3052,6 +3072,8 @@
3052
3072
  programId,
3053
3073
  });
3054
3074
  await RETAIL_API.UpdateUserTask(getUpdateUserTaskData(participantId, taskId, profileId, formData));
3075
+ saveUserData(participantId, taskId, profileId);
3076
+ saveForm(JSON.stringify(formData));
3055
3077
  globalThis.location.href = '/credit-lead';
3056
3078
  }
3057
3079
  catch {
@@ -3094,12 +3116,17 @@
3094
3116
  }, []);
3095
3117
  };
3096
3118
 
3097
- const ApplicationLeadForm = JSX(({ className, title, programId, typeForm = '', sections = [], button, ...rest }) => {
3119
+ const ApplicationLeadForm = JSX(({ className, title, programId = '', typeForm = '', sections = [], button, ...rest }) => {
3098
3120
  const inputs = (sections?.flatMap((_) => _?.inputs) || []);
3099
- const initialFormState = getInitialFormState(inputs, typeForm);
3100
3121
  const [responseType, setResponseType] = useState('');
3101
3122
  useInitApplicationLead();
3102
- const { handleSubmit, responseStatus } = useApplicationLeadApi(inputs, programId || '');
3123
+ const [leadForm, setLeadForm] = useLocalStorage('leadForm');
3124
+ const initialFormState = getInitialFormState(inputs, leadForm, typeForm);
3125
+ const { handleSubmit, responseStatus } = useApplicationLeadApi({
3126
+ inputs,
3127
+ programId,
3128
+ saveForm: setLeadForm,
3129
+ });
3103
3130
  if (responseStatus) {
3104
3131
  const responseTypeDialog = useResponseTypeDialog({ responseType: responseStatus, typeForm });
3105
3132
  responseTypeDialog.open();
@@ -4783,7 +4810,7 @@
4783
4810
  page: rest.options?.page,
4784
4811
  normalize: (content) => ({ ...content, period: getPeriod(content) }),
4785
4812
  });
4786
- const rateRows = blocksWithProps.map(([, _]) => _?.paramsSource?.rateRows);
4813
+ const rateRows = blocksWithProps.map(([, _]) => _?.paramsSource?.rows?.[0]?.rates);
4787
4814
  const months = getMonths(rateRows);
4788
4815
  return (jsxs(BlockWrapper, { className: style('space-y-2xs', className), defaultPadding: "p-0", version: "transparent", ...rest, children: [jsx(FiltrationForm, { filtrationSchema: filtrationSchema, resetButton: resetButton, field: field, reset: reset, children: jsxs("div", { className: "@4xl:max-w-xs space-y-lg", children: [jsx(CurrencyInput, { label: sumInput?.title, min: DEFAULT_MIN_SUM, max: DEFAULT_MAX_SUM, ...field('sum', {
4789
4816
  parse: (min) => ({ min: Number(min), max: DEFAULT_MAX_SUM }),
@@ -7558,7 +7585,7 @@
7558
7585
  slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
7559
7586
  });
7560
7587
 
7561
- const packageVersion = "0.14.596";
7588
+ const packageVersion = "0.14.598";
7562
7589
 
7563
7590
  exports.Blocks = Blocks;
7564
7591
  exports.ContentPage = ContentPage;