@redneckz/wildless-cms-uni-blocks 0.14.621 → 0.14.622

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 (176) hide show
  1. package/bundle/blocks.schema.json +1 -1
  2. package/bundle/bundle.umd.js +35 -27
  3. package/bundle/bundle.umd.min.js +1 -1
  4. package/bundle/components/ApplicationForm/ApplicationFormContent.d.ts +1 -1
  5. package/bundle/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +1 -1
  6. package/bundle/components/CreditForm/CreditFormStep.d.ts +1 -2
  7. package/bundle/components/CreditForm/StepsNavigationButtons.d.ts +0 -1
  8. package/bundle/components/CreditForm/creditFormStepsData.d.ts +2 -178
  9. package/bundle/ui-kit/FormField/getNamesFromInput.d.ts +1 -1
  10. package/dist/components/ApplicationForm/ApplicationFormContent.d.ts +1 -1
  11. package/dist/components/ApplicationForm/getInitialFormState.js +1 -1
  12. package/dist/components/ApplicationForm/getInitialFormState.js.map +1 -1
  13. package/dist/components/ApplicationForm/renderInputs.js +2 -2
  14. package/dist/components/ApplicationForm/renderInputs.js.map +1 -1
  15. package/dist/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +1 -1
  16. package/dist/components/ApplicationLeadForm/GroupedConsents.js.map +1 -1
  17. package/dist/components/ApplicationLeadForm/getInitialFormState.js +1 -1
  18. package/dist/components/ApplicationLeadForm/getInitialFormState.js.map +1 -1
  19. package/dist/components/ApplicationLeadForm/useInitApplicationLead.js +1 -1
  20. package/dist/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  21. package/dist/components/CreditForm/CreditForm.js +3 -3
  22. package/dist/components/CreditForm/CreditForm.js.map +1 -1
  23. package/dist/components/CreditForm/CreditFormProgress.js +3 -3
  24. package/dist/components/CreditForm/CreditFormProgress.js.map +1 -1
  25. package/dist/components/CreditForm/CreditFormStep.d.ts +1 -2
  26. package/dist/components/CreditForm/CreditFormStep.js +3 -3
  27. package/dist/components/CreditForm/CreditFormStep.js.map +1 -1
  28. package/dist/components/CreditForm/StepsNavigationButtons.d.ts +0 -1
  29. package/dist/components/CreditForm/StepsNavigationButtons.js +2 -1
  30. package/dist/components/CreditForm/StepsNavigationButtons.js.map +1 -1
  31. package/dist/components/CreditForm/creditFormStepsData.d.ts +2 -178
  32. package/dist/components/CreditForm/creditFormStepsData.js +7 -8
  33. package/dist/components/CreditForm/creditFormStepsData.js.map +1 -1
  34. package/dist/ui-kit/FormField/Fields/PartInBusinessField.js +9 -1
  35. package/dist/ui-kit/FormField/Fields/PartInBusinessField.js.map +1 -1
  36. package/dist/ui-kit/FormField/getField.js +1 -1
  37. package/dist/ui-kit/FormField/getField.js.map +1 -1
  38. package/dist/ui-kit/FormField/getNamesFromInput.d.ts +1 -1
  39. package/dist/ui-kit/FormField/getObjectValidator.js +1 -1
  40. package/dist/ui-kit/FormField/getObjectValidator.js.map +1 -1
  41. package/lib/components/ApplicationForm/ApplicationFormContent.d.ts +1 -1
  42. package/lib/components/ApplicationForm/getInitialFormState.js +1 -1
  43. package/lib/components/ApplicationForm/getInitialFormState.js.map +1 -1
  44. package/lib/components/ApplicationForm/renderInputs.js +2 -2
  45. package/lib/components/ApplicationForm/renderInputs.js.map +1 -1
  46. package/lib/components/ApplicationLeadForm/ApplicationLeadForm.fixture.d.ts +0 -2
  47. package/lib/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +1 -1
  48. package/lib/components/ApplicationLeadForm/GroupedConsents.js.map +1 -1
  49. package/lib/components/ApplicationLeadForm/getInitialFormState.js +1 -1
  50. package/lib/components/ApplicationLeadForm/getInitialFormState.js.map +1 -1
  51. package/lib/components/ApplicationLeadForm/useInitApplicationLead.js +1 -1
  52. package/lib/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  53. package/lib/components/CreditForm/CreditForm.js +3 -3
  54. package/lib/components/CreditForm/CreditForm.js.map +1 -1
  55. package/lib/components/CreditForm/CreditFormProgress.js +3 -3
  56. package/lib/components/CreditForm/CreditFormProgress.js.map +1 -1
  57. package/lib/components/CreditForm/CreditFormStep.d.ts +1 -2
  58. package/lib/components/CreditForm/CreditFormStep.js +3 -3
  59. package/lib/components/CreditForm/CreditFormStep.js.map +1 -1
  60. package/lib/components/CreditForm/StepsNavigationButtons.d.ts +0 -1
  61. package/lib/components/CreditForm/StepsNavigationButtons.js +2 -1
  62. package/lib/components/CreditForm/StepsNavigationButtons.js.map +1 -1
  63. package/lib/components/CreditForm/creditFormStepsData.d.ts +2 -178
  64. package/lib/components/CreditForm/creditFormStepsData.js +7 -8
  65. package/lib/components/CreditForm/creditFormStepsData.js.map +1 -1
  66. package/lib/components/OfficesAtmsMap/OfficesAtmsMapLayout.d.ts +1 -1
  67. package/lib/ui-kit/FormField/Fields/PartInBusinessField.js +9 -1
  68. package/lib/ui-kit/FormField/Fields/PartInBusinessField.js.map +1 -1
  69. package/lib/ui-kit/FormField/getField.js +1 -1
  70. package/lib/ui-kit/FormField/getField.js.map +1 -1
  71. package/lib/ui-kit/FormField/getNamesFromInput.d.ts +1 -1
  72. package/lib/ui-kit/FormField/getObjectValidator.js +1 -1
  73. package/lib/ui-kit/FormField/getObjectValidator.js.map +1 -1
  74. package/mobile/bundle/bundle.umd.js +35 -27
  75. package/mobile/bundle/bundle.umd.min.js +1 -1
  76. package/mobile/bundle/components/ApplicationForm/ApplicationFormContent.d.ts +1 -1
  77. package/mobile/bundle/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +1 -1
  78. package/mobile/bundle/components/CreditForm/CreditFormStep.d.ts +1 -2
  79. package/mobile/bundle/components/CreditForm/StepsNavigationButtons.d.ts +0 -1
  80. package/mobile/bundle/components/CreditForm/creditFormStepsData.d.ts +2 -178
  81. package/mobile/bundle/ui-kit/FormField/getNamesFromInput.d.ts +1 -1
  82. package/mobile/dist/components/ApplicationForm/ApplicationFormContent.d.ts +1 -1
  83. package/mobile/dist/components/ApplicationForm/getInitialFormState.js +1 -1
  84. package/mobile/dist/components/ApplicationForm/getInitialFormState.js.map +1 -1
  85. package/mobile/dist/components/ApplicationForm/renderInputs.js +2 -2
  86. package/mobile/dist/components/ApplicationForm/renderInputs.js.map +1 -1
  87. package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +1 -1
  88. package/mobile/dist/components/ApplicationLeadForm/GroupedConsents.js.map +1 -1
  89. package/mobile/dist/components/ApplicationLeadForm/getInitialFormState.js +1 -1
  90. package/mobile/dist/components/ApplicationLeadForm/getInitialFormState.js.map +1 -1
  91. package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.js +1 -1
  92. package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  93. package/mobile/dist/components/CreditForm/CreditForm.js +3 -3
  94. package/mobile/dist/components/CreditForm/CreditForm.js.map +1 -1
  95. package/mobile/dist/components/CreditForm/CreditFormProgress.js +3 -3
  96. package/mobile/dist/components/CreditForm/CreditFormProgress.js.map +1 -1
  97. package/mobile/dist/components/CreditForm/CreditFormStep.d.ts +1 -2
  98. package/mobile/dist/components/CreditForm/CreditFormStep.js +3 -3
  99. package/mobile/dist/components/CreditForm/CreditFormStep.js.map +1 -1
  100. package/mobile/dist/components/CreditForm/StepsNavigationButtons.d.ts +0 -1
  101. package/mobile/dist/components/CreditForm/StepsNavigationButtons.js +2 -1
  102. package/mobile/dist/components/CreditForm/StepsNavigationButtons.js.map +1 -1
  103. package/mobile/dist/components/CreditForm/creditFormStepsData.d.ts +2 -178
  104. package/mobile/dist/components/CreditForm/creditFormStepsData.js +7 -8
  105. package/mobile/dist/components/CreditForm/creditFormStepsData.js.map +1 -1
  106. package/mobile/dist/ui-kit/FormField/Fields/PartInBusinessField.js +9 -1
  107. package/mobile/dist/ui-kit/FormField/Fields/PartInBusinessField.js.map +1 -1
  108. package/mobile/dist/ui-kit/FormField/getField.js +1 -1
  109. package/mobile/dist/ui-kit/FormField/getField.js.map +1 -1
  110. package/mobile/dist/ui-kit/FormField/getNamesFromInput.d.ts +1 -1
  111. package/mobile/dist/ui-kit/FormField/getObjectValidator.js +1 -1
  112. package/mobile/dist/ui-kit/FormField/getObjectValidator.js.map +1 -1
  113. package/mobile/lib/components/ApplicationForm/ApplicationFormContent.d.ts +1 -1
  114. package/mobile/lib/components/ApplicationForm/getInitialFormState.js +1 -1
  115. package/mobile/lib/components/ApplicationForm/getInitialFormState.js.map +1 -1
  116. package/mobile/lib/components/ApplicationForm/renderInputs.js +2 -2
  117. package/mobile/lib/components/ApplicationForm/renderInputs.js.map +1 -1
  118. package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +1 -1
  119. package/mobile/lib/components/ApplicationLeadForm/GroupedConsents.js.map +1 -1
  120. package/mobile/lib/components/ApplicationLeadForm/getInitialFormState.js +1 -1
  121. package/mobile/lib/components/ApplicationLeadForm/getInitialFormState.js.map +1 -1
  122. package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.js +1 -1
  123. package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  124. package/mobile/lib/components/CreditForm/CreditForm.js +3 -3
  125. package/mobile/lib/components/CreditForm/CreditForm.js.map +1 -1
  126. package/mobile/lib/components/CreditForm/CreditFormProgress.js +3 -3
  127. package/mobile/lib/components/CreditForm/CreditFormProgress.js.map +1 -1
  128. package/mobile/lib/components/CreditForm/CreditFormStep.d.ts +1 -2
  129. package/mobile/lib/components/CreditForm/CreditFormStep.js +3 -3
  130. package/mobile/lib/components/CreditForm/CreditFormStep.js.map +1 -1
  131. package/mobile/lib/components/CreditForm/StepsNavigationButtons.d.ts +0 -1
  132. package/mobile/lib/components/CreditForm/StepsNavigationButtons.js +2 -1
  133. package/mobile/lib/components/CreditForm/StepsNavigationButtons.js.map +1 -1
  134. package/mobile/lib/components/CreditForm/creditFormStepsData.d.ts +2 -178
  135. package/mobile/lib/components/CreditForm/creditFormStepsData.js +7 -8
  136. package/mobile/lib/components/CreditForm/creditFormStepsData.js.map +1 -1
  137. package/mobile/lib/ui-kit/FormField/Fields/PartInBusinessField.js +9 -1
  138. package/mobile/lib/ui-kit/FormField/Fields/PartInBusinessField.js.map +1 -1
  139. package/mobile/lib/ui-kit/FormField/getField.js +1 -1
  140. package/mobile/lib/ui-kit/FormField/getField.js.map +1 -1
  141. package/mobile/lib/ui-kit/FormField/getNamesFromInput.d.ts +1 -1
  142. package/mobile/lib/ui-kit/FormField/getObjectValidator.js +1 -1
  143. package/mobile/lib/ui-kit/FormField/getObjectValidator.js.map +1 -1
  144. package/mobile/src/components/ApplicationForm/ApplicationFormContent.ts +1 -1
  145. package/mobile/src/components/ApplicationForm/getInitialFormState.tsx +1 -1
  146. package/mobile/src/components/ApplicationForm/renderInputs.tsx +2 -2
  147. package/mobile/src/components/ApplicationLeadForm/ApplicationLeadFormContent.ts +1 -1
  148. package/mobile/src/components/ApplicationLeadForm/GroupedConsents.tsx +9 -2
  149. package/mobile/src/components/ApplicationLeadForm/getInitialFormState.tsx +1 -1
  150. package/mobile/src/components/ApplicationLeadForm/useInitApplicationLead.ts +1 -1
  151. package/mobile/src/components/CreditForm/CreditForm.tsx +7 -5
  152. package/mobile/src/components/CreditForm/CreditFormProgress.tsx +5 -5
  153. package/mobile/src/components/CreditForm/CreditFormStep.tsx +4 -5
  154. package/mobile/src/components/CreditForm/StepsNavigationButtons.tsx +3 -2
  155. package/mobile/src/components/CreditForm/creditFormStepsData.tsx +9 -8
  156. package/mobile/src/ui-kit/FormField/Fields/PartInBusinessField.tsx +25 -9
  157. package/mobile/src/ui-kit/FormField/getField.tsx +1 -1
  158. package/mobile/src/ui-kit/FormField/getObjectValidator.tsx +1 -1
  159. package/package.json +1 -1
  160. package/src/components/ApplicationForm/ApplicationFormContent.ts +1 -1
  161. package/src/components/ApplicationForm/getInitialFormState.tsx +1 -1
  162. package/src/components/ApplicationForm/renderInputs.tsx +2 -2
  163. package/src/components/ApplicationLeadForm/ApplicationLeadForm.fixture.tsx +0 -121
  164. package/src/components/ApplicationLeadForm/ApplicationLeadFormContent.ts +1 -1
  165. package/src/components/ApplicationLeadForm/GroupedConsents.tsx +9 -2
  166. package/src/components/ApplicationLeadForm/getInitialFormState.tsx +1 -1
  167. package/src/components/ApplicationLeadForm/useInitApplicationLead.ts +1 -1
  168. package/src/components/CreditForm/CreditForm.tsx +7 -5
  169. package/src/components/CreditForm/CreditFormProgress.tsx +5 -5
  170. package/src/components/CreditForm/CreditFormStep.tsx +4 -5
  171. package/src/components/CreditForm/StepsNavigationButtons.tsx +3 -2
  172. package/src/components/CreditForm/creditFormStepsData.tsx +9 -8
  173. package/src/icons/IconName.ts +6 -360
  174. package/src/ui-kit/FormField/Fields/PartInBusinessField.tsx +25 -9
  175. package/src/ui-kit/FormField/getField.tsx +1 -1
  176. package/src/ui-kit/FormField/getObjectValidator.tsx +1 -1
