@redneckz/wildless-cms-uni-blocks 0.14.1033 → 0.14.1035

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 (77) hide show
  1. package/bundle/bundle.umd.js +20 -16
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/bundle/components/ApplicationForm/renderAgreementSubmit.d.ts +10 -7
  4. package/bundle/retail/components/ConsentBkiDialog/useConsentBkiDialog.d.ts +1 -2
  5. package/dist/components/ApplicationForm/ApplicationForm.js +5 -0
  6. package/dist/components/ApplicationForm/ApplicationForm.js.map +1 -1
  7. package/dist/components/ApplicationForm/renderAgreementSubmit.d.ts +10 -7
  8. package/dist/components/ApplicationForm/renderAgreementSubmit.js +1 -1
  9. package/dist/components/ApplicationForm/renderAgreementSubmit.js.map +1 -1
  10. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +0 -1
  11. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  12. package/dist/hooks/useForm/useForm.js +2 -2
  13. package/dist/hooks/useForm/useForm.js.map +1 -1
  14. package/dist/retail/api/getLastTaskStatus.js +4 -1
  15. package/dist/retail/api/getLastTaskStatus.js.map +1 -1
  16. package/dist/retail/components/ConsentBkiDialog/useConsentBkiDialog.d.ts +1 -2
  17. package/dist/retail/components/ConsentBkiDialog/useConsentBkiDialog.js +1 -2
  18. package/dist/retail/components/ConsentBkiDialog/useConsentBkiDialog.js.map +1 -1
  19. package/lib/components/ApplicationForm/ApplicationForm.js +5 -0
  20. package/lib/components/ApplicationForm/ApplicationForm.js.map +1 -1
  21. package/lib/components/ApplicationForm/renderAgreementSubmit.d.ts +10 -7
  22. package/lib/components/ApplicationForm/renderAgreementSubmit.js +1 -1
  23. package/lib/components/ApplicationForm/renderAgreementSubmit.js.map +1 -1
  24. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +0 -1
  25. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  26. package/lib/hooks/useForm/useForm.js +2 -2
  27. package/lib/hooks/useForm/useForm.js.map +1 -1
  28. package/lib/retail/api/getLastTaskStatus.js +4 -1
  29. package/lib/retail/api/getLastTaskStatus.js.map +1 -1
  30. package/lib/retail/components/ConsentBkiDialog/useConsentBkiDialog.d.ts +1 -2
  31. package/lib/retail/components/ConsentBkiDialog/useConsentBkiDialog.js +1 -2
  32. package/lib/retail/components/ConsentBkiDialog/useConsentBkiDialog.js.map +1 -1
  33. package/mobile/bundle/bundle.umd.js +20 -16
  34. package/mobile/bundle/bundle.umd.min.js +1 -1
  35. package/mobile/bundle/components/ApplicationForm/renderAgreementSubmit.d.ts +10 -7
  36. package/mobile/bundle/retail/components/ConsentBkiDialog/useConsentBkiDialog.d.ts +1 -2
  37. package/mobile/dist/components/ApplicationForm/ApplicationForm.js +5 -0
  38. package/mobile/dist/components/ApplicationForm/ApplicationForm.js.map +1 -1
  39. package/mobile/dist/components/ApplicationForm/renderAgreementSubmit.d.ts +10 -7
  40. package/mobile/dist/components/ApplicationForm/renderAgreementSubmit.js +1 -1
  41. package/mobile/dist/components/ApplicationForm/renderAgreementSubmit.js.map +1 -1
  42. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +0 -1
  43. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  44. package/mobile/dist/hooks/useForm/useForm.js +2 -2
  45. package/mobile/dist/hooks/useForm/useForm.js.map +1 -1
  46. package/mobile/dist/retail/api/getLastTaskStatus.js +4 -1
  47. package/mobile/dist/retail/api/getLastTaskStatus.js.map +1 -1
  48. package/mobile/dist/retail/components/ConsentBkiDialog/useConsentBkiDialog.d.ts +1 -2
  49. package/mobile/dist/retail/components/ConsentBkiDialog/useConsentBkiDialog.js +1 -2
  50. package/mobile/dist/retail/components/ConsentBkiDialog/useConsentBkiDialog.js.map +1 -1
  51. package/mobile/lib/components/ApplicationForm/ApplicationForm.js +5 -0
  52. package/mobile/lib/components/ApplicationForm/ApplicationForm.js.map +1 -1
  53. package/mobile/lib/components/ApplicationForm/renderAgreementSubmit.d.ts +10 -7
  54. package/mobile/lib/components/ApplicationForm/renderAgreementSubmit.js +1 -1
  55. package/mobile/lib/components/ApplicationForm/renderAgreementSubmit.js.map +1 -1
  56. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +0 -1
  57. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  58. package/mobile/lib/hooks/useForm/useForm.js +2 -2
  59. package/mobile/lib/hooks/useForm/useForm.js.map +1 -1
  60. package/mobile/lib/retail/api/getLastTaskStatus.js +4 -1
  61. package/mobile/lib/retail/api/getLastTaskStatus.js.map +1 -1
  62. package/mobile/lib/retail/components/ConsentBkiDialog/useConsentBkiDialog.d.ts +1 -2
  63. package/mobile/lib/retail/components/ConsentBkiDialog/useConsentBkiDialog.js +1 -2
  64. package/mobile/lib/retail/components/ConsentBkiDialog/useConsentBkiDialog.js.map +1 -1
  65. package/mobile/src/components/ApplicationForm/ApplicationForm.tsx +5 -0
  66. package/mobile/src/components/ApplicationForm/renderAgreementSubmit.tsx +12 -8
  67. package/mobile/src/components/ApplicationLeadForm/useApplicationLeadApi.tsx +0 -1
  68. package/mobile/src/hooks/useForm/useForm.ts +2 -2
  69. package/mobile/src/retail/api/getLastTaskStatus.ts +6 -5
  70. package/mobile/src/retail/components/ConsentBkiDialog/useConsentBkiDialog.tsx +1 -3
  71. package/package.json +1 -1
  72. package/src/components/ApplicationForm/ApplicationForm.tsx +5 -0
  73. package/src/components/ApplicationForm/renderAgreementSubmit.tsx +12 -8
  74. package/src/components/ApplicationLeadForm/useApplicationLeadApi.tsx +0 -1
  75. package/src/hooks/useForm/useForm.ts +2 -2
  76. package/src/retail/api/getLastTaskStatus.ts +6 -5
  77. package/src/retail/components/ConsentBkiDialog/useConsentBkiDialog.tsx +1 -3
