@redneckz/wildless-cms-uni-blocks 0.14.685 → 0.14.687

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 (88) hide show
  1. package/bundle/api/RetailAPI/getGenderFromName.d.ts +1 -0
  2. package/bundle/bundle.umd.js +57 -19
  3. package/bundle/bundle.umd.min.js +1 -1
  4. package/bundle/components/ApplicationLeadForm/applicationFormData.d.ts +2 -0
  5. package/dist/api/RetailAPI/getGenderFromName.d.ts +1 -0
  6. package/dist/api/RetailAPI/getGenderFromName.js +15 -0
  7. package/dist/api/RetailAPI/getGenderFromName.js.map +1 -0
  8. package/dist/components/ApplicationLeadForm/ApplicationLeadForm.js +4 -3
  9. package/dist/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  10. package/dist/components/ApplicationLeadForm/applicationFormData.d.ts +2 -0
  11. package/dist/components/ApplicationLeadForm/applicationFormData.js +25 -0
  12. package/dist/components/ApplicationLeadForm/applicationFormData.js.map +1 -0
  13. package/dist/components/CreditForm/calculateInputs.js +2 -1
  14. package/dist/components/CreditForm/calculateInputs.js.map +1 -1
  15. package/dist/ui-kit/FormField/Fields/MiddleNameField.js +1 -10
  16. package/dist/ui-kit/FormField/Fields/MiddleNameField.js.map +1 -1
  17. package/dist/ui-kit/FormField/Fields/SexField.js +17 -1
  18. package/dist/ui-kit/FormField/Fields/SexField.js.map +1 -1
  19. package/dist/ui-kit/FormField/Fields/SnilsField.js +1 -4
  20. package/dist/ui-kit/FormField/Fields/SnilsField.js.map +1 -1
  21. package/lib/api/RetailAPI/getGenderFromName.d.ts +1 -0
  22. package/lib/api/RetailAPI/getGenderFromName.js +12 -0
  23. package/lib/api/RetailAPI/getGenderFromName.js.map +1 -0
  24. package/lib/components/ApplicationLeadForm/ApplicationLeadForm.js +4 -3
  25. package/lib/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  26. package/lib/components/ApplicationLeadForm/applicationFormData.d.ts +2 -0
  27. package/lib/components/ApplicationLeadForm/applicationFormData.js +23 -0
  28. package/lib/components/ApplicationLeadForm/applicationFormData.js.map +1 -0
  29. package/lib/components/CreditForm/calculateInputs.js +2 -1
  30. package/lib/components/CreditForm/calculateInputs.js.map +1 -1
  31. package/lib/ui-kit/FormField/Fields/MiddleNameField.js +1 -10
  32. package/lib/ui-kit/FormField/Fields/MiddleNameField.js.map +1 -1
  33. package/lib/ui-kit/FormField/Fields/SexField.js +17 -1
  34. package/lib/ui-kit/FormField/Fields/SexField.js.map +1 -1
  35. package/lib/ui-kit/FormField/Fields/SnilsField.js +1 -4
  36. package/lib/ui-kit/FormField/Fields/SnilsField.js.map +1 -1
  37. package/mobile/bundle/api/RetailAPI/getGenderFromName.d.ts +1 -0
  38. package/mobile/bundle/bundle.umd.js +57 -19
  39. package/mobile/bundle/bundle.umd.min.js +1 -1
  40. package/mobile/bundle/components/ApplicationLeadForm/applicationFormData.d.ts +2 -0
  41. package/mobile/dist/api/RetailAPI/getGenderFromName.d.ts +1 -0
  42. package/mobile/dist/api/RetailAPI/getGenderFromName.js +15 -0
  43. package/mobile/dist/api/RetailAPI/getGenderFromName.js.map +1 -0
  44. package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadForm.js +4 -3
  45. package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  46. package/mobile/dist/components/ApplicationLeadForm/applicationFormData.d.ts +2 -0
  47. package/mobile/dist/components/ApplicationLeadForm/applicationFormData.js +25 -0
  48. package/mobile/dist/components/ApplicationLeadForm/applicationFormData.js.map +1 -0
  49. package/mobile/dist/components/CreditForm/calculateInputs.js +2 -1
  50. package/mobile/dist/components/CreditForm/calculateInputs.js.map +1 -1
  51. package/mobile/dist/ui-kit/FormField/Fields/MiddleNameField.js +1 -10
  52. package/mobile/dist/ui-kit/FormField/Fields/MiddleNameField.js.map +1 -1
  53. package/mobile/dist/ui-kit/FormField/Fields/SexField.js +17 -1
  54. package/mobile/dist/ui-kit/FormField/Fields/SexField.js.map +1 -1
  55. package/mobile/dist/ui-kit/FormField/Fields/SnilsField.js +1 -4
  56. package/mobile/dist/ui-kit/FormField/Fields/SnilsField.js.map +1 -1
  57. package/mobile/lib/api/RetailAPI/getGenderFromName.d.ts +1 -0
  58. package/mobile/lib/api/RetailAPI/getGenderFromName.js +12 -0
  59. package/mobile/lib/api/RetailAPI/getGenderFromName.js.map +1 -0
  60. package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadForm.js +4 -3
  61. package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  62. package/mobile/lib/components/ApplicationLeadForm/applicationFormData.d.ts +2 -0
  63. package/mobile/lib/components/ApplicationLeadForm/applicationFormData.js +23 -0
  64. package/mobile/lib/components/ApplicationLeadForm/applicationFormData.js.map +1 -0
  65. package/mobile/lib/components/CreditForm/calculateInputs.js +2 -1
  66. package/mobile/lib/components/CreditForm/calculateInputs.js.map +1 -1
  67. package/mobile/lib/ui-kit/FormField/Fields/MiddleNameField.js +1 -10
  68. package/mobile/lib/ui-kit/FormField/Fields/MiddleNameField.js.map +1 -1
  69. package/mobile/lib/ui-kit/FormField/Fields/SexField.js +17 -1
  70. package/mobile/lib/ui-kit/FormField/Fields/SexField.js.map +1 -1
  71. package/mobile/lib/ui-kit/FormField/Fields/SnilsField.js +1 -4
  72. package/mobile/lib/ui-kit/FormField/Fields/SnilsField.js.map +1 -1
  73. package/mobile/src/api/RetailAPI/getGenderFromName.ts +20 -0
  74. package/mobile/src/components/ApplicationLeadForm/ApplicationLeadForm.tsx +4 -11
  75. package/mobile/src/components/ApplicationLeadForm/applicationFormData.tsx +24 -0
  76. package/mobile/src/components/CreditForm/calculateInputs.ts +4 -1
  77. package/mobile/src/ui-kit/FormField/Fields/MiddleNameField.tsx +9 -22
  78. package/mobile/src/ui-kit/FormField/Fields/SexField.tsx +26 -8
  79. package/mobile/src/ui-kit/FormField/Fields/SnilsField.tsx +7 -11
  80. package/package.json +1 -1
  81. package/src/api/RetailAPI/getGenderFromName.ts +20 -0
  82. package/src/components/ApplicationLeadForm/ApplicationLeadForm.fixture.tsx +1 -23
  83. package/src/components/ApplicationLeadForm/ApplicationLeadForm.tsx +4 -11
  84. package/src/components/ApplicationLeadForm/applicationFormData.tsx +24 -0
  85. package/src/components/CreditForm/calculateInputs.ts +4 -1
  86. package/src/ui-kit/FormField/Fields/MiddleNameField.tsx +9 -22
  87. package/src/ui-kit/FormField/Fields/SexField.tsx +26 -8
  88. package/src/ui-kit/FormField/Fields/SnilsField.tsx +7 -11
