@redneckz/wildless-cms-uni-blocks 0.14.684 → 0.14.686

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 (166) hide show
  1. package/bundle/api/RetailAPI/getCardTypes.d.ts +1 -1
  2. package/bundle/api/RetailAPI/getGenderFromName.d.ts +1 -0
  3. package/bundle/api/RetailAPI/getPaymentSystems.d.ts +1 -1
  4. package/bundle/api/RetailAPI/updateUserProfile.d.ts +1 -2
  5. package/bundle/bundle.umd.js +104 -48
  6. package/bundle/bundle.umd.min.js +1 -1
  7. package/bundle/components/ApplicationLeadForm/applicationFormData.d.ts +2 -0
  8. package/dist/api/RetailAPI/getCardTypes.d.ts +1 -1
  9. package/dist/api/RetailAPI/getCardTypes.js +3 -4
  10. package/dist/api/RetailAPI/getCardTypes.js.map +1 -1
  11. package/dist/api/RetailAPI/getGenderFromName.d.ts +1 -0
  12. package/dist/api/RetailAPI/getGenderFromName.js +15 -0
  13. package/dist/api/RetailAPI/getGenderFromName.js.map +1 -0
  14. package/dist/api/RetailAPI/getPaymentSystems.d.ts +1 -1
  15. package/dist/api/RetailAPI/getPaymentSystems.js +3 -4
  16. package/dist/api/RetailAPI/getPaymentSystems.js.map +1 -1
  17. package/dist/api/RetailAPI/updateUserProfile.d.ts +1 -2
  18. package/dist/api/RetailAPI/updateUserProfile.js +1 -1
  19. package/dist/api/RetailAPI/updateUserProfile.js.map +1 -1
  20. package/dist/api/RetailAPI/utils/getUpdateUserProfile.js +2 -2
  21. package/dist/api/RetailAPI/utils/getUpdateUserProfile.js.map +1 -1
  22. package/dist/components/ApplicationLeadForm/ApplicationLeadForm.js +4 -3
  23. package/dist/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  24. package/dist/components/ApplicationLeadForm/applicationFormData.d.ts +2 -0
  25. package/dist/components/ApplicationLeadForm/applicationFormData.js +25 -0
  26. package/dist/components/ApplicationLeadForm/applicationFormData.js.map +1 -0
  27. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +11 -6
  28. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  29. package/dist/ui-kit/FormField/Fields/CardCategoryField.js +13 -4
  30. package/dist/ui-kit/FormField/Fields/CardCategoryField.js.map +1 -1
  31. package/dist/ui-kit/FormField/Fields/MiddleNameField.js +1 -10
  32. package/dist/ui-kit/FormField/Fields/MiddleNameField.js.map +1 -1
  33. package/dist/ui-kit/FormField/Fields/PaymentSystemField.js +8 -4
  34. package/dist/ui-kit/FormField/Fields/PaymentSystemField.js.map +1 -1
  35. package/dist/ui-kit/FormField/Fields/SexField.js +17 -1
  36. package/dist/ui-kit/FormField/Fields/SexField.js.map +1 -1
  37. package/dist/ui-kit/FormField/getObjectValidator.js +2 -0
  38. package/dist/ui-kit/FormField/getObjectValidator.js.map +1 -1
  39. package/lib/api/RetailAPI/getCardTypes.d.ts +1 -1
  40. package/lib/api/RetailAPI/getCardTypes.js +4 -5
  41. package/lib/api/RetailAPI/getCardTypes.js.map +1 -1
  42. package/lib/api/RetailAPI/getGenderFromName.d.ts +1 -0
  43. package/lib/api/RetailAPI/getGenderFromName.js +12 -0
  44. package/lib/api/RetailAPI/getGenderFromName.js.map +1 -0
  45. package/lib/api/RetailAPI/getPaymentSystems.d.ts +1 -1
  46. package/lib/api/RetailAPI/getPaymentSystems.js +4 -5
  47. package/lib/api/RetailAPI/getPaymentSystems.js.map +1 -1
  48. package/lib/api/RetailAPI/updateUserProfile.d.ts +1 -2
  49. package/lib/api/RetailAPI/updateUserProfile.js +2 -2
  50. package/lib/api/RetailAPI/updateUserProfile.js.map +1 -1
  51. package/lib/api/RetailAPI/utils/getUpdateUserProfile.js +2 -2
  52. package/lib/api/RetailAPI/utils/getUpdateUserProfile.js.map +1 -1
  53. package/lib/components/ApplicationLeadForm/ApplicationLeadForm.js +4 -3
  54. package/lib/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  55. package/lib/components/ApplicationLeadForm/applicationFormData.d.ts +2 -0
  56. package/lib/components/ApplicationLeadForm/applicationFormData.js +23 -0
  57. package/lib/components/ApplicationLeadForm/applicationFormData.js.map +1 -0
  58. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +11 -6
  59. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  60. package/lib/ui-kit/FormField/Fields/CardCategoryField.js +13 -4
  61. package/lib/ui-kit/FormField/Fields/CardCategoryField.js.map +1 -1
  62. package/lib/ui-kit/FormField/Fields/MiddleNameField.js +1 -10
  63. package/lib/ui-kit/FormField/Fields/MiddleNameField.js.map +1 -1
  64. package/lib/ui-kit/FormField/Fields/PaymentSystemField.js +8 -4
  65. package/lib/ui-kit/FormField/Fields/PaymentSystemField.js.map +1 -1
  66. package/lib/ui-kit/FormField/Fields/SexField.js +17 -1
  67. package/lib/ui-kit/FormField/Fields/SexField.js.map +1 -1
  68. package/lib/ui-kit/FormField/getObjectValidator.js +2 -0
  69. package/lib/ui-kit/FormField/getObjectValidator.js.map +1 -1
  70. package/mobile/bundle/api/RetailAPI/getCardTypes.d.ts +1 -1
  71. package/mobile/bundle/api/RetailAPI/getGenderFromName.d.ts +1 -0
  72. package/mobile/bundle/api/RetailAPI/getPaymentSystems.d.ts +1 -1
  73. package/mobile/bundle/api/RetailAPI/updateUserProfile.d.ts +1 -2
  74. package/mobile/bundle/bundle.umd.js +104 -48
  75. package/mobile/bundle/bundle.umd.min.js +1 -1
  76. package/mobile/bundle/components/ApplicationLeadForm/applicationFormData.d.ts +2 -0
  77. package/mobile/dist/api/RetailAPI/getCardTypes.d.ts +1 -1
  78. package/mobile/dist/api/RetailAPI/getCardTypes.js +3 -4
  79. package/mobile/dist/api/RetailAPI/getCardTypes.js.map +1 -1
  80. package/mobile/dist/api/RetailAPI/getGenderFromName.d.ts +1 -0
  81. package/mobile/dist/api/RetailAPI/getGenderFromName.js +15 -0
  82. package/mobile/dist/api/RetailAPI/getGenderFromName.js.map +1 -0
  83. package/mobile/dist/api/RetailAPI/getPaymentSystems.d.ts +1 -1
  84. package/mobile/dist/api/RetailAPI/getPaymentSystems.js +3 -4
  85. package/mobile/dist/api/RetailAPI/getPaymentSystems.js.map +1 -1
  86. package/mobile/dist/api/RetailAPI/updateUserProfile.d.ts +1 -2
  87. package/mobile/dist/api/RetailAPI/updateUserProfile.js +1 -1
  88. package/mobile/dist/api/RetailAPI/updateUserProfile.js.map +1 -1
  89. package/mobile/dist/api/RetailAPI/utils/getUpdateUserProfile.js +2 -2
  90. package/mobile/dist/api/RetailAPI/utils/getUpdateUserProfile.js.map +1 -1
  91. package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadForm.js +4 -3
  92. package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  93. package/mobile/dist/components/ApplicationLeadForm/applicationFormData.d.ts +2 -0
  94. package/mobile/dist/components/ApplicationLeadForm/applicationFormData.js +25 -0
  95. package/mobile/dist/components/ApplicationLeadForm/applicationFormData.js.map +1 -0
  96. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +11 -6
  97. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  98. package/mobile/dist/ui-kit/FormField/Fields/CardCategoryField.js +13 -4
  99. package/mobile/dist/ui-kit/FormField/Fields/CardCategoryField.js.map +1 -1
  100. package/mobile/dist/ui-kit/FormField/Fields/MiddleNameField.js +1 -10
  101. package/mobile/dist/ui-kit/FormField/Fields/MiddleNameField.js.map +1 -1
  102. package/mobile/dist/ui-kit/FormField/Fields/PaymentSystemField.js +8 -4
  103. package/mobile/dist/ui-kit/FormField/Fields/PaymentSystemField.js.map +1 -1
  104. package/mobile/dist/ui-kit/FormField/Fields/SexField.js +17 -1
  105. package/mobile/dist/ui-kit/FormField/Fields/SexField.js.map +1 -1
  106. package/mobile/dist/ui-kit/FormField/getObjectValidator.js +2 -0
  107. package/mobile/dist/ui-kit/FormField/getObjectValidator.js.map +1 -1
  108. package/mobile/lib/api/RetailAPI/getCardTypes.d.ts +1 -1
  109. package/mobile/lib/api/RetailAPI/getCardTypes.js +4 -5
  110. package/mobile/lib/api/RetailAPI/getCardTypes.js.map +1 -1
  111. package/mobile/lib/api/RetailAPI/getGenderFromName.d.ts +1 -0
  112. package/mobile/lib/api/RetailAPI/getGenderFromName.js +12 -0
  113. package/mobile/lib/api/RetailAPI/getGenderFromName.js.map +1 -0
  114. package/mobile/lib/api/RetailAPI/getPaymentSystems.d.ts +1 -1
  115. package/mobile/lib/api/RetailAPI/getPaymentSystems.js +4 -5
  116. package/mobile/lib/api/RetailAPI/getPaymentSystems.js.map +1 -1
  117. package/mobile/lib/api/RetailAPI/updateUserProfile.d.ts +1 -2
  118. package/mobile/lib/api/RetailAPI/updateUserProfile.js +2 -2
  119. package/mobile/lib/api/RetailAPI/updateUserProfile.js.map +1 -1
  120. package/mobile/lib/api/RetailAPI/utils/getUpdateUserProfile.js +2 -2
  121. package/mobile/lib/api/RetailAPI/utils/getUpdateUserProfile.js.map +1 -1
  122. package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadForm.js +4 -3
  123. package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  124. package/mobile/lib/components/ApplicationLeadForm/applicationFormData.d.ts +2 -0
  125. package/mobile/lib/components/ApplicationLeadForm/applicationFormData.js +23 -0
  126. package/mobile/lib/components/ApplicationLeadForm/applicationFormData.js.map +1 -0
  127. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +11 -6
  128. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  129. package/mobile/lib/ui-kit/FormField/Fields/CardCategoryField.js +13 -4
  130. package/mobile/lib/ui-kit/FormField/Fields/CardCategoryField.js.map +1 -1
  131. package/mobile/lib/ui-kit/FormField/Fields/MiddleNameField.js +1 -10
  132. package/mobile/lib/ui-kit/FormField/Fields/MiddleNameField.js.map +1 -1
  133. package/mobile/lib/ui-kit/FormField/Fields/PaymentSystemField.js +8 -4
  134. package/mobile/lib/ui-kit/FormField/Fields/PaymentSystemField.js.map +1 -1
  135. package/mobile/lib/ui-kit/FormField/Fields/SexField.js +17 -1
  136. package/mobile/lib/ui-kit/FormField/Fields/SexField.js.map +1 -1
  137. package/mobile/lib/ui-kit/FormField/getObjectValidator.js +2 -0
  138. package/mobile/lib/ui-kit/FormField/getObjectValidator.js.map +1 -1
  139. package/mobile/src/api/RetailAPI/getCardTypes.ts +4 -6
  140. package/mobile/src/api/RetailAPI/getGenderFromName.ts +20 -0
  141. package/mobile/src/api/RetailAPI/getPaymentSystems.ts +9 -7
  142. package/mobile/src/api/RetailAPI/updateUserProfile.ts +2 -3
  143. package/mobile/src/api/RetailAPI/utils/getUpdateUserProfile.ts +2 -2
  144. package/mobile/src/components/ApplicationLeadForm/ApplicationLeadForm.tsx +4 -11
  145. package/mobile/src/components/ApplicationLeadForm/applicationFormData.tsx +24 -0
  146. package/mobile/src/components/ApplicationLeadForm/useApplicationLeadApi.ts +12 -8
  147. package/mobile/src/ui-kit/FormField/Fields/CardCategoryField.tsx +17 -4
  148. package/mobile/src/ui-kit/FormField/Fields/MiddleNameField.tsx +9 -22
  149. package/mobile/src/ui-kit/FormField/Fields/PaymentSystemField.tsx +8 -4
  150. package/mobile/src/ui-kit/FormField/Fields/SexField.tsx +26 -8
  151. package/mobile/src/ui-kit/FormField/getObjectValidator.tsx +2 -0
  152. package/package.json +1 -1
  153. package/src/api/RetailAPI/getCardTypes.ts +4 -6
  154. package/src/api/RetailAPI/getGenderFromName.ts +20 -0
  155. package/src/api/RetailAPI/getPaymentSystems.ts +9 -7
  156. package/src/api/RetailAPI/updateUserProfile.ts +2 -3
  157. package/src/api/RetailAPI/utils/getUpdateUserProfile.ts +2 -2
  158. package/src/components/ApplicationLeadForm/ApplicationLeadForm.fixture.tsx +1 -23
  159. package/src/components/ApplicationLeadForm/ApplicationLeadForm.tsx +4 -11
  160. package/src/components/ApplicationLeadForm/applicationFormData.tsx +24 -0
  161. package/src/components/ApplicationLeadForm/useApplicationLeadApi.ts +12 -8
  162. package/src/ui-kit/FormField/Fields/CardCategoryField.tsx +17 -4
  163. package/src/ui-kit/FormField/Fields/MiddleNameField.tsx +9 -22
  164. package/src/ui-kit/FormField/Fields/PaymentSystemField.tsx +8 -4
  165. package/src/ui-kit/FormField/Fields/SexField.tsx +26 -8
  166. package/src/ui-kit/FormField/getObjectValidator.tsx +2 -0
