@wf-financing/ui 1.0.0 → 1.1.1
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/dist/index.es.js +20177 -20213
- package/package.json +2 -2
- package/src/App.tsx +4 -3
- package/src/CtaWidget.tsx +13 -2
- package/src/api/getHeadlessSdkInstance.ts +8 -1
- package/src/components/banner/BannerActionsDesktop.tsx +10 -10
- package/src/components/banner/CloseButton.tsx +16 -0
- package/src/components/banner/CtaBanner.stories.tsx +60 -3
- package/src/components/banner/CtaBanner.tsx +4 -4
- package/src/components/banner/FooterActions.tsx +8 -0
- package/src/components/banner/HeaderActions.tsx +9 -0
- package/src/components/modal/ConsentModal.tsx +6 -3
- package/src/components/modal/FundingSteps.tsx +6 -13
- package/src/components/modal/Modal.tsx +1 -1
- package/src/components/modal/ModalFooter.tsx +3 -2
- package/src/components/modal/modalEnhancements.ts +2 -0
- package/src/constants/modalItems.ts +0 -12
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useCtaBanner.ts +2 -9
- package/src/hooks/useDetectSmallScreen.ts +7 -0
- package/src/hooks/usePartnerContext.ts +7 -0
- package/src/hooks/useStartHostedApplication.ts +3 -12
- package/src/locales/en.json +7 -8
- package/src/main.tsx +8 -10
- package/src/utils/index.ts +1 -1
- package/src/utils/partnerContext.ts +6 -3
- package/src/components/banner/BannerActions.stories.tsx +0 -22
- package/src/components/banner/BannerActionsMobile.tsx +0 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wf-financing/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"import": "./dist/index.es.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"react-aria": "^3.41.1",
|
|
39
39
|
"react-intl": "^6.2.5",
|
|
40
40
|
"styled-components": "^6.1.19",
|
|
41
|
-
"@wf-financing/embedded-types": "0.2.
|
|
41
|
+
"@wf-financing/embedded-types": "0.2.5"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|
package/src/App.tsx
CHANGED
|
@@ -5,13 +5,14 @@ import { createIntl, createIntlCache, IntlShape } from 'react-intl';
|
|
|
5
5
|
|
|
6
6
|
import { CtaWidget } from './CtaWidget';
|
|
7
7
|
import enMessages from './locales/en.json';
|
|
8
|
-
import { PartnerContext } from './utils
|
|
8
|
+
import { PartnerContext } from './utils';
|
|
9
9
|
|
|
10
10
|
type AppPropsType = {
|
|
11
11
|
partnerDesignId: Themes;
|
|
12
12
|
companyToken: string;
|
|
13
13
|
mockedMode?: MockedModeType;
|
|
14
14
|
partnerCallback: PartnerCallbackType;
|
|
15
|
+
onWidgetClose: () => void;
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
const queryClient = new QueryClient();
|
|
@@ -19,7 +20,7 @@ const messages = {
|
|
|
19
20
|
en: enMessages,
|
|
20
21
|
};
|
|
21
22
|
|
|
22
|
-
export const App = ({ partnerDesignId, companyToken, mockedMode, partnerCallback }: AppPropsType) => {
|
|
23
|
+
export const App = ({ partnerDesignId, companyToken, mockedMode, partnerCallback, onWidgetClose }: AppPropsType) => {
|
|
23
24
|
const locale = 'en';
|
|
24
25
|
|
|
25
26
|
const intl: IntlShape = createIntl(
|
|
@@ -32,7 +33,7 @@ export const App = ({ partnerDesignId, companyToken, mockedMode, partnerCallback
|
|
|
32
33
|
|
|
33
34
|
return (
|
|
34
35
|
<QueryClientProvider client={queryClient}>
|
|
35
|
-
<PartnerContext.Provider value={{ companyToken, mockedMode, partnerCallback }}>
|
|
36
|
+
<PartnerContext.Provider value={{ companyToken, mockedMode, partnerCallback, onWidgetClose }}>
|
|
36
37
|
<FlyUIProvider theme={partnerDesignId} intl={intl}>
|
|
37
38
|
<CtaWidget />
|
|
38
39
|
</FlyUIProvider>
|
package/src/CtaWidget.tsx
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
|
|
1
3
|
import { CtaBanner } from './components/banner/CtaBanner';
|
|
2
|
-
import { useCtaBanner } from './hooks
|
|
4
|
+
import { useCtaBanner, usePartnerContext } from './hooks';
|
|
3
5
|
|
|
4
6
|
export const CtaWidget = () => {
|
|
5
7
|
const banner = useCtaBanner();
|
|
8
|
+
const partnerContext = usePartnerContext();
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (!banner.isLoading && !banner.data) {
|
|
12
|
+
requestAnimationFrame(() => {
|
|
13
|
+
partnerContext.onWidgetClose();
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}, [banner.data]);
|
|
6
17
|
|
|
7
|
-
return <>{!banner.isLoading && <CtaBanner />}</>;
|
|
18
|
+
return <>{!banner.isLoading && banner.data && <CtaBanner />}</>;
|
|
8
19
|
};
|
|
@@ -7,7 +7,13 @@ let cachedSdkInstance: IHeadlessWayflyerCtaSdk | null = null;
|
|
|
7
7
|
|
|
8
8
|
export const getHeadlessSdkInstance = async (companyToken: string, mockedMode?: MockedModeType) => {
|
|
9
9
|
try {
|
|
10
|
-
if (cachedSdkInstance)
|
|
10
|
+
if (cachedSdkInstance) {
|
|
11
|
+
if (mockedMode) {
|
|
12
|
+
cachedSdkInstance.setSdkScenario(mockedMode.sdkScenario);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return cachedSdkInstance;
|
|
16
|
+
}
|
|
11
17
|
|
|
12
18
|
const existingScript = document.getElementById(WAYFLYER_HEADLESS_SDK_ID) as HTMLScriptElement;
|
|
13
19
|
|
|
@@ -25,6 +31,7 @@ export const getHeadlessSdkInstance = async (companyToken: string, mockedMode?:
|
|
|
25
31
|
script.id = WAYFLYER_HEADLESS_SDK_ID;
|
|
26
32
|
script.async = true;
|
|
27
33
|
|
|
34
|
+
console.log(script, 'script');
|
|
28
35
|
document.head.appendChild(script);
|
|
29
36
|
|
|
30
37
|
const headlessSdk: IHeadlessWayflyerCtaSdk = await loadScriptAndInitializeSdk(script, companyToken, mockedMode);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IconX16Line } from '@wayflyer/flyui-icons/16/line';
|
|
1
|
+
import { Flex } from '@wayflyer/flyui';
|
|
3
2
|
|
|
3
|
+
import { CloseButton } from './CloseButton';
|
|
4
4
|
import { ProceedFundingButton } from './ProceedFundingButton';
|
|
5
5
|
|
|
6
|
-
export const BannerActionsDesktop = () =>
|
|
7
|
-
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
<
|
|
11
|
-
</
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
export const BannerActionsDesktop = () => {
|
|
7
|
+
return (
|
|
8
|
+
<Flex gap="4">
|
|
9
|
+
<ProceedFundingButton />
|
|
10
|
+
<CloseButton />
|
|
11
|
+
</Flex>
|
|
12
|
+
);
|
|
13
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Button, Flex } from '@wayflyer/flyui';
|
|
2
|
+
import { IconX16Line } from '@wayflyer/flyui-icons/16/line';
|
|
3
|
+
|
|
4
|
+
import { usePartnerContext } from '../../hooks';
|
|
5
|
+
|
|
6
|
+
export const CloseButton = () => {
|
|
7
|
+
const { onWidgetClose: closeWidget } = usePartnerContext();
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<Button onClick={closeWidget} variant="Tertiary">
|
|
11
|
+
<Flex padding="2">
|
|
12
|
+
<IconX16Line />
|
|
13
|
+
</Flex>
|
|
14
|
+
</Button>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
@@ -1,14 +1,71 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Themes } from '@wayflyer/flyui';
|
|
3
|
+
import { SdkScenarios, MockedModeType } from '@wf-financing/embedded-types';
|
|
4
|
+
import { App } from '../../App';
|
|
2
5
|
import { CtaBanner } from './CtaBanner';
|
|
3
6
|
|
|
7
|
+
const defaultArgs = {
|
|
8
|
+
partnerDesignId: 'whiteLabel' as Themes,
|
|
9
|
+
companyToken: 'demo-token',
|
|
10
|
+
partnerCallback: () => {},
|
|
11
|
+
onWidgetClose: () => {},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type CtaBannerStoryArgs = typeof defaultArgs & { mockedMode: MockedModeType };
|
|
15
|
+
|
|
16
|
+
const Template = (args: CtaBannerStoryArgs) => (
|
|
17
|
+
<App {...args}>
|
|
18
|
+
<CtaBanner />
|
|
19
|
+
</App>
|
|
20
|
+
);
|
|
21
|
+
|
|
4
22
|
const meta: Meta<typeof CtaBanner> = {
|
|
5
23
|
title: 'CtaBanner',
|
|
6
24
|
component: CtaBanner,
|
|
25
|
+
argTypes: {
|
|
26
|
+
mockedMode: {
|
|
27
|
+
control: { type: 'object' },
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
args: {
|
|
31
|
+
...defaultArgs,
|
|
32
|
+
mockedMode: {
|
|
33
|
+
isMockedMode: true,
|
|
34
|
+
sdkScenario: SdkScenarios.GENERIC_NEW_APPLICATION,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
decorators: [(Story, context) => <Template {...(context.args as CtaBannerStoryArgs)} />],
|
|
7
38
|
};
|
|
8
39
|
|
|
9
40
|
export default meta;
|
|
10
41
|
type Story = StoryObj<typeof CtaBanner>;
|
|
11
42
|
|
|
12
|
-
export const
|
|
13
|
-
|
|
43
|
+
export const GenericOffer: Story = {
|
|
44
|
+
name: 'Generic Offer',
|
|
45
|
+
args: {
|
|
46
|
+
mockedMode: {
|
|
47
|
+
isMockedMode: true,
|
|
48
|
+
sdkScenario: SdkScenarios.GENERIC_NEW_APPLICATION,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const IndicativeOffer: Story = {
|
|
54
|
+
name: 'Indicative Offer',
|
|
55
|
+
args: {
|
|
56
|
+
mockedMode: {
|
|
57
|
+
isMockedMode: true,
|
|
58
|
+
sdkScenario: SdkScenarios.INDICATIVE_NEW_APPLICATION,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const ContinueApplication: Story = {
|
|
64
|
+
name: 'Continue Application',
|
|
65
|
+
args: {
|
|
66
|
+
mockedMode: {
|
|
67
|
+
isMockedMode: true,
|
|
68
|
+
sdkScenario: SdkScenarios.CONTINUE_APPLICATION,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
14
71
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Flex, Theme, useDetectDeviceSize, useTheme } from '@wayflyer/flyui';
|
|
2
2
|
import { styled } from 'styled-components';
|
|
3
3
|
|
|
4
|
-
import { BannerActionsDesktop } from './BannerActionsDesktop';
|
|
5
|
-
import { BannerActionsMobile } from './BannerActionsMobile';
|
|
6
4
|
import { CtaBannerContent } from './CtaBannerContent';
|
|
5
|
+
import { FooterActions } from './FooterActions';
|
|
6
|
+
import { HeaderActions } from './HeaderActions';
|
|
7
7
|
|
|
8
8
|
type BannerContainerPropTypes = {
|
|
9
9
|
theme: Theme;
|
|
@@ -28,9 +28,9 @@ export const CtaBanner = () => {
|
|
|
28
28
|
<BannerContainer isMobile={isMobile} theme={theme}>
|
|
29
29
|
<Flex gap="4" align="center" justify="space-between" width="100%">
|
|
30
30
|
<CtaBannerContent isMobile={isMobile} isTablet={isTablet} />
|
|
31
|
-
|
|
31
|
+
<HeaderActions />
|
|
32
32
|
</Flex>
|
|
33
|
-
|
|
33
|
+
<FooterActions />
|
|
34
34
|
</BannerContainer>
|
|
35
35
|
);
|
|
36
36
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useDetectDeviceSize } from '@wayflyer/flyui';
|
|
2
|
+
import { ProceedFundingButton } from './ProceedFundingButton';
|
|
3
|
+
|
|
4
|
+
export const FooterActions = () => {
|
|
5
|
+
const { isMobile } = useDetectDeviceSize();
|
|
6
|
+
|
|
7
|
+
return isMobile ? <ProceedFundingButton /> : null;
|
|
8
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useDetectDeviceSize } from '@wayflyer/flyui';
|
|
2
|
+
import { BannerActionsDesktop } from './BannerActionsDesktop';
|
|
3
|
+
import { CloseButton } from './CloseButton';
|
|
4
|
+
|
|
5
|
+
export const HeaderActions = () => {
|
|
6
|
+
const { isMobile } = useDetectDeviceSize();
|
|
7
|
+
|
|
8
|
+
return isMobile ? <CloseButton /> : <BannerActionsDesktop />;
|
|
9
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Flex, Image, Text } from '@wayflyer/flyui';
|
|
1
|
+
import { Flex, Image, Text, useDetectDeviceSize } from '@wayflyer/flyui';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
3
|
|
|
4
4
|
import { FundingSteps } from './FundingSteps';
|
|
5
5
|
import { Modal } from './Modal';
|
|
6
6
|
import { ModalFooter } from './ModalFooter';
|
|
7
|
+
import { useDetectSmallScreen } from '../../hooks';
|
|
7
8
|
|
|
8
9
|
type ConsentModalProps = {
|
|
9
10
|
isModalOpen: boolean;
|
|
@@ -12,11 +13,13 @@ type ConsentModalProps = {
|
|
|
12
13
|
|
|
13
14
|
export const ConsentModal = ({ isModalOpen, setIsModalOpen }: ConsentModalProps) => {
|
|
14
15
|
const { formatMessage } = useIntl();
|
|
16
|
+
const isSmallScreen = useDetectSmallScreen();
|
|
17
|
+
const { isMobile } = useDetectDeviceSize();
|
|
15
18
|
|
|
16
19
|
return (
|
|
17
20
|
<Modal isModalOpen={isModalOpen} setIsModalOpen={setIsModalOpen}>
|
|
18
|
-
<Image src="https://static.wayflyer.com/flyui-assets/logos/wayflyer-ef.png" />
|
|
19
|
-
<Flex
|
|
21
|
+
{!isSmallScreen && <Image src="https://static.wayflyer.com/flyui-assets/logos/wayflyer-ef.png" />}
|
|
22
|
+
<Flex direction="column" gap="8" padding={isSmallScreen || isMobile ? '4' : '6'}>
|
|
20
23
|
<Flex direction="column" gap="6">
|
|
21
24
|
<Text fontStyle="regular" fontWeight="medium" lineHeight="tight" size="2xl">
|
|
22
25
|
{formatMessage({ id: 'ctaModal.title' })}
|
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Flex, Text } from '@wayflyer/flyui';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
3
|
|
|
4
4
|
import { MODAL_ITEMS } from '../../constants';
|
|
5
5
|
|
|
6
6
|
export const FundingSteps = () => {
|
|
7
7
|
const { formatMessage } = useIntl();
|
|
8
|
-
const theme = useTheme();
|
|
9
8
|
|
|
10
9
|
return (
|
|
11
|
-
<Flex direction="column" gap="
|
|
12
|
-
{MODAL_ITEMS.map(({ id, title, subtitle
|
|
13
|
-
<Flex key={id} direction="column"
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
<Text fontWeight="medium">{formatMessage(title)}</Text>
|
|
17
|
-
<Badge size="small">{formatMessage(time)}</Badge>
|
|
18
|
-
</Flex>
|
|
19
|
-
<div style={{ paddingLeft: theme.spacing('8') }}>
|
|
20
|
-
<Text color="placeholder">{formatMessage(subtitle)}</Text>
|
|
21
|
-
</div>
|
|
10
|
+
<Flex direction="column" gap="3">
|
|
11
|
+
{MODAL_ITEMS.map(({ id, title, subtitle }) => (
|
|
12
|
+
<Flex key={id} direction="column">
|
|
13
|
+
<Text fontWeight="medium">{formatMessage(title)}</Text>
|
|
14
|
+
<Text color="placeholder">{formatMessage(subtitle)}</Text>
|
|
22
15
|
</Flex>
|
|
23
16
|
))}
|
|
24
17
|
</Flex>
|
|
@@ -31,7 +31,7 @@ export const Modal = ({ isModalOpen, setIsModalOpen, children }: ModalProps) =>
|
|
|
31
31
|
animate={fullSize}
|
|
32
32
|
exit={small}
|
|
33
33
|
transition={{ duration: 0.3 }}
|
|
34
|
-
style={{ width: '438px', border: 'none' }}
|
|
34
|
+
style={{ width: '438px', border: 'none', maxWidth: '90vw', maxHeight: '90vh' }}
|
|
35
35
|
>
|
|
36
36
|
<MotionModalOverlay
|
|
37
37
|
data-id="modal-mask"
|
|
@@ -3,7 +3,7 @@ import { IconArrowOnSquareUpRight16Line } from '@wayflyer/flyui-icons/16/line';
|
|
|
3
3
|
import { StartHostedApplicationResponseType } from '@wf-financing/embedded-types';
|
|
4
4
|
import { FormattedMessage } from 'react-intl';
|
|
5
5
|
|
|
6
|
-
import { useStartHostedApplication } from '../../hooks
|
|
6
|
+
import { useStartHostedApplication, useDetectSmallScreen } from '../../hooks';
|
|
7
7
|
|
|
8
8
|
type ModalFooterType = {
|
|
9
9
|
setOpen: (isOpen: boolean) => void;
|
|
@@ -11,6 +11,7 @@ type ModalFooterType = {
|
|
|
11
11
|
|
|
12
12
|
export const ModalFooter = ({ setOpen }: ModalFooterType) => {
|
|
13
13
|
const startHostedAppMutation = useStartHostedApplication();
|
|
14
|
+
const isSmallScreen = useDetectSmallScreen();
|
|
14
15
|
|
|
15
16
|
const handleStartApplication = () => {
|
|
16
17
|
startHostedAppMutation.mutate(undefined, {
|
|
@@ -30,7 +31,7 @@ export const ModalFooter = ({ setOpen }: ModalFooterType) => {
|
|
|
30
31
|
|
|
31
32
|
return (
|
|
32
33
|
<Flex direction="column" gap="3">
|
|
33
|
-
<Flex gap="2">
|
|
34
|
+
<Flex gap="2" direction={isSmallScreen ? 'column' : 'row'}>
|
|
34
35
|
<Button fullWidth onClick={handleStartApplication} variant="Primary" external>
|
|
35
36
|
<FormattedMessage id="ctaModal.action" />
|
|
36
37
|
<IconArrowOnSquareUpRight16Line />
|
|
@@ -1,29 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IconArrowsCwHorizontal24Line,
|
|
3
|
-
IconCheckCircle24Line,
|
|
4
|
-
IconPersonCircle24Line,
|
|
5
|
-
} from '@wayflyer/flyui-icons/24/line';
|
|
6
|
-
|
|
7
1
|
export const MODAL_ITEMS = [
|
|
8
2
|
{
|
|
9
3
|
id: 'step1',
|
|
10
4
|
title: { id: 'ctaModal.step1.title' },
|
|
11
5
|
subtitle: { id: 'ctaModal.step1.subtitle' },
|
|
12
|
-
Icon: IconPersonCircle24Line,
|
|
13
|
-
time: { id: 'ctaModal.step1.time' },
|
|
14
6
|
},
|
|
15
7
|
{
|
|
16
8
|
id: 'step2',
|
|
17
9
|
title: { id: 'ctaModal.step2.title' },
|
|
18
10
|
subtitle: { id: 'ctaModal.step2.subtitle' },
|
|
19
|
-
Icon: IconArrowsCwHorizontal24Line,
|
|
20
|
-
time: { id: 'ctaModal.step2.time' },
|
|
21
11
|
},
|
|
22
12
|
{
|
|
23
13
|
id: 'step3',
|
|
24
14
|
title: { id: 'ctaModal.step3.title' },
|
|
25
15
|
subtitle: { id: 'ctaModal.step3.subtitle' },
|
|
26
|
-
Icon: IconCheckCircle24Line,
|
|
27
|
-
time: { id: 'ctaModal.step3.time' },
|
|
28
16
|
},
|
|
29
17
|
];
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import { useQuery } from '@tanstack/react-query';
|
|
2
|
-
import { useContext } from 'react';
|
|
3
|
-
import { MockedModeType } from '@wf-financing/embedded-types';
|
|
4
2
|
|
|
5
3
|
import { fetchCtaBanner } from '../api/ctaBanner';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
type PartnerDataType = {
|
|
9
|
-
companyToken: string;
|
|
10
|
-
mockedMode?: MockedModeType;
|
|
11
|
-
};
|
|
4
|
+
import { usePartnerContext } from './usePartnerContext';
|
|
12
5
|
|
|
13
6
|
export const useCtaBanner = () => {
|
|
14
|
-
const { companyToken, mockedMode } =
|
|
7
|
+
const { companyToken, mockedMode } = usePartnerContext();
|
|
15
8
|
|
|
16
9
|
return useQuery({
|
|
17
10
|
queryKey: ['cta', companyToken, mockedMode],
|
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
import { PartnerCallbackType, MockedModeType } from '@wf-financing/embedded-types';
|
|
2
|
-
import { useContext } from 'react';
|
|
3
|
-
|
|
4
|
-
import { PartnerContext } from '../utils/partnerContext';
|
|
5
|
-
|
|
6
|
-
type PartnerDataType = {
|
|
7
|
-
companyToken: string;
|
|
8
|
-
mockedMode?: MockedModeType;
|
|
9
|
-
partnerCallback: PartnerCallbackType;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
1
|
import { useMutation } from '@tanstack/react-query';
|
|
2
|
+
|
|
13
3
|
import { startHostedApplication } from '../api/startHostedApplication';
|
|
4
|
+
import { usePartnerContext } from './usePartnerContext';
|
|
14
5
|
|
|
15
6
|
export const useStartHostedApplication = () => {
|
|
16
|
-
const { companyToken, mockedMode, partnerCallback } =
|
|
7
|
+
const { companyToken, mockedMode, partnerCallback } = usePartnerContext();
|
|
17
8
|
|
|
18
9
|
return useMutation({
|
|
19
10
|
mutationFn: () => startHostedApplication(companyToken, partnerCallback, mockedMode),
|
package/src/locales/en.json
CHANGED
|
@@ -2,17 +2,16 @@
|
|
|
2
2
|
"common.cancel": "Cancel",
|
|
3
3
|
"common.dismiss": "Dismiss",
|
|
4
4
|
"ctaModal.call": "Get funded",
|
|
5
|
-
"ctaModal.title": "
|
|
5
|
+
"ctaModal.title": "Fuel your growth with capital from Wayflyer",
|
|
6
6
|
"ctaModal.action": "Continue with Wayflyer",
|
|
7
7
|
"ctaModal.consent": "By proceeding, you consent to us sharing your information with Wayflyer so they can assess your eligibility for financing, in accordance with the Wayflyer ",
|
|
8
8
|
"ctaModal.consent.privacy_policy": "Privacy Policy.",
|
|
9
|
-
"ctaModal.step1.title": "
|
|
10
|
-
"ctaModal.step1.subtitle": "
|
|
9
|
+
"ctaModal.step1.title": "Built for businesses like yours",
|
|
10
|
+
"ctaModal.step1.subtitle": "$5B+ deployed to 5,000+ companies since 2019",
|
|
11
11
|
"ctaModal.step1.time": "2 mins",
|
|
12
|
-
"ctaModal.step2.title": "
|
|
13
|
-
"ctaModal.step2.subtitle": "
|
|
12
|
+
"ctaModal.step2.title": "Your growth, your way",
|
|
13
|
+
"ctaModal.step2.subtitle": "Flexible products with terms that fit your business",
|
|
14
14
|
"ctaModal.step2.time": "10 mins",
|
|
15
|
-
"ctaModal.step3.title": "
|
|
16
|
-
"ctaModal.step3.subtitle": "
|
|
17
|
-
"ctaModal.step3.time": "24 hrs"
|
|
15
|
+
"ctaModal.step3.title": "Quick to get started",
|
|
16
|
+
"ctaModal.step3.subtitle": "Apply in minutes and get capital in hours"
|
|
18
17
|
}
|
package/src/main.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import ReactDOM from 'react-dom/client';
|
|
|
4
4
|
|
|
5
5
|
import { App } from './App';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
let root: ReactDOM.Root | undefined = undefined;
|
|
8
8
|
|
|
9
9
|
export const mountToTarget = (
|
|
10
10
|
targetId: string,
|
|
@@ -14,17 +14,14 @@ export const mountToTarget = (
|
|
|
14
14
|
mockedMode?: MockedModeType,
|
|
15
15
|
) => {
|
|
16
16
|
const targetElement = document.getElementById(targetId);
|
|
17
|
+
if (!targetElement) throw new Error(`Target element with id "${targetId}" not found.`);
|
|
17
18
|
|
|
18
|
-
if (!targetElement)
|
|
19
|
-
console.warn(`Target element with id "${targetId}" not found.`);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
let root = roots.get(targetElement);
|
|
19
|
+
if (!root) root = ReactDOM.createRoot(targetElement);
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
root
|
|
27
|
-
|
|
21
|
+
function handleCloseWidget() {
|
|
22
|
+
if (!root) throw new Error('Root is not found');
|
|
23
|
+
root.unmount();
|
|
24
|
+
root = undefined;
|
|
28
25
|
}
|
|
29
26
|
|
|
30
27
|
root.render(
|
|
@@ -33,6 +30,7 @@ export const mountToTarget = (
|
|
|
33
30
|
companyToken={companyToken}
|
|
34
31
|
mockedMode={mockedMode}
|
|
35
32
|
partnerCallback={partnerCallback}
|
|
33
|
+
onWidgetClose={handleCloseWidget}
|
|
36
34
|
/>,
|
|
37
35
|
);
|
|
38
36
|
};
|
package/src/utils/index.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { PartnerCallbackType, MockedModeType } from '@wf-financing/embedded-types';
|
|
2
2
|
import { createContext } from 'react';
|
|
3
3
|
|
|
4
|
-
type PartnerContextType = {
|
|
4
|
+
export type PartnerContextType = {
|
|
5
5
|
companyToken: string;
|
|
6
6
|
isMockedMode?: boolean;
|
|
7
7
|
partnerCallback: PartnerCallbackType;
|
|
8
8
|
mockedMode?: MockedModeType;
|
|
9
|
-
|
|
9
|
+
onWidgetClose: () => void;
|
|
10
|
+
};
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
type PartnerContextWithDefaultType = PartnerContextType | null;
|
|
13
|
+
|
|
14
|
+
export const PartnerContext = createContext<PartnerContextWithDefaultType>(null);
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { BannerActionsDesktop } from './BannerActionsDesktop';
|
|
2
|
-
import { BannerActionsMobile } from './BannerActionsMobile';
|
|
3
|
-
|
|
4
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
|
-
|
|
6
|
-
const meta: Meta = {
|
|
7
|
-
title: 'Banner/BannerActions',
|
|
8
|
-
component: BannerActionsDesktop,
|
|
9
|
-
tags: ['autodocs'],
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default meta;
|
|
13
|
-
|
|
14
|
-
export const Desktop: StoryObj = {
|
|
15
|
-
render: () => <BannerActionsDesktop />,
|
|
16
|
-
name: 'Desktop Actions',
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const Mobile: StoryObj = {
|
|
20
|
-
render: () => <BannerActionsMobile />,
|
|
21
|
-
name: 'Mobile Actions',
|
|
22
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Button, Flex } from '@wayflyer/flyui';
|
|
2
|
-
|
|
3
|
-
import { ProceedFundingButton } from './ProceedFundingButton';
|
|
4
|
-
|
|
5
|
-
export const BannerActionsMobile = () => (
|
|
6
|
-
<Flex gap="2" align="center" width="100%" justify="space-around">
|
|
7
|
-
<ProceedFundingButton />
|
|
8
|
-
<Button fullWidth title="Dismiss" variant="Secondary">
|
|
9
|
-
Dismiss
|
|
10
|
-
</Button>
|
|
11
|
-
</Flex>
|
|
12
|
-
);
|