@@ -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
+ });
@@ -4,14 +4,10 @@ import { type CustomFieldProps } from '../CustomFieldProps';
4
4
  import { validatorObj } from '../getObjectValidator';
5
5
  import { getValidation } from '../getValidation';
6
6
 
7
- export const SnilsField = JSX<CustomFieldProps>(({ field, input }) => {
8
- const isPfrFlg = field('consentPfrFlg')?.value;
9
-
10
- return (
11
- <InputSnilsControl
12
- label="СНИЛС"
13
- {...getValidation(field('snils'), validatorObj.snils, isPfrFlg ? input?.required : false)}
14
- {...input}
15
- />
16
- );
17
- });
7
+ export const SnilsField = JSX<CustomFieldProps>(({ field, input }) => (
8
+ <InputSnilsControl
9
+ label="СНИЛС"
10
+ {...getValidation(field('snils'), validatorObj.snils, input?.required)}
11
+ {...input}
12
+ />
13
+ ));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.14.685",
3
+ "version": "0.14.687",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -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
+ };
@@ -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
+ ];
@@ -31,7 +31,7 @@ const checkBusinessOwner = ({ name }: FieldDef, getValue: GetValue) =>
31
31
  name === 'partInBusiness' && getValue('positionOrganization')?.key !== 'BUSINESS_OWNER';
32
32
 
33
33
  const checkConsentPfrFlg = ({ name }: FieldDef, getValue: GetValue) =>
34
- name === 'snils' && !getValue('consentPfrFlg');
34
+ name === 'snils' && isSnilsRequired(getValue);
35
35
 
36
36
  const checkAddressFillFromESIA = ({ name, filledByEsia }: FieldDef, getValue: GetValue) =>
37
37
  name?.startsWith('address') && getValue('esiaAccountTypeCd')?.key && filledByEsia;
@@ -46,3 +46,6 @@ export const checkCondition = ({ condition }: FieldDef, getValue: GetValue) =>
46
46
 
47
47
  return _ !== ((dataValue as Option)?.key ?? dataValue);
48
48
  });
49
+
50
+ const isSnilsRequired = (getValue: GetValue) =>
51
+ getValue('confirmationIncome')?.key !== 'PFR_CERTIFICATE';
@@ -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,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
+ });
@@ -4,14 +4,10 @@ import { type CustomFieldProps } from '../CustomFieldProps';
4
4
  import { validatorObj } from '../getObjectValidator';
5
5
  import { getValidation } from '../getValidation';
6
6
 
7
- export const SnilsField = JSX<CustomFieldProps>(({ field, input }) => {
8
- const isPfrFlg = field('consentPfrFlg')?.value;
9
-
10
- return (
11
- <InputSnilsControl
12
- label="СНИЛС"
13
- {...getValidation(field('snils'), validatorObj.snils, isPfrFlg ? input?.required : false)}
14
- {...input}
15
- />
16
- );
17
- });
7
+ export const SnilsField = JSX<CustomFieldProps>(({ field, input }) => (
8
+ <InputSnilsControl
9
+ label="СНИЛС"
10
+ {...getValidation(field('snils'), validatorObj.snils, input?.required)}
11
+ {...input}
12
+ />
13
+ ));