@redneckz/wildless-cms-uni-blocks 0.14.135 → 0.14.136
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.
- package/bundle/blocks.schema.json +1 -1
- package/bundle/bundle.umd.js +294 -211
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/ApplicationForm/ApplicationFormAntiFraud.d.ts +12 -0
- package/bundle/components/ApplicationForm/ApplicationFormContent.d.ts +8 -1
- package/bundle/components/ApplicationForm/ApplicationFormFeedback.d.ts +9 -12
- package/bundle/components/ApplicationForm/EmbeddableForms.d.ts +1 -0
- package/bundle/components/ApplicationForm/handleSubmit.d.ts +16 -0
- package/bundle/components/ApplicationForm/renderUserData.d.ts +8 -1
- package/dist/components/ApplicationForm/ApplicationForm.js +1 -1
- package/dist/components/ApplicationForm/ApplicationForm.js.map +1 -1
- package/dist/components/ApplicationForm/ApplicationFormAntiFraud.d.ts +12 -0
- package/dist/components/ApplicationForm/ApplicationFormAntiFraud.js +49 -0
- package/dist/components/ApplicationForm/ApplicationFormAntiFraud.js.map +1 -0
- package/dist/components/ApplicationForm/ApplicationFormContent.d.ts +8 -1
- package/dist/components/ApplicationForm/ApplicationFormFeedback.d.ts +9 -12
- package/dist/components/ApplicationForm/ApplicationFormFeedback.js +13 -28
- package/dist/components/ApplicationForm/ApplicationFormFeedback.js.map +1 -1
- package/dist/components/ApplicationForm/EmbeddableForms.d.ts +1 -0
- package/dist/components/ApplicationForm/EmbeddableForms.js +2 -0
- package/dist/components/ApplicationForm/EmbeddableForms.js.map +1 -1
- package/dist/components/ApplicationForm/handleSubmit.d.ts +16 -0
- package/dist/components/ApplicationForm/handleSubmit.js +71 -0
- package/dist/components/ApplicationForm/handleSubmit.js.map +1 -0
- package/dist/components/ApplicationForm/renderUserData.d.ts +8 -1
- package/dist/components/ApplicationForm/renderUserData.js.map +1 -1
- package/lib/components/ApplicationForm/ApplicationForm.fixture.d.ts +1 -0
- package/lib/components/ApplicationForm/ApplicationForm.js +1 -1
- package/lib/components/ApplicationForm/ApplicationForm.js.map +1 -1
- package/lib/components/ApplicationForm/ApplicationFormAntiFraud.d.ts +12 -0
- package/lib/components/ApplicationForm/ApplicationFormAntiFraud.js +47 -0
- package/lib/components/ApplicationForm/ApplicationFormAntiFraud.js.map +1 -0
- package/lib/components/ApplicationForm/ApplicationFormContent.d.ts +8 -1
- package/lib/components/ApplicationForm/ApplicationFormFeedback.d.ts +9 -12
- package/lib/components/ApplicationForm/ApplicationFormFeedback.js +14 -29
- package/lib/components/ApplicationForm/ApplicationFormFeedback.js.map +1 -1
- package/lib/components/ApplicationForm/EmbeddableForms.d.ts +1 -0
- package/lib/components/ApplicationForm/EmbeddableForms.js +2 -0
- package/lib/components/ApplicationForm/EmbeddableForms.js.map +1 -1
- package/lib/components/ApplicationForm/handleSubmit.d.ts +16 -0
- package/lib/components/ApplicationForm/handleSubmit.js +66 -0
- package/lib/components/ApplicationForm/handleSubmit.js.map +1 -0
- package/lib/components/ApplicationForm/renderUserData.d.ts +8 -1
- package/lib/components/ApplicationForm/renderUserData.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +294 -211
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/ApplicationForm/ApplicationFormAntiFraud.d.ts +12 -0
- package/mobile/bundle/components/ApplicationForm/ApplicationFormContent.d.ts +8 -1
- package/mobile/bundle/components/ApplicationForm/ApplicationFormFeedback.d.ts +9 -12
- package/mobile/bundle/components/ApplicationForm/EmbeddableForms.d.ts +1 -0
- package/mobile/bundle/components/ApplicationForm/handleSubmit.d.ts +16 -0
- package/mobile/bundle/components/ApplicationForm/renderUserData.d.ts +8 -1
- package/mobile/dist/components/ApplicationForm/ApplicationForm.js +1 -1
- package/mobile/dist/components/ApplicationForm/ApplicationForm.js.map +1 -1
- package/mobile/dist/components/ApplicationForm/ApplicationFormAntiFraud.d.ts +12 -0
- package/mobile/dist/components/ApplicationForm/ApplicationFormAntiFraud.js +49 -0
- package/mobile/dist/components/ApplicationForm/ApplicationFormAntiFraud.js.map +1 -0
- package/mobile/dist/components/ApplicationForm/ApplicationFormContent.d.ts +8 -1
- package/mobile/dist/components/ApplicationForm/ApplicationFormFeedback.d.ts +9 -12
- package/mobile/dist/components/ApplicationForm/ApplicationFormFeedback.js +13 -28
- package/mobile/dist/components/ApplicationForm/ApplicationFormFeedback.js.map +1 -1
- package/mobile/dist/components/ApplicationForm/EmbeddableForms.d.ts +1 -0
- package/mobile/dist/components/ApplicationForm/EmbeddableForms.js +2 -0
- package/mobile/dist/components/ApplicationForm/EmbeddableForms.js.map +1 -1
- package/mobile/dist/components/ApplicationForm/handleSubmit.d.ts +16 -0
- package/mobile/dist/components/ApplicationForm/handleSubmit.js +71 -0
- package/mobile/dist/components/ApplicationForm/handleSubmit.js.map +1 -0
- package/mobile/dist/components/ApplicationForm/renderUserData.d.ts +8 -1
- package/mobile/dist/components/ApplicationForm/renderUserData.js.map +1 -1
- package/mobile/lib/components/ApplicationForm/ApplicationForm.js +1 -1
- package/mobile/lib/components/ApplicationForm/ApplicationForm.js.map +1 -1
- package/mobile/lib/components/ApplicationForm/ApplicationFormAntiFraud.d.ts +12 -0
- package/mobile/lib/components/ApplicationForm/ApplicationFormAntiFraud.js +47 -0
- package/mobile/lib/components/ApplicationForm/ApplicationFormAntiFraud.js.map +1 -0
- package/mobile/lib/components/ApplicationForm/ApplicationFormContent.d.ts +8 -1
- package/mobile/lib/components/ApplicationForm/ApplicationFormFeedback.d.ts +9 -12
- package/mobile/lib/components/ApplicationForm/ApplicationFormFeedback.js +14 -29
- package/mobile/lib/components/ApplicationForm/ApplicationFormFeedback.js.map +1 -1
- package/mobile/lib/components/ApplicationForm/EmbeddableForms.d.ts +1 -0
- package/mobile/lib/components/ApplicationForm/EmbeddableForms.js +2 -0
- package/mobile/lib/components/ApplicationForm/EmbeddableForms.js.map +1 -1
- package/mobile/lib/components/ApplicationForm/handleSubmit.d.ts +16 -0
- package/mobile/lib/components/ApplicationForm/handleSubmit.js +66 -0
- package/mobile/lib/components/ApplicationForm/handleSubmit.js.map +1 -0
- package/mobile/lib/components/ApplicationForm/renderUserData.d.ts +8 -1
- package/mobile/lib/components/ApplicationForm/renderUserData.js.map +1 -1
- package/mobile/src/components/ApplicationForm/ApplicationForm.tsx +6 -9
- package/mobile/src/components/ApplicationForm/ApplicationFormAntiFraud.tsx +86 -0
- package/mobile/src/components/ApplicationForm/ApplicationFormContent.ts +11 -1
- package/mobile/src/components/ApplicationForm/ApplicationFormFeedback.tsx +26 -61
- package/mobile/src/components/ApplicationForm/EmbeddableForms.tsx +2 -0
- package/mobile/src/components/ApplicationForm/handleSubmit.tsx +87 -0
- package/mobile/src/components/ApplicationForm/renderUserData.tsx +11 -1
- package/package.json +2 -2
- package/src/components/ApplicationForm/ApplicationForm.fixture.tsx +14 -0
- package/src/components/ApplicationForm/ApplicationForm.tsx +6 -9
- package/src/components/ApplicationForm/ApplicationFormAntiFraud.tsx +86 -0
- package/src/components/ApplicationForm/ApplicationFormContent.ts +11 -1
- package/src/components/ApplicationForm/ApplicationFormFeedback.tsx +26 -61
- package/src/components/ApplicationForm/EmbeddableForms.tsx +2 -0
- package/src/components/ApplicationForm/handleSubmit.tsx +87 -0
- package/src/components/ApplicationForm/renderUserData.tsx +11 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { objectValidator } from '../../validation/objectValidator';
|
|
2
|
+
import { isValidationSuccess } from '../../validation/validator';
|
|
3
|
+
import { type FeedbackFormState } from './ApplicationFormFeedback';
|
|
4
|
+
import { type ApplicationFormsProps } from './ApplicationFormsProps';
|
|
5
|
+
import {
|
|
6
|
+
consentDataProcessingValidator,
|
|
7
|
+
defaultValidator,
|
|
8
|
+
innValidator,
|
|
9
|
+
nameValidator,
|
|
10
|
+
phoneValidator,
|
|
11
|
+
} from './validators';
|
|
12
|
+
|
|
13
|
+
export const feedbackValidatorDefaultObject = {
|
|
14
|
+
typeForm: defaultValidator,
|
|
15
|
+
region: defaultValidator,
|
|
16
|
+
surname: defaultValidator,
|
|
17
|
+
name: nameValidator,
|
|
18
|
+
feedbackMethod: defaultValidator,
|
|
19
|
+
phone: phoneValidator,
|
|
20
|
+
email: defaultValidator,
|
|
21
|
+
comment: defaultValidator,
|
|
22
|
+
consentDataProcessing: consentDataProcessingValidator,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const handleSubmitIndividual = (
|
|
26
|
+
formState: FeedbackFormState,
|
|
27
|
+
onSubmit: ApplicationFormsProps['onSubmit'],
|
|
28
|
+
) => {
|
|
29
|
+
const feedbackValidator = objectValidator({
|
|
30
|
+
...feedbackValidatorDefaultObject,
|
|
31
|
+
addressBranch: defaultValidator,
|
|
32
|
+
});
|
|
33
|
+
const { region, phone, secondaryPhone } = formState;
|
|
34
|
+
|
|
35
|
+
const submitData = {
|
|
36
|
+
...formState,
|
|
37
|
+
typeForm: formState.typeForm.key,
|
|
38
|
+
addressBranch: formState.addressBranch?.text || '',
|
|
39
|
+
feedbackMethod: formState.feedbackMethod.text,
|
|
40
|
+
regionBranch: region?.text,
|
|
41
|
+
phoneNumber: phone.replace(/[^+\d]/g, ''),
|
|
42
|
+
secondaryPhoneNumber: secondaryPhone,
|
|
43
|
+
};
|
|
44
|
+
isValidationSuccess(feedbackValidator(formState)) && onSubmit(submitData);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const handleSubmitLegal = (
|
|
48
|
+
formState: FeedbackFormState,
|
|
49
|
+
onSubmit: ApplicationFormsProps['onSubmit'],
|
|
50
|
+
) => {
|
|
51
|
+
const feedbackValidator = objectValidator({
|
|
52
|
+
...feedbackValidatorDefaultObject,
|
|
53
|
+
addressBranch: defaultValidator,
|
|
54
|
+
inn: innValidator,
|
|
55
|
+
});
|
|
56
|
+
const { secondaryPhone, email } = formState;
|
|
57
|
+
const submitData = {
|
|
58
|
+
...formState,
|
|
59
|
+
typeForm: formState.typeForm.key,
|
|
60
|
+
region: formState.region?.text,
|
|
61
|
+
addressBranch: formState.addressBranch?.text || '',
|
|
62
|
+
feedbackMethod: formState.feedbackMethod.text,
|
|
63
|
+
phone: formState.phone.replace(/[^+\d]/g, ''),
|
|
64
|
+
secondaryPhoneNumber: secondaryPhone,
|
|
65
|
+
mail: email,
|
|
66
|
+
};
|
|
67
|
+
isValidationSuccess(feedbackValidator(formState)) && onSubmit(submitData, true);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const handleSubmitQuestion = (
|
|
71
|
+
formState: FeedbackFormState,
|
|
72
|
+
onSubmit: ApplicationFormsProps['onSubmit'],
|
|
73
|
+
) => {
|
|
74
|
+
const feedbackValidator = objectValidator({
|
|
75
|
+
...feedbackValidatorDefaultObject,
|
|
76
|
+
birthday: defaultValidator,
|
|
77
|
+
});
|
|
78
|
+
const { region, phone } = formState;
|
|
79
|
+
const submitData = {
|
|
80
|
+
...formState,
|
|
81
|
+
typeForm: formState.typeForm.key,
|
|
82
|
+
feedbackMethod: formState.feedbackMethod.text,
|
|
83
|
+
regionBranch: region?.text,
|
|
84
|
+
phoneNumber: phone.replace(/[^+\d]/g, ''),
|
|
85
|
+
};
|
|
86
|
+
isValidationSuccess(feedbackValidator(formState)) && onSubmit(submitData);
|
|
87
|
+
};
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { type FormFieldRegisterer } from '../../hooks/useForm';
|
|
2
2
|
import { withValidator } from '../../validation/withValidator';
|
|
3
|
+
import { type AntiFraudFormState } from './ApplicationFormAntiFraud';
|
|
3
4
|
import { type FeedbackFormState } from './ApplicationFormFeedback';
|
|
4
5
|
import { DatePickerControl } from './DatePickerControl';
|
|
5
6
|
import { InputControl } from './InputControl';
|
|
6
7
|
import { defaultValidator, nameValidator } from './validators';
|
|
7
8
|
|
|
8
|
-
export
|
|
9
|
+
export interface UserDataState {
|
|
10
|
+
surname: string;
|
|
11
|
+
name: string;
|
|
12
|
+
middleName?: string;
|
|
13
|
+
birthday: Date | undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const renderUserData = <T extends AntiFraudFormState | FeedbackFormState>(
|
|
17
|
+
field: FormFieldRegisterer<T>,
|
|
18
|
+
) => (
|
|
9
19
|
<div>
|
|
10
20
|
<InputControl label="Фамилия*" {...withValidator(field('surname'), nameValidator)} />
|
|
11
21
|
<InputControl label="Имя*" {...withValidator(field('name'), nameValidator)} />
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redneckz/wildless-cms-uni-blocks",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.136",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ЦК",
|
|
@@ -206,7 +206,7 @@
|
|
|
206
206
|
"path": "lib/common.css"
|
|
207
207
|
},
|
|
208
208
|
{
|
|
209
|
-
"limit": "
|
|
209
|
+
"limit": "63 kB",
|
|
210
210
|
"path": "bundle/bundle.umd.min.js"
|
|
211
211
|
}
|
|
212
212
|
],
|
|
@@ -60,6 +60,14 @@ const ApplicationFormFeedback: ApplicationFormContent = {
|
|
|
60
60
|
formBlock: { ...formBlockProps, formType: 'ApplicationFormFeedback', title: 'Обратная связь' },
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
+
const ApplicationFormAntiFraud: ApplicationFormContent = {
|
|
64
|
+
formBlock: {
|
|
65
|
+
...formBlockProps,
|
|
66
|
+
formType: 'ApplicationFormAntiFraud',
|
|
67
|
+
title: 'Предупреждение о мошенничестве',
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
63
71
|
export default {
|
|
64
72
|
credit: (
|
|
65
73
|
<div className="container grid grid-cols-12">
|
|
@@ -109,4 +117,10 @@ export default {
|
|
|
109
117
|
<PopupManager />
|
|
110
118
|
</div>
|
|
111
119
|
),
|
|
120
|
+
'anti-fraud': (
|
|
121
|
+
<div className="container grid grid-cols-12">
|
|
122
|
+
<ApplicationForm className="col-span-12" {...ApplicationFormAntiFraud} />
|
|
123
|
+
<PopupManager />
|
|
124
|
+
</div>
|
|
125
|
+
),
|
|
112
126
|
};
|
|
@@ -20,15 +20,12 @@ export const ApplicationForm = JSX<ApplicationFormProps>((props) => {
|
|
|
20
20
|
|
|
21
21
|
const [responseType, setResponseType] = useState<'OK' | 'Fail' | ''>('');
|
|
22
22
|
|
|
23
|
-
const handleSubmit = useCallback(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
[],
|
|
31
|
-
);
|
|
23
|
+
const handleSubmit = useCallback(async (data: Record<string, any>, isIndividualType = false) => {
|
|
24
|
+
const status = (await API.send(data, isIndividualType)) ? 'OK' : 'Fail';
|
|
25
|
+
setResponseType(status);
|
|
26
|
+
|
|
27
|
+
return status;
|
|
28
|
+
}, []);
|
|
32
29
|
|
|
33
30
|
return (
|
|
34
31
|
<BlockWrapper className={className} defaultPadding="p-6xl" {...rest}>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/* eslint-disable max-lines-per-function,max-lines */
|
|
2
|
+
|
|
3
|
+
import { JSX } from '@redneckz/uni-jsx';
|
|
4
|
+
import { useCallback } from '@redneckz/uni-jsx/lib/hooks';
|
|
5
|
+
import { useForm } from '../../hooks/useForm';
|
|
6
|
+
import { type Option } from '../../ui-kit/Select/Option';
|
|
7
|
+
import { objectValidator } from '../../validation/objectValidator';
|
|
8
|
+
import { isValidationSuccess } from '../../validation/validator';
|
|
9
|
+
import { withValidator } from '../../validation/withValidator';
|
|
10
|
+
import { ApplicationFieldsetLayout } from './ApplicationFieldsetLayout';
|
|
11
|
+
import { type ApplicationFormsProps } from './ApplicationFormsProps';
|
|
12
|
+
import { formStyle } from './formStyle';
|
|
13
|
+
import { PhoneInputControl } from './PhoneInputControl';
|
|
14
|
+
import { renderAgreementWithSubmit } from './renderAgreementWithSubmit';
|
|
15
|
+
import { renderUserData, type UserDataState } from './renderUserData';
|
|
16
|
+
import {
|
|
17
|
+
consentDataProcessingValidator,
|
|
18
|
+
defaultValidator,
|
|
19
|
+
nameValidator,
|
|
20
|
+
phoneValidator,
|
|
21
|
+
} from './validators';
|
|
22
|
+
|
|
23
|
+
export type AntiFraudFormState = UserDataState & {
|
|
24
|
+
typeForm: Option;
|
|
25
|
+
phone: string;
|
|
26
|
+
birthday: Date | undefined;
|
|
27
|
+
isClient: boolean;
|
|
28
|
+
comment?: string;
|
|
29
|
+
consentDataProcessing: boolean;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const initialFormState: AntiFraudFormState = {
|
|
33
|
+
typeForm: { key: 'ANTIFRAUD', text: 'Предупреждение о мошенничестве' },
|
|
34
|
+
surname: '',
|
|
35
|
+
name: '',
|
|
36
|
+
middleName: '',
|
|
37
|
+
phone: '',
|
|
38
|
+
birthday: undefined,
|
|
39
|
+
isClient: false,
|
|
40
|
+
comment: '',
|
|
41
|
+
consentDataProcessing: false,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const feedbackValidator = objectValidator({
|
|
45
|
+
typeForm: defaultValidator,
|
|
46
|
+
surname: defaultValidator,
|
|
47
|
+
name: nameValidator,
|
|
48
|
+
birthday: defaultValidator,
|
|
49
|
+
phone: phoneValidator,
|
|
50
|
+
consentDataProcessing: consentDataProcessingValidator,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export const ApplicationFormAntiFraud = JSX<ApplicationFormsProps>(({ button, link, onSubmit }) => {
|
|
54
|
+
const handleSubmit = useCallback(
|
|
55
|
+
(formState: AntiFraudFormState) => {
|
|
56
|
+
const { typeForm, phone, ...usedFields } = formState;
|
|
57
|
+
|
|
58
|
+
const submitData = {
|
|
59
|
+
...usedFields,
|
|
60
|
+
typeForm: typeForm.key,
|
|
61
|
+
phone: phone.replace(/[^+\d]/g, ''),
|
|
62
|
+
};
|
|
63
|
+
isValidationSuccess(feedbackValidator(formState)) && onSubmit(submitData);
|
|
64
|
+
},
|
|
65
|
+
[onSubmit],
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const [, { field, ...formProps }] = useForm(initialFormState, handleSubmit);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<form className={formStyle} onSubmit={formProps.onSubmit}>
|
|
72
|
+
<ApplicationFieldsetLayout
|
|
73
|
+
firstChildren={
|
|
74
|
+
<div className="w-full max-w-xl space-y-s m-auto">
|
|
75
|
+
{renderUserData<AntiFraudFormState>(field)}
|
|
76
|
+
<PhoneInputControl
|
|
77
|
+
label="Телефон*"
|
|
78
|
+
{...withValidator(field('phone'), phoneValidator)}
|
|
79
|
+
/>
|
|
80
|
+
{renderAgreementWithSubmit(field('consentDataProcessing'), link, button)}
|
|
81
|
+
</div>
|
|
82
|
+
}
|
|
83
|
+
/>
|
|
84
|
+
</form>
|
|
85
|
+
);
|
|
86
|
+
});
|
|
@@ -94,6 +94,15 @@ export type FeedbackFormParamsDef = TitleProps &
|
|
|
94
94
|
formType: 'ApplicationFormFeedback';
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
+
/**
|
|
98
|
+
* @title Сообщить о мошенничестве
|
|
99
|
+
*/
|
|
100
|
+
export type AntiFraudFormParamsDef = TitleProps &
|
|
101
|
+
CommonApplicationFormProps & {
|
|
102
|
+
/** @default ApplicationFormAntiFraud */
|
|
103
|
+
formType: 'ApplicationFormAntiFraud';
|
|
104
|
+
};
|
|
105
|
+
|
|
97
106
|
/**
|
|
98
107
|
* @title Настройки формы
|
|
99
108
|
*/
|
|
@@ -105,7 +114,8 @@ export type ApplicationFormBlockDef =
|
|
|
105
114
|
| AcquiringFormParamsDef
|
|
106
115
|
| GrantSupportFormParamsDef
|
|
107
116
|
| IndividualsFormParamsDef
|
|
108
|
-
| FeedbackFormParamsDef
|
|
117
|
+
| FeedbackFormParamsDef
|
|
118
|
+
| AntiFraudFormParamsDef;
|
|
109
119
|
|
|
110
120
|
/**
|
|
111
121
|
* @title Форма заявки
|
|
@@ -5,47 +5,36 @@ import { useCallback } from '@redneckz/uni-jsx/lib/hooks';
|
|
|
5
5
|
import { useBranches } from '../../hooks/useBranches';
|
|
6
6
|
import { useForm } from '../../hooks/useForm';
|
|
7
7
|
import { type Option } from '../../ui-kit/Select/Option';
|
|
8
|
-
import { objectValidator } from '../../validation/objectValidator';
|
|
9
|
-
import { isValidationSuccess } from '../../validation/validator';
|
|
10
8
|
import { withValidator } from '../../validation/withValidator';
|
|
11
9
|
import { useGetRegions } from '../SafeDepositRental/useGetRegions';
|
|
12
10
|
import { ApplicationFieldsetLayout } from './ApplicationFieldsetLayout';
|
|
13
11
|
import { type ApplicationFormsProps } from './ApplicationFormsProps';
|
|
14
12
|
import { FEEDBACK_METHOD, FEEDBACK_TYPES, SERVICE_DIRECTIONS } from './feedbackTypes';
|
|
15
13
|
import { formStyle } from './formStyle';
|
|
14
|
+
import { handleSubmitIndividual, handleSubmitLegal, handleSubmitQuestion } from './handleSubmit';
|
|
16
15
|
import { InputControl } from './InputControl';
|
|
17
16
|
import { PhoneInputControl } from './PhoneInputControl';
|
|
18
17
|
import { renderAgreementWithSubmit } from './renderAgreementWithSubmit';
|
|
19
|
-
import { renderUserData } from './renderUserData';
|
|
18
|
+
import { renderUserData, type UserDataState } from './renderUserData';
|
|
20
19
|
import { SelectControl } from './SelectControl';
|
|
21
|
-
import {
|
|
22
|
-
consentDataProcessingValidator,
|
|
23
|
-
defaultValidator,
|
|
24
|
-
innValidator,
|
|
25
|
-
nameValidator,
|
|
26
|
-
phoneValidator,
|
|
27
|
-
} from './validators';
|
|
20
|
+
import { defaultValidator, innValidator, phoneValidator } from './validators';
|
|
28
21
|
|
|
29
|
-
export
|
|
22
|
+
export type FeedbackFormState = UserDataState & {
|
|
30
23
|
typeForm: Option;
|
|
31
24
|
region?: Option;
|
|
32
|
-
serviceDirection
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
name: string;
|
|
36
|
-
middleName;
|
|
25
|
+
serviceDirection?: Option;
|
|
26
|
+
addressBranch?: Option;
|
|
27
|
+
inn?: string;
|
|
37
28
|
fullName?: string;
|
|
38
|
-
birthday: Date | undefined;
|
|
39
29
|
feedbackMethod: Option;
|
|
40
30
|
phone: string;
|
|
41
|
-
|
|
42
|
-
email
|
|
31
|
+
secondaryPhone?: string;
|
|
32
|
+
email?: string;
|
|
43
33
|
bankEmpolee?: string;
|
|
44
34
|
applicationDate?: string;
|
|
45
|
-
comment
|
|
35
|
+
comment: string;
|
|
46
36
|
consentDataProcessing: boolean;
|
|
47
|
-
|
|
48
|
-
}
|
|
37
|
+
};
|
|
49
38
|
|
|
50
39
|
const initialFormState: FeedbackFormState = {
|
|
51
40
|
typeForm: { key: 'FEEDBACK', text: 'Задать вопрос по продуктам и услугам' },
|
|
@@ -61,45 +50,21 @@ const initialFormState: FeedbackFormState = {
|
|
|
61
50
|
consentDataProcessing: false,
|
|
62
51
|
};
|
|
63
52
|
|
|
64
|
-
const feedbackValidator = objectValidator({
|
|
65
|
-
typeForm: defaultValidator,
|
|
66
|
-
region: defaultValidator,
|
|
67
|
-
department: defaultValidator,
|
|
68
|
-
name: nameValidator,
|
|
69
|
-
birthday: defaultValidator,
|
|
70
|
-
feedbackMethod: defaultValidator,
|
|
71
|
-
phone: phoneValidator,
|
|
72
|
-
email: defaultValidator,
|
|
73
|
-
consentDataProcessing: consentDataProcessingValidator,
|
|
74
|
-
inn: innValidator,
|
|
75
|
-
});
|
|
76
|
-
|
|
77
53
|
export const ApplicationFormFeedback = JSX<ApplicationFormsProps>(({ button, link, onSubmit }) => {
|
|
78
54
|
const handleSubmit = useCallback(
|
|
79
|
-
(
|
|
80
|
-
const
|
|
81
|
-
typeForm,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
phone,
|
|
85
|
-
email,
|
|
86
|
-
inn,
|
|
87
|
-
fullName,
|
|
88
|
-
feedbackMethod,
|
|
89
|
-
...usedFields
|
|
90
|
-
} = formState;
|
|
55
|
+
(feedbackFormState: FeedbackFormState) => {
|
|
56
|
+
const isLegal = getLegalEntity(
|
|
57
|
+
feedbackFormState.typeForm.key,
|
|
58
|
+
feedbackFormState.serviceDirection?.key,
|
|
59
|
+
);
|
|
91
60
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
[isLegalEntity ? 'mail' : 'email']: email,
|
|
100
|
-
...(isLegalEntity ? { inn, fullName } : {}),
|
|
101
|
-
};
|
|
102
|
-
isValidationSuccess(feedbackValidator(formState)) && onSubmit(submitData, isLegalEntity);
|
|
61
|
+
if (isLegal) {
|
|
62
|
+
handleSubmitLegal(feedbackFormState, onSubmit);
|
|
63
|
+
} else if (feedbackFormState.typeForm.key === 'FEEDBACK') {
|
|
64
|
+
handleSubmitQuestion(feedbackFormState, onSubmit);
|
|
65
|
+
} else {
|
|
66
|
+
handleSubmitIndividual(feedbackFormState, onSubmit);
|
|
67
|
+
}
|
|
103
68
|
},
|
|
104
69
|
[onSubmit],
|
|
105
70
|
);
|
|
@@ -147,10 +112,10 @@ export const ApplicationFormFeedback = JSX<ApplicationFormsProps>(({ button, lin
|
|
|
147
112
|
key: branchCode,
|
|
148
113
|
text: address,
|
|
149
114
|
}))}
|
|
150
|
-
{...withValidator(field('
|
|
115
|
+
{...withValidator(field('addressBranch'), defaultValidator)}
|
|
151
116
|
/>
|
|
152
117
|
) : null}
|
|
153
|
-
{renderUserData(field)}
|
|
118
|
+
{renderUserData<FeedbackFormState>(field)}
|
|
154
119
|
{isLegalEntity ? (
|
|
155
120
|
<div>
|
|
156
121
|
<InputControl label="ИНН*" {...withValidator(field('inn'), innValidator)} />
|
|
@@ -168,7 +133,7 @@ export const ApplicationFormFeedback = JSX<ApplicationFormsProps>(({ button, lin
|
|
|
168
133
|
/>
|
|
169
134
|
{isQualityService ? (
|
|
170
135
|
<div>
|
|
171
|
-
<InputControl label="Дополнительный телефон" {...field('
|
|
136
|
+
<InputControl label="Дополнительный телефон" {...field('secondaryPhone')} />
|
|
172
137
|
<InputControl
|
|
173
138
|
label="Электронная почта*"
|
|
174
139
|
{...withValidator(field('email'), defaultValidator)}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ApplicationFormAcquiring } from './ApplicationFormAcquiring';
|
|
2
|
+
import { ApplicationFormAntiFraud } from './ApplicationFormAntiFraud';
|
|
2
3
|
import { ApplicationFormBusinessCard } from './ApplicationFormBusinessCard';
|
|
3
4
|
import { ApplicationFormCredit } from './ApplicationFormCredit';
|
|
4
5
|
import { ApplicationFormDeposit } from './ApplicationFormDeposit';
|
|
@@ -16,4 +17,5 @@ export const EmbeddableForms = {
|
|
|
16
17
|
ApplicationFormGrantSupport,
|
|
17
18
|
ApplicationFormIndividuals,
|
|
18
19
|
ApplicationFormFeedback,
|
|
20
|
+
ApplicationFormAntiFraud,
|
|
19
21
|
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { objectValidator } from '../../validation/objectValidator';
|
|
2
|
+
import { isValidationSuccess } from '../../validation/validator';
|
|
3
|
+
import { type FeedbackFormState } from './ApplicationFormFeedback';
|
|
4
|
+
import { type ApplicationFormsProps } from './ApplicationFormsProps';
|
|
5
|
+
import {
|
|
6
|
+
consentDataProcessingValidator,
|
|
7
|
+
defaultValidator,
|
|
8
|
+
innValidator,
|
|
9
|
+
nameValidator,
|
|
10
|
+
phoneValidator,
|
|
11
|
+
} from './validators';
|
|
12
|
+
|
|
13
|
+
export const feedbackValidatorDefaultObject = {
|
|
14
|
+
typeForm: defaultValidator,
|
|
15
|
+
region: defaultValidator,
|
|
16
|
+
surname: defaultValidator,
|
|
17
|
+
name: nameValidator,
|
|
18
|
+
feedbackMethod: defaultValidator,
|
|
19
|
+
phone: phoneValidator,
|
|
20
|
+
email: defaultValidator,
|
|
21
|
+
comment: defaultValidator,
|
|
22
|
+
consentDataProcessing: consentDataProcessingValidator,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const handleSubmitIndividual = (
|
|
26
|
+
formState: FeedbackFormState,
|
|
27
|
+
onSubmit: ApplicationFormsProps['onSubmit'],
|
|
28
|
+
) => {
|
|
29
|
+
const feedbackValidator = objectValidator({
|
|
30
|
+
...feedbackValidatorDefaultObject,
|
|
31
|
+
addressBranch: defaultValidator,
|
|
32
|
+
});
|
|
33
|
+
const { region, phone, secondaryPhone } = formState;
|
|
34
|
+
|
|
35
|
+
const submitData = {
|
|
36
|
+
...formState,
|
|
37
|
+
typeForm: formState.typeForm.key,
|
|
38
|
+
addressBranch: formState.addressBranch?.text || '',
|
|
39
|
+
feedbackMethod: formState.feedbackMethod.text,
|
|
40
|
+
regionBranch: region?.text,
|
|
41
|
+
phoneNumber: phone.replace(/[^+\d]/g, ''),
|
|
42
|
+
secondaryPhoneNumber: secondaryPhone,
|
|
43
|
+
};
|
|
44
|
+
isValidationSuccess(feedbackValidator(formState)) && onSubmit(submitData);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const handleSubmitLegal = (
|
|
48
|
+
formState: FeedbackFormState,
|
|
49
|
+
onSubmit: ApplicationFormsProps['onSubmit'],
|
|
50
|
+
) => {
|
|
51
|
+
const feedbackValidator = objectValidator({
|
|
52
|
+
...feedbackValidatorDefaultObject,
|
|
53
|
+
addressBranch: defaultValidator,
|
|
54
|
+
inn: innValidator,
|
|
55
|
+
});
|
|
56
|
+
const { secondaryPhone, email } = formState;
|
|
57
|
+
const submitData = {
|
|
58
|
+
...formState,
|
|
59
|
+
typeForm: formState.typeForm.key,
|
|
60
|
+
region: formState.region?.text,
|
|
61
|
+
addressBranch: formState.addressBranch?.text || '',
|
|
62
|
+
feedbackMethod: formState.feedbackMethod.text,
|
|
63
|
+
phone: formState.phone.replace(/[^+\d]/g, ''),
|
|
64
|
+
secondaryPhoneNumber: secondaryPhone,
|
|
65
|
+
mail: email,
|
|
66
|
+
};
|
|
67
|
+
isValidationSuccess(feedbackValidator(formState)) && onSubmit(submitData, true);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const handleSubmitQuestion = (
|
|
71
|
+
formState: FeedbackFormState,
|
|
72
|
+
onSubmit: ApplicationFormsProps['onSubmit'],
|
|
73
|
+
) => {
|
|
74
|
+
const feedbackValidator = objectValidator({
|
|
75
|
+
...feedbackValidatorDefaultObject,
|
|
76
|
+
birthday: defaultValidator,
|
|
77
|
+
});
|
|
78
|
+
const { region, phone } = formState;
|
|
79
|
+
const submitData = {
|
|
80
|
+
...formState,
|
|
81
|
+
typeForm: formState.typeForm.key,
|
|
82
|
+
feedbackMethod: formState.feedbackMethod.text,
|
|
83
|
+
regionBranch: region?.text,
|
|
84
|
+
phoneNumber: phone.replace(/[^+\d]/g, ''),
|
|
85
|
+
};
|
|
86
|
+
isValidationSuccess(feedbackValidator(formState)) && onSubmit(submitData);
|
|
87
|
+
};
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { type FormFieldRegisterer } from '../../hooks/useForm';
|
|
2
2
|
import { withValidator } from '../../validation/withValidator';
|
|
3
|
+
import { type AntiFraudFormState } from './ApplicationFormAntiFraud';
|
|
3
4
|
import { type FeedbackFormState } from './ApplicationFormFeedback';
|
|
4
5
|
import { DatePickerControl } from './DatePickerControl';
|
|
5
6
|
import { InputControl } from './InputControl';
|
|
6
7
|
import { defaultValidator, nameValidator } from './validators';
|
|
7
8
|
|
|
8
|
-
export
|
|
9
|
+
export interface UserDataState {
|
|
10
|
+
surname: string;
|
|
11
|
+
name: string;
|
|
12
|
+
middleName?: string;
|
|
13
|
+
birthday: Date | undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const renderUserData = <T extends AntiFraudFormState | FeedbackFormState>(
|
|
17
|
+
field: FormFieldRegisterer<T>,
|
|
18
|
+
) => (
|
|
9
19
|
<div>
|
|
10
20
|
<InputControl label="Фамилия*" {...withValidator(field('surname'), nameValidator)} />
|
|
11
21
|
<InputControl label="Имя*" {...withValidator(field('name'), nameValidator)} />
|