@@ -1,4 +1,6 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
+ import { useEffect } from '@redneckz/uni-jsx/lib/hooks';
3
+ import { getGenderFromName } from '../../../api/RetailAPI/getGenderFromName';
2
4
  import { type RadioButtonItem } from '../../RadioButtonGroup/RadioButtonGroup';
3
5
  import { RadioButtonGroupControl } from '../../RadioButtonGroup/RadioButtonGroupControl';
4
6
  import { type CustomFieldProps } from '../CustomFieldProps';
@@ -10,11 +12,27 @@ export const SEX_TYPES: RadioButtonItem[] = [
10
12
  { id: 'female', text: 'Женский' },
11
13
  ];
12
14
 
13
- export const SexField = JSX<CustomFieldProps>(({ field, input }) => (
14
- <RadioButtonGroupControl
15
- label="Пол"
16
- orientation="horizontal"
17
- items={SEX_TYPES}
18
- {...getValidation(field('sex'), validatorObj.sex, input?.required)}
19
- />
20
- ));
15
+ export const SexField = JSX<CustomFieldProps>(({ field, input }) => {
16
+ const name = field('name')?.value;
17
+ const { value: selectedSex, onChange: changeSex } = field('sex');
18
+
19
+ useEffect(() => {
20
+ if (name && !selectedSex) {
21
+ (async () => {
22
+ const gender = await getGenderFromName(name as string);
23
+ if (gender) {
24
+ changeSex?.(gender);
25
+ }
26
+ })();
27
+ }
28
+ }, []);
29
+
30
+ return (
31
+ <RadioButtonGroupControl
32
+ label="Пол"
33
+ orientation="horizontal"
34
+ items={SEX_TYPES}
35
+ {...getValidation(field('sex'), validatorObj.sex, input?.required)}
36
+ />
37
+ );
38
+ });
@@ -105,6 +105,8 @@ export const validatorObj: Record<string, Validator> = {
105
105
  confirmationIncome: defaultValidator(),
106
106
  deliveryDate: defaultValidator('Укажите дату доставки'),
107
107
  addressCourier: addressDaDataValidator(),
108
+ cardCategory: defaultValidator('Укажите категорию карты'),
109
+ paymentSystem: defaultValidator('Укажите тип платежной системы'),
108
110
  };
