@redneckz/wildless-cms-uni-blocks 0.14.581 → 0.14.583
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/api/RetailApi/RetailApi.d.ts +9 -0
- package/bundle/api/RetailApi/RetailApiTypes.d.ts +83 -0
- package/bundle/api/RetailApi/utils/getUpdateUserProfile.d.ts +3 -0
- package/bundle/api/RetailApi/utils/getUpdateUserTask.d.ts +2 -0
- package/bundle/blocks.schema.json +1 -1
- package/bundle/bundle.umd.js +278 -37
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +2 -0
- package/bundle/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +6 -0
- package/bundle/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
- package/bundle/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
- package/dist/api/RetailApi/RetailApi.d.ts +9 -0
- package/dist/api/RetailApi/RetailApi.js +29 -0
- package/dist/api/RetailApi/RetailApi.js.map +1 -0
- package/dist/api/RetailApi/RetailApiTypes.d.ts +83 -0
- package/dist/api/RetailApi/RetailApiTypes.js +2 -0
- package/dist/api/RetailApi/RetailApiTypes.js.map +1 -0
- package/dist/api/RetailApi/utils/getUpdateUserProfile.d.ts +3 -0
- package/dist/api/RetailApi/utils/getUpdateUserProfile.js +27 -0
- package/dist/api/RetailApi/utils/getUpdateUserProfile.js.map +1 -0
- package/dist/api/RetailApi/utils/getUpdateUserTask.d.ts +2 -0
- package/dist/api/RetailApi/utils/getUpdateUserTask.js +43 -0
- package/dist/api/RetailApi/utils/getUpdateUserTask.js.map +1 -0
- package/dist/components/ApplicationLeadForm/ApplicationLeadForm.js +9 -23
- package/dist/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
- package/dist/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +2 -0
- package/dist/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +6 -0
- package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +70 -0
- package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -0
- package/dist/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
- package/dist/components/ApplicationLeadForm/useInitApplicationLead.js +11 -0
- package/dist/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -0
- package/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
- package/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js +20 -11
- package/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
- package/lib/api/RetailApi/RetailApi.d.ts +9 -0
- package/lib/api/RetailApi/RetailApi.js +27 -0
- package/lib/api/RetailApi/RetailApi.js.map +1 -0
- package/lib/api/RetailApi/RetailApiTypes.d.ts +83 -0
- package/lib/api/RetailApi/RetailApiTypes.js +2 -0
- package/lib/api/RetailApi/RetailApiTypes.js.map +1 -0
- package/lib/api/RetailApi/utils/getUpdateUserProfile.d.ts +3 -0
- package/lib/api/RetailApi/utils/getUpdateUserProfile.js +24 -0
- package/lib/api/RetailApi/utils/getUpdateUserProfile.js.map +1 -0
- package/lib/api/RetailApi/utils/getUpdateUserTask.d.ts +2 -0
- package/lib/api/RetailApi/utils/getUpdateUserTask.js +40 -0
- package/lib/api/RetailApi/utils/getUpdateUserTask.js.map +1 -0
- package/lib/components/ApplicationLeadForm/ApplicationLeadForm.js +10 -24
- package/lib/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
- package/lib/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +2 -0
- package/lib/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +6 -0
- package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +67 -0
- package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -0
- package/lib/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
- package/lib/components/ApplicationLeadForm/useInitApplicationLead.js +8 -0
- package/lib/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -0
- package/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
- package/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js +20 -11
- package/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
- package/mobile/bundle/api/RetailApi/RetailApi.d.ts +9 -0
- package/mobile/bundle/api/RetailApi/RetailApiTypes.d.ts +83 -0
- package/mobile/bundle/api/RetailApi/utils/getUpdateUserProfile.d.ts +3 -0
- package/mobile/bundle/api/RetailApi/utils/getUpdateUserTask.d.ts +2 -0
- package/mobile/bundle/bundle.umd.js +278 -37
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +2 -0
- package/mobile/bundle/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +6 -0
- package/mobile/bundle/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
- package/mobile/bundle/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
- package/mobile/dist/api/RetailApi/RetailApi.d.ts +9 -0
- package/mobile/dist/api/RetailApi/RetailApi.js +29 -0
- package/mobile/dist/api/RetailApi/RetailApi.js.map +1 -0
- package/mobile/dist/api/RetailApi/RetailApiTypes.d.ts +83 -0
- package/mobile/dist/api/RetailApi/RetailApiTypes.js +2 -0
- package/mobile/dist/api/RetailApi/RetailApiTypes.js.map +1 -0
- package/mobile/dist/api/RetailApi/utils/getUpdateUserProfile.d.ts +3 -0
- package/mobile/dist/api/RetailApi/utils/getUpdateUserProfile.js +27 -0
- package/mobile/dist/api/RetailApi/utils/getUpdateUserProfile.js.map +1 -0
- package/mobile/dist/api/RetailApi/utils/getUpdateUserTask.d.ts +2 -0
- package/mobile/dist/api/RetailApi/utils/getUpdateUserTask.js +43 -0
- package/mobile/dist/api/RetailApi/utils/getUpdateUserTask.js.map +1 -0
- package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadForm.js +9 -23
- package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
- package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +2 -0
- package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +6 -0
- package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +70 -0
- package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -0
- package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
- package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.js +11 -0
- package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -0
- package/mobile/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
- package/mobile/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js +20 -11
- package/mobile/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
- package/mobile/lib/api/RetailApi/RetailApi.d.ts +9 -0
- package/mobile/lib/api/RetailApi/RetailApi.js +27 -0
- package/mobile/lib/api/RetailApi/RetailApi.js.map +1 -0
- package/mobile/lib/api/RetailApi/RetailApiTypes.d.ts +83 -0
- package/mobile/lib/api/RetailApi/RetailApiTypes.js +2 -0
- package/mobile/lib/api/RetailApi/RetailApiTypes.js.map +1 -0
- package/mobile/lib/api/RetailApi/utils/getUpdateUserProfile.d.ts +3 -0
- package/mobile/lib/api/RetailApi/utils/getUpdateUserProfile.js +24 -0
- package/mobile/lib/api/RetailApi/utils/getUpdateUserProfile.js.map +1 -0
- package/mobile/lib/api/RetailApi/utils/getUpdateUserTask.d.ts +2 -0
- package/mobile/lib/api/RetailApi/utils/getUpdateUserTask.js +40 -0
- package/mobile/lib/api/RetailApi/utils/getUpdateUserTask.js.map +1 -0
- package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadForm.js +10 -24
- package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
- package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +2 -0
- package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.d.ts +6 -0
- package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +67 -0
- package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -0
- package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
- package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.js +8 -0
- package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -0
- package/mobile/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +3 -0
- package/mobile/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js +20 -11
- package/mobile/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
- package/mobile/src/api/RetailApi/RetailApi.ts +51 -0
- package/mobile/src/api/RetailApi/RetailApiTypes.ts +91 -0
- package/mobile/src/api/RetailApi/utils/getUpdateUserProfile.ts +44 -0
- package/mobile/src/api/RetailApi/utils/getUpdateUserTask.ts +46 -0
- package/mobile/src/components/ApplicationLeadForm/ApplicationLeadForm.tsx +11 -26
- package/mobile/src/components/ApplicationLeadForm/ApplicationLeadFormContent.ts +2 -0
- package/mobile/src/components/ApplicationLeadForm/useApplicationLeadApi.ts +75 -0
- package/mobile/src/components/ApplicationLeadForm/useInitApplicationLead.ts +8 -0
- package/mobile/src/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.tsx +35 -14
- package/package.json +2 -2
- package/src/api/RetailApi/RetailApi.ts +51 -0
- package/src/api/RetailApi/RetailApiTypes.ts +91 -0
- package/src/api/RetailApi/utils/getUpdateUserProfile.ts +44 -0
- package/src/api/RetailApi/utils/getUpdateUserTask.ts +46 -0
- package/src/components/ApplicationLeadForm/ApplicationLeadForm.fixture.tsx +1 -0
- package/src/components/ApplicationLeadForm/ApplicationLeadForm.tsx +11 -26
- package/src/components/ApplicationLeadForm/ApplicationLeadFormContent.ts +2 -0
- package/src/components/ApplicationLeadForm/useApplicationLeadApi.ts +75 -0
- package/src/components/ApplicationLeadForm/useInitApplicationLead.ts +8 -0
- package/src/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.fixture.tsx +5 -4
- package/src/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.tsx +35 -14
- package/bundle/components/ApplicationLeadForm/getFormatData.d.ts +0 -2
- package/bundle/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +0 -13
- package/dist/components/ApplicationLeadForm/getFormatData.d.ts +0 -2
- package/dist/components/ApplicationLeadForm/getFormatData.js +0 -13
- package/dist/components/ApplicationLeadForm/getFormatData.js.map +0 -1
- package/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +0 -13
- package/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js +0 -30
- package/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js.map +0 -1
- package/lib/components/ApplicationLeadForm/getFormatData.d.ts +0 -2
- package/lib/components/ApplicationLeadForm/getFormatData.js +0 -10
- package/lib/components/ApplicationLeadForm/getFormatData.js.map +0 -1
- package/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +0 -13
- package/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js +0 -27
- package/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js.map +0 -1
- package/mobile/bundle/components/ApplicationLeadForm/getFormatData.d.ts +0 -2
- package/mobile/bundle/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +0 -13
- package/mobile/dist/components/ApplicationLeadForm/getFormatData.d.ts +0 -2
- package/mobile/dist/components/ApplicationLeadForm/getFormatData.js +0 -13
- package/mobile/dist/components/ApplicationLeadForm/getFormatData.js.map +0 -1
- package/mobile/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +0 -13
- package/mobile/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js +0 -30
- package/mobile/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js.map +0 -1
- package/mobile/lib/components/ApplicationLeadForm/getFormatData.d.ts +0 -2
- package/mobile/lib/components/ApplicationLeadForm/getFormatData.js +0 -10
- package/mobile/lib/components/ApplicationLeadForm/getFormatData.js.map +0 -1
- package/mobile/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +0 -13
- package/mobile/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js +0 -27
- package/mobile/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js.map +0 -1
- package/mobile/src/components/ApplicationLeadForm/getFormatData.tsx +0 -17
- package/mobile/src/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.tsx +0 -36
- package/src/components/ApplicationLeadForm/getFormatData.tsx +0 -17
- package/src/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.tsx +0 -36
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type UpdateUserTaskBody } from '../RetailApiTypes';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable max-params */
|
|
4
|
+
export const getUpdateUserTaskData = (
|
|
5
|
+
participantId: number,
|
|
6
|
+
taskId: number,
|
|
7
|
+
profileId: number,
|
|
8
|
+
formatData?: Record<string, any>,
|
|
9
|
+
): UpdateUserTaskBody => ({
|
|
10
|
+
sendToBank: true,
|
|
11
|
+
taskKind: 'SHORT',
|
|
12
|
+
task: {
|
|
13
|
+
taskSource: globalThis.location.origin,
|
|
14
|
+
id: taskId,
|
|
15
|
+
participants: [
|
|
16
|
+
{
|
|
17
|
+
birthDate: formatData?.birthDate,
|
|
18
|
+
id: participantId,
|
|
19
|
+
midname: formatData?.midname,
|
|
20
|
+
name: formatData?.name,
|
|
21
|
+
surname: formatData?.surname,
|
|
22
|
+
profile: {
|
|
23
|
+
id: profileId,
|
|
24
|
+
},
|
|
25
|
+
participantContacts: [
|
|
26
|
+
{
|
|
27
|
+
contactTypeCd: {
|
|
28
|
+
key: 'EMAIL',
|
|
29
|
+
},
|
|
30
|
+
value: formatData?.email,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
contactTypeCd: {
|
|
34
|
+
key: 'MAIN_PHONE',
|
|
35
|
+
},
|
|
36
|
+
value: formatData?.phone,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
roleCd: {
|
|
40
|
+
key: 'BORROWER',
|
|
41
|
+
value: 'Заемщик',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
});
|
|
@@ -1,54 +1,39 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
-
import {
|
|
3
|
-
import { LeadServiceAPI } from '../../api/LeadServiceAPI';
|
|
2
|
+
import { useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
4
3
|
import { useForm } from '../../hooks/useForm';
|
|
5
4
|
import { ApplicationFormLayout } from '../../ui-kit/ApplicationFormLayout/ApplicationFormLayout';
|
|
6
5
|
import { getField } from '../../ui-kit/FormField/getField';
|
|
7
|
-
import { getObjectValidator } from '../../ui-kit/FormField/getObjectValidator';
|
|
8
6
|
import { inputColumnStyles } from '../../ui-kit/FormField/inputColumnStyle';
|
|
9
7
|
import { renderTitle } from '../../ui-kit/FormField/renderTitle';
|
|
10
8
|
import { useResponseTypeDialog } from '../../ui-kit/ResponseTypeDialog/useResponseTypeDialog';
|
|
11
9
|
import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
|
|
12
10
|
import { style } from '../../utils/style';
|
|
13
|
-
import { objectValidator } from '../../validation/objectValidator';
|
|
14
|
-
import { isValidationSuccess } from '../../validation/validator';
|
|
15
11
|
import {
|
|
16
12
|
type ApplicationLeadFormContent,
|
|
17
13
|
type FieldDef,
|
|
18
14
|
type GroupedConsentsProps,
|
|
19
15
|
} from './ApplicationLeadFormContent';
|
|
20
16
|
import { CONSENTS } from './consents';
|
|
21
|
-
import {
|
|
22
|
-
import { getInitialFormState, type FormState } from './getInitialFormState';
|
|
17
|
+
import { getInitialFormState } from './getInitialFormState';
|
|
23
18
|
import { GroupedConsents } from './GroupedConsents';
|
|
24
19
|
import { renderSubmitButton } from './renderSubmitButton';
|
|
20
|
+
import { useApplicationLeadApi } from './useApplicationLeadApi';
|
|
21
|
+
import { useInitApplicationLead } from './useInitApplicationLead';
|
|
25
22
|
|
|
26
23
|
interface ApplicationLeadFormProps extends ApplicationLeadFormContent, UniBlockProps {}
|
|
27
24
|
|
|
28
|
-
const API = LeadServiceAPI();
|
|
29
|
-
|
|
30
25
|
export const ApplicationLeadForm = JSX<ApplicationLeadFormProps>(
|
|
31
|
-
|
|
32
|
-
({ className, title, typeForm = '', sections = [], button, endpoint, ...rest }) => {
|
|
26
|
+
({ className, title, programId, typeForm = '', sections = [], button, ...rest }) => {
|
|
33
27
|
const inputs = (sections?.flatMap((_) => _?.inputs) || []) as FieldDef[];
|
|
34
28
|
const initialFormState = getInitialFormState(inputs, typeForm);
|
|
35
29
|
const [responseType, setResponseType] = useState<'OK' | 'Fail' | ''>('');
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (!isValidationSuccess(feedbackValidator(formData))) {
|
|
39
|
-
return 'Fail';
|
|
40
|
-
}
|
|
41
|
-
const formatData = getFormatData(formData);
|
|
42
|
-
const status = (await API.send(formatData, endpoint === 'lead')) ? 'OK' : 'Fail';
|
|
43
|
-
setResponseType(status);
|
|
44
|
-
|
|
45
|
-
if (status) {
|
|
46
|
-
const responseTypeDialog = useResponseTypeDialog({ responseType: status, typeForm });
|
|
47
|
-
responseTypeDialog.open();
|
|
48
|
-
}
|
|
30
|
+
useInitApplicationLead();
|
|
31
|
+
const { handleSubmit, responseStatus } = useApplicationLeadApi(inputs, programId || '');
|
|
49
32
|
|
|
50
|
-
|
|
51
|
-
|
|
33
|
+
if (responseStatus) {
|
|
34
|
+
const responseTypeDialog = useResponseTypeDialog({ responseType: responseStatus, typeForm });
|
|
35
|
+
responseTypeDialog.open();
|
|
36
|
+
}
|
|
52
37
|
|
|
53
38
|
const [, { field, onSubmit, reset }] = useForm(initialFormState, { onSubmit: handleSubmit });
|
|
54
39
|
|
|
@@ -179,6 +179,8 @@ export type ApplicationLeadFormContent = UniBlockContent &
|
|
|
179
179
|
/** @default "" */
|
|
180
180
|
target?: Target;
|
|
181
181
|
};
|
|
182
|
+
/** @title Номер кредитной программы */
|
|
183
|
+
programId?: string;
|
|
182
184
|
typeForm?: TypeFormFieldDef;
|
|
183
185
|
/** @hidden */
|
|
184
186
|
sections?: SectionsProps[];
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { useCallback, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
+
import { RETAIL_API } from '../../api/RetailApi/RetailApi';
|
|
3
|
+
import { getUpdateUserProfileData } from '../../api/RetailApi/utils/getUpdateUserProfile';
|
|
4
|
+
import { getUpdateUserTaskData } from '../../api/RetailApi/utils/getUpdateUserTask';
|
|
5
|
+
import { getObjectValidator } from '../../ui-kit/FormField/getObjectValidator';
|
|
6
|
+
import { useVerifyPhoneDialog } from '../../ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog';
|
|
7
|
+
import { formatPhone } from '../../utils/formatPhone';
|
|
8
|
+
import { objectValidator } from '../../validation/objectValidator';
|
|
9
|
+
import { isValidationSuccess } from '../../validation/validator';
|
|
10
|
+
import { type FieldDef } from './ApplicationLeadFormContent';
|
|
11
|
+
import { type FormState } from './getInitialFormState';
|
|
12
|
+
|
|
13
|
+
export const useApplicationLeadApi = (inputs: FieldDef[], programId: string) => {
|
|
14
|
+
const [responseStatus, setResponseStatus] = useState<'OK' | 'Fail' | ''>('');
|
|
15
|
+
|
|
16
|
+
// eslint-disable-next-line consistent-return
|
|
17
|
+
const handleSubmit = useCallback(async (formData: FormState) => {
|
|
18
|
+
const feedbackValidator = objectValidator(getObjectValidator(inputs));
|
|
19
|
+
if (!isValidationSuccess(feedbackValidator(formData))) {
|
|
20
|
+
return 'Fail';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
const { profile } = await RETAIL_API.CreateUserProfile({
|
|
25
|
+
profile: { phone: formatPhone(formData.phone as string) },
|
|
26
|
+
});
|
|
27
|
+
const profileId = profile?.id;
|
|
28
|
+
|
|
29
|
+
if (profileId && formData?.phone) {
|
|
30
|
+
const handleSuccessVerify = async () => {
|
|
31
|
+
try {
|
|
32
|
+
await RETAIL_API.UpdateUserProfile(getUpdateUserProfileData(profileId, formData));
|
|
33
|
+
const { taskId, participantId } = await RETAIL_API.CreateDraftTask({
|
|
34
|
+
profileId,
|
|
35
|
+
programId,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
await RETAIL_API.UpdateUserTask(
|
|
39
|
+
getUpdateUserTaskData(participantId, taskId, profileId, formData),
|
|
40
|
+
);
|
|
41
|
+
setResponseStatus('OK');
|
|
42
|
+
} catch {
|
|
43
|
+
setResponseStatus('Fail');
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
47
|
+
const verifyPhoneDialog = useVerifyPhoneDialog({
|
|
48
|
+
onClose: handleSuccessVerify,
|
|
49
|
+
...verifyPhoneContent(formData?.phone),
|
|
50
|
+
});
|
|
51
|
+
verifyPhoneDialog.open();
|
|
52
|
+
}
|
|
53
|
+
} catch {
|
|
54
|
+
setResponseStatus('Fail');
|
|
55
|
+
}
|
|
56
|
+
}, []);
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
handleSubmit,
|
|
60
|
+
responseStatus,
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const verifyPhoneContent = (phone: string) => ({
|
|
65
|
+
title: 'Подтвердите номер телефона',
|
|
66
|
+
description: `Мы отправили код на ${phone}`,
|
|
67
|
+
phone: formatPhone(phone),
|
|
68
|
+
textButton: 'Оформить',
|
|
69
|
+
__html: `<span>Вводя код, я подтверждаю, что ознакомлен и подписываю:</span>
|
|
70
|
+
<ul><li>соглашение о порядке использования простой электронной подписи,
|
|
71
|
+
</li><li>согласие на обработку персональных данных,
|
|
72
|
+
</li><li>предоставление и подписание прочих согласий Банка,
|
|
73
|
+
</li><li>согласие на запрос в ПФР</li></ul>`,
|
|
74
|
+
href: '/credit-lead',
|
|
75
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
-
import { useCallback, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
3
|
-
import {
|
|
2
|
+
import { useCallback, useEffect, useMemo, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
3
|
+
import { RETAIL_API } from '../../api/RetailApi/RetailApi';
|
|
4
4
|
import { Headline } from '../../components/Headline/Headline';
|
|
5
5
|
import { Dialog } from '../DialogManager/Dialog';
|
|
6
6
|
import { useDialogManager } from '../DialogManager/useDialogManager';
|
|
@@ -10,38 +10,59 @@ import { RichText } from '../RichText/RichText';
|
|
|
10
10
|
import { Timer } from '../TimerCircle/Timer';
|
|
11
11
|
import { InputCode } from './InputCode';
|
|
12
12
|
import { SubmitButton } from './SubmitButton';
|
|
13
|
-
import { submitVerifyPhoneForm } from './submitVerifyPhoneForm';
|
|
14
13
|
|
|
15
14
|
export interface VerifyPhoneDialogProps {
|
|
15
|
+
phone: string;
|
|
16
16
|
title?: string;
|
|
17
17
|
description?: string;
|
|
18
18
|
code?: boolean;
|
|
19
19
|
__html?: string;
|
|
20
20
|
codeLength?: number;
|
|
21
21
|
textButton?: string;
|
|
22
|
+
onClose?: () => Promise<void>;
|
|
23
|
+
href?: string;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
export const VerifyPhoneDialog = JSX<VerifyPhoneDialogProps>(
|
|
25
|
-
({
|
|
27
|
+
({
|
|
28
|
+
title,
|
|
29
|
+
phone,
|
|
30
|
+
description,
|
|
31
|
+
__html,
|
|
32
|
+
code = true,
|
|
33
|
+
codeLength = 4,
|
|
34
|
+
textButton = '',
|
|
35
|
+
onClose,
|
|
36
|
+
href = '',
|
|
37
|
+
}) => {
|
|
26
38
|
const { close } = useDialogManager();
|
|
27
39
|
|
|
28
|
-
const [values, setValues] = useState(Array(codeLength).fill(''));
|
|
40
|
+
const [values, setValues] = useState<string[]>(Array(codeLength).fill('') as string[]);
|
|
29
41
|
const [hasError, setHasError] = useState(false);
|
|
30
42
|
const [isLoading, setIsLoading] = useState(false);
|
|
31
|
-
const [timeNextReq, setTimeNextReq] = useState<number>(
|
|
43
|
+
const [timeNextReq, setTimeNextReq] = useState<number>(180);
|
|
32
44
|
|
|
33
45
|
const isValidCode = useMemo(() => values.every(Boolean), [values]);
|
|
34
46
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
RETAIL_API.SendCode({
|
|
49
|
+
phoneNumber: phone,
|
|
50
|
+
smsCodesSetName: { key: 'AUTHENTICATION' },
|
|
51
|
+
});
|
|
52
|
+
}, []);
|
|
41
53
|
|
|
42
|
-
|
|
54
|
+
const handleSubmit = useCallback(async () => {
|
|
55
|
+
try {
|
|
56
|
+
setIsLoading(true);
|
|
57
|
+
await RETAIL_API.CheckCode({
|
|
58
|
+
smsText: values.join(''),
|
|
59
|
+
smsCodesSetName: { key: 'AUTHENTICATION' },
|
|
60
|
+
});
|
|
61
|
+
globalThis.location.href = href;
|
|
43
62
|
close();
|
|
44
|
-
|
|
63
|
+
onClose && onClose();
|
|
64
|
+
} catch {
|
|
65
|
+
setIsLoading(false);
|
|
45
66
|
setHasError(true);
|
|
46
67
|
}
|
|
47
68
|
}, [values]);
|
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.583",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ЦК",
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
"path": "lib/common.css"
|
|
211
211
|
},
|
|
212
212
|
{
|
|
213
|
-
"limit": "
|
|
213
|
+
"limit": "73 kB",
|
|
214
214
|
"path": "bundle/bundle.umd.min.js"
|
|
215
215
|
}
|
|
216
216
|
],
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type CheckCodeBody,
|
|
3
|
+
type CheckCodeResponse,
|
|
4
|
+
type CreateDraftTaskBody,
|
|
5
|
+
type CreateDraftTaskResponse,
|
|
6
|
+
type CreateUserProfileBody,
|
|
7
|
+
type CreateUserProfileResponse,
|
|
8
|
+
type SendCodeBody,
|
|
9
|
+
type UpdateUserProfileBody,
|
|
10
|
+
type UpdateUserTaskBody,
|
|
11
|
+
} from './RetailApiTypes';
|
|
12
|
+
|
|
13
|
+
type RequsetMethod = 'POST' | 'GET' | 'PUT';
|
|
14
|
+
|
|
15
|
+
const getAthorizationHeaders = () => {
|
|
16
|
+
const token = sessionStorage.getItem('accessToken');
|
|
17
|
+
|
|
18
|
+
return token ? { Authorization: `Bearer ${token}` } : null;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const isJSON = (response: Response) => response.headers.get('Content-Type') === 'application/json';
|
|
22
|
+
|
|
23
|
+
const request = async <T>(url: string, method: RequsetMethod, body?: any): Promise<T> =>
|
|
24
|
+
await fetch('https://retail-light-api.cprb.dev.rshbdev.ru/api/v1' + url, {
|
|
25
|
+
method,
|
|
26
|
+
headers: {
|
|
27
|
+
'Content-Type': 'application/json',
|
|
28
|
+
...getAthorizationHeaders(),
|
|
29
|
+
},
|
|
30
|
+
credentials: 'include',
|
|
31
|
+
body: body ? JSON.stringify(body) : null,
|
|
32
|
+
}).then((response) => (isJSON(response) ? response.json() : response));
|
|
33
|
+
|
|
34
|
+
const saveToken = (data: CheckCodeResponse) => {
|
|
35
|
+
sessionStorage.setItem('accessToken', data.access_token as string);
|
|
36
|
+
sessionStorage.setItem('refreshToken', data.refresh_token as string);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const RETAIL_API = {
|
|
40
|
+
CreateUserProfile: async (body: CreateUserProfileBody) =>
|
|
41
|
+
await request<CreateUserProfileResponse>('/public-data/createUserProfile', 'POST', body),
|
|
42
|
+
UpdateUserProfile: async (body: UpdateUserProfileBody) =>
|
|
43
|
+
await request('/user-data/updateUserProfile', 'PUT', body),
|
|
44
|
+
CreateDraftTask: async (body: CreateDraftTaskBody) =>
|
|
45
|
+
await request<CreateDraftTaskResponse>('/user-data/createDraftTask', 'POST', body),
|
|
46
|
+
UpdateUserTask: async (body: UpdateUserTaskBody) =>
|
|
47
|
+
await request('/user-data/updateUserTask', 'PUT', body),
|
|
48
|
+
SendCode: async (body: SendCodeBody) => await request('/sms/sendCode', 'POST', body),
|
|
49
|
+
CheckCode: async (body: CheckCodeBody) =>
|
|
50
|
+
await request<CheckCodeResponse>('/sms/checkCode', 'POST', body).then(saveToken),
|
|
51
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export type CreateUserProfileBody = {
|
|
2
|
+
profile: {
|
|
3
|
+
phone: string;
|
|
4
|
+
};
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type CreateUserProfileResponse = {
|
|
8
|
+
profile: {
|
|
9
|
+
id: number;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type UpdateUserProfileBody = {
|
|
14
|
+
profile: {
|
|
15
|
+
id: number;
|
|
16
|
+
phone: string;
|
|
17
|
+
email: string;
|
|
18
|
+
name: string;
|
|
19
|
+
surname: string;
|
|
20
|
+
midname: string;
|
|
21
|
+
birthDate: string;
|
|
22
|
+
processPersonalDataLeadFlg: boolean;
|
|
23
|
+
consentProviderFlg: boolean;
|
|
24
|
+
consentPfrFlg: boolean;
|
|
25
|
+
consentPhotoFlg: boolean;
|
|
26
|
+
consentAssignmentClaimsFlg: boolean;
|
|
27
|
+
consentCollectionFlg: boolean;
|
|
28
|
+
consentInformFlg: boolean;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type CreateDraftTaskBody = {
|
|
33
|
+
profileId: number;
|
|
34
|
+
programId: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type CreateDraftTaskResponse = {
|
|
38
|
+
taskId: number;
|
|
39
|
+
participantId: number;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type UpdateUserTaskBody = {
|
|
43
|
+
sendToBank: boolean;
|
|
44
|
+
taskKind: 'SHORT' | 'FULL' | 'UNITED';
|
|
45
|
+
task: {
|
|
46
|
+
taskSource: string;
|
|
47
|
+
id: number;
|
|
48
|
+
participants: [
|
|
49
|
+
{
|
|
50
|
+
birthDate: string;
|
|
51
|
+
id: number;
|
|
52
|
+
midname: string;
|
|
53
|
+
name: string;
|
|
54
|
+
surname: string;
|
|
55
|
+
profile: {
|
|
56
|
+
id: number;
|
|
57
|
+
};
|
|
58
|
+
participantContacts: Array<{
|
|
59
|
+
contactTypeCd: {
|
|
60
|
+
key: 'EMAIL' | 'MAIN_PHONE';
|
|
61
|
+
};
|
|
62
|
+
value: string;
|
|
63
|
+
}>;
|
|
64
|
+
roleCd: {
|
|
65
|
+
key: string;
|
|
66
|
+
value: string;
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type SendCodeBody = {
|
|
74
|
+
phoneNumber: string;
|
|
75
|
+
smsCodesSetName: {
|
|
76
|
+
key: 'AUTHENTICATION' | 'SEND_TASK';
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export type CheckCodeBody = {
|
|
81
|
+
smsText: string;
|
|
82
|
+
smsCodesSetName: {
|
|
83
|
+
key: 'AUTHENTICATION' | 'SEND_TASK';
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export type CheckCodeResponse = {
|
|
88
|
+
access_token: string;
|
|
89
|
+
expires_in: number;
|
|
90
|
+
refresh_token: string;
|
|
91
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type FormState } from '../../../components/ApplicationLeadForm/getInitialFormState';
|
|
2
|
+
import { formatDate } from '../../../utils/formatDate';
|
|
3
|
+
import { formatPhone } from '../../../utils/formatPhone';
|
|
4
|
+
import { type UpdateUserProfileBody } from '../RetailApiTypes';
|
|
5
|
+
|
|
6
|
+
export const getUpdateUserProfileData = (
|
|
7
|
+
profileId: number,
|
|
8
|
+
formData: FormState,
|
|
9
|
+
): UpdateUserProfileBody => {
|
|
10
|
+
const {
|
|
11
|
+
name = '',
|
|
12
|
+
surname = '',
|
|
13
|
+
middleName = '',
|
|
14
|
+
birthday = '',
|
|
15
|
+
phone = '',
|
|
16
|
+
email = '',
|
|
17
|
+
processPersonalDataLeadFlg,
|
|
18
|
+
consentProviderFlg,
|
|
19
|
+
consentPfrFlg,
|
|
20
|
+
consentPhotoFlg,
|
|
21
|
+
consentAssignmentClaimsFlg,
|
|
22
|
+
consentCollectionFlg,
|
|
23
|
+
consentInformFlg,
|
|
24
|
+
} = formData;
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
profile: {
|
|
28
|
+
id: profileId,
|
|
29
|
+
name,
|
|
30
|
+
surname,
|
|
31
|
+
midname: middleName,
|
|
32
|
+
birthDate: birthday && formatDate(birthday, true),
|
|
33
|
+
email,
|
|
34
|
+
phone: formatPhone(phone),
|
|
35
|
+
processPersonalDataLeadFlg: Boolean(processPersonalDataLeadFlg),
|
|
36
|
+
consentProviderFlg: Boolean(consentProviderFlg),
|
|
37
|
+
consentPfrFlg: Boolean(consentPfrFlg),
|
|
38
|
+
consentPhotoFlg: Boolean(consentPhotoFlg),
|
|
39
|
+
consentAssignmentClaimsFlg: Boolean(consentAssignmentClaimsFlg),
|
|
40
|
+
consentCollectionFlg: Boolean(consentCollectionFlg),
|
|
41
|
+
consentInformFlg: Boolean(consentInformFlg),
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type UpdateUserTaskBody } from '../RetailApiTypes';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable max-params */
|
|
4
|
+
export const getUpdateUserTaskData = (
|
|
5
|
+
participantId: number,
|
|
6
|
+
taskId: number,
|
|
7
|
+
profileId: number,
|
|
8
|
+
formatData?: Record<string, any>,
|
|
9
|
+
): UpdateUserTaskBody => ({
|
|
10
|
+
sendToBank: true,
|
|
11
|
+
taskKind: 'SHORT',
|
|
12
|
+
task: {
|
|
13
|
+
taskSource: globalThis.location.origin,
|
|
14
|
+
id: taskId,
|
|
15
|
+
participants: [
|
|
16
|
+
{
|
|
17
|
+
birthDate: formatData?.birthDate,
|
|
18
|
+
id: participantId,
|
|
19
|
+
midname: formatData?.midname,
|
|
20
|
+
name: formatData?.name,
|
|
21
|
+
surname: formatData?.surname,
|
|
22
|
+
profile: {
|
|
23
|
+
id: profileId,
|
|
24
|
+
},
|
|
25
|
+
participantContacts: [
|
|
26
|
+
{
|
|
27
|
+
contactTypeCd: {
|
|
28
|
+
key: 'EMAIL',
|
|
29
|
+
},
|
|
30
|
+
value: formatData?.email,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
contactTypeCd: {
|
|
34
|
+
key: 'MAIN_PHONE',
|
|
35
|
+
},
|
|
36
|
+
value: formatData?.phone,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
roleCd: {
|
|
40
|
+
key: 'BORROWER',
|
|
41
|
+
value: 'Заемщик',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
});
|
|
@@ -1,54 +1,39 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
-
import {
|
|
3
|
-
import { LeadServiceAPI } from '../../api/LeadServiceAPI';
|
|
2
|
+
import { useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
4
3
|
import { useForm } from '../../hooks/useForm';
|
|
5
4
|
import { ApplicationFormLayout } from '../../ui-kit/ApplicationFormLayout/ApplicationFormLayout';
|
|
6
5
|
import { getField } from '../../ui-kit/FormField/getField';
|
|
7
|
-
import { getObjectValidator } from '../../ui-kit/FormField/getObjectValidator';
|
|
8
6
|
import { inputColumnStyles } from '../../ui-kit/FormField/inputColumnStyle';
|
|
9
7
|
import { renderTitle } from '../../ui-kit/FormField/renderTitle';
|
|
10
8
|
import { useResponseTypeDialog } from '../../ui-kit/ResponseTypeDialog/useResponseTypeDialog';
|
|
11
9
|
import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
|
|
12
10
|
import { style } from '../../utils/style';
|
|
13
|
-
import { objectValidator } from '../../validation/objectValidator';
|
|
14
|
-
import { isValidationSuccess } from '../../validation/validator';
|
|
15
11
|
import {
|
|
16
12
|
type ApplicationLeadFormContent,
|
|
17
13
|
type FieldDef,
|
|
18
14
|
type GroupedConsentsProps,
|
|
19
15
|
} from './ApplicationLeadFormContent';
|
|
20
16
|
import { CONSENTS } from './consents';
|
|
21
|
-
import {
|
|
22
|
-
import { getInitialFormState, type FormState } from './getInitialFormState';
|
|
17
|
+
import { getInitialFormState } from './getInitialFormState';
|
|
23
18
|
import { GroupedConsents } from './GroupedConsents';
|
|
24
19
|
import { renderSubmitButton } from './renderSubmitButton';
|
|
20
|
+
import { useApplicationLeadApi } from './useApplicationLeadApi';
|
|
21
|
+
import { useInitApplicationLead } from './useInitApplicationLead';
|
|
25
22
|
|
|
26
23
|
interface ApplicationLeadFormProps extends ApplicationLeadFormContent, UniBlockProps {}
|
|
27
24
|
|
|
28
|
-
const API = LeadServiceAPI();
|
|
29
|
-
|
|
30
25
|
export const ApplicationLeadForm = JSX<ApplicationLeadFormProps>(
|
|
31
|
-
|
|
32
|
-
({ className, title, typeForm = '', sections = [], button, endpoint, ...rest }) => {
|
|
26
|
+
({ className, title, programId, typeForm = '', sections = [], button, ...rest }) => {
|
|
33
27
|
const inputs = (sections?.flatMap((_) => _?.inputs) || []) as FieldDef[];
|
|
34
28
|
const initialFormState = getInitialFormState(inputs, typeForm);
|
|
35
29
|
const [responseType, setResponseType] = useState<'OK' | 'Fail' | ''>('');
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (!isValidationSuccess(feedbackValidator(formData))) {
|
|
39
|
-
return 'Fail';
|
|
40
|
-
}
|
|
41
|
-
const formatData = getFormatData(formData);
|
|
42
|
-
const status = (await API.send(formatData, endpoint === 'lead')) ? 'OK' : 'Fail';
|
|
43
|
-
setResponseType(status);
|
|
44
|
-
|
|
45
|
-
if (status) {
|
|
46
|
-
const responseTypeDialog = useResponseTypeDialog({ responseType: status, typeForm });
|
|
47
|
-
responseTypeDialog.open();
|
|
48
|
-
}
|
|
30
|
+
useInitApplicationLead();
|
|
31
|
+
const { handleSubmit, responseStatus } = useApplicationLeadApi(inputs, programId || '');
|
|
49
32
|
|
|
50
|
-
|
|
51
|
-
|
|
33
|
+
if (responseStatus) {
|
|
34
|
+
const responseTypeDialog = useResponseTypeDialog({ responseType: responseStatus, typeForm });
|
|
35
|
+
responseTypeDialog.open();
|
|
36
|
+
}
|
|
52
37
|
|
|
53
38
|
const [, { field, onSubmit, reset }] = useForm(initialFormState, { onSubmit: handleSubmit });
|
|
54
39
|
|
|
@@ -179,6 +179,8 @@ export type ApplicationLeadFormContent = UniBlockContent &
|
|
|
179
179
|
/** @default "" */
|
|
180
180
|
target?: Target;
|
|
181
181
|
};
|
|
182
|
+
/** @title Номер кредитной программы */
|
|
183
|
+
programId?: string;
|
|
182
184
|
typeForm?: TypeFormFieldDef;
|
|
183
185
|
/** @hidden */
|
|
184
186
|
sections?: SectionsProps[];
|