@@ -4,12 +4,28 @@ import { type CustomFieldProps } from '../CustomFieldProps';
4
4
  import { validatorObj } from '../getObjectValidator';
5
5
  import { getValidation } from '../getValidation';
6
6
 
7
- export const PartInBusinessField = JSX<CustomFieldProps>(({ field, input }) => (
8
- <InputControl
9
- label="Доля участия в бизнесе"
10
- placeholder= %"
11
- inputLength={2}
12
- {...getValidation(field('partInBusiness'), validatorObj.partInBusiness, input?.required)}
13
- {...input}
14
- />
15
- ));
7
+ const MAX_PART = 100;
8
+
9
+ export const PartInBusinessField = JSX<CustomFieldProps>(({ field, input }) => {
10
+ const partInBusinessField = {
11
+ ...getValidation(field('partInBusiness'), validatorObj.partInBusiness, input?.required),
12
+ };
13
+
14
+ const handleChange = (value: string) =>
15
+ partInBusinessField?.onChange &&
16
+ partInBusinessField?.onChange(
17
+ String(Number(value) > MAX_PART ? MAX_PART : Number(value) || ''),
18
+ );
19
+
20
+ return (
21
+ <InputControl
22
+ label="Доля участия в бизнесе"
23
+ placeholder="в %"
24
+ inputLength={3}
25
+ type="number"
26
+ {...partInBusinessField}
27
+ {...input}
28
+ onChange={handleChange}
29
+ />
30
+ );
31
+ });
@@ -183,6 +183,6 @@ export const getField =
183
183
  };
