@redneckz/wildless-cms-uni-blocks 0.14.792 → 0.14.793

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 (73) hide show
  1. package/bundle/bundle.umd.js +35 -16
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/bundle/components/ApplicationLeadForm/useSendLeadFormAspects.d.ts +2 -0
  4. package/bundle/retail/components/DraftDialog/DraftDialog.d.ts +1 -0
  5. package/bundle/retail/components/DraftDialog/useDraftDialog.d.ts +2 -1
  6. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +6 -9
  7. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  8. package/dist/components/ApplicationLeadForm/useSendLeadFormAspects.d.ts +2 -0
  9. package/dist/components/ApplicationLeadForm/useSendLeadFormAspects.js +23 -0
  10. package/dist/components/ApplicationLeadForm/useSendLeadFormAspects.js.map +1 -0
  11. package/dist/hooks/useAspects/aspects/getAspectsWithInclude.js +3 -1
  12. package/dist/hooks/useAspects/aspects/getAspectsWithInclude.js.map +1 -1
  13. package/dist/retail/components/DraftDialog/DraftDialog.d.ts +1 -0
  14. package/dist/retail/components/DraftDialog/DraftDialog.js +4 -1
  15. package/dist/retail/components/DraftDialog/DraftDialog.js.map +1 -1
  16. package/dist/retail/components/DraftDialog/useDraftDialog.d.ts +2 -1
  17. package/dist/retail/components/DraftDialog/useDraftDialog.js +2 -2
  18. package/dist/retail/components/DraftDialog/useDraftDialog.js.map +1 -1
  19. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +6 -9
  20. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  21. package/lib/components/ApplicationLeadForm/useSendLeadFormAspects.d.ts +2 -0
  22. package/lib/components/ApplicationLeadForm/useSendLeadFormAspects.js +20 -0
  23. package/lib/components/ApplicationLeadForm/useSendLeadFormAspects.js.map +1 -0
  24. package/lib/hooks/useAspects/aspects/getAspectsWithInclude.js +3 -1
  25. package/lib/hooks/useAspects/aspects/getAspectsWithInclude.js.map +1 -1
  26. package/lib/retail/components/DraftDialog/DraftDialog.d.ts +1 -0
  27. package/lib/retail/components/DraftDialog/DraftDialog.js +4 -1
  28. package/lib/retail/components/DraftDialog/DraftDialog.js.map +1 -1
  29. package/lib/retail/components/DraftDialog/useDraftDialog.d.ts +2 -1
  30. package/lib/retail/components/DraftDialog/useDraftDialog.js +2 -2
  31. package/lib/retail/components/DraftDialog/useDraftDialog.js.map +1 -1
  32. package/mobile/bundle/bundle.umd.js +35 -16
  33. package/mobile/bundle/bundle.umd.min.js +1 -1
  34. package/mobile/bundle/components/ApplicationLeadForm/useSendLeadFormAspects.d.ts +2 -0
  35. package/mobile/bundle/retail/components/DraftDialog/DraftDialog.d.ts +1 -0
  36. package/mobile/bundle/retail/components/DraftDialog/useDraftDialog.d.ts +2 -1
  37. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +6 -9
  38. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  39. package/mobile/dist/components/ApplicationLeadForm/useSendLeadFormAspects.d.ts +2 -0
  40. package/mobile/dist/components/ApplicationLeadForm/useSendLeadFormAspects.js +23 -0
  41. package/mobile/dist/components/ApplicationLeadForm/useSendLeadFormAspects.js.map +1 -0
  42. package/mobile/dist/hooks/useAspects/aspects/getAspectsWithInclude.js +3 -1
  43. package/mobile/dist/hooks/useAspects/aspects/getAspectsWithInclude.js.map +1 -1
  44. package/mobile/dist/retail/components/DraftDialog/DraftDialog.d.ts +1 -0
  45. package/mobile/dist/retail/components/DraftDialog/DraftDialog.js +4 -1
  46. package/mobile/dist/retail/components/DraftDialog/DraftDialog.js.map +1 -1
  47. package/mobile/dist/retail/components/DraftDialog/useDraftDialog.d.ts +2 -1
  48. package/mobile/dist/retail/components/DraftDialog/useDraftDialog.js +2 -2
  49. package/mobile/dist/retail/components/DraftDialog/useDraftDialog.js.map +1 -1
  50. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +6 -9
  51. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  52. package/mobile/lib/components/ApplicationLeadForm/useSendLeadFormAspects.d.ts +2 -0
  53. package/mobile/lib/components/ApplicationLeadForm/useSendLeadFormAspects.js +20 -0
  54. package/mobile/lib/components/ApplicationLeadForm/useSendLeadFormAspects.js.map +1 -0
  55. package/mobile/lib/hooks/useAspects/aspects/getAspectsWithInclude.js +3 -1
  56. package/mobile/lib/hooks/useAspects/aspects/getAspectsWithInclude.js.map +1 -1
  57. package/mobile/lib/retail/components/DraftDialog/DraftDialog.d.ts +1 -0
  58. package/mobile/lib/retail/components/DraftDialog/DraftDialog.js +4 -1
  59. package/mobile/lib/retail/components/DraftDialog/DraftDialog.js.map +1 -1
  60. package/mobile/lib/retail/components/DraftDialog/useDraftDialog.d.ts +2 -1
  61. package/mobile/lib/retail/components/DraftDialog/useDraftDialog.js +2 -2
  62. package/mobile/lib/retail/components/DraftDialog/useDraftDialog.js.map +1 -1
  63. package/mobile/src/components/ApplicationLeadForm/useApplicationLeadApi.tsx +7 -9
  64. package/mobile/src/components/ApplicationLeadForm/useSendLeadFormAspects.tsx +28 -0
  65. package/mobile/src/hooks/useAspects/aspects/getAspectsWithInclude.tsx +4 -1
  66. package/mobile/src/retail/components/DraftDialog/DraftDialog.tsx +5 -0
  67. package/mobile/src/retail/components/DraftDialog/useDraftDialog.tsx +3 -2
  68. package/package.json +1 -1
  69. package/src/components/ApplicationLeadForm/useApplicationLeadApi.tsx +7 -9
  70. package/src/components/ApplicationLeadForm/useSendLeadFormAspects.tsx +28 -0
  71. package/src/hooks/useAspects/aspects/getAspectsWithInclude.tsx +4 -1
  72. package/src/retail/components/DraftDialog/DraftDialog.tsx +5 -0
  73. package/src/retail/components/DraftDialog/useDraftDialog.tsx +3 -2
