@redneckz/wildless-cms-uni-blocks 0.14.607 → 0.14.609

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/bundle/api/RetailAPI/updateUserProfile.d.ts +2 -0
  2. package/bundle/bundle.umd.js +101 -29
  3. package/bundle/bundle.umd.min.js +1 -1
  4. package/bundle/ui-kit/ConsentBkiDialog/ConsentBkiDialog.d.ts +5 -0
  5. package/bundle/ui-kit/ConsentBkiDialog/useConsentBkiDialog.d.ts +3 -0
  6. package/bundle/ui-kit/DialogManager/openDocument.d.ts +2 -0
  7. package/bundle/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +1 -1
  8. package/bundle/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.d.ts +2 -3
  9. package/bundle/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -1
  10. package/dist/api/RetailAPI/updateUserProfile.d.ts +2 -0
  11. package/dist/api/RetailAPI/updateUserProfile.js +1 -1
  12. package/dist/api/RetailAPI/updateUserProfile.js.map +1 -1
  13. package/dist/components/ApplicationLeadForm/GroupedConsents.js +1 -1
  14. package/dist/components/ApplicationLeadForm/GroupedConsents.js.map +1 -1
  15. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +8 -7
  16. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  17. package/dist/ui-kit/Checkbox/CheckboxWithDoc.js +2 -7
  18. package/dist/ui-kit/Checkbox/CheckboxWithDoc.js.map +1 -1
  19. package/dist/ui-kit/ConsentBkiDialog/ConsentBkiDialog.d.ts +5 -0
  20. package/dist/ui-kit/ConsentBkiDialog/ConsentBkiDialog.js +44 -0
  21. package/dist/ui-kit/ConsentBkiDialog/ConsentBkiDialog.js.map +1 -0
  22. package/dist/ui-kit/ConsentBkiDialog/useConsentBkiDialog.d.ts +3 -0
  23. package/dist/ui-kit/ConsentBkiDialog/useConsentBkiDialog.js +49 -0
  24. package/dist/ui-kit/ConsentBkiDialog/useConsentBkiDialog.js.map +1 -0
  25. package/dist/ui-kit/DialogManager/openDocument.d.ts +2 -0
  26. package/dist/ui-kit/DialogManager/openDocument.js +11 -0
  27. package/dist/ui-kit/DialogManager/openDocument.js.map +1 -0
  28. package/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +1 -1
  29. package/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.d.ts +2 -3
  30. package/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.js +2 -2
  31. package/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.js.map +1 -1
  32. package/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -1
  33. package/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +1 -1
  34. package/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
  35. package/lib/api/RetailAPI/updateUserProfile.d.ts +2 -0
  36. package/lib/api/RetailAPI/updateUserProfile.js +1 -1
  37. package/lib/api/RetailAPI/updateUserProfile.js.map +1 -1
  38. package/lib/common.css +1 -1
  39. package/lib/components/ApplicationLeadForm/GroupedConsents.js +1 -1
  40. package/lib/components/ApplicationLeadForm/GroupedConsents.js.map +1 -1
  41. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +8 -7
  42. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  43. package/lib/ui-kit/Checkbox/CheckboxWithDoc.js +2 -7
  44. package/lib/ui-kit/Checkbox/CheckboxWithDoc.js.map +1 -1
  45. package/lib/ui-kit/ConsentBkiDialog/ConsentBkiDialog.d.ts +5 -0
  46. package/lib/ui-kit/ConsentBkiDialog/ConsentBkiDialog.fixture.d.ts +6 -0
  47. package/lib/ui-kit/ConsentBkiDialog/ConsentBkiDialog.js +42 -0
  48. package/lib/ui-kit/ConsentBkiDialog/ConsentBkiDialog.js.map +1 -0
  49. package/lib/ui-kit/ConsentBkiDialog/useConsentBkiDialog.d.ts +3 -0
  50. package/lib/ui-kit/ConsentBkiDialog/useConsentBkiDialog.js +46 -0
  51. package/lib/ui-kit/ConsentBkiDialog/useConsentBkiDialog.js.map +1 -0
  52. package/lib/ui-kit/DialogManager/openDocument.d.ts +2 -0
  53. package/lib/ui-kit/DialogManager/openDocument.js +8 -0
  54. package/lib/ui-kit/DialogManager/openDocument.js.map +1 -0
  55. package/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +1 -1
  56. package/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.d.ts +2 -3
  57. package/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.js +2 -2
  58. package/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.js.map +1 -1
  59. package/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -1
  60. package/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +1 -1
  61. package/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
  62. package/mobile/bundle/api/RetailAPI/updateUserProfile.d.ts +2 -0
  63. package/mobile/bundle/bundle.umd.js +101 -29
  64. package/mobile/bundle/bundle.umd.min.js +1 -1
  65. package/mobile/bundle/ui-kit/ConsentBkiDialog/ConsentBkiDialog.d.ts +5 -0
  66. package/mobile/bundle/ui-kit/ConsentBkiDialog/useConsentBkiDialog.d.ts +3 -0
  67. package/mobile/bundle/ui-kit/DialogManager/openDocument.d.ts +2 -0
  68. package/mobile/bundle/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +1 -1
  69. package/mobile/bundle/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.d.ts +2 -3
  70. package/mobile/bundle/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -1
  71. package/mobile/dist/api/RetailAPI/updateUserProfile.d.ts +2 -0
  72. package/mobile/dist/api/RetailAPI/updateUserProfile.js +1 -1
  73. package/mobile/dist/api/RetailAPI/updateUserProfile.js.map +1 -1
  74. package/mobile/dist/components/ApplicationLeadForm/GroupedConsents.js +1 -1
  75. package/mobile/dist/components/ApplicationLeadForm/GroupedConsents.js.map +1 -1
  76. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +8 -7
  77. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  78. package/mobile/dist/ui-kit/Checkbox/CheckboxWithDoc.js +2 -7
  79. package/mobile/dist/ui-kit/Checkbox/CheckboxWithDoc.js.map +1 -1
  80. package/mobile/dist/ui-kit/ConsentBkiDialog/ConsentBkiDialog.d.ts +5 -0
  81. package/mobile/dist/ui-kit/ConsentBkiDialog/ConsentBkiDialog.js +44 -0
  82. package/mobile/dist/ui-kit/ConsentBkiDialog/ConsentBkiDialog.js.map +1 -0
  83. package/mobile/dist/ui-kit/ConsentBkiDialog/useConsentBkiDialog.d.ts +3 -0
  84. package/mobile/dist/ui-kit/ConsentBkiDialog/useConsentBkiDialog.js +49 -0
  85. package/mobile/dist/ui-kit/ConsentBkiDialog/useConsentBkiDialog.js.map +1 -0
  86. package/mobile/dist/ui-kit/DialogManager/openDocument.d.ts +2 -0
  87. package/mobile/dist/ui-kit/DialogManager/openDocument.js +11 -0
  88. package/mobile/dist/ui-kit/DialogManager/openDocument.js.map +1 -0
  89. package/mobile/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +1 -1
  90. package/mobile/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.d.ts +2 -3
  91. package/mobile/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.js +2 -2
  92. package/mobile/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.js.map +1 -1
  93. package/mobile/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -1
  94. package/mobile/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +1 -1
  95. package/mobile/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
  96. package/mobile/lib/api/RetailAPI/updateUserProfile.d.ts +2 -0
  97. package/mobile/lib/api/RetailAPI/updateUserProfile.js +1 -1
  98. package/mobile/lib/api/RetailAPI/updateUserProfile.js.map +1 -1
  99. package/mobile/lib/common.css +1 -1
  100. package/mobile/lib/components/ApplicationLeadForm/GroupedConsents.js +1 -1
  101. package/mobile/lib/components/ApplicationLeadForm/GroupedConsents.js.map +1 -1
  102. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +8 -7
  103. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  104. package/mobile/lib/ui-kit/Checkbox/CheckboxWithDoc.js +2 -7
  105. package/mobile/lib/ui-kit/Checkbox/CheckboxWithDoc.js.map +1 -1
  106. package/mobile/lib/ui-kit/ConsentBkiDialog/ConsentBkiDialog.d.ts +5 -0
  107. package/mobile/lib/ui-kit/ConsentBkiDialog/ConsentBkiDialog.js +42 -0
  108. package/mobile/lib/ui-kit/ConsentBkiDialog/ConsentBkiDialog.js.map +1 -0
  109. package/mobile/lib/ui-kit/ConsentBkiDialog/useConsentBkiDialog.d.ts +3 -0
  110. package/mobile/lib/ui-kit/ConsentBkiDialog/useConsentBkiDialog.js +46 -0
  111. package/mobile/lib/ui-kit/ConsentBkiDialog/useConsentBkiDialog.js.map +1 -0
  112. package/mobile/lib/ui-kit/DialogManager/openDocument.d.ts +2 -0
  113. package/mobile/lib/ui-kit/DialogManager/openDocument.js +8 -0
  114. package/mobile/lib/ui-kit/DialogManager/openDocument.js.map +1 -0
  115. package/mobile/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +1 -1
  116. package/mobile/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.d.ts +2 -3
  117. package/mobile/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.js +2 -2
  118. package/mobile/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.js.map +1 -1
  119. package/mobile/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.d.ts +1 -1
  120. package/mobile/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js +1 -1
  121. package/mobile/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.js.map +1 -1
  122. package/mobile/src/api/RetailAPI/updateUserProfile.ts +3 -1
  123. package/mobile/src/components/ApplicationLeadForm/GroupedConsents.tsx +1 -1
  124. package/mobile/src/components/ApplicationLeadForm/useApplicationLeadApi.ts +12 -7
  125. package/mobile/src/ui-kit/Checkbox/CheckboxWithDoc.tsx +2 -16
  126. package/mobile/src/ui-kit/ConsentBkiDialog/ConsentBkiDialog.tsx +73 -0
  127. package/mobile/src/ui-kit/ConsentBkiDialog/useConsentBkiDialog.tsx +58 -0
  128. package/mobile/src/ui-kit/DialogManager/openDocument.tsx +13 -0
  129. package/mobile/src/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.tsx +1 -1
  130. package/mobile/src/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.tsx +4 -4
  131. package/mobile/src/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.tsx +2 -2
  132. package/package.json +1 -1
  133. package/src/api/RetailAPI/updateUserProfile.ts +3 -1
  134. package/src/components/ApplicationLeadForm/GroupedConsents.tsx +1 -1
  135. package/src/components/ApplicationLeadForm/useApplicationLeadApi.ts +12 -7
  136. package/src/ui-kit/Checkbox/CheckboxWithDoc.tsx +2 -16
  137. package/src/ui-kit/ConsentBkiDialog/ConsentBkiDialog.fixture.tsx +7 -0
  138. package/src/ui-kit/ConsentBkiDialog/ConsentBkiDialog.tsx +73 -0
  139. package/src/ui-kit/ConsentBkiDialog/useConsentBkiDialog.tsx +58 -0
  140. package/src/ui-kit/DialogManager/openDocument.tsx +13 -0
  141. package/src/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.tsx +1 -1
  142. package/src/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.tsx +4 -4
  143. package/src/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialogSubmit.tsx +2 -2
