@wf-financing/ui 4.7.4 → 4.7.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wf-financing/ui",
3
- "version": "4.7.4",
3
+ "version": "4.7.6",
4
4
  "exports": {
5
5
  ".": {
6
6
  "import": "./dist/index.es.js",
@@ -37,10 +37,10 @@
37
37
  "react-intl": "^6.2.5",
38
38
  "react-markdown": "^10.1.0",
39
39
  "styled-components": "^6.1.19",
40
- "@wf-financing/headless": "3.3.3",
41
- "@wf-financing/embedded-types": "1.1.1",
42
- "@wf-financing/logger": "2.2.2",
43
- "@wf-financing/ui-assets": "1.1.3"
40
+ "@wf-financing/headless": "3.3.4",
41
+ "@wf-financing/logger": "2.2.3",
42
+ "@wf-financing/ui-assets": "1.1.4",
43
+ "@wf-financing/embedded-types": "1.1.1"
44
44
  },
45
45
  "publishConfig": {
46
46
  "access": "public"
@@ -3,6 +3,7 @@ import { IconXmark16Line } from '@wayflyer/flyui-icons/16/line';
3
3
  import { AnimatePresence, LazyMotion, domAnimation } from 'framer-motion';
4
4
  import { ReactNode, useId, useRef } from 'react';
5
5
  import { UNSAFE_PortalProvider as PortalProvider } from 'react-aria';
6
+ import { Logger } from '@wf-financing/logger';
6
7
 
7
8
  import { usePartnerContext, useRemoveInerted } from '../../hooks';
8
9
  import { DialogBody } from './modalEnhancements';
@@ -51,7 +52,13 @@ export const Modal = ({ isModalOpen, setIsModalOpen, children }: ModalProps) =>
51
52
  />
52
53
  <Dialog role="dialog" aria-labelledby={modalId}>
53
54
  <div style={{ position: 'absolute', right: '10px', top: '10px' }}>
54
- <Button variant="Tertiary" onClick={() => setIsModalOpen(false)}>
55
+ <Button
56
+ variant="Tertiary"
57
+ onClick={() => {
58
+ setIsModalOpen(false);
59
+ Logger.logEvent('modal_window_closed');
60
+ }}
61
+ >
55
62
  <Flex padding="2">
56
63
  <IconXmark16Line />
57
64
  </Flex>
@@ -1,5 +1,6 @@
1
1
  import type { Copy, ConsentModal, PartnerTemplate } from '@wf-financing/ui-assets';
2
2
  import { CtaStateType, ApplicationRequiredActions, CtaResponseType } from '@wf-financing/embedded-types';
3
+ import { Logger } from '@wf-financing/logger';
3
4
 
4
5
  import { buildBannerProps, type BannerProps } from './buildBannerProps.ts';
5
6
 
@@ -34,43 +35,68 @@ export const buildCtaUiProps: BuildCtaUiProps = (cta, copy, onModalStateChange,
34
35
  partnerTemplate,
35
36
  } = copy;
36
37
 
38
+ const logClickOnBannerWrapper = (actionDescription: string, action: () => void) => {
39
+ const eventMessage = `${actionDescription}_clicked`;
40
+
41
+ action();
42
+ Logger.logEvent(eventMessage);
43
+ };
44
+
37
45
  const continueApplicationMap: Record<ApplicationRequiredActions, () => ReturnType<BuildCtaUiProps>> = {
38
46
  [ApplicationRequiredActions.COMPLETE_APPLICATION]: () => ({
39
- bannerProps: buildBannerProps(completeApplication, onContinueApplication),
47
+ bannerProps: buildBannerProps(completeApplication, () =>
48
+ logClickOnBannerWrapper(ApplicationRequiredActions.COMPLETE_APPLICATION, onContinueApplication),
49
+ ),
40
50
  }),
41
51
 
42
52
  [ApplicationRequiredActions.SELECT_OFFER]: () => {
43
53
  const offer = 'offer' in data ? data.offer : undefined;
44
54
 
45
55
  return {
46
- bannerProps: buildBannerProps(selectOffer, onContinueApplication, offer),
56
+ bannerProps: buildBannerProps(
57
+ selectOffer,
58
+ () => logClickOnBannerWrapper(ApplicationRequiredActions.SELECT_OFFER, onContinueApplication),
59
+ offer,
60
+ ),
47
61
  };
48
62
  },
49
63
 
50
64
  [ApplicationRequiredActions.COMPLETE_KYC]: () => ({
51
- bannerProps: buildBannerProps(completeKyc, onContinueApplication),
65
+ bannerProps: buildBannerProps(completeKyc, () =>
66
+ logClickOnBannerWrapper(ApplicationRequiredActions.COMPLETE_KYC, onContinueApplication),
67
+ ),
52
68
  }),
53
69
 
54
70
  [ApplicationRequiredActions.SIGN_CONTRACT]: () => ({
55
- bannerProps: buildBannerProps(signContract, onContinueApplication),
71
+ bannerProps: buildBannerProps(signContract, () =>
72
+ logClickOnBannerWrapper(ApplicationRequiredActions.SIGN_CONTRACT, onContinueApplication),
73
+ ),
56
74
  }),
57
75
 
58
76
  [ApplicationRequiredActions.PROVIDE_ADDITIONAL_INFO]: () => ({
59
- bannerProps: buildBannerProps(provideAdditionalInfo, onContinueApplication),
77
+ bannerProps: buildBannerProps(provideAdditionalInfo, () =>
78
+ logClickOnBannerWrapper(ApplicationRequiredActions.PROVIDE_ADDITIONAL_INFO, onContinueApplication),
79
+ ),
60
80
  }),
61
81
  };
62
82
 
63
83
  switch (state) {
64
84
  case CtaStateType.GENERIC_OFFER:
65
85
  return {
66
- bannerProps: buildBannerProps(genericOffer, onModalStateChange),
86
+ bannerProps: buildBannerProps(genericOffer, () =>
87
+ logClickOnBannerWrapper(`${CtaStateType.GENERIC_OFFER}_modal_opened`, onModalStateChange),
88
+ ),
67
89
  consentModalProps: { ...consentModal, onModalStateChange },
68
90
  partnerTemplateProps: partnerTemplate,
69
91
  };
70
92
 
71
93
  case CtaStateType.INDICATIVE_OFFER:
72
94
  return {
73
- bannerProps: buildBannerProps(indicativeOffer, onModalStateChange, data.offer),
95
+ bannerProps: buildBannerProps(
96
+ indicativeOffer,
97
+ () => logClickOnBannerWrapper(`${CtaStateType.INDICATIVE_OFFER}_modal_opened`, onModalStateChange),
98
+ data.offer,
99
+ ),
74
100
  consentModalProps: { ...consentModal, onModalStateChange },
75
101
  partnerTemplateProps: partnerTemplate,
76
102
  };