@@ -1,8 +1,6 @@
1
1
  /* eslint-disable max-lines */
2
2
  import { useCallback, useState } from '@redneckz/uni-jsx/lib/hooks';
3
3
  import { useBool } from '@redneckz/uni-jsx/lib/hooks/useBool';
4
- import { handleAspects } from '../../hooks/useAspects/handleAspects';
5
- import { useAspects } from '../../hooks/useAspects/useAspects';
6
4
  import { type AspectsProps } from '../../model/AspectsProps';
7
5
  import { createDraftTask } from '../../retail/api/createDraftTask';
8
6
  import { createUserProfile } from '../../retail/api/createUserProfile';
@@ -18,12 +16,12 @@ import { VerifyPhoneDialog } from '../../retail/components/VerifyPhoneDialog/Ver
18
16
  import { type FormRetailConsents, type LeadFormState } from '../../retail/model/LeadFormState';
19
17
  import { getUpdateUserProfileData } from '../../retail/utils/getUpdateUserProfile';
20
18
  import { useDialog } from '../../ui-kit/DialogManager/useDialog';
21
- import { type PreventableEventWithTarget } from '../../ui-kit/PreventableEvent';
22
19
  import { formatPhone } from '../../utils/formatPhone';
23
20
  import { type ProductType } from './ApplicationLeadFormContent';
24
21
  import { productTypeToConsentsMap } from './consents';
25
22
  import { getCreditLeadFormTaskData, getDebitLeadFormTaskData } from './getLeadFormTaskData';
26
23
  import { useSaveUserData, type UserData } from './useSaveUserData';
24
+ import { useSendLeadFormAspects } from './useSendLeadFormAspects';
27
25
 