@@ -6,6 +6,7 @@ import { updateUserTask } from '../../api/RetailAPI/updateUserTask';
6
6
  import { getUpdateUserProfileData } from '../../api/RetailAPI/utils/getUpdateUserProfile';
7
7
  import { getUpdateUserTaskData } from '../../api/RetailAPI/utils/getUpdateUserTask';
8
8
  import { useLocalStorage } from '../../hooks/useLocalStorage';
9
+ import { useConsentBkiDialog } from '../../ui-kit/ConsentBkiDialog/useConsentBkiDialog';
9
10
  import { getObjectValidator } from '../../ui-kit/FormField/getObjectValidator';
10
11
  import { useVerifyPhoneDialog } from '../../ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog';
11
12
  import { formatPhone } from '../../utils/formatPhone';
@@ -26,6 +27,8 @@ export const useApplicationLeadApi = ({ inputs, programId, saveForm }: Applicati
26
27
  const [, setTaskId] = useLocalStorage<number>('taskId');
27
28
  const [, setProfileId] = useLocalStorage<number>('profileId');
28
29
  const [, setParticipantId] = useLocalStorage<number>('participantId');
30
+ const consentBkiDialog = useConsentBkiDialog();
31
+ const verifyPhoneDialog = useVerifyPhoneDialog();
29
32
 
30
33
  const saveUserData = useCallback((participantId: number, taskId: number, profileId: number) => {
31
34
  setParticipantId(participantId);
@@ -67,22 +70,24 @@ export const useApplicationLeadApi = ({ inputs, programId, saveForm }: Applicati
67
70
  );
68
71
  saveUserData(participantId, taskId, profileId);
69
72
  saveForm(JSON.stringify(formData));
70
- globalThis.location.href = '/credit-lead';
71
73
  } catch {
72
74
  setResponseStatus('Fail');
73
75
  }
74
76
  };
75
77
 
78
+ const handleCloseVerify = async () => {
79
+ await handleSuccessVerify();
80
+ consentBkiDialog.open(formData.phone, profileId);
81
+ };
82
+
76
83
  const acceptedConsents: string[] = Object.keys(CONSENTS)
77
84
  .filter((_) => formData[_])
78
85
  .map((_) => CONSENTS[_]?.text);
79
86
 
80
- // eslint-disable-next-line react-hooks/rules-of-hooks
81
- const verifyPhoneDialog = useVerifyPhoneDialog({
82
- close: handleSuccessVerify,
83
- ...verifyPhoneContent(formData?.phone, acceptedConsents),
84
- });
85
- verifyPhoneDialog.open();
87
+ verifyPhoneDialog.open(
88
+ handleCloseVerify,
89
+ verifyPhoneContent(formData?.phone, acceptedConsents),
90
+ );
86
91
  }
