@redneckz/wildless-cms-uni-blocks 0.14.654 → 0.14.656

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 (119) hide show
  1. package/bundle/bundle.umd.js +99 -66
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/bundle/components/CreditCardForm/formStateMap.d.ts +10 -10
  4. package/bundle/components/CreditCardForm/getFilteredInputs.d.ts +3 -0
  5. package/bundle/components/CreditCardForm/renderInfo.d.ts +2 -1
  6. package/bundle/components/CreditCardForm/renderStep.d.ts +3 -4
  7. package/dist/api/RetailAPI/updateRefreshToken.js +12 -5
  8. package/dist/api/RetailAPI/updateRefreshToken.js.map +1 -1
  9. package/dist/components/CreditCardForm/CreditCardFormStep.js +2 -4
  10. package/dist/components/CreditCardForm/CreditCardFormStep.js.map +1 -1
  11. package/dist/components/CreditCardForm/creditCardFormStepsData.js +61 -34
  12. package/dist/components/CreditCardForm/creditCardFormStepsData.js.map +1 -1
  13. package/dist/components/CreditCardForm/formStateMap.d.ts +10 -10
  14. package/dist/components/CreditCardForm/formStateMap.js +3 -7
  15. package/dist/components/CreditCardForm/formStateMap.js.map +1 -1
  16. package/dist/components/CreditCardForm/getFilteredInputs.d.ts +3 -0
  17. package/dist/components/CreditCardForm/getFilteredInputs.js +11 -0
  18. package/dist/components/CreditCardForm/getFilteredInputs.js.map +1 -0
  19. package/dist/components/CreditCardForm/getInitialFormState.js +3 -0
  20. package/dist/components/CreditCardForm/getInitialFormState.js.map +1 -1
  21. package/dist/components/CreditCardForm/renderInfo.d.ts +2 -1
  22. package/dist/components/CreditCardForm/renderInfo.js +5 -3
  23. package/dist/components/CreditCardForm/renderInfo.js.map +1 -1
  24. package/dist/components/CreditCardForm/renderStep.d.ts +3 -4
  25. package/dist/components/CreditCardForm/renderStep.js +1 -9
  26. package/dist/components/CreditCardForm/renderStep.js.map +1 -1
  27. package/dist/components/CreditCardForm/useCreditCardFormAPI.js +3 -1
  28. package/dist/components/CreditCardForm/useCreditCardFormAPI.js.map +1 -1
  29. package/lib/api/RetailAPI/updateRefreshToken.js +12 -5
  30. package/lib/api/RetailAPI/updateRefreshToken.js.map +1 -1
  31. package/lib/components/CreditCardForm/CreditCardFormStep.js +2 -4
  32. package/lib/components/CreditCardForm/CreditCardFormStep.js.map +1 -1
  33. package/lib/components/CreditCardForm/creditCardFormStepsData.js +61 -34
  34. package/lib/components/CreditCardForm/creditCardFormStepsData.js.map +1 -1
  35. package/lib/components/CreditCardForm/formStateMap.d.ts +10 -10
  36. package/lib/components/CreditCardForm/formStateMap.js +3 -7
  37. package/lib/components/CreditCardForm/formStateMap.js.map +1 -1
  38. package/lib/components/CreditCardForm/getFilteredInputs.d.ts +3 -0
  39. package/lib/components/CreditCardForm/getFilteredInputs.js +8 -0
  40. package/lib/components/CreditCardForm/getFilteredInputs.js.map +1 -0
  41. package/lib/components/CreditCardForm/getInitialFormState.js +3 -0
  42. package/lib/components/CreditCardForm/getInitialFormState.js.map +1 -1
  43. package/lib/components/CreditCardForm/renderInfo.d.ts +2 -1
  44. package/lib/components/CreditCardForm/renderInfo.js +5 -3
  45. package/lib/components/CreditCardForm/renderInfo.js.map +1 -1
  46. package/lib/components/CreditCardForm/renderStep.d.ts +3 -4
  47. package/lib/components/CreditCardForm/renderStep.js +1 -9
  48. package/lib/components/CreditCardForm/renderStep.js.map +1 -1
  49. package/lib/components/CreditCardForm/useCreditCardFormAPI.js +3 -1
  50. package/lib/components/CreditCardForm/useCreditCardFormAPI.js.map +1 -1
  51. package/mobile/bundle/bundle.umd.js +99 -66
  52. package/mobile/bundle/bundle.umd.min.js +1 -1
  53. package/mobile/bundle/components/CreditCardForm/formStateMap.d.ts +10 -10
  54. package/mobile/bundle/components/CreditCardForm/getFilteredInputs.d.ts +3 -0
  55. package/mobile/bundle/components/CreditCardForm/renderInfo.d.ts +2 -1
  56. package/mobile/bundle/components/CreditCardForm/renderStep.d.ts +3 -4
  57. package/mobile/dist/api/RetailAPI/updateRefreshToken.js +12 -5
  58. package/mobile/dist/api/RetailAPI/updateRefreshToken.js.map +1 -1
  59. package/mobile/dist/components/CreditCardForm/CreditCardFormStep.js +2 -4
  60. package/mobile/dist/components/CreditCardForm/CreditCardFormStep.js.map +1 -1
  61. package/mobile/dist/components/CreditCardForm/creditCardFormStepsData.js +61 -34
  62. package/mobile/dist/components/CreditCardForm/creditCardFormStepsData.js.map +1 -1
  63. package/mobile/dist/components/CreditCardForm/formStateMap.d.ts +10 -10
  64. package/mobile/dist/components/CreditCardForm/formStateMap.js +3 -7
  65. package/mobile/dist/components/CreditCardForm/formStateMap.js.map +1 -1
  66. package/mobile/dist/components/CreditCardForm/getFilteredInputs.d.ts +3 -0
  67. package/mobile/dist/components/CreditCardForm/getFilteredInputs.js +11 -0
  68. package/mobile/dist/components/CreditCardForm/getFilteredInputs.js.map +1 -0
  69. package/mobile/dist/components/CreditCardForm/getInitialFormState.js +3 -0
  70. package/mobile/dist/components/CreditCardForm/getInitialFormState.js.map +1 -1
  71. package/mobile/dist/components/CreditCardForm/renderInfo.d.ts +2 -1
  72. package/mobile/dist/components/CreditCardForm/renderInfo.js +5 -3
  73. package/mobile/dist/components/CreditCardForm/renderInfo.js.map +1 -1
  74. package/mobile/dist/components/CreditCardForm/renderStep.d.ts +3 -4
  75. package/mobile/dist/components/CreditCardForm/renderStep.js +1 -9
  76. package/mobile/dist/components/CreditCardForm/renderStep.js.map +1 -1
  77. package/mobile/dist/components/CreditCardForm/useCreditCardFormAPI.js +3 -1
  78. package/mobile/dist/components/CreditCardForm/useCreditCardFormAPI.js.map +1 -1
  79. package/mobile/lib/api/RetailAPI/updateRefreshToken.js +12 -5
  80. package/mobile/lib/api/RetailAPI/updateRefreshToken.js.map +1 -1
  81. package/mobile/lib/components/CreditCardForm/CreditCardFormStep.js +2 -4
  82. package/mobile/lib/components/CreditCardForm/CreditCardFormStep.js.map +1 -1
  83. package/mobile/lib/components/CreditCardForm/creditCardFormStepsData.js +61 -34
  84. package/mobile/lib/components/CreditCardForm/creditCardFormStepsData.js.map +1 -1
  85. package/mobile/lib/components/CreditCardForm/formStateMap.d.ts +10 -10
  86. package/mobile/lib/components/CreditCardForm/formStateMap.js +3 -7
  87. package/mobile/lib/components/CreditCardForm/formStateMap.js.map +1 -1
  88. package/mobile/lib/components/CreditCardForm/getFilteredInputs.d.ts +3 -0
  89. package/mobile/lib/components/CreditCardForm/getFilteredInputs.js +8 -0
  90. package/mobile/lib/components/CreditCardForm/getFilteredInputs.js.map +1 -0
  91. package/mobile/lib/components/CreditCardForm/getInitialFormState.js +3 -0
  92. package/mobile/lib/components/CreditCardForm/getInitialFormState.js.map +1 -1
  93. package/mobile/lib/components/CreditCardForm/renderInfo.d.ts +2 -1
  94. package/mobile/lib/components/CreditCardForm/renderInfo.js +5 -3
  95. package/mobile/lib/components/CreditCardForm/renderInfo.js.map +1 -1
  96. package/mobile/lib/components/CreditCardForm/renderStep.d.ts +3 -4
  97. package/mobile/lib/components/CreditCardForm/renderStep.js +1 -9
  98. package/mobile/lib/components/CreditCardForm/renderStep.js.map +1 -1
  99. package/mobile/lib/components/CreditCardForm/useCreditCardFormAPI.js +3 -1
  100. package/mobile/lib/components/CreditCardForm/useCreditCardFormAPI.js.map +1 -1
  101. package/mobile/src/api/RetailAPI/updateRefreshToken.ts +15 -5
  102. package/mobile/src/components/CreditCardForm/CreditCardFormStep.tsx +3 -6
  103. package/mobile/src/components/CreditCardForm/creditCardFormStepsData.tsx +61 -34
  104. package/mobile/src/components/CreditCardForm/formStateMap.tsx +14 -17
  105. package/mobile/src/components/CreditCardForm/getFilteredInputs.tsx +18 -0
  106. package/mobile/src/components/CreditCardForm/getInitialFormState.tsx +3 -0
  107. package/mobile/src/components/CreditCardForm/renderInfo.tsx +9 -3
  108. package/mobile/src/components/CreditCardForm/renderStep.tsx +5 -22
  109. package/mobile/src/components/CreditCardForm/useCreditCardFormAPI.tsx +3 -1
  110. package/package.json +1 -1
  111. package/src/api/RetailAPI/updateRefreshToken.ts +15 -5
  112. package/src/components/CreditCardForm/CreditCardFormStep.tsx +3 -6
  113. package/src/components/CreditCardForm/creditCardFormStepsData.tsx +61 -34
  114. package/src/components/CreditCardForm/formStateMap.tsx +14 -17
  115. package/src/components/CreditCardForm/getFilteredInputs.tsx +18 -0
  116. package/src/components/CreditCardForm/getInitialFormState.tsx +3 -0
  117. package/src/components/CreditCardForm/renderInfo.tsx +9 -3
  118. package/src/components/CreditCardForm/renderStep.tsx +5 -22
  119. package/src/components/CreditCardForm/useCreditCardFormAPI.tsx +3 -1