109
111
 
110
112
  export const getObjectValidator = (inputs: FieldDef[]): Record<string, Validator> => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.14.684",
3
+ "version": "0.14.686",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -1,4 +1,4 @@
1
- import { doRequest } from './doRequest';
1
+ import { fetchRetailJSON } from './doRequest';
2
2
 
3
3
  export type CardTypeData = {
4
4
  type: string;
@@ -8,13 +8,11 @@ export type CardTypeData = {
8
8
  description: string;
9
9
  };
10
10
 
11
- export const getCardTypes = async (paymentSystemType: string) => {
12
- const response: Response = await doRequest('/dictionaryFiltered', 'POST', {
11
+ export const getCardTypes = async (paymentSystemTypeCd: string, creditProgramId: string) => {
12
+ const data = await fetchRetailJSON<CardTypeData[]>('/dictionaryFiltered', 'POST', {
13
13
  type: 'CARD_TYPE',
14
- presets: { paymentSystemType, creditProgramId: 13 },
14
+ presets: { paymentSystemTypeCd, creditProgramId },
15
15
  });
16
16
 
17
- const data: CardTypeData[] = await response?.json();
18
-
19
17
  return Array.isArray(data) ? data : [];
20
18
  };
@@ -0,0 +1,20 @@
1
+ import { type DaDataSuggestion } from '../dadataHints/dadataHintsType';
2
+ import { fetchRetailJSON } from './doRequest';
3
+
4
+ const GENDERS = ['male', 'female'];
5
+
6
+ export const getGenderFromName = async (name: string): Promise<string> => {
7
+ const res = await fetchRetailJSON<{ suggestions: Array<DaDataSuggestion> }>(
8
+ '/suggestions/suggest/fio',
9
+ 'POST',
10
+ {
11
+ query: name,
12
+ count: 1,
13
+ parts: ['NAME'],
14
+ },
15
+ );
16
+
17
+ const gender = res?.suggestions[0]?.data?.gender?.toLowerCase() || '';
18
+
19
+ return GENDERS.includes(gender) ? gender : '';
20
+ };
@@ -1,4 +1,4 @@
1
- import { doRequest } from './doRequest';
1
+ import { fetchRetailJSON } from './doRequest';
2
2
 
3
3
  type PaymentSystemResponse = {
4
4
  paymentSystems?: {
@@ -7,12 +7,14 @@ type PaymentSystemResponse = {
7
7
  }[];
8
8
  };
9
9
 
10
- export const getPaymentSystems = async () => {
11
- const response: Response = await doRequest('/public-data/creditProgramConditions', 'POST', {
12
- creditProgramId: 13,
13
- });
14
-
15
- const data: PaymentSystemResponse = await response?.json();
10
+ export const getPaymentSystems = async (creditProgramId: string) => {
11
+ const data = await fetchRetailJSON<PaymentSystemResponse>(
12
+ '/public-data/creditProgramConditions',
13
+ 'POST',
14
+ {
15
+ creditProgramId,
16
+ },
17
+ );
16
18
 
17
19
  return (
18
20
  data?.paymentSystems?.map((paymentSystem) => ({
@@ -1,5 +1,4 @@
1
- import { fetchRetailJSON } from './doRequest';
2
- import { type CreateUserProfileResponse } from './updateUserTask';
1
+ import { doRequest } from './doRequest';
3
2
 
4
3
  export type UpdateUserProfileBody = {
5
4
  profile: {
@@ -23,4 +22,4 @@ export type UpdateUserProfileBody = {
23
22
  };
24
23
 
25
24
  export const updateUserProfile = (body: UpdateUserProfileBody) =>
26
- fetchRetailJSON<CreateUserProfileResponse>('/user-data/updateUserProfile', 'PUT', body);
25
+ doRequest('/user-data/updateUserProfile', 'PUT', body);
@@ -11,7 +11,7 @@ export const getUpdateUserProfileData = (
11
11
  name = '',
12
12
  surname = '',
13
13
  middleName = '',
14
- birthday = '',
14
+ limitedBirthday = '',
15
15
  phone = '',
16
16
  email = '',
17
17
  processPersonalDataFlg,
@@ -29,7 +29,7 @@ export const getUpdateUserProfileData = (
29
29
  name,
30
30
  surname,
31
31
  midname: middleName,
32
- birthDate: birthday && formatDate(birthday, true),
32
+ birthDate: limitedBirthday && formatDate(limitedBirthday, true),
33
33
  email,
34
34
  phone: formatPhone(phone),
35
35
  processPersonalDataFlg: Boolean(processPersonalDataFlg),
@@ -15,30 +15,8 @@ export default {
15
15
  <div className="container grid grid-cols-12">
16
16
  <ApplicationLeadForm
17
17
  className="col-span-12"
18
- title="Заголовок"
18
+ title="Заявка на кредит"
19
19
  programId="10"
20
- sections={[
21
- {
22
- columns: 2,
23
- inputs: [
24
- { fieldType: 'common', name: 'surname', required: true, dadata: true },
25
- { fieldType: 'common', name: 'name', required: true, dadata: true },
26
- { fieldType: 'common', name: 'middleName', dadata: true },
27
- { fieldType: 'common', name: 'limitedBirthday', required: true },
28
- { fieldType: 'common', name: 'phone', required: true },
29
- { fieldType: 'common', name: 'email', required: true, dadata: true },
30
- ],
31
- },
32
- {
33
- inputs: [
34
- { fieldType: 'common', name: 'processPersonalDataFlg', required: true },
35
- { fieldType: 'common', name: 'consentProviderFlg', required: true },
36
- { fieldType: 'common', name: 'consentOthersFlg', required: true },
37
- { fieldType: 'common', name: 'consentInformFlg' },
38
- { fieldType: 'common', name: 'consentPfrFlg' },
39
- ],
40
- },
41
- ]}
42
20
  button={button}
43
21
  />
44
22
  <PopupManager />
@@ -10,6 +10,7 @@ import { useResponseTypeDialog } from '../../ui-kit/ResponseTypeDialog/useRespon
10
10
  import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
11
11
  import { style } from '../../utils/style';
12
12
  import { renderInputs } from '../ApplicationForm/renderInputs';
13
+ import { applicationFormData } from './applicationFormData';
13
14
  import { type ApplicationLeadFormContent, type FieldDef } from './ApplicationLeadFormContent';
14
15
  import { getInitialFormState, type FormState } from './getInitialFormState';
15
16
  import { renderSubmitButton } from './renderSubmitButton';
@@ -19,16 +20,8 @@ import { useInitApplicationLead } from './useInitApplicationLead';
19
20
  interface ApplicationLeadFormProps extends ApplicationLeadFormContent, UniBlockProps {}
20
21
 
21
22
  export const ApplicationLeadForm = JSX<ApplicationLeadFormProps>(
22
- ({
23
- className,
24
- title,
25
- programId = '',
26
- nextStepLink = '/credit-lead',
27
- sections = [],
28
- button,
29
- ...rest
30
- }) => {
31
- const inputs = (sections?.flatMap((_) => _?.inputs) || []) as FieldDef[];
23
+ ({ className, title, programId = '', nextStepLink = '/credit-lead', button, ...rest }) => {
24
+ const inputs = (applicationFormData?.flatMap((_) => _?.inputs) || []) as FieldDef[];
32
25
  const [responseType, setResponseType] = useState<'OK' | 'Fail' | ''>('');
33
26
 
34
27
  const { isLoading } = useInitApplicationLead(nextStepLink);
@@ -63,7 +56,7 @@ export const ApplicationLeadForm = JSX<ApplicationLeadFormProps>(
63
56
  >
64
57
  <form onSubmit={onSubmit} className="space-y-m relative">
65
58
  {isLoading ? <Loader blur={false} /> : null}
66
- {sections.map((_, i) => (
59
+ {applicationFormData.map((_, i) => (
67
60
  <div
68
61
  key={`section-${i}`}
69
62
  className={style(inputColumnStyles(_.columns), 'grid gap-x-m')}
@@ -0,0 +1,24 @@
1
+ import { type SectionsProps } from '../../model/InputSectionsType';
2
+
3
+ export const applicationFormData: SectionsProps[] = [
4
+ {
5
+ columns: 2,
6
+ inputs: [
7
+ { fieldType: 'common', name: 'surname', required: true, dadata: true },
8
+ { fieldType: 'common', name: 'name', required: true, dadata: true },
9
+ { fieldType: 'common', name: 'middleName', dadata: true },
10
+ { fieldType: 'common', name: 'limitedBirthday', required: true },
11
+ { fieldType: 'common', name: 'phone', required: true },
12
+ { fieldType: 'common', name: 'email', required: true, dadata: true },
13
+ ],
14
+ },
15
+ {
16
+ inputs: [
17
+ { fieldType: 'common', name: 'processPersonalDataFlg', required: true },
18
+ { fieldType: 'common', name: 'consentProviderFlg', required: true },
19
+ { fieldType: 'common', name: 'consentOthersFlg', required: true },
20
+ { fieldType: 'common', name: 'consentInformFlg' },
21
+ { fieldType: 'common', name: 'consentPfrFlg' },
22
+ ],
23
+ },
24
+ ];
@@ -127,14 +127,18 @@ const updateUserData = async ({
127
127
  programId,
128
128
  });
129
129
 
130
- await updateUserTask(
131
- getLeadFormTaskData({
132
- participantId,
133
- taskId,
134
- profileId,
135
- formData: transformedForm,
136
- }),
137
- );
130
+ try {
131
+ await updateUserTask(
132
+ getLeadFormTaskData({
133
+ participantId,
134
+ taskId,
135
+ profileId,
136
+ formData: transformedForm,
137
+ }),
138
+ );
139
+ } catch (ex) {
140
+ console.log(ex);
141
+ }
138
142
 
139
143
  saveUserData({ participantId, taskId, profileId, programId });
140
144
  saveForm(formData);
@@ -1,18 +1,28 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
2
  import { useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
3
3
  import { getCardTypes, type CardTypeData } from '../../../api/RetailAPI/getCardTypes';
4
+ import { useLocalStorage } from '../../../hooks/useLocalStorage';
5
+ import { type Option } from '../../Select/Option';
4
6
  import { type CustomFieldProps } from '../CustomFieldProps';
5
7
  import { SelectField } from '../SelectField';
6
8
 
7
9
  export const CardCategoryField = JSX<CustomFieldProps>(({ field, input }) => {
8
10
  const [cardTypes, setCardTypes] = useState<CardTypeData[]>([]);
11
+ const [programId] = useLocalStorage<string>('programId');
12
+ const { value: selectedCardCategory, onChange: cardCategoryChange } = field('cardCategory');
9
13
  const selectedPaymentSystem = field('paymentSystem').value;
10
14
 
11
15
  useEffect(() => {
12
- (async () => {
13
- const fetchedCardTypes = await getCardTypes(selectedPaymentSystem as string);
14
- setCardTypes(fetchedCardTypes);
15
- })();
16
+ if (selectedPaymentSystem && programId) {
17
+ (async () => {
18
+ const fetchedCardTypes = await getCardTypes(selectedPaymentSystem as string, programId);
19
+ setCardTypes(fetchedCardTypes);
20
+
21
+ if (!isValidCardCategory(fetchedCardTypes, selectedCardCategory as Option)) {
22
+ cardCategoryChange && cardCategoryChange(null);
23
+ }
24
+ })();
25
+ }
16
26
  }, [selectedPaymentSystem]);
17
27
 
18
28
  return (
@@ -25,3 +35,6 @@ export const CardCategoryField = JSX<CustomFieldProps>(({ field, input }) => {
25
35
  />
26
36
  );
27
37
  });
38
+
39
+ const isValidCardCategory = (cardTypes: CardTypeData[], selectedCardCategory: Option | null) =>
40
+ cardTypes.some((cardType) => cardType.key === selectedCardCategory?.key);
@@ -1,6 +1,4 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import { useCallback } from '@redneckz/uni-jsx/lib/hooks';
3
- import { type DaDataSuggestion } from '../../../api/dadataHints/dadataHintsType';
4
2
  import { InputControl } from '../../Input/InputControl';
5
3
  import { type CustomFieldProps } from '../CustomFieldProps';
6
4
  import { validatorObj } from '../getObjectValidator';
@@ -9,23 +7,12 @@ import { isEsiaAuthorize } from '../isEsiaAuthorize';
9
7
 
10
8
  const FIELD_NAME = 'middleName';
11
9
 
12
- export const MiddleNameField = JSX<CustomFieldProps>(({ field, input }) => {
13
- const onDaDataChange = useCallback((item: DaDataSuggestion) => {
14
- const dadataGender = item?.data?.gender;
15
-
16
- if (dadataGender && dadataGender !== 'UNKNOWN') {
17
- field('sex')?.onChange?.(dadataGender.toLowerCase());
18
- }
19
- }, []);
20
-
21
- return (
22
- <InputControl
23
- label="Отчество (Обязательно, при наличии)"
24
- maxLength={60}
25
- disabled={input?.filledByEsia && isEsiaAuthorize(field, FIELD_NAME)}
26
- {...getValidation(field(FIELD_NAME), validatorObj.middleName, input?.required)}
27
- {...input}
28
- onDaDataChange={onDaDataChange}
29
- />
30
- );
31
- });
10
+ export const MiddleNameField = JSX<CustomFieldProps>(({ field, input }) => (
11
+ <InputControl
12
+ label="Отчество (Обязательно, при наличии)"
13
+ maxLength={60}
14
+ disabled={input?.filledByEsia && isEsiaAuthorize(field, FIELD_NAME)}
15
+ {...getValidation(field(FIELD_NAME), validatorObj.middleName, input?.required)}
16
+ {...input}
17
+ />
18
+ ));
@@ -1,6 +1,7 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
2
  import { useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
3
3
  import { getPaymentSystems } from '../../../api/RetailAPI/getPaymentSystems';
4
+ import { useLocalStorage } from '../../../hooks/useLocalStorage';
4
5
  import { type RadioButtonItem } from '../../RadioButtonGroup/RadioButtonGroup';
5
6
  import { RadioButtonGroupControl } from '../../RadioButtonGroup/RadioButtonGroupControl';
6
7
  import { type CustomFieldProps } from '../CustomFieldProps';
@@ -9,14 +10,17 @@ import { getValidation } from '../getValidation';
9
10
 
10
11
  export const PaymentSystemField = JSX<CustomFieldProps>(({ field, input }) => {
11
12
  const { value, onChange } = field('paymentSystem');
13
+ const [programId] = useLocalStorage<string>('programId');
12
14
 
13
15
  const [paymentSystemOptions, setPaymentSystemOptions] = useState<RadioButtonItem[]>([]);
14
16
 
15
17
  useEffect(() => {
16
- (async () => {
17
- const fetchedPaymentSystems = await getPaymentSystems();
18
- setPaymentSystemOptions(fetchedPaymentSystems || []);
19
- })();
18
+ if (programId) {
19
+ (async () => {
20
+ const fetchedPaymentSystems = await getPaymentSystems(programId);
21
+ setPaymentSystemOptions(fetchedPaymentSystems || []);
22
+ })();
23
+ }
20
24
  }, []);
21
25
 
22
26
  return (
@@ -1,4 +1,6 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
+ import { useEffect } from '@redneckz/uni-jsx/lib/hooks';
3
+ import { getGenderFromName } from '../../../api/RetailAPI/getGenderFromName';
2
4
  import { type RadioButtonItem } from '../../RadioButtonGroup/RadioButtonGroup';
3
5
  import { RadioButtonGroupControl } from '../../RadioButtonGroup/RadioButtonGroupControl';
4
6
  import { type CustomFieldProps } from '../CustomFieldProps';
@@ -10,11 +12,27 @@ export const SEX_TYPES: RadioButtonItem[] = [
10
12
  { id: 'female', text: 'Женский' },
11
13
  ];
12
14
 
13
- export const SexField = JSX<CustomFieldProps>(({ field, input }) => (
14
- <RadioButtonGroupControl
15
- label="Пол"
16
- orientation="horizontal"
17
- items={SEX_TYPES}
18
- {...getValidation(field('sex'), validatorObj.sex, input?.required)}
19
- />
20
- ));
15
+ export const SexField = JSX<CustomFieldProps>(({ field, input }) => {
16
+ const name = field('name')?.value;
17
+ const { value: selectedSex, onChange: changeSex } = field('sex');
18
+
19
+ useEffect(() => {
20
+ if (name && !selectedSex) {
21
+ (async () => {
22
+ const gender = await getGenderFromName(name as string);
23
+ if (gender) {
24
+ changeSex?.(gender);
25
+ }
26
+ })();
27
+ }
28
+ }, []);
29
+
30
+ return (
31
+ <RadioButtonGroupControl
32
+ label="Пол"
33
+ orientation="horizontal"
34
+ items={SEX_TYPES}
35
+ {...getValidation(field('sex'), validatorObj.sex, input?.required)}
36
+ />
37
+ );
38
+ });
@@ -105,6 +105,8 @@ export const validatorObj: Record<string, Validator> = {
105
105
  confirmationIncome: defaultValidator(),
106
106
  deliveryDate: defaultValidator('Укажите дату доставки'),
107
107
  addressCourier: addressDaDataValidator(),
108
+ cardCategory: defaultValidator('Укажите категорию карты'),
109
+ paymentSystem: defaultValidator('Укажите тип платежной системы'),
108
110
  };
109
111
 
110
112
  export const getObjectValidator = (inputs: FieldDef[]): Record<string, Validator> => {