87
92
  } catch {
88
93
  setResponseStatus('Fail');
@@ -1,13 +1,11 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import { type VNode } from '../../model/VNode';
3
- import { Dialog } from '../DialogManager/Dialog';
2
+ import { openDocument } from '../DialogManager/openDocument';
4
3
  import { useDialogManager } from '../DialogManager/useDialogManager';
5
4
  import { renderErrorText } from '../Input/renderErrorText';
6
5
  import { LinkButton } from '../LinkButton/LinkButton';
7
6
  import { Text } from '../Text/Text';
8
7
  import { Checkbox } from './Checkbox';
9
8
  import { type CheckboxProps } from './CheckboxProps';
10
- import { getDocument } from './getDocument';
11
9
 
12
10
  const OPEN_DOC_BUTTON_TEXT = 'Ознакомиться';
13
11
 
@@ -24,10 +22,7 @@ export const CheckboxWithDoc = JSX<CheckboxWithDocProps>(
24
22
  <div className="flex flex-wrap gap-x-m">
25
23
  <Checkbox {...props} />
26
24
  {docId ? (
27
- <LinkButton
28
- className="text-primary-main"
29
- onClick={() => handleOpenDocument(docId, open)}
30
- >
25
+ <LinkButton className="text-primary-main" onClick={() => openDocument(docId, open)}>
31
26
  <Text>{OPEN_DOC_BUTTON_TEXT}</Text>
32
27
  </LinkButton>
33
28
  ) : null}
@@ -37,12 +32,3 @@ export const CheckboxWithDoc = JSX<CheckboxWithDocProps>(
37
32
  );
38
33
  },
39
34
  );