@@ -286,7 +286,6 @@ const createHandleSuccessVerifyNew =
286
286
  try {
287
287
  const lastTaskId = await getLastTaskStatus({
288
288
  userId,
289
- profileId: userId,
290
289
  programId,
291
290
  });
292
291
 
@@ -90,11 +90,11 @@ export function useForm<FormState extends Record<string, any>>(
90
90
  }, [initialState, setFormState]);
91
91
 
92
92
  const handleSubmit = useCallback(
93
- (ev: PreventableEvent) => {
93
+ async (ev: PreventableEvent) => {
94
94
  ev.preventDefault();
95
95
  if (isValid) {
96
+ await onSubmit?.(formState, ev);
96
97
  resetOnSubmit && reset();
97
- onSubmit?.(formState, ev);
98
98
  } else {
99
99
  const errorFieldName = getErrorFieldName(formState, fieldValidatorsMap);
100
100
  markAsDirty();
@@ -1,3 +1,4 @@
1
+ import { checkNewMicroservice } from '../utils/checkNewMicroservice';
1
2
  import { fetchRetailJSON } from './doRequest';
2
3
 
3
4
  type GetLastTaskStatusBody = {
@@ -12,11 +13,11 @@ type GetLastTaskStatusResponse = {
12
13
  };
13
14
 
14
15
  export const getLastTaskStatus = async (body: GetLastTaskStatusBody): Promise<number | null> => {
15
- const res = await fetchRetailJSON<GetLastTaskStatusResponse>(
16
- '/user-data/getLastStatus',
17
- 'POST',
18
- body,
19
- );
16
+ const isNewMicroservice = checkNewMicroservice();
17
+
18
+ const endpoint = isNewMicroservice ? '/public-data/getLastStatus' : '/user-data/getLastStatus';
19
+
20
+ const res = await fetchRetailJSON<GetLastTaskStatusResponse>(endpoint, 'POST', body);
20
21
 
21
22
  return res?.statusCd === 'DRAFT' ? res?.taskId : null;
22
23
  };
@@ -7,7 +7,6 @@ import { ConsentBkiDialog } from './ConsentBkiDialog';
7
7
  type SubmitBkiConsentProps = {
8
8
  phone?: string;
9
9
  profileId?: number;
10
- userId?: string | number;
11
10
  onFail?: () => void;
12
11
  taskId?: number;
13
12
  participantId?: string | number;
@@ -66,12 +65,11 @@ export const useConsentBkiDialog = (onClose: () => void) => {
66
65
  };
67
66
 
68
67
  return {
69
- open: ({ phone, profileId, userId, onFail, taskId, participantId }: SubmitBkiConsentProps) =>
68
+ open: ({ phone, profileId, onFail, taskId, participantId }: SubmitBkiConsentProps) =>
70
69
  open({
71
70
  onSubmit: handleSubmitBkiConsent({
72
71
  phone,
73
72
  profileId,
74
- userId,
75
73
  onFail,
76
74
  taskId,
77
75
  participantId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.14.1033",
3
+ "version": "0.14.1035",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -1,4 +1,5 @@
1
1
  import { useCallback, useMemo } from '@redneckz/uni-jsx/lib/hooks';
2
+ import { useBool } from '@redneckz/uni-jsx/lib/hooks/useBool';
2
3
  import { useRouter } from '../../external/useRouter';
3
4
  import { useAspects } from '../../hooks/useAspects/useAspects';
4
5
  import { useForm } from '../../hooks/useForm/useForm';
@@ -74,9 +75,11 @@ export const ApplicationForm = UniBlock<ApplicationFormProps>(
74
75
  const responseTypeDialog = useDialog(ResponseTypeDialog);
75
76
  const verifyPhoneDialog = useDialog(VerifyPhoneDialog);
76
77
  const openUserSurvey = useUserSurveyDialog(true);
78
+ const [isSending, { setTrue: startSending, setFalse: endSending }] = useBool(false);
77
79
 
78
80
  const handleSubmit = useCallback(
79
81
  async (formData: FormState, ev: PreventableEventWithTarget) => {
82
+ startSending();
80
83
  const formatData = getFormatData({ ...formData, ...additionalParams });
81
84
 
82
85
  await executeHandler(
@@ -95,6 +98,7 @@ export const ApplicationForm = UniBlock<ApplicationFormProps>(
95
98
  },
96
99
  endpoint,
97
100
  );
101
+ endSending();
98
102
  },
99
103
  [typeForm],
100
104
  );
@@ -121,6 +125,7 @@ export const ApplicationForm = UniBlock<ApplicationFormProps>(
121
125
  additionalLink,
122
126
  button,
123
127
  typeForm,
128
+ isSending,
124
129
  })}
125
130
  </form>
126
131
  {isContacts ? renderContacts() : null}
@@ -11,19 +11,23 @@ import { Footnote } from './Footnote';
11
11
  const agreementText = 'Нажимая кнопку, вы подтверждаете согласие с ';
12
12
  const agreementTextPF = 'Нажимая на кнопку, вы подтверждаете, что клиент дал согласие на ';
13
13
 
14
+ type renderAgreementSubmitProps = {
15
+ consentDataProcessing?: FieldProps<boolean>;
16
+ link?: LinkProps;
17
+ additionalLink?: LinkProps;
18
+ button?: SubmitButtonProps;
19
+ typeForm?: string;
20
+ isSending?: boolean;
21
+ };
22
+
14
23
  export const renderAgreementSubmit = ({
15
24
  consentDataProcessing,
16
25
  link,
17
26
  additionalLink,
18
27
  button,
19
28
  typeForm,
20
- }: {
21
- consentDataProcessing?: FieldProps<boolean>;
22
- link?: LinkProps;
23
- additionalLink?: LinkProps;
24
- button?: SubmitButtonProps;
25
- typeForm?: string;
26
- }) => (
29
+ isSending = false,
30
+ }: renderAgreementSubmitProps) => (
27
31
  <div className="flex col-span-2 gap-xs flex-col w-full items-baseline">
28
32
  {consentDataProcessing ? (
29
33
  <div>
@@ -40,7 +44,7 @@ export const renderAgreementSubmit = ({
40
44
  additionalLink={additionalLink}
41
45
  />
42
46
  )}
43
- <SubmitButton className="w-full @xl:w-auto">
47
+ <SubmitButton className="w-full @xl:w-auto" isLoading={isSending}>
44
48
  {button?.text ? button.text : 'Отправить заявку'}
45
49
  </SubmitButton>
46
50
  </div>
@@ -286,7 +286,6 @@ const createHandleSuccessVerifyNew =
286
286
  try {
287
287
  const lastTaskId = await getLastTaskStatus({
288
288
  userId,
289
- profileId: userId,
290
289
  programId,
291
290
  });
292
291
 
@@ -90,11 +90,11 @@ export function useForm<FormState extends Record<string, any>>(
90
90
  }, [initialState, setFormState]);
91
91
 
92
92
  const handleSubmit = useCallback(
93
- (ev: PreventableEvent) => {
93
+ async (ev: PreventableEvent) => {
94
94
  ev.preventDefault();
95
95
  if (isValid) {
96
+ await onSubmit?.(formState, ev);
96
97
  resetOnSubmit && reset();
97
- onSubmit?.(formState, ev);
98
98
  } else {
99
99
  const errorFieldName = getErrorFieldName(formState, fieldValidatorsMap);
100
100
  markAsDirty();
@@ -1,3 +1,4 @@
1
+ import { checkNewMicroservice } from '../utils/checkNewMicroservice';
1
2
  import { fetchRetailJSON } from './doRequest';
2
3
 
3
4
  type GetLastTaskStatusBody = {
@@ -12,11 +13,11 @@ type GetLastTaskStatusResponse = {
12
13
  };
13
14
 
14
15
  export const getLastTaskStatus = async (body: GetLastTaskStatusBody): Promise<number | null> => {
15
- const res = await fetchRetailJSON<GetLastTaskStatusResponse>(
16
- '/user-data/getLastStatus',
17
- 'POST',
18
- body,
19
- );
16
+ const isNewMicroservice = checkNewMicroservice();
17
+
18
+ const endpoint = isNewMicroservice ? '/public-data/getLastStatus' : '/user-data/getLastStatus';
19
+
20
+ const res = await fetchRetailJSON<GetLastTaskStatusResponse>(endpoint, 'POST', body);
20
21
 
21
22
  return res?.statusCd === 'DRAFT' ? res?.taskId : null;
22
23
  };
@@ -7,7 +7,6 @@ import { ConsentBkiDialog } from './ConsentBkiDialog';
7
7
  type SubmitBkiConsentProps = {
8
8
  phone?: string;
9
9
  profileId?: number;
10
- userId?: string | number;
11
10
  onFail?: () => void;
12
11
  taskId?: number;
13
12
  participantId?: string | number;
@@ -66,12 +65,11 @@ export const useConsentBkiDialog = (onClose: () => void) => {
66
65
  };
67
66
 
68
67
  return {
69
- open: ({ phone, profileId, userId, onFail, taskId, participantId }: SubmitBkiConsentProps) =>
68
+ open: ({ phone, profileId, onFail, taskId, participantId }: SubmitBkiConsentProps) =>
70
69
  open({
71
70
  onSubmit: handleSubmitBkiConsent({
72
71
  phone,
73
72
  profileId,
74
- userId,
75
73
  onFail,
76
74
  taskId,
77
75
  participantId,