@redneckz/wildless-cms-uni-blocks 0.14.134 → 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 +329 -236
- 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 +8 -12
- package/bundle/components/ApplicationForm/ApplicationFormIndividuals.d.ts +2 -2
- package/bundle/components/ApplicationForm/EmbeddableForms.d.ts +1 -0
- package/bundle/components/ApplicationForm/InputControl.d.ts +2 -9
- package/bundle/components/ApplicationForm/PhoneInputControl.d.ts +2 -2
- package/bundle/components/ApplicationForm/handleSubmit.d.ts +16 -0
- package/bundle/components/ApplicationForm/renderTextarea.d.ts +9 -1
- package/bundle/components/ApplicationForm/renderUserData.d.ts +8 -1
- package/bundle/ui-kit/Input/InputProps.d.ts +2 -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 +8 -12
- package/dist/components/ApplicationForm/ApplicationFormFeedback.js +21 -34
- package/dist/components/ApplicationForm/ApplicationFormFeedback.js.map +1 -1
- package/dist/components/ApplicationForm/ApplicationFormIndividuals.d.ts +2 -2
- package/dist/components/ApplicationForm/ApplicationFormIndividuals.js +9 -9
- package/dist/components/ApplicationForm/ApplicationFormIndividuals.js.map +1 -1
- package/dist/components/ApplicationForm/ApplicationFormWed.js +5 -1
- package/dist/components/ApplicationForm/ApplicationFormWed.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/InputControl.d.ts +2 -9
- package/dist/components/ApplicationForm/InputControl.js +1 -1
- package/dist/components/ApplicationForm/InputControl.js.map +1 -1
- package/dist/components/ApplicationForm/PhoneInputControl.d.ts +2 -2
- package/dist/components/ApplicationForm/PhoneInputControl.js.map +1 -1
- package/dist/components/ApplicationForm/feedbackTypes.js +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/renderAgreementWithSubmit.js +1 -1
- package/dist/components/ApplicationForm/renderAgreementWithSubmit.js.map +1 -1
- package/dist/components/ApplicationForm/renderIndividualsFields.js +1 -1
- package/dist/components/ApplicationForm/renderIndividualsFields.js.map +1 -1
- package/dist/components/ApplicationForm/renderTextarea.d.ts +9 -1
- package/dist/components/ApplicationForm/renderTextarea.js +2 -1
- package/dist/components/ApplicationForm/renderTextarea.js.map +1 -1
- package/dist/components/ApplicationForm/renderUserData.d.ts +8 -1
- package/dist/components/ApplicationForm/renderUserData.js +1 -1
- package/dist/components/ApplicationForm/renderUserData.js.map +1 -1
- package/dist/ui-kit/Input/Input.js +8 -5
- package/dist/ui-kit/Input/Input.js.map +1 -1
- package/dist/ui-kit/Input/InputProps.d.ts +2 -1
- package/lib/common.css +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 +8 -12
- package/lib/components/ApplicationForm/ApplicationFormFeedback.js +22 -35
- package/lib/components/ApplicationForm/ApplicationFormFeedback.js.map +1 -1
- package/lib/components/ApplicationForm/ApplicationFormIndividuals.d.ts +2 -2
- package/lib/components/ApplicationForm/ApplicationFormIndividuals.js +9 -9
- package/lib/components/ApplicationForm/ApplicationFormIndividuals.js.map +1 -1
- package/lib/components/ApplicationForm/ApplicationFormWed.js +5 -1
- package/lib/components/ApplicationForm/ApplicationFormWed.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/InputControl.d.ts +2 -9
- package/lib/components/ApplicationForm/InputControl.js +1 -1
- package/lib/components/ApplicationForm/InputControl.js.map +1 -1
- package/lib/components/ApplicationForm/PhoneInputControl.d.ts +2 -2
- package/lib/components/ApplicationForm/PhoneInputControl.js.map +1 -1
- package/lib/components/ApplicationForm/feedbackTypes.js +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/renderAgreementWithSubmit.js +1 -1
- package/lib/components/ApplicationForm/renderAgreementWithSubmit.js.map +1 -1
- package/lib/components/ApplicationForm/renderIndividualsFields.js +1 -1
- package/lib/components/ApplicationForm/renderIndividualsFields.js.map +1 -1
- package/lib/components/ApplicationForm/renderTextarea.d.ts +9 -1
- package/lib/components/ApplicationForm/renderTextarea.js +2 -1
- package/lib/components/ApplicationForm/renderTextarea.js.map +1 -1
- package/lib/components/ApplicationForm/renderUserData.d.ts +8 -1
- package/lib/components/ApplicationForm/renderUserData.js +1 -1
- package/lib/components/ApplicationForm/renderUserData.js.map +1 -1
- package/lib/ui-kit/Input/Input.js +8 -5
- package/lib/ui-kit/Input/Input.js.map +1 -1
- package/lib/ui-kit/Input/InputProps.d.ts +2 -1
- package/mobile/bundle/bundle.umd.js +329 -236
- 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 +8 -12
- package/mobile/bundle/components/ApplicationForm/ApplicationFormIndividuals.d.ts +2 -2
- package/mobile/bundle/components/ApplicationForm/EmbeddableForms.d.ts +1 -0
- package/mobile/bundle/components/ApplicationForm/InputControl.d.ts +2 -9
- package/mobile/bundle/components/ApplicationForm/PhoneInputControl.d.ts +2 -2
- package/mobile/bundle/components/ApplicationForm/handleSubmit.d.ts +16 -0
- package/mobile/bundle/components/ApplicationForm/renderTextarea.d.ts +9 -1
- package/mobile/bundle/components/ApplicationForm/renderUserData.d.ts +8 -1
- package/mobile/bundle/ui-kit/Input/InputProps.d.ts +2 -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 +8 -12
- package/mobile/dist/components/ApplicationForm/ApplicationFormFeedback.js +21 -34
- package/mobile/dist/components/ApplicationForm/ApplicationFormFeedback.js.map +1 -1
- package/mobile/dist/components/ApplicationForm/ApplicationFormIndividuals.d.ts +2 -2
- package/mobile/dist/components/ApplicationForm/ApplicationFormIndividuals.js +9 -9
- package/mobile/dist/components/ApplicationForm/ApplicationFormIndividuals.js.map +1 -1
- package/mobile/dist/components/ApplicationForm/ApplicationFormWed.js +5 -1
- package/mobile/dist/components/ApplicationForm/ApplicationFormWed.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/InputControl.d.ts +2 -9
- package/mobile/dist/components/ApplicationForm/InputControl.js +1 -1
- package/mobile/dist/components/ApplicationForm/InputControl.js.map +1 -1
- package/mobile/dist/components/ApplicationForm/PhoneInputControl.d.ts +2 -2
- package/mobile/dist/components/ApplicationForm/PhoneInputControl.js.map +1 -1
- package/mobile/dist/components/ApplicationForm/feedbackTypes.js +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/renderAgreementWithSubmit.js +1 -1
- package/mobile/dist/components/ApplicationForm/renderAgreementWithSubmit.js.map +1 -1
- package/mobile/dist/components/ApplicationForm/renderIndividualsFields.js +1 -1
- package/mobile/dist/components/ApplicationForm/renderIndividualsFields.js.map +1 -1
- package/mobile/dist/components/ApplicationForm/renderTextarea.d.ts +9 -1
- package/mobile/dist/components/ApplicationForm/renderTextarea.js +2 -1
- package/mobile/dist/components/ApplicationForm/renderTextarea.js.map +1 -1
- package/mobile/dist/components/ApplicationForm/renderUserData.d.ts +8 -1
- package/mobile/dist/components/ApplicationForm/renderUserData.js +1 -1
- package/mobile/dist/components/ApplicationForm/renderUserData.js.map +1 -1
- package/mobile/dist/ui-kit/Input/Input.js +8 -5
- package/mobile/dist/ui-kit/Input/Input.js.map +1 -1
- package/mobile/dist/ui-kit/Input/InputProps.d.ts +2 -1
- package/mobile/lib/common.css +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 +8 -12
- package/mobile/lib/components/ApplicationForm/ApplicationFormFeedback.js +22 -35
- package/mobile/lib/components/ApplicationForm/ApplicationFormFeedback.js.map +1 -1
- package/mobile/lib/components/ApplicationForm/ApplicationFormIndividuals.d.ts +2 -2
- package/mobile/lib/components/ApplicationForm/ApplicationFormIndividuals.js +9 -9
- package/mobile/lib/components/ApplicationForm/ApplicationFormIndividuals.js.map +1 -1
- package/mobile/lib/components/ApplicationForm/ApplicationFormWed.js +5 -1
- package/mobile/lib/components/ApplicationForm/ApplicationFormWed.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/InputControl.d.ts +2 -9
- package/mobile/lib/components/ApplicationForm/InputControl.js +1 -1
- package/mobile/lib/components/ApplicationForm/InputControl.js.map +1 -1
- package/mobile/lib/components/ApplicationForm/PhoneInputControl.d.ts +2 -2
- package/mobile/lib/components/ApplicationForm/PhoneInputControl.js.map +1 -1
- package/mobile/lib/components/ApplicationForm/feedbackTypes.js +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/renderAgreementWithSubmit.js +1 -1
- package/mobile/lib/components/ApplicationForm/renderAgreementWithSubmit.js.map +1 -1
- package/mobile/lib/components/ApplicationForm/renderIndividualsFields.js +1 -1
- package/mobile/lib/components/ApplicationForm/renderIndividualsFields.js.map +1 -1
- package/mobile/lib/components/ApplicationForm/renderTextarea.d.ts +9 -1
- package/mobile/lib/components/ApplicationForm/renderTextarea.js +2 -1
- package/mobile/lib/components/ApplicationForm/renderTextarea.js.map +1 -1
- package/mobile/lib/components/ApplicationForm/renderUserData.d.ts +8 -1
- package/mobile/lib/components/ApplicationForm/renderUserData.js +1 -1
- package/mobile/lib/components/ApplicationForm/renderUserData.js.map +1 -1
- package/mobile/lib/ui-kit/Input/Input.js +8 -5
- package/mobile/lib/ui-kit/Input/Input.js.map +1 -1
- package/mobile/lib/ui-kit/Input/InputProps.d.ts +2 -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 +62 -85
- package/mobile/src/components/ApplicationForm/ApplicationFormIndividuals.tsx +13 -12
- package/mobile/src/components/ApplicationForm/ApplicationFormWed.tsx +5 -4
- package/mobile/src/components/ApplicationForm/EmbeddableForms.tsx +2 -0
- package/mobile/src/components/ApplicationForm/InputControl.tsx +5 -11
- package/mobile/src/components/ApplicationForm/PhoneInputControl.tsx +2 -2
- package/mobile/src/components/ApplicationForm/feedbackTypes.ts +1 -1
- package/mobile/src/components/ApplicationForm/handleSubmit.tsx +87 -0
- package/mobile/src/components/ApplicationForm/renderAgreementWithSubmit.tsx +1 -1
- package/mobile/src/components/ApplicationForm/renderIndividualsFields.tsx +2 -2
- package/mobile/src/components/ApplicationForm/renderTextarea.tsx +35 -23
- package/mobile/src/components/ApplicationForm/renderUserData.tsx +15 -5
- package/mobile/src/ui-kit/Input/Input.tsx +45 -31
- package/mobile/src/ui-kit/Input/InputProps.ts +2 -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 +62 -85
- package/src/components/ApplicationForm/ApplicationFormIndividuals.tsx +13 -12
- package/src/components/ApplicationForm/ApplicationFormWed.tsx +5 -4
- package/src/components/ApplicationForm/EmbeddableForms.tsx +2 -0
- package/src/components/ApplicationForm/InputControl.tsx +5 -11
- package/src/components/ApplicationForm/PhoneInputControl.tsx +2 -2
- package/src/components/ApplicationForm/feedbackTypes.ts +1 -1
- package/src/components/ApplicationForm/handleSubmit.tsx +87 -0
- package/src/components/ApplicationForm/renderAgreementWithSubmit.tsx +1 -1
- package/src/components/ApplicationForm/renderIndividualsFields.tsx +2 -2
- package/src/components/ApplicationForm/renderTextarea.tsx +35 -23
- package/src/components/ApplicationForm/renderUserData.tsx +15 -5
- package/src/ui-kit/Input/Input.tsx +45 -31
- package/src/ui-kit/Input/InputProps.ts +2 -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
|
+
};
|
|
@@ -13,7 +13,7 @@ export const renderAgreementWithSubmit = (
|
|
|
13
13
|
link?: LinkProps,
|
|
14
14
|
button?: SubmitButtonProps,
|
|
15
15
|
) => (
|
|
16
|
-
<div className="flex w-full justify-between items-baseline">
|
|
16
|
+
<div className="flex flex-col lg:flex-row w-full justify-between items-baseline">
|
|
17
17
|
<div>
|
|
18
18
|
<div className="flex gap-3">
|
|
19
19
|
<Checkbox {...consentDataProcessing} />
|
|
@@ -21,11 +21,11 @@ export const renderIndividualsFields = (field: FormFieldRegisterer<IndividualsFo
|
|
|
21
21
|
<InputControl label="Имя" {...withValidator(field('name'), nameValidator)} />
|
|
22
22
|
<DatePickerControl
|
|
23
23
|
label="Дата рождения*"
|
|
24
|
-
{...withValidator(field('
|
|
24
|
+
{...withValidator(field('birthday'), defaultValidator)}
|
|
25
25
|
/>
|
|
26
26
|
<InputControl
|
|
27
27
|
label="Электронная почта"
|
|
28
|
-
{...withValidator(field('
|
|
28
|
+
{...withValidator(field('email'), defaultValidator)}
|
|
29
29
|
/>
|
|
30
30
|
</div>
|
|
31
31
|
}
|
|
@@ -1,30 +1,42 @@
|
|
|
1
1
|
import { type FieldProps } from '../../hooks/useForm';
|
|
2
2
|
import { Text } from '../../ui-kit/Text/Text';
|
|
3
3
|
import { style } from '../../utils/style';
|
|
4
|
+
import { renderErrorText } from './renderErrorText';
|
|
5
|
+
|
|
6
|
+
interface TextFieldProps {
|
|
7
|
+
textField: FieldProps<string>;
|
|
8
|
+
text?: string;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
value?: string;
|
|
11
|
+
error?: string;
|
|
12
|
+
}
|
|
4
13
|
|
|
5
14
|
const activeTextareaStyles =
|
|
6
15
|
'hover:border-primary-hover active:focus:border-primary-text focus:border-primary-text';
|
|
7
|
-
export const renderTextarea = (textField
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
export const renderTextarea = ({ textField, text, placeholder = '', error }: TextFieldProps) => (
|
|
17
|
+
<div>
|
|
18
|
+
<label className="space-y-xs" htmlFor="textarea">
|
|
19
|
+
{text ? (
|
|
20
|
+
<div>
|
|
21
|
+
<Text size="text-m" font="font-light">
|
|
22
|
+
{text}
|
|
23
|
+
</Text>
|
|
24
|
+
</div>
|
|
25
|
+
) : null}
|
|
26
|
+
<textarea
|
|
27
|
+
id="textarea"
|
|
28
|
+
placeholder={placeholder}
|
|
29
|
+
className={style(
|
|
30
|
+
'block w-full resize-y min-h-24 p-m outline-none border rounded-md border-gray',
|
|
31
|
+
activeTextareaStyles,
|
|
32
|
+
)}
|
|
33
|
+
value={textField.value}
|
|
34
|
+
onInput={
|
|
35
|
+
((e: { target?: { value?: string } }) =>
|
|
36
|
+
textField.onChange && textField.onChange(e.target?.value || '')) as any
|
|
37
|
+
}
|
|
38
|
+
/>
|
|
39
|
+
</label>
|
|
40
|
+
{renderErrorText(error)}
|
|
41
|
+
</div>
|
|
30
42
|
);
|
|
@@ -1,18 +1,28 @@
|
|
|
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)} />
|
|
12
|
-
<InputControl
|
|
13
|
-
|
|
14
|
-
|
|
22
|
+
<InputControl label="Отчество (Обязательно, при наличии)" {...field('middleName')} />
|
|
23
|
+
<DatePickerControl
|
|
24
|
+
label="Дата рождения*"
|
|
25
|
+
{...withValidator(field('birthday'), defaultValidator)}
|
|
15
26
|
/>
|
|
16
|
-
<DatePickerControl label="Дата рождения*" {...withValidator(field('date'), defaultValidator)} />
|
|
17
27
|
</div>
|
|
18
28
|
);
|
|
@@ -8,7 +8,6 @@ export const Input = JSX<InputProps>(
|
|
|
8
8
|
({
|
|
9
9
|
key,
|
|
10
10
|
className = '',
|
|
11
|
-
inputClassName = '',
|
|
12
11
|
id,
|
|
13
12
|
name,
|
|
14
13
|
type = 'text',
|
|
@@ -22,6 +21,7 @@ export const Input = JSX<InputProps>(
|
|
|
22
21
|
onBlur,
|
|
23
22
|
pattern,
|
|
24
23
|
autoFocus = false,
|
|
24
|
+
isTextarea = false,
|
|
25
25
|
}) => {
|
|
26
26
|
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
27
27
|
const handleChange = useCallback(
|
|
@@ -36,44 +36,58 @@ export const Input = JSX<InputProps>(
|
|
|
36
36
|
inputRef.current?.focus();
|
|
37
37
|
}
|
|
38
38
|
}, [autoFocus, inputRef]);
|
|
39
|
-
|
|
39
|
+
const defaultStyle = 'w-full border rounded-md text-primary-text outline-none p-m';
|
|
40
40
|
const paddingStyle = children ? 'pr-3xl' : '';
|
|
41
|
-
const validStyle = valid
|
|
42
|
-
? 'border-gray hover:border-primary-hover active:border-primary-text focus:border-primary-text'
|
|
43
|
-
: 'border-error';
|
|
41
|
+
const validStyle = getValidStyle(valid);
|
|
44
42
|
|
|
45
43
|
return (
|
|
46
44
|
<div className={style('relative', className)}>
|
|
47
45
|
<label>
|
|
48
|
-
{label ? (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
46
|
+
{label ? renderLabel(label) : null}
|
|
47
|
+
{isTextarea ? (
|
|
48
|
+
<textarea
|
|
49
|
+
className={style('block resize-y min-h-24', defaultStyle, validStyle)}
|
|
50
|
+
key={key}
|
|
51
|
+
id={style('textarea', id)}
|
|
52
|
+
name={name || id}
|
|
53
|
+
placeholder={placeholder}
|
|
54
|
+
value={value}
|
|
55
|
+
onInput={handleChange as any}
|
|
56
|
+
onFocus={onFocus}
|
|
57
|
+
onBlur={onBlur}
|
|
58
|
+
/>
|
|
59
|
+
) : (
|
|
60
|
+
<input
|
|
61
|
+
type={type}
|
|
62
|
+
className={style('h-14', defaultStyle, paddingStyle, validStyle)}
|
|
63
|
+
ref={inputRef}
|
|
64
|
+
key={key}
|
|
65
|
+
id={id}
|
|
66
|
+
name={name || id}
|
|
67
|
+
placeholder={placeholder}
|
|
68
|
+
value={value}
|
|
69
|
+
onInput={handleChange as any}
|
|
70
|
+
onFocus={onFocus}
|
|
71
|
+
onBlur={onBlur}
|
|
72
|
+
pattern={pattern}
|
|
73
|
+
/>
|
|
74
|
+
)}
|
|
74
75
|
</label>
|
|
75
76
|
{children}
|
|
76
77
|
</div>
|
|
77
78
|
);
|
|
78
79
|
},
|
|
79
80
|
);
|
|
81
|
+
|
|
82
|
+
const renderLabel = (label: string) => (
|
|
83
|
+
<div className="mb-xs">
|
|
84
|
+
<Text size="text-m" font="font-light">
|
|
85
|
+
{label}
|
|
86
|
+
</Text>
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
const getValidStyle = (valid: boolean) =>
|
|
91
|
+
valid
|
|
92
|
+
? 'border-gray hover:border-primary-hover active:border-primary-text focus:border-primary-text'
|
|
93
|
+
: 'border-error';
|
|
@@ -4,7 +4,6 @@ import { type ControlProps } from '../ControlProps';
|
|
|
4
4
|
|
|
5
5
|
export interface InputProps<V = string> extends ControlProps<V>, LabelProps {
|
|
6
6
|
className?: string;
|
|
7
|
-
inputClassName?: string;
|
|
8
7
|
id?: string;
|
|
9
8
|
name?: string;
|
|
10
9
|
type?: InputTypes;
|
|
@@ -15,4 +14,6 @@ export interface InputProps<V = string> extends ControlProps<V>, LabelProps {
|
|
|
15
14
|
valid?: boolean;
|
|
16
15
|
disabled?: boolean;
|
|
17
16
|
autoFocus?: boolean;
|
|
17
|
+
isTextarea?: boolean;
|
|
18
|
+
error?: string;
|
|
18
19
|
}
|
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 Форма заявки
|