40
-
41
- const handleOpenDocument = async (id: number, open: (dialog: VNode) => void) => {
42
- const document = await getDocument(id);
43
- open(
44
- <Dialog className="my-6xl max-w-4xl mx-auto px-0 min-h-0 pb-0">
45
- <iframe src={`${document}#toolbar=0`} className="w-full h-[80vh]" id="iframe-dialog" />
46
- </Dialog>,
47
- );
48
- };
@@ -0,0 +1,73 @@
1
+ import { JSX } from '@redneckz/uni-jsx';
2
+ import { useCallback, useState } from '@redneckz/uni-jsx/lib/hooks';
3
+ import { noop } from '../../utils/noop';
4
+ import { Button } from '../Button/Button';
5
+ import { Dialog } from '../DialogManager/Dialog';
6
+ import { openDocument } from '../DialogManager/openDocument';
7
+ import { useDialogManager } from '../DialogManager/useDialogManager';
8
+ import { Heading } from '../Heading/Heading';
9
+ import { Paragraph } from '../Paragraph/Paragraph';
10
+ import { RadioButtonGroup } from '../RadioButtonGroup/RadioButtonGroup';
11
+ export interface ConsentBkiDialogProps {
12
+ handleSubmit?: (confirmStatus: string) => void;
13
+ onClose?: () => void;
14
+ }
15
+
16
+ const defaultConsentText = {
17
+ title: 'Подпишите согласие на запрос в БКИ',
18
+ description: 'Согласие на запрос в Бюро кредитных историй (БКИ) ускорит решение по кредиту',
19
+ };
20
+
21
+ const refuseConsentText = {
22
+ title: 'Вы уверены, что хотите отказаться от запроса в БКИ',
23
+ description: 'Согласие на запрос в Бюро кредитных историй (БКИ) повысит вероятность одобрения',
24
+ };
25
+
26
+ export const ConsentBkiDialog = JSX<ConsentBkiDialogProps>(function ({
27
+ handleSubmit = noop,
28
+ onClose = noop,
29
+ }) {
30
+ const [confirmStatus, setConfirmStatus] = useState('');
31
+ const [showRefuceContent, setShowRefuceContent] = useState(false);
32
+ const { open, close } = useDialogManager();
33
+ const handleClose = useCallback(() => {
34
+ close();
35
+ handleSubmit(confirmStatus);
36
+ }, [confirmStatus]);
37
+
38
+ const handleConfirmChange = useCallback((value: string) => {
39
+ setConfirmStatus(value);
40
+ if (value === 'REFUSE') {
41
+ setShowRefuceContent(true);
42
+ }
43
+ }, []);
44
+ const consentText = showRefuceContent ? refuseConsentText : defaultConsentText;
45
+
46
+ return (
47
+ <Dialog className="my-6xl max-w-3xl w-full min-h-fit mx-auto rounded-lg" onClose={onClose}>
48
+ <div className="flex flex-col gap-lg items-center">
49
+ <div role="button" onClick={() => openDocument(CONSENT_BKI_ID, open)}>
50
+ <Heading className="text-center text-balance" title={consentText.title} />
51
+ </div>
52
+ <Paragraph align="text-center">{consentText.description}</Paragraph>
53
+ <RadioButtonGroup
54
+ className="whitespace-normal"
55
+ orientation="horizontal"
56
+ items={ITEMS}
57
+ value={confirmStatus}
58
+ onChange={handleConfirmChange}
59
+ />
60
+ <Button disabled={!confirmStatus} type="button" onClick={handleClose}>
61
+ Продолжить
62
+ </Button>
63
+ </div>
64
+ </Dialog>
65
+ );
66
+ });
67
+
68
+ const ITEMS = [
69
+ { id: 'SIGNED', text: 'Подписать' },
70
+ { id: 'REFUSE', text: 'Отказаться' },
71
+ ];
72
+
73
+ const CONSENT_BKI_ID = 2;
@@ -0,0 +1,58 @@
1
+ import { updateUserProfile } from '../../api/RetailAPI/updateUserProfile';
2
+ import { formatPhone } from '../../utils/formatPhone';
3
+ import { useDialogManager } from '../DialogManager/useDialogManager';
4
+ import { useVerifyPhoneDialog } from '../VerifyPhoneDialog/useVerifyPhoneDialog';
5
+ import { ConsentBkiDialog } from './ConsentBkiDialog';
6
+
7
+ export const useConsentBkiDialog = () => {
8
+ const { open, closeAll } = useDialogManager();
9
+ const verifyPhoneDialog = useVerifyPhoneDialog();
10
+
11
+ const redirectToCreditForm = () => {
12
+ globalThis.location.href = '/credit-lead';
13
+ };
14
+
15
+ const handleSuccessVerify = (profileId?: number) => async (smsCode?: string) => {
16
+ if (profileId) {
17
+ await updateUserProfile({
18
+ profile: {
19
+ id: profileId,
20
+ consentBkiFlg: true,
21
+ smsConsentBki: smsCode,
22
+ },
23
+ });
24
+ }
25
+
26
+ redirectToCreditForm();
27
+ };
28
+
29
+ const handleSubmitBkiConstent =
30
+ (phone?: string, profileId?: number) => async (confirmStatus: string) => {
31
+ await closeAll();
32
+
33
+ if (confirmStatus === 'SIGNED' && phone) {
34
+ verifyPhoneDialog.open(handleSuccessVerify(profileId), verifyPhoneContent(phone));
35
+ } else {
36
+ redirectToCreditForm();
37
+ }
38
+ };
39
+
40
+ return {
41
+ open: (phone?: string, profileId?: number) =>
42
+ open(
43
+ <ConsentBkiDialog
44
+ handleSubmit={handleSubmitBkiConstent(phone, profileId)}
45
+ onClose={redirectToCreditForm}
46
+ />,
47
+ ),
48
+ };
49
+ };
50
+
51
+ const verifyPhoneContent = (phone: string) => ({
52
+ title: 'Подтвердите номер телефона',
53
+ description: `Мы отправили код на ${phone}`,
54
+ phoneNumber: formatPhone(phone),
55
+ textButton: 'Отправить',
56
+ __html: `<span>Вводя код, я подтверждаю, что ознакомлен и подписываю:</span>
57
+ <ul><li>согласие на запрос информации в БКИ</li></ul>`,
58
+ });
@@ -0,0 +1,13 @@
1
+ import { type VNode } from '../../model/VNode';
2
+ import { getDocument } from '../Checkbox/getDocument';
3
+ import { Dialog } from './Dialog';
4
+
5
+ export const openDocument = async (id: number, open: (dialog: VNode) => void) => {
6
+ const document = await getDocument(id);
7
+
8
+ open(
9
+ <Dialog className="my-6xl max-w-4xl mx-auto px-0 min-h-0 pb-0">
10
+ <iframe src={`${document}#toolbar=0`} className="w-full h-[80vh]" id="iframe-dialog" />
11
+ </Dialog>,
12
+ );
13
+ };
@@ -14,7 +14,7 @@ import { SubmitButton } from './SubmitButton';
14
14
  import { useVerifyPhoneDialogSubmit } from './useVerifyPhoneDialogSubmit';