184
184
 
185
185
  return isRenderField({ input, field }) ? (
186
- <div key={String(i)}>{InputsMap[input?.name]}</div>
186
+ <div key={String(i)}>{InputsMap[input?.name || '']}</div>
187
187
  ) : null;
188
188
  };
@@ -96,5 +96,5 @@ export const validatorObj: Record<string, Validator> = {
96
96
  export const getObjectValidator = (inputs: FieldDef[]): Record<string, Validator> => {
97
97
  const requiredInputs = getNamesFromInput(inputs.filter((_: FieldDef) => Boolean(_?.required)));
98
98
 
99
- return Object.fromEntries(requiredInputs.map((_) => [_, validatorObj?.[_]]));
99
+ return Object.fromEntries(requiredInputs.map((_) => [_, validatorObj?.[_ || '']]));
100
100
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.14.621",
3
+ "version": "0.14.622",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -29,7 +29,7 @@ export type ConditionFieldProps = {
29
29
  export type FieldDefaultDef = Required &
30
30
  LabelProps &
31
31
  ConditionFieldProps & {
32
- name: NameFieldDef;
32
+ name?: NameFieldDef;
33
33
  dadata?: boolean;
34
34
  };
35
35
 
@@ -60,7 +60,7 @@ export const getInitialFormState = (inputs: FieldDef[], typeForm = ''): FormStat
60
60
  const formState = Object.fromEntries(
61
61
  inputs.map((_) => [
62
62
  _.name,
63
- (_.fieldType === 'ved' && _?.defaultValue) || initialFormState[_.name],
63
+ (_.fieldType === 'ved' && _?.defaultValue) || initialFormState[_.name || ''],
64
64
  ]),
65
65
  );
66
66
 
@@ -20,6 +20,6 @@ export const renderInputs = ({ field, typeForm = '', inputs }: GroupedConsentsPr
20
20
  };
21
21
 
22
22
  const splitInputs = (inputs?: FieldDef[]) => ({
23
- consentInputs: inputs?.filter((_) => Object.keys(CONSENTS).includes(_.name)) || [],
24
- restInputs: inputs?.filter((_) => !Object.keys(CONSENTS).includes(_.name)) || [],
23
+ consentInputs: inputs?.filter((_) => Object.keys(CONSENTS).includes(_.name || '')) || [],
24
+ restInputs: inputs?.filter((_) => !Object.keys(CONSENTS).includes(_.name || '')) || [],
25
25
  });
@@ -47,125 +47,4 @@ export default {
47
47
  <DialogManager />
48
48
  </div>
49
49
  ),
50
- step1: (
51
- <div className="container grid grid-cols-12">
52
- <ApplicationLeadForm
53
- className="col-span-12"
54
- title="Заявка на кредит &#171;Кредит на любые цели&#187;"
55
- typeForm="CORRUPTION"
56
- endpoint="lead"
57
- sections={[
58
- { title: 'Персональные данные', inputs: [] },
59
- {
60
- columns: 2,
61
- inputs: [
62
- { fieldType: 'common', name: 'surname', required: true, dadata: true },
63
- { fieldType: 'common', name: 'name', required: true, dadata: true },
64
- { fieldType: 'common', name: 'middleName', dadata: true },
65
- { fieldType: 'common', name: 'sex', required: true },
66
- { fieldType: 'common', name: 'birthday', required: true },
67
- { fieldType: 'common', name: 'birthPlace', required: true },
68
- { fieldType: 'common', name: 'phone', required: true },
69
- { fieldType: 'common', name: 'email', required: true, dadata: true },
70
- ],
71
- },
72
- {
73
- title: 'Паспортные данные',
74
- inputs: [
75
- { fieldType: 'common', name: 'dulSerie', required: true },
76
- { fieldType: 'common', name: 'dulNumber', required: true },
77
- { fieldType: 'common', name: 'dulIssueDateField', required: true },
78
- { fieldType: 'common', name: 'dulSubdivisionCode', required: true, dadata: true },
79
- ],
80
- },
81
- {
82
- inputs: [
83
- { fieldType: 'common', name: 'dulIssuedBy', required: true, dadata: true },
84
- {
85
- fieldType: 'common',
86
- name: 'education',
87
- required: true,
88
- },
89
- ],
90
- },
91
- {
92
- title: 'Адрес регистрации по месту жительства',
93
- inputs: [],
94
- },
95
- {
96
- inputs: [
97
- { fieldType: 'common', name: 'participantDateRegistration', required: true },
98
- { fieldType: 'common', name: 'participantAddress', required: true, dadata: true },
99
- ],
100
- },
101
- ]}
102
- button={button}
103
- />
104
- <PopupManager />
105
- <DialogManager />
106
- </div>
107
- ),
108
- employmentData: (
109
- <div className="container grid grid-cols-12">
110
- <ApplicationLeadForm
111
- className="col-span-12"
112
- title="Заявка на кредит &#171;Кредит на любые цели&#187;"
113
- typeForm="CORRUPTION"
114
- endpoint="lead"
115
- sections={[
116
- {
117
- title: 'Данные о трудоустройстве',
118
- inputs: [],
119
- },
120
- {
121
- inputs: [
122
- { fieldType: 'common', name: 'employment', required: true },
123
- { fieldType: 'common', name: 'organizationName', required: true, dadata: true },
124
- ],
125
- },
126
- {
127
- columns: 2,
128
- inputs: [
129
- { fieldType: 'common', name: 'inn', required: true, dadata: true },
130
- { fieldType: 'common', name: 'legalForm', required: true },
131
- ],
132
- },
133
- {
134
- inputs: [
135
- { fieldType: 'common', name: 'organization', required: true },
136
- { fieldType: 'common', name: 'amountWorkers', required: true },
137
- ],
138
- },
139
- {
140
- columns: 2,
141
- inputs: [
142
- { fieldType: 'common', name: 'employerActivities', required: true },
143
- { fieldType: 'common', name: 'employerOrganization', required: true },
144
- { fieldType: 'common', name: 'generalSeniority', required: true },
145
- { fieldType: 'common', name: 'lastJobExperience', required: true },
146
- { fieldType: 'common', name: 'experience5Years', required: true },
147
- { fieldType: 'common', name: 'jobsNumber', required: true },
148
- ],
149
- },
150
- {
151
- inputs: [
152
- { fieldType: 'common', name: 'phone', label: 'Телефон работодателя', required: true },
153
- { fieldType: 'common', name: 'beginDate', required: true },
154
- { fieldType: 'common', name: 'positionOrganization', required: true },
155
- ],
156
- },
157
- {
158
- title: 'Адрес работодателя',
159
- inputs: [],
160
- },
161
- {
162
- inputs: [{ fieldType: 'common', name: 'fullAddress', required: true }],
163
- },
164
- ]}
165
- button={button}
166
- />
167
- <PopupManager />
168
- <DialogManager />
169
- </div>
170
- ),
171
50
  };
@@ -28,7 +28,7 @@ export type FieldDefaultDef = Required &
28
28
  TextProps &
29
29
  LabelProps &
30
30
  ConditionFieldProps & {
31
- name: NameFieldDef;
31
+ name?: NameFieldDef;
32
32
  };
33
33
 
34
34
  /**
@@ -18,7 +18,7 @@ const CONSENT_REQUIRED = 'Отметьте все обязательные со
18
18
 
19
19
  export const GroupedConsents = JSX<GroupedConsentsProps>(
20
20
  ({ inputs = [], typeForm = '', field, key }) => {
21
- const isChecked = inputs.every((_) => Boolean(field(_.name).value));
21
+ const isChecked = inputs.every((_) => Boolean(field(_.name as keyof FormState).value));
22
22
 
23
23
  const handleGeneralToggle = (value: boolean) => {
24
24
  for (const item of inputs) {
@@ -31,7 +31,14 @@ export const GroupedConsents = JSX<GroupedConsentsProps>(
31
31
  () =>
32
32
  inputs
33
33
  ?.filter((_) => _.required)
34
- ?.some((_) => Boolean(withValidator(field(_?.name), validatorObj[_?.name]).error)),
34
+ ?.some((_) =>
35
+ Boolean(
36
+ withValidator(
37
+ field(_?.name as keyof FormState),
38
+ validatorObj[_?.name as keyof FormState],
39
+ ).error,
40
+ ),
41
+ ),
35
42
  [inputs],
36
43
  );
37
44
 
@@ -150,7 +150,7 @@ export const getInitialFormState = (
150
150
  const formState = Object.fromEntries(
151
151
  inputs.map((_) => [
152
152
  _.name,
153
- (_.fieldType === 'ved' && _?.defaultValue) || initialFormState[_.name],
153
+ (_.fieldType === 'ved' && _?.defaultValue) || initialFormState[_.name || ''],
154
154
  ]),
155
155
  );
156
156
 
@@ -7,7 +7,7 @@ export const useInitApplicationLead = (nextStepLink: string) => {
7
7
  const [isLoading, setIsLoading] = useState(false);
8
8
  const [profileId] = useLocalStorage<string>('profileId');
9
9
  const [, setEsiaData] = useLocalStorage('esiaData');
10
- const params = new URLSearchParams(decodeURIComponent(window.location.search));
10
+ const params = new URLSearchParams(decodeURIComponent(globalThis.location.search));
11
11
  const esiaAuth = params.get('esiaAuth');
12
12
 
13
13
  const updateEsiaProfile = useCallback(async () => {
@@ -3,8 +3,10 @@ import { useCallback, useMemo, useState } from '@redneckz/uni-jsx/lib/hooks';
3
3
  import { BlockWrapper } from '../../ui-kit/BlockWrapper';
4
4
  import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
5
5
  import { style } from '../../utils/style';
6
- import { type SectionsProps } from '../ApplicationForm/ApplicationFormContent';
7
- import { type FieldDef } from '../ApplicationLeadForm/ApplicationLeadFormContent';
6
+ import {
7
+ type FieldDef,
8
+ type SectionsProps,
9
+ } from '../ApplicationLeadForm/ApplicationLeadFormContent';
8
10
  import { type CreditFormContent } from './CreditFormContent';
9
11
  import { CreditFormProgress } from './CreditFormProgress';
10
12
  import { CreditFormStep } from './CreditFormStep';
@@ -22,12 +24,13 @@ const STEPS_TITLES = [
22
24
  interface CreditFormProps extends CreditFormContent, UniBlockProps {}
23
25
 
24
26
  export const CreditForm = JSX<CreditFormProps>(({ className, ...rest }) => {
25
- const [step, setStep] = useState(1);
27
+ const [step, setStep] = useState(0);
26
28
  const sections = useMemo(() => stepsSectionsMap[step], [step]);
29
+
27
30
  const inputs = (sections?.flatMap((_: SectionsProps) => _?.inputs) || []) as FieldDef[];
28
31
 
29
32
  const handleNextStep = useCallback(() => {
30
- setStep((_) => Math.min(_ + 1, STEPS_COUNT));
33
+ setStep((_) => Math.min(_ + 1, STEPS_COUNT - 1));
31
34
  }, []);
32
35
 
33
36
  const handlePrevStep = useCallback(() => {
@@ -43,7 +46,6 @@ export const CreditForm = JSX<CreditFormProps>(({ className, ...rest }) => {
43
46
  <CreditFormStep
44
47
  inputs={inputs}
45
48
  key={String(step)}
46
- totalSteps={STEPS_COUNT}
47
49
  step={step}
48
50
  sections={sections}
49
51
  onNextStep={handleNextStep}
@@ -9,16 +9,16 @@ export interface CreditFormProgressProps {
9
9
  }
10
10
 
11
11
  export const CreditFormProgress = JSX<CreditFormProgressProps>(
12
- ({ step = 1, totalSteps = 5, stepsTitles = [] }) => {
13
- const progress = useMemo(() => (step / totalSteps) * 100, [step, totalSteps]);
12
+ ({ step = 0, totalSteps = 5, stepsTitles = [] }) => {
13
+ const progress = useMemo(() => ((step + 1) / totalSteps) * 100, [step, totalSteps]);
14
14
 
15
15
  return (
16
16
  <div className="py-lg px-5xl bg-white col-span-12">
17
17
  <div>
18
18
  <span className="font-bold">
19
- Шаг {step} из {totalSteps}.
20
- </span>{' '}
21
- {stepsTitles[step - 1] || null}
19
+ Шаг {step + 1} из {totalSteps}.
20
+ </span>
21
+ {stepsTitles[step] || null}
22
22
  <ProgressBar step={progress} showPercentage={false} />
23
23
  </div>
24
24
  </div>
@@ -13,12 +13,11 @@ import { StepsNavigationButtons } from './StepsNavigationButtons';
13
13
  import { useCreditFormApi } from './useCreditFormApi';
14
14
 
15
15
  export interface StepProps {
16
- sections: SectionsProps[];
16
+ sections?: SectionsProps[];
17
17
  field: FormFieldRegisterer<FormStateMap[keyof FormStateMap]>;
18
18
  }
19
19
 
20
20
  export interface CreditFormStepProps {
21
- totalSteps: number;
22
21
  step: number;
23
22
  sections: SectionsProps[];
24
23
  inputs: FieldDef[];
@@ -27,7 +26,7 @@ export interface CreditFormStepProps {
27
26
  }
28
27
 
29
28
  export const CreditFormStep = JSX<CreditFormStepProps>(
30
- ({ totalSteps, step, sections, onPrevStep, onNextStep, inputs }) => {
29
+ ({ step, sections, onPrevStep, onNextStep, inputs }) => {
31
30
  const [localStorageData, saveStep] = useLocalStorage<Record<string, any>>('leadForm');
32
31
  const initialState = getInitialFormState(step as keyof FormStateMap, localStorageData);
33
32
 
@@ -42,14 +41,14 @@ export const CreditFormStep = JSX<CreditFormStepProps>(
42
41
  return (
43
42
  <form onSubmit={onSubmit} className="space-y-m">
44
43
  {renderStep({ sections, field })}
45
- <StepsNavigationButtons step={step} totalSteps={totalSteps} onPrevStep={onPrevStep} />
44
+ <StepsNavigationButtons step={step} onPrevStep={onPrevStep} />
46
45
  </form>
47
46
  );
48
47
  },
49
48
  );
50
49
 
51
50
  const renderStep = ({ sections, field }: StepProps) => {
52
- return sections.map((_, i) => (
51
+ return sections?.map((_, i) => (
53
52
  <div key={`section-${i}`} className={style(inputColumnStyles(_.columns), 'grid gap-x-m')}>
54
53
  {renderInfo(_?.inputs)}
55
54
  {renderTitle(_?.title)}
@@ -4,11 +4,12 @@ import { style } from '../../utils/style';
4
4
 
5
5
  export interface StepsNavigationButtonsProps {
6
6
  step: number;
7
- totalSteps: number;
8
7
  onPrevStep?: () => void;
9
8
  }
10
9
 
11
10
  export const StepsNavigationButtons = JSX<StepsNavigationButtonsProps>(({ step, onPrevStep }) => {
11
+ const isFirstStep = step === 0;
12
+
12
13
  return (
13
14
  <div className={'flex justify-between'}>
14
15
  <Button
@@ -16,7 +17,7 @@ export const StepsNavigationButtons = JSX<StepsNavigationButtonsProps>(({ step,
16
17
  className={style('w-full @xl:w-auto')}
17
18
  type="button"
18
19
  version="secondary"
19
- disabled={step === 1}
20
+ disabled={isFirstStep}
20
21
  >
21
22
  Назад
22
23
  </Button>
@@ -1,9 +1,10 @@
1
1
  /* eslint-disable max-lines */
2
2
  /* eslint-disable max-len */
3
3
 
4
- //TODO: DO List
5
- export const stepsSectionsMap = {
6
- 1: [
4
+ import { type SectionsProps } from '../ApplicationLeadForm/ApplicationLeadFormContent';
5
+
6
+ export const stepsSectionsMap: SectionsProps[][] = [
7
+ [
7
8
  {
8
9
  title: 'Персональные данные',
9
10
  columns: 2,
@@ -58,7 +59,7 @@ export const stepsSectionsMap = {
58
59
  ],
59
60
  },
60
61
  ],
61
- 2: [
62
+ [
62
63
  {
63
64
  title: 'Данные о трудоустройстве',
64
65
  inputs: [],
@@ -122,7 +123,7 @@ export const stepsSectionsMap = {
122
123
  inputs: [{ fieldType: 'common', name: 'fullAddress', required: true }],
123
124
  },
124
125
  ],
125
- 3: [
126
+ [
126
127
  {
127
128
  title: 'Семейное положение',
128
129
  },
@@ -166,7 +167,7 @@ export const stepsSectionsMap = {
166
167
  inputs: [{ fieldType: 'common', name: 'armyIdFlg' }],
167
168
  },
168
169
  ],
169
- 4: [
170
+ [
170
171
  {
171
172
  title: 'Дополнительные сведения',
172
173
  columns: 1,
@@ -188,7 +189,7 @@ export const stepsSectionsMap = {
188
189
  inputs: [{ fieldType: 'common', name: 'creditInRshbCd' }],
189
190
  },
190
191
  ],
191
- 5: [
192
+ [
192
193
  {
193
194
  title: 'Отделение Банка',
194
195
  columns: 1,
@@ -217,4 +218,4 @@ export const stepsSectionsMap = {
217
218
  inputs: [{ fieldType: 'common', name: 'bankEmployeeCode' }],
218
219
  },
219
220
  ],
220
- };
221
+ ];