28
26
  interface ApplicationLeadApiProps extends AspectsProps {
29
27
  programId: string;
@@ -41,7 +39,7 @@ export const useApplicationLeadApi = ({
41
39
  const [isSending, { setTrue: startSending, setFalse: endSending }] = useBool(false);
42
40
  const [ok, setOK] = useState<boolean | undefined>();
43
41
  const saveUserData = useSaveUserData();
44
- const aspects = useAspects();
42
+ const sendAspects = useSendLeadFormAspects({ data });
45
43
 
46
44
  const openEsiaLoginDialog = useEsiaLoginDialog(nextStepLink);
47
45
  const consentBkiDialog = useConsentBkiDialog(openEsiaLoginDialog);
@@ -63,11 +61,7 @@ export const useApplicationLeadApi = ({
63
61
  formData,
64
62
  productType,
65
63
  saveUserData,
66
- });
67
- handleAspects({
68
- aspectsAttributes: data,
69
- aspects,
70
- ev: {} as PreventableEventWithTarget,
64
+ sendAspects,
71
65
  });
72
66
  verifyPhoneDialog.close();
73
67
  if (productType === 'debitCard') {
@@ -86,6 +80,7 @@ export const useApplicationLeadApi = ({
86
80
  draftDialog.open({
87
81
  task,
88
82
  isFromLead: true,
83
+ sendAspects,
89
84
  onClose: sendCurrentTask,
90
85
  });
91
86
  } else {
@@ -127,12 +122,14 @@ const updateUserData = async ({
127
122
  formData,
128
123
  productType,
129
124
  saveUserData,
125
+ sendAspects,
130
126
  }: {
131
127
  programId: string;
132
128
  profileId: number;
133
129
  formData: LeadFormState;
134
130
  productType: ProductType;
135
131
  saveUserData: (userData: UserData) => void;
132
+ sendAspects: (profileId: number, taskId: number) => void;
136
133
  }) => {
137
134
  let taskId: number;
138
135
  let participantId: number;
@@ -164,6 +161,7 @@ const updateUserData = async ({
164
161
  );
165
162
  }
166
163
 
164
+ sendAspects(profileId, taskId);
167
165
  saveUserData({ participantId, taskId, profileId, programId, formData });
168
166
  } catch (ex) {
169
167
  console.log(ex);
@@ -0,0 +1,28 @@
1
+ import { useCallback } from '@redneckz/uni-jsx/lib/hooks';
2
+ import { getAspectsWithInclude } from '../../hooks/useAspects/aspects/getAspectsWithInclude';
3
+ import { handleAspects } from '../../hooks/useAspects/handleAspects';
4
+ import { useAspects } from '../../hooks/useAspects/useAspects';
5
+ import { type AspectsProps } from '../../model/AspectsProps';
6
+ import { type PreventableEventWithTarget } from '../../ui-kit/PreventableEvent';
7
+
8
+ export const useSendLeadFormAspects = ({ data }: AspectsProps) => {
9
+ const aspects = useAspects();
10
+
11
+ const sendAspects = useCallback(
12
+ (ProfileId: number, TaskId: number) => {
13
+ const snowplowParams = JSON.stringify({
14
+ ProfileId,
15
+ TaskId,
16
+ });
17
+
18
+ handleAspects({
19
+ aspectsAttributes: getAspectsWithInclude(data, snowplowParams),
20
+ aspects,
21
+ ev: {} as PreventableEventWithTarget,
22
+ });
23
+ },
24
+ [data],
25
+ );
26
+
27
+ return sendAspects;
28
+ };
@@ -4,5 +4,8 @@ import { type AspectsAttribute } from '../useAspects';
4
4
  export const getAspectsWithInclude = (data?: AspectsDef[], include?: string): AspectsDef[] =>
5
5
  data?.map(({ aspectName, params }: AspectsAttribute) => ({
6
6
  aspectName,
7
- params: aspectName === 'mindboxEvent' ? { ...params, eventJson: include } : params,
7
+ params:
8
+ aspectName === 'mindboxEvent' || aspectName === 'snowplowEvent'
9
+ ? { ...params, eventJson: include }
10
+ : params,
8
11
  })) as AspectsDef[];
@@ -14,12 +14,14 @@ import { creditCodesToProgrammIdMap, creditProgramCodeToProductIdMap } from './u
14
14
  export interface DraftDialogProps {
15
15
  task: Task;
16
16
  isFromLead?: boolean;
17
+ sendAspects?: (profileId: number, taskId: number) => void;
17
18
  onClose?: () => void;
18
19
  }
19
20
 
20
21
  export const DraftDialog = JSX<DraftDialogProps>(function ({
21
22
  task,
22
23
  isFromLead = false,
24
+ sendAspects = noop,
23
25
  onClose = noop,
24
26
  }) {
25
27
  const retailFormStore = useRetailFormStore();
@@ -40,6 +42,9 @@ export const DraftDialog = JSX<DraftDialogProps>(function ({
40
42
  retailFormStore.profileId = profile?.id ?? null;
41
43
  retailFormStore.programId = programmId;
42
44
  retailFormStore.leadForm = taskFromDraft;
45
+ if (profile?.id) {
46
+ sendAspects(profile.id, taskId);
47
+ }
43
48
  navigator.assign(nextStepLink);
44
49
  }, []);
45
50
 
@@ -6,6 +6,7 @@ import { EmptyDraftDialog } from './EmptyDraftDialog';
6
6
  type useDraftDialogOpenProps = {
7
7
  task?: Task;
8
8
  isFromLead?: boolean;
9
+ sendAspects?: (profileId: number, taskId: number) => void;
9
10
  onClose?: () => void;
10
11
  };
11
12
 
@@ -14,8 +15,8 @@ export const useDraftDialog = () => {
14
15
  const { open: openEmptyDraftDialog } = useDialog(EmptyDraftDialog);
15
16
 
16
17
  return {
17
- open: ({ task, isFromLead, onClose }: useDraftDialogOpenProps) => {
18
- task ? openDraftDialog({ task, isFromLead, onClose }) : openEmptyDraftDialog({});
18
+ open: ({ task, isFromLead, onClose, sendAspects }: useDraftDialogOpenProps) => {
19
+ task ? openDraftDialog({ task, isFromLead, onClose, sendAspects }) : openEmptyDraftDialog({});
19
20
  },
20
21
  };
21
22
  };