15
15
 
16
16
  export interface VerifyPhoneDialogProps {
17
- close?: () => void;
17
+ close?: (smsCode?: string) => void;
18
18
  onClose?: () => void;
19
19
  title?: string;
20
20
  description?: string;
@@ -1,12 +1,12 @@
1
- import { useDialogManager, type DialogOptions } from '../DialogManager/useDialogManager';
1
+ import { useDialogManager } from '../DialogManager/useDialogManager';
2
2
  import { VerifyPhoneDialog, type VerifyPhoneDialogProps } from './VerifyPhoneDialog';
3
3
 
4
- export const useVerifyPhoneDialog = (props: VerifyPhoneDialogProps) => {
4
+ export const useVerifyPhoneDialog = () => {
5
5
  const { open, close } = useDialogManager();
6
6
 
7
7
  return {
8
- open: (options: DialogOptions = {}) =>
9
- open(<VerifyPhoneDialog onClose={close} {...props} />, options),
8
+ open: (handleClose: () => void, props: VerifyPhoneDialogProps) =>
9
+ open(<VerifyPhoneDialog onClose={close} close={handleClose} {...props} />),
10
10
  close,
11
11
  };
12
12
  };
@@ -3,7 +3,7 @@ import { checkCode } from '../../api/RetailAPI/checkCode';
3
3
 
4
4
  type useVerifyPhoneDialogSubmitProps = {
5
5
  values: string[];
6
- close?: () => void;
6
+ close?: (smsCode?: string) => void;
7
7
  };
8
8
 
9
9
  export const useVerifyPhoneDialogSubmit = ({ close, values }: useVerifyPhoneDialogSubmitProps) => {
@@ -40,7 +40,7 @@ export const useVerifyPhoneDialogSubmit = ({ close, values }: useVerifyPhoneDial
40
40
  smsCodesSetName: { key: 'AUTHENTICATION' },
41
41
  });
42
42
  resetError();
43
- close && close();
43
+ close && close(values.join(''));
44
44
  } catch {
45
45
  setIsLoading(false);
46
46
  attemps > 1 ? setErrorText('Исчерпан лимит ввода смс-кода') : setErrorText('Неверный код');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.14.607",
3
+ "version": "0.14.609",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -17,8 +17,10 @@ export type UpdateUserProfileBody = {
17
17
  consentAssignmentClaimsFlg?: boolean;
18
18
  consentCollectionFlg?: boolean;
19
19
  consentInformFlg?: boolean;
20
+ consentBkiFlg?: boolean;
21
+ smsConsentBki?: string;
20
22
  };
21
23
  };
22
24
 
23
25
  export const updateUserProfile = (body: UpdateUserProfileBody) =>
24
- doRequest<CreateUserProfileResponse>('/user-data/updateUserProfile', 'POST', body);
26
+ doRequest<CreateUserProfileResponse>('/user-data/updateUserProfile', 'PUT', body);
@@ -68,7 +68,7 @@ const renderGeneralCheckbox =
68
68
  (
69
69
  <div className="flex items-start">
70
70
  {generalCheckBox}
71
- <button onClick={foldableData.onToggle} className="px-m py-2xs">
71
+ <button onClick={foldableData.onToggle} className="px-m py-2xs" type="button">
72
72
  <Icon
73
73
  className="text-primary-text"
74
74
  name={foldableData.isUnfolded ? 'ArrowUpIcon' : 'ArrowDownIcon'}
@@ -6,6 +6,7 @@ import { updateUserTask } from '../../api/RetailAPI/updateUserTask';
6
6
  import { getUpdateUserProfileData } from '../../api/RetailAPI/utils/getUpdateUserProfile';
7
7
  import { getUpdateUserTaskData } from '../../api/RetailAPI/utils/getUpdateUserTask';
8
8
  import { useLocalStorage } from '../../hooks/useLocalStorage';
9
+ import { useConsentBkiDialog } from '../../ui-kit/ConsentBkiDialog/useConsentBkiDialog';
9
10
  import { getObjectValidator } from '../../ui-kit/FormField/getObjectValidator';
10
11
  import { useVerifyPhoneDialog } from '../../ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog';
11
12
  import { formatPhone } from '../../utils/formatPhone';
@@ -26,6 +27,8 @@ export const useApplicationLeadApi = ({ inputs, programId, saveForm }: Applicati
26
27
  const [, setTaskId] = useLocalStorage<number>('taskId');
27
28
  const [, setProfileId] = useLocalStorage<number>('profileId');
28
29
  const [, setParticipantId] = useLocalStorage<number>('participantId');
30
+ const consentBkiDialog = useConsentBkiDialog();
31
+ const verifyPhoneDialog = useVerifyPhoneDialog();
29
32
 
30
33
  const saveUserData = useCallback((participantId: number, taskId: number, profileId: number) => {
31
34
  setParticipantId(participantId);
@@ -67,22 +70,24 @@ export const useApplicationLeadApi = ({ inputs, programId, saveForm }: Applicati
67
70
  );
68
71
  saveUserData(participantId, taskId, profileId);
69
72
  saveForm(JSON.stringify(formData));
70
- globalThis.location.href = '/credit-lead';
71
73
  } catch {
72
74
  setResponseStatus('Fail');
73
75
  }
74
76
  };
75
77
 
78
+ const handleCloseVerify = async () => {
79
+ await handleSuccessVerify();
80
+ consentBkiDialog.open(formData.phone, profileId);
81
+ };
82
+
76
83
  const acceptedConsents: string[] = Object.keys(CONSENTS)
77
84
  .filter((_) => formData[_])
78
85
  .map((_) => CONSENTS[_]?.text);
79
86
 
80
- // eslint-disable-next-line react-hooks/rules-of-hooks
81
- const verifyPhoneDialog = useVerifyPhoneDialog({
82
- close: handleSuccessVerify,
83
- ...verifyPhoneContent(formData?.phone, acceptedConsents),
84
- });
85
- verifyPhoneDialog.open();
87
+ verifyPhoneDialog.open(
88
+ handleCloseVerify,
89
+ verifyPhoneContent(formData?.phone, acceptedConsents),
90
+ );
86
91
  }
87
92
  } catch {
88
93
  setResponseStatus('Fail');
@@ -1,13 +1,11 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import { type VNode } from '../../model/VNode';
3
- import { Dialog } from '../DialogManager/Dialog';
2
+ import { openDocument } from '../DialogManager/openDocument';
4
3
  import { useDialogManager } from '../DialogManager/useDialogManager';
5
4
  import { renderErrorText } from '../Input/renderErrorText';
6
5
  import { LinkButton } from '../LinkButton/LinkButton';
7
6
  import { Text } from '../Text/Text';
8
7
  import { Checkbox } from './Checkbox';
9
8
  import { type CheckboxProps } from './CheckboxProps';
10
- import { getDocument } from './getDocument';
11
9
 
12
10
  const OPEN_DOC_BUTTON_TEXT = 'Ознакомиться';
13
11
 
@@ -24,10 +22,7 @@ export const CheckboxWithDoc = JSX<CheckboxWithDocProps>(
24
22
  <div className="flex flex-wrap gap-x-m">
25
23
  <Checkbox {...props} />
26
24
  {docId ? (
27
- <LinkButton
28
- className="text-primary-main"
29
- onClick={() => handleOpenDocument(docId, open)}
30
- >
25
+ <LinkButton className="text-primary-main" onClick={() => openDocument(docId, open)}>
31
26
  <Text>{OPEN_DOC_BUTTON_TEXT}</Text>
32
27
  </LinkButton>
33
28
  ) : null}
@@ -37,12 +32,3 @@ export const CheckboxWithDoc = JSX<CheckboxWithDocProps>(
37
32
  );
38
33
  },
39
34
  );
40
-
41
- const handleOpenDocument = async (id: number, open: (dialog: VNode) => void) => {
42
- const document = await getDocument(id);
43
- open(
44
- <Dialog className="my-6xl max-w-4xl mx-auto px-0 min-h-0 pb-0">
45
- <iframe src={`${document}#toolbar=0`} className="w-full h-[80vh]" id="iframe-dialog" />
46
- </Dialog>,
47
- );
48
- };
@@ -0,0 +1,7 @@
1
+ import '../../setup-fixture';
2
+
3
+ import { ConsentBkiDialog } from './ConsentBkiDialog';
4
+
5
+ export default {
6
+ default: <ConsentBkiDialog />,
7
+ };
@@ -0,0 +1,73 @@
1
+ import { JSX } from '@redneckz/uni-jsx';
2
+ import { useCallback, useState } from '@redneckz/uni-jsx/lib/hooks';
3
+ import { noop } from '../../utils/noop';
4
+ import { Button } from '../Button/Button';
5
+ import { Dialog } from '../DialogManager/Dialog';
6
+ import { openDocument } from '../DialogManager/openDocument';
7
+ import { useDialogManager } from '../DialogManager/useDialogManager';
8
+ import { Heading } from '../Heading/Heading';
9
+ import { Paragraph } from '../Paragraph/Paragraph';
10
+ import { RadioButtonGroup } from '../RadioButtonGroup/RadioButtonGroup';
11
+ export interface ConsentBkiDialogProps {
12
+ handleSubmit?: (confirmStatus: string) => void;
13
+ onClose?: () => void;
14
+ }
15
+
16
+ const defaultConsentText = {
17
+ title: 'Подпишите согласие на запрос в БКИ',
18
+ description: 'Согласие на запрос в Бюро кредитных историй (БКИ) ускорит решение по кредиту',
19
+ };
20
+
21
+ const refuseConsentText = {
22
+ title: 'Вы уверены, что хотите отказаться от запроса в БКИ',
23
+ description: 'Согласие на запрос в Бюро кредитных историй (БКИ) повысит вероятность одобрения',
24
+ };
25
+
26
+ export const ConsentBkiDialog = JSX<ConsentBkiDialogProps>(function ({
27
+ handleSubmit = noop,
28
+ onClose = noop,
29
+ }) {
30
+ const [confirmStatus, setConfirmStatus] = useState('');
31
+ const [showRefuceContent, setShowRefuceContent] = useState(false);
32
+ const { open, close } = useDialogManager();
33
+ const handleClose = useCallback(() => {
34
+ close();
35
+ handleSubmit(confirmStatus);
36
+ }, [confirmStatus]);
37
+
38
+ const handleConfirmChange = useCallback((value: string) => {
39
+ setConfirmStatus(value);
40
+ if (value === 'REFUSE') {
41
+ setShowRefuceContent(true);
42
+ }
43
+ }, []);
44
+ const consentText = showRefuceContent ? refuseConsentText : defaultConsentText;
45
+
46
+ return (
47
+ <Dialog className="my-6xl max-w-3xl w-full min-h-fit mx-auto rounded-lg" onClose={onClose}>
48
+ <div className="flex flex-col gap-lg items-center">
49
+ <div role="button" onClick={() => openDocument(CONSENT_BKI_ID, open)}>
50
+ <Heading className="text-center text-balance" title={consentText.title} />
51
+ </div>
52
+ <Paragraph align="text-center">{consentText.description}</Paragraph>
53
+ <RadioButtonGroup
54
+ className="whitespace-normal"
55
+ orientation="horizontal"
56
+ items={ITEMS}
57
+ value={confirmStatus}
58
+ onChange={handleConfirmChange}
59
+ />
60
+ <Button disabled={!confirmStatus} type="button" onClick={handleClose}>
61
+ Продолжить
62
+ </Button>
63
+ </div>
64
+ </Dialog>
65
+ );
66
+ });
67
+
68
+ const ITEMS = [
69
+ { id: 'SIGNED', text: 'Подписать' },
70
+ { id: 'REFUSE', text: 'Отказаться' },
71
+ ];
72
+
73
+ const CONSENT_BKI_ID = 2;
@@ -0,0 +1,58 @@
1
+ import { updateUserProfile } from '../../api/RetailAPI/updateUserProfile';
2
+ import { formatPhone } from '../../utils/formatPhone';
3
+ import { useDialogManager } from '../DialogManager/useDialogManager';
4
+ import { useVerifyPhoneDialog } from '../VerifyPhoneDialog/useVerifyPhoneDialog';
5
+ import { ConsentBkiDialog } from './ConsentBkiDialog';
6
+
7
+ export const useConsentBkiDialog = () => {
8
+ const { open, closeAll } = useDialogManager();
9
+ const verifyPhoneDialog = useVerifyPhoneDialog();
10
+
11
+ const redirectToCreditForm = () => {
12
+ globalThis.location.href = '/credit-lead';
13
+ };
14
+
15
+ const handleSuccessVerify = (profileId?: number) => async (smsCode?: string) => {
16
+ if (profileId) {
17
+ await updateUserProfile({
18
+ profile: {
19
+ id: profileId,
20
+ consentBkiFlg: true,
21
+ smsConsentBki: smsCode,
22
+ },
23
+ });
24
+ }
25
+
26
+ redirectToCreditForm();
27
+ };
28
+
29
+ const handleSubmitBkiConstent =
30
+ (phone?: string, profileId?: number) => async (confirmStatus: string) => {
31
+ await closeAll();
32
+
33
+ if (confirmStatus === 'SIGNED' && phone) {
34
+ verifyPhoneDialog.open(handleSuccessVerify(profileId), verifyPhoneContent(phone));
35
+ } else {
36
+ redirectToCreditForm();
37
+ }
38
+ };
39
+
40
+ return {
41
+ open: (phone?: string, profileId?: number) =>
42
+ open(
43
+ <ConsentBkiDialog
44
+ handleSubmit={handleSubmitBkiConstent(phone, profileId)}
45
+ onClose={redirectToCreditForm}
46
+ />,
47
+ ),
48
+ };
49
+ };
50
+
51
+ const verifyPhoneContent = (phone: string) => ({
52
+ title: 'Подтвердите номер телефона',
53
+ description: `Мы отправили код на ${phone}`,
54
+ phoneNumber: formatPhone(phone),
55
+ textButton: 'Отправить',
56
+ __html: `<span>Вводя код, я подтверждаю, что ознакомлен и подписываю:</span>
57
+ <ul><li>согласие на запрос информации в БКИ</li></ul>`,
58
+ });
@@ -0,0 +1,13 @@
1
+ import { type VNode } from '../../model/VNode';
2
+ import { getDocument } from '../Checkbox/getDocument';
3
+ import { Dialog } from './Dialog';
4
+
5
+ export const openDocument = async (id: number, open: (dialog: VNode) => void) => {
6
+ const document = await getDocument(id);
7
+
8
+ open(
9
+ <Dialog className="my-6xl max-w-4xl mx-auto px-0 min-h-0 pb-0">
10
+ <iframe src={`${document}#toolbar=0`} className="w-full h-[80vh]" id="iframe-dialog" />
11
+ </Dialog>,
12
+ );
13
+ };
@@ -14,7 +14,7 @@ import { SubmitButton } from './SubmitButton';
14
14
  import { useVerifyPhoneDialogSubmit } from './useVerifyPhoneDialogSubmit';
15
15
 
16
16
  export interface VerifyPhoneDialogProps {
17
- close?: () => void;
17
+ close?: (smsCode?: string) => void;
18
18
  onClose?: () => void;
19
19
  title?: string;
20
20
  description?: string;
@@ -1,12 +1,12 @@
1
- import { useDialogManager, type DialogOptions } from '../DialogManager/useDialogManager';
1
+ import { useDialogManager } from '../DialogManager/useDialogManager';
2
2
  import { VerifyPhoneDialog, type VerifyPhoneDialogProps } from './VerifyPhoneDialog';
3
3
 
4
- export const useVerifyPhoneDialog = (props: VerifyPhoneDialogProps) => {
4
+ export const useVerifyPhoneDialog = () => {
5
5
  const { open, close } = useDialogManager();
6
6
 
7
7
  return {
8
- open: (options: DialogOptions = {}) =>
9
- open(<VerifyPhoneDialog onClose={close} {...props} />, options),
8
+ open: (handleClose: () => void, props: VerifyPhoneDialogProps) =>
9
+ open(<VerifyPhoneDialog onClose={close} close={handleClose} {...props} />),
10
10
  close,
11
11
  };
12
12
  };
@@ -3,7 +3,7 @@ import { checkCode } from '../../api/RetailAPI/checkCode';
3
3
 
4
4
  type useVerifyPhoneDialogSubmitProps = {
5
5
  values: string[];
6
- close?: () => void;
6
+ close?: (smsCode?: string) => void;
7
7
  };
8
8
 
9
9
  export const useVerifyPhoneDialogSubmit = ({ close, values }: useVerifyPhoneDialogSubmitProps) => {
@@ -40,7 +40,7 @@ export const useVerifyPhoneDialogSubmit = ({ close, values }: useVerifyPhoneDial
40
40
  smsCodesSetName: { key: 'AUTHENTICATION' },
41
41
  });
42
42
  resetError();
43
- close && close();
43
+ close && close(values.join(''));
44
44
  } catch {
45
45
  setIsLoading(false);
46
46
  attemps > 1 ? setErrorText('Исчерпан лимит ввода смс-кода') : setErrorText('Неверный код');