@@ -3,6 +3,15 @@ import { PAYMENT_SYSTEM_TYPES } from '../../ui-kit/FormField/Fields/PaymentSyste
3
3
  import type { Option } from '../../ui-kit/Select/Option';
4
4
  import { type Address } from '../ApplicationLeadForm/getInitialFormState';
5
5
 
6
+ export type FormStateDeliveryType = {
7
+ regionRetail?: string;
8
+ bankEmployeeCode?: string;
9
+ methodObtain?: 'office' | 'courier';
10
+ deliveryDate?: Date;
11
+ addressRetail?: Address;
12
+ addressCourier?: Address;
13
+ };
14
+
6
15
  export interface FormStateMap {
7
16
  0: {
8
17
  currency?: string;
@@ -28,8 +37,6 @@ export interface FormStateMap {
28
37
  participantDateRegistration?: Date;
29
38
  addressFact?: Address;
30
39
  housing?: string;
31
- methodObtain?: string;
32
- addressCourier?: Address;
33
40
  };
34
41
  2: {
35
42
  amountWorkers?: Option;
@@ -53,6 +60,7 @@ export interface FormStateMap {
53
60
  familyStatus?: Option;
54
61
  dependents?: number;
55
62
  familyMembers?: number;
63
+ confirmationIncome?: Option;
56
64
  mandatoryIncome?: number;
57
65
  otherPayments?: number;
58
66
  snils?: string;
@@ -65,14 +73,7 @@ export interface FormStateMap {
65
73
  legalEntityName?: string;
66
74
  creditInRshbCd?: Option;
67
75
  };
68
- 5: {
69
- regionRetail?: string;
70
- addressRetail?: Address;
71
- bankEmployeeCode?: string;
72
- addressCoutier?: Address;
73
- methodObtain?: 'office' | 'courier';
74
- deliveryDate?: Date;
75
- };
76
+ 5: FormStateDeliveryType;
76
77
  }
77
78
 
78
79
  export const formStateMap: FormStateMap = {
@@ -105,11 +106,6 @@ export const formStateMap: FormStateMap = {
105
106
  fiasCode: '',
106
107
  },
107
108
  housing: '',
108
- methodObtain: 'office',
109
- addressCourier: {
110
- fullAddress: '',
111
- fiasCode: '',
112
- },
113
109
  },
114
110
  2: {
115
111
  amountWorkers: { key: '', text: '' },
@@ -136,6 +132,7 @@ export const formStateMap: FormStateMap = {
136
132
  familyStatus: { key: '', text: '' },
137
133
  dependents: undefined,
138
134
  familyMembers: undefined,
135
+ confirmationIncome: { key: '', text: '' },
139
136
  mandatoryIncome: undefined,
140
137
  otherPayments: undefined,
141
138
  snils: '',
@@ -154,11 +151,11 @@ export const formStateMap: FormStateMap = {
154
151
  fullAddress: '',
155
152
  fiasCode: '',
156
153
  },
157
- bankEmployeeCode: '',
158
- addressCoutier: {
154
+ addressCourier: {
159
155
  fullAddress: '',
160
156
  fiasCode: '',
161
157
  },
158
+ bankEmployeeCode: '',
162
159
  methodObtain: 'office',
163
160
  deliveryDate: undefined,
164
161
  },
@@ -0,0 +1,18 @@
1
+ import type { FieldDef } from '../ApplicationForm/ApplicationFormContent';
2
+ import type { FormStateMap } from './formStateMap';
3
+
4
+ export const getFilteredInputs = (
5
+ inputs: FieldDef[],
6
+ data: FormStateMap[keyof FormStateMap],
7
+ ): FieldDef[] =>
8
+ inputs
9
+ .filter((_) => _)
10
+ .filter(
11
+ (input) =>
12
+ !input?.condition ||
13
+ input?.condition.values.find((_) => {
14
+ const dataValue = data?.[input?.condition?.name ?? ''];
15
+
16
+ return _ === (dataValue?.key ?? dataValue);
17
+ }),
18
+ );
@@ -19,6 +19,9 @@ export const getInitialFormState = <Step extends keyof FormStateMap>(
19
19
  localStorageData.beginDate = localStorageData?.beginDate
20
20
  ? new Date(localStorageData.beginDate as string)
21
21
  : undefined;
22
+ localStorageData.deliveryDate = localStorageData?.deliveryDate
23
+ ? new Date(localStorageData.deliveryDate as string)
24
+ : undefined;
22
25
  }
23
26
 
24
27
  return {
@@ -1,10 +1,16 @@
1
1
  import { InfoCard } from '../../ui-kit/InfoCard/InfoCard';
2
2
  import { type FieldDef } from '../ApplicationLeadForm/ApplicationLeadFormContent';
3
+ import { type FormStateDeliveryType } from './formStateMap';
4
+ import { getFilteredInputs } from './getFilteredInputs';
3
5
 
4
- export const renderInfo = (inputs: FieldDef[] = []) => {
6
+ export const renderInfo = (state?: FormStateDeliveryType, inputs: FieldDef[] = []) => {
5
7
  const infoInputs = inputs.filter((_) => _.fieldType === 'info');
8
+ const filteredInputs = getFilteredInputs(
9
+ infoInputs,
10
+ state as FormStateDeliveryType,
11
+ ) as FieldDef[];
6
12
 
7
- return infoInputs.length
8
- ? infoInputs.map(({ text, name }, i) => <InfoCard key={`${name}_${i}`} __html={text} />)
13
+ return filteredInputs.length
14
+ ? filteredInputs.map(({ text, name }, i) => <InfoCard key={`${name}_${i}`} __html={text} />)
9
15
  : null;
10
16
  };
@@ -3,7 +3,7 @@ import { inputColumnStyles } from '../../ui-kit/FormField/inputColumnStyle';
3
3
  import { renderTitle } from '../../ui-kit/FormField/renderTitle';
4
4
  import { style } from '../../utils/style';
5
5
  import { type CreditCardSectionsProps } from './CreditCardFormContent';
6
- import { type FormStateMap } from './formStateMap';
6
+ import { type FormStateDeliveryType, type FormStateMap } from './formStateMap';
7
7
  import { renderInfo } from './renderInfo';
8
8
  import { renderInputs } from './renderInputs';
9
9
 
@@ -13,31 +13,14 @@ export interface StepProps {
13
13
  sections?: CreditCardSectionsProps[];
14
14
  field: FormFieldRegisterer<FormStateMap[keyof FormStateMap]>;
15
15
  registerSubmit?: (submit: CustomSubmit) => void;
16
- isLastStep?: boolean;
17
- methodObtain?: string;
16
+ userInputParams?: FormStateDeliveryType;
18
17
  }
19
18
 
20
- const renderLastStep = ({ sections, field, methodObtain }: StepProps) =>
21
- sections
22
- ?.filter(({ type }) => type === methodObtain || !type)
23
- .map(({ inputs, columns, title }, i) => (
24
- <div key={`section-${i}`} className={style(inputColumnStyles(columns), 'grid gap-x-m')}>
25
- {renderInfo(inputs)}
26
- {renderTitle(title)}
27
- {renderInputs({ field, inputs })}
28
- </div>
29
- ));
30
-
31
- export const renderStep = ({ sections, field, isLastStep, methodObtain }: StepProps) => {
32
- if (isLastStep) {
33
- return renderLastStep({ sections, field, methodObtain });
34
- }
35
-
36
- return sections?.map(({ inputs, columns, title }, i) => (
19
+ export const renderStep = ({ sections, field, userInputParams }: StepProps) =>
20
+ sections?.map(({ inputs, columns, title }, i) => (
37
21
  <div key={`section-${i}`} className={style(inputColumnStyles(columns), 'grid gap-x-m')}>
38
- {renderInfo(inputs)}
22
+ {renderInfo(userInputParams, inputs)}
39
23
  {renderTitle(title)}
40
24
  {renderInputs({ field, inputs })}
41
25
  </div>
42
26
  ));
43
- };
@@ -7,6 +7,7 @@ import { isValidationSuccess } from '../../validation/validator';
7
7
  import { type FieldDef } from '../ApplicationLeadForm/ApplicationLeadFormContent';
8
8
  import { type FormStateMap } from './formStateMap';
9
9
  import { getCreditCardFormTaskData } from './getCreditCardFormTaskData';
10
+ import { getFilteredInputs } from './getFilteredInputs';
10
11
 
11
12
  type CreditCardFormApiProps = {
12
13
  step: number;
@@ -28,8 +29,9 @@ export const useCreditCardFormAPI = ({
28
29
  const [participantId] = useLocalStorage<number>('participantId');
29
30
 
30
31
  const handleSubmit = useCallback(async (formData: FormStateMap[keyof FormStateMap]) => {
32
+ const inputsFiltered = getFilteredInputs(inputs, formData);
31
33
  const feedbackValidator = objectValidator(
32
- getObjectValidator(calculateInputs(formData, inputs, step)),
34
+ getObjectValidator(calculateInputs(formData, inputsFiltered, step)),
33
35
  );
34
36
  if (!isValidationSuccess(feedbackValidator(formData))) {
35
37
  return console.warn('validation fail');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.14.654",
3
+ "version": "0.14.656",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -20,7 +20,7 @@ export const updateRefreshToken = () => {
20
20
  return () => null;
21
21
  }
22
22
 
23
- const timer = setInterval(async () => {
23
+ const updateTokenRequest = async () => {
24
24
  const res = await doRequest<UpdateRefreshTokenBody | Response>('/auth/refresh', 'POST', {
25
25
  // eslint-disable-next-line camelcase
26
26
  refresh_token: refreshToken,
@@ -29,14 +29,24 @@ export const updateRefreshToken = () => {
29
29
  });
30
30
 
31
31
  if (res instanceof Response) {
32
- globalThis.location.href = PORTAL_NATURAL_URL;
32
+ handleStatus(res.status);
33
33
 
34
34
  return;
35
35
  }
36
36
 
37
- sessionStorage.setItem('refreshToken', res.refresh_token);
38
- sessionStorage.setItem('accessToken', res.access_token);
39
- }, UPDATING_INTERVAL);
37
+ globalThis.sessionStorage.setItem('refreshToken', res.refresh_token);
38
+ globalThis.sessionStorage.setItem('accessToken', res.access_token);
39
+ };
40
+
41
+ updateTokenRequest();
42
+
43
+ const timer = setInterval(updateTokenRequest, UPDATING_INTERVAL);
40
44
 
41
45
  return () => clearInterval(timer);
42
46
  };
47
+
48
+ const handleStatus = (status: number) => {
49
+ if (status == 401) {
50
+ globalThis.location.href = PORTAL_NATURAL_URL;
51
+ }
52
+ };
@@ -5,7 +5,7 @@ import { useLocalStorage } from '../../hooks/useLocalStorage';
5
5
  import { type SectionsProps } from '../ApplicationForm/ApplicationFormContent';
6
6
  import { type FieldDef } from '../ApplicationLeadForm/ApplicationLeadFormContent';
7
7
  import { CreditCardFormStatusTracker } from './CreditCardFormStatusTracker';
8
- import { type FormStateMap } from './formStateMap';
8
+ import { type FormStateDeliveryType, type FormStateMap } from './formStateMap';
9
9
  import { getInitialFormState } from './getInitialFormState';
10
10
  import { renderStep, type CustomSubmit } from './renderStep';
11
11
  import { StepsNavigationButtons } from './StepsNavigationButtons';
@@ -40,14 +40,12 @@ export const CreditCardFormStep = JSX<CreditCardFormStepProps>(
40
40
  finishForm,
41
41
  });
42
42
 
43
- const [state, { field, onSubmit }] = useForm(initialState, {
43
+ const [userInputParams, { field, onSubmit }] = useForm(initialState, {
44
44
  onSubmit: (formData, ev) => {
45
45
  handleSubmit({ ...formData, ...customSubmit.current?.(ev) });
46
46
  },
47
47
  });
48
48
 
49
- const methodObtain = 'methodObtain' in state ? state.methodObtain : undefined;
50
-
51
49
  return isFormFinished ? (
52
50
  <CreditCardFormStatusTracker />
53
51
  ) : (
@@ -56,8 +54,7 @@ export const CreditCardFormStep = JSX<CreditCardFormStepProps>(
56
54
  sections,
57
55
  field,
58
56
  registerSubmit,
59
- methodObtain,
60
- isLastStep: step === 5,
57
+ userInputParams: userInputParams as FormStateDeliveryType,
61
58
  })}
62
59
  <StepsNavigationButtons step={step} onPrevStep={onPrevStep} />
63
60
  </form>
@@ -256,55 +256,82 @@ export const stepsSectionsMap: CreditCardSectionsProps[][] = [
256
256
  inputs: [{ fieldType: 'common', name: 'methodObtain' }],
257
257
  },
258
258
  {
259
- type: 'courier',
260
259
  title: 'Адрес',
261
260
  columns: 1,
262
261
  inputs: [],
263
262
  },
264
263
  {
265
- type: 'courier',
266
- inputs: [{ fieldType: 'common', name: 'addressCourier', dadata: true }],
267
- },
268
- {
269
- type: 'courier',
270
- inputs: [{ fieldType: 'common', name: 'deliveryDate' }],
271
- },
272
- {
273
- type: 'courier',
274
- inputs: [{ fieldType: 'common', name: 'comment' }],
275
- },
276
- {
277
- type: 'office',
278
- title: 'Отделение Банка',
279
- columns: 1,
280
- inputs: [],
281
- },
282
- {
283
- type: 'office',
284
- inputs: [{ fieldType: 'common', name: 'regionRetail', required: true }],
285
- },
286
- {
287
- type: 'office',
288
- inputs: [{ fieldType: 'common', name: 'addressRetail', required: true }],
264
+ inputs: [
265
+ {
266
+ fieldType: 'common',
267
+ name: 'addressCourier',
268
+ dadata: true,
269
+ condition: {
270
+ name: 'methodObtain',
271
+ values: ['courier'],
272
+ },
273
+ required: true,
274
+ },
275
+ {
276
+ fieldType: 'common',
277
+ name: 'deliveryDate',
278
+ condition: {
279
+ name: 'methodObtain',
280
+ values: ['courier'],
281
+ },
282
+ required: true,
283
+ },
284
+ {
285
+ fieldType: 'common',
286
+ name: 'comment',
287
+ condition: {
288
+ name: 'methodObtain',
289
+ values: ['courier'],
290
+ },
291
+ },
292
+ ],
289
293
  },
290
294
  {
291
- type: 'office',
292
- title: 'Код представителя Банка',
293
- columns: 1,
294
- inputs: [],
295
+ inputs: [
296
+ {
297
+ fieldType: 'common',
298
+ name: 'regionRetail',
299
+ required: true,
300
+ condition: {
301
+ name: 'methodObtain',
302
+ values: ['office'],
303
+ },
304
+ },
305
+ {
306
+ fieldType: 'common',
307
+ name: 'addressRetail',
308
+ required: true,
309
+ condition: {
310
+ name: 'methodObtain',
311
+ values: ['office'],
312
+ },
313
+ },
314
+ ],
295
315
  },
296
316
  {
297
- type: 'office',
298
317
  inputs: [
299
318
  {
300
319
  fieldType: 'info',
301
320
  text: 'Если представитель Банка помогал Вам в заведении заявки, введите здесь его код',
321
+ condition: {
322
+ name: 'methodObtain',
323
+ values: ['office'],
324
+ },
325
+ },
326
+ {
327
+ fieldType: 'common',
328
+ name: 'bankEmployeeCode',
329
+ condition: {
330
+ name: 'methodObtain',
331
+ values: ['office'],
332
+ },
302
333
  },
303
334
  ],
304
335
  },
305
- {
306
- type: 'office',
307
- inputs: [{ fieldType: 'common', name: 'bankEmployeeCode' }],
308
- },
309
336
  ],
310
337
  ];
@@ -3,6 +3,15 @@ import { PAYMENT_SYSTEM_TYPES } from '../../ui-kit/FormField/Fields/PaymentSyste
3
3
  import type { Option } from '../../ui-kit/Select/Option';
4
4
  import { type Address } from '../ApplicationLeadForm/getInitialFormState';
5
5
 
6
+ export type FormStateDeliveryType = {
7
+ regionRetail?: string;
8
+ bankEmployeeCode?: string;
9
+ methodObtain?: 'office' | 'courier';
10
+ deliveryDate?: Date;
11
+ addressRetail?: Address;
12
+ addressCourier?: Address;
13
+ };
14
+
6
15
  export interface FormStateMap {
7
16
  0: {
8
17
  currency?: string;
@@ -28,8 +37,6 @@ export interface FormStateMap {
28
37
  participantDateRegistration?: Date;
29
38
  addressFact?: Address;
30
39
  housing?: string;
31
- methodObtain?: string;
32
- addressCourier?: Address;
33
40
  };
34
41
  2: {
35
42
  amountWorkers?: Option;
@@ -53,6 +60,7 @@ export interface FormStateMap {
53
60
  familyStatus?: Option;
54
61
  dependents?: number;
55
62
  familyMembers?: number;
63
+ confirmationIncome?: Option;
56
64
  mandatoryIncome?: number;
57
65
  otherPayments?: number;
58
66
  snils?: string;
@@ -65,14 +73,7 @@ export interface FormStateMap {
65
73
  legalEntityName?: string;
66
74
  creditInRshbCd?: Option;
67
75
  };
68
- 5: {
69
- regionRetail?: string;
70
- addressRetail?: Address;
71
- bankEmployeeCode?: string;
72
- addressCoutier?: Address;
73
- methodObtain?: 'office' | 'courier';
74
- deliveryDate?: Date;
75
- };
76
+ 5: FormStateDeliveryType;
76
77
  }
77
78
 
78
79
  export const formStateMap: FormStateMap = {
@@ -105,11 +106,6 @@ export const formStateMap: FormStateMap = {
105
106
  fiasCode: '',
106
107
  },
107
108
  housing: '',
108
- methodObtain: 'office',
109
- addressCourier: {
110
- fullAddress: '',
111
- fiasCode: '',
112
- },
113
109
  },
114
110
  2: {
115
111
  amountWorkers: { key: '', text: '' },
@@ -136,6 +132,7 @@ export const formStateMap: FormStateMap = {
136
132
  familyStatus: { key: '', text: '' },
137
133
  dependents: undefined,
138
134
  familyMembers: undefined,
135
+ confirmationIncome: { key: '', text: '' },
139
136
  mandatoryIncome: undefined,
140
137
  otherPayments: undefined,
141
138
  snils: '',
@@ -154,11 +151,11 @@ export const formStateMap: FormStateMap = {
154
151
  fullAddress: '',
155
152
  fiasCode: '',
156
153
  },
157
- bankEmployeeCode: '',
158
- addressCoutier: {
154
+ addressCourier: {
159
155
  fullAddress: '',
160
156
  fiasCode: '',
161
157
  },
158
+ bankEmployeeCode: '',
162
159
  methodObtain: 'office',
163
160
  deliveryDate: undefined,
164
161
  },
@@ -0,0 +1,18 @@
1
+ import type { FieldDef } from '../ApplicationForm/ApplicationFormContent';
2
+ import type { FormStateMap } from './formStateMap';
3
+
4
+ export const getFilteredInputs = (
5
+ inputs: FieldDef[],
6
+ data: FormStateMap[keyof FormStateMap],
7
+ ): FieldDef[] =>
8
+ inputs
9
+ .filter((_) => _)
10
+ .filter(
11
+ (input) =>
12
+ !input?.condition ||
13
+ input?.condition.values.find((_) => {
14
+ const dataValue = data?.[input?.condition?.name ?? ''];
15
+
16
+ return _ === (dataValue?.key ?? dataValue);
17
+ }),
18
+ );
@@ -19,6 +19,9 @@ export const getInitialFormState = <Step extends keyof FormStateMap>(
19
19
  localStorageData.beginDate = localStorageData?.beginDate
20
20
  ? new Date(localStorageData.beginDate as string)
21
21
  : undefined;
22
+ localStorageData.deliveryDate = localStorageData?.deliveryDate
23
+ ? new Date(localStorageData.deliveryDate as string)
24
+ : undefined;
22
25
  }
23
26
 
24
27
  return {
@@ -1,10 +1,16 @@
1
1
  import { InfoCard } from '../../ui-kit/InfoCard/InfoCard';
2
2
  import { type FieldDef } from '../ApplicationLeadForm/ApplicationLeadFormContent';
3
+ import { type FormStateDeliveryType } from './formStateMap';
4
+ import { getFilteredInputs } from './getFilteredInputs';
3
5
 
4
- export const renderInfo = (inputs: FieldDef[] = []) => {
6
+ export const renderInfo = (state?: FormStateDeliveryType, inputs: FieldDef[] = []) => {
5
7
  const infoInputs = inputs.filter((_) => _.fieldType === 'info');
8
+ const filteredInputs = getFilteredInputs(
9
+ infoInputs,
10
+ state as FormStateDeliveryType,
11
+ ) as FieldDef[];
6
12
 
7
- return infoInputs.length
8
- ? infoInputs.map(({ text, name }, i) => <InfoCard key={`${name}_${i}`} __html={text} />)
13
+ return filteredInputs.length
14
+ ? filteredInputs.map(({ text, name }, i) => <InfoCard key={`${name}_${i}`} __html={text} />)
9
15
  : null;
10
16
  };
@@ -3,7 +3,7 @@ import { inputColumnStyles } from '../../ui-kit/FormField/inputColumnStyle';
3
3
  import { renderTitle } from '../../ui-kit/FormField/renderTitle';
4
4
  import { style } from '../../utils/style';
5
5
  import { type CreditCardSectionsProps } from './CreditCardFormContent';
6
- import { type FormStateMap } from './formStateMap';
6
+ import { type FormStateDeliveryType, type FormStateMap } from './formStateMap';
7
7
  import { renderInfo } from './renderInfo';
8
8
  import { renderInputs } from './renderInputs';
9
9
 
@@ -13,31 +13,14 @@ export interface StepProps {
13
13
  sections?: CreditCardSectionsProps[];
14
14
  field: FormFieldRegisterer<FormStateMap[keyof FormStateMap]>;
15
15
  registerSubmit?: (submit: CustomSubmit) => void;
16
- isLastStep?: boolean;
17
- methodObtain?: string;
16
+ userInputParams?: FormStateDeliveryType;
18
17
  }
19
18
 
20
- const renderLastStep = ({ sections, field, methodObtain }: StepProps) =>
21
- sections
22
- ?.filter(({ type }) => type === methodObtain || !type)
23
- .map(({ inputs, columns, title }, i) => (
24
- <div key={`section-${i}`} className={style(inputColumnStyles(columns), 'grid gap-x-m')}>
25
- {renderInfo(inputs)}
26
- {renderTitle(title)}
27
- {renderInputs({ field, inputs })}
28
- </div>
29
- ));
30
-
31
- export const renderStep = ({ sections, field, isLastStep, methodObtain }: StepProps) => {
32
- if (isLastStep) {
33
- return renderLastStep({ sections, field, methodObtain });
34
- }
35
-
36
- return sections?.map(({ inputs, columns, title }, i) => (
19
+ export const renderStep = ({ sections, field, userInputParams }: StepProps) =>
20
+ sections?.map(({ inputs, columns, title }, i) => (
37
21
  <div key={`section-${i}`} className={style(inputColumnStyles(columns), 'grid gap-x-m')}>
38
- {renderInfo(inputs)}
22
+ {renderInfo(userInputParams, inputs)}
39
23
  {renderTitle(title)}
40
24
  {renderInputs({ field, inputs })}
41
25
  </div>
42
26
  ));
43
- };
@@ -7,6 +7,7 @@ import { isValidationSuccess } from '../../validation/validator';
7
7
  import { type FieldDef } from '../ApplicationLeadForm/ApplicationLeadFormContent';
8
8
  import { type FormStateMap } from './formStateMap';
9
9
  import { getCreditCardFormTaskData } from './getCreditCardFormTaskData';
10
+ import { getFilteredInputs } from './getFilteredInputs';
10
11
 
11
12
  type CreditCardFormApiProps = {
12
13
  step: number;
@@ -28,8 +29,9 @@ export const useCreditCardFormAPI = ({
28
29
  const [participantId] = useLocalStorage<number>('participantId');
29
30
 
30
31
  const handleSubmit = useCallback(async (formData: FormStateMap[keyof FormStateMap]) => {
32
+ const inputsFiltered = getFilteredInputs(inputs, formData);
31
33
  const feedbackValidator = objectValidator(
32
- getObjectValidator(calculateInputs(formData, inputs, step)),
34
+ getObjectValidator(calculateInputs(formData, inputsFiltered, step)),
33
35
  );
34
36
  if (!isValidationSuccess(feedbackValidator(formData))) {
35
37
  return console.warn('validation fail');