@wf-financing/ui 1.1.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 +10828 -10943
- package/package.json +2 -2
- package/src/App.tsx +1 -1
- package/src/api/getHeadlessSdkInstance.ts +8 -1
- package/src/components/banner/CtaBanner.stories.tsx +23 -3
- 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/constants/modalItems.ts +0 -12
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useDetectSmallScreen.ts +7 -0
- package/src/locales/en.json +7 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wf-financing/ui",
|
|
3
|
-
"version": "1.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,7 +5,7 @@ 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;
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
import { Themes } from '@wayflyer/flyui';
|
|
3
|
-
import {
|
|
3
|
+
import { SdkScenarios, MockedModeType } from '@wf-financing/embedded-types';
|
|
4
4
|
import { App } from '../../App';
|
|
5
5
|
import { CtaBanner } from './CtaBanner';
|
|
6
6
|
|
|
@@ -31,7 +31,7 @@ const meta: Meta<typeof CtaBanner> = {
|
|
|
31
31
|
...defaultArgs,
|
|
32
32
|
mockedMode: {
|
|
33
33
|
isMockedMode: true,
|
|
34
|
-
sdkScenario:
|
|
34
|
+
sdkScenario: SdkScenarios.GENERIC_NEW_APPLICATION,
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
37
|
decorators: [(Story, context) => <Template {...(context.args as CtaBannerStoryArgs)} />],
|
|
@@ -45,7 +45,27 @@ export const GenericOffer: Story = {
|
|
|
45
45
|
args: {
|
|
46
46
|
mockedMode: {
|
|
47
47
|
isMockedMode: true,
|
|
48
|
-
sdkScenario:
|
|
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,
|
|
49
69
|
},
|
|
50
70
|
},
|
|
51
71
|
};
|
|
@@ -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', maxWidth: '
|
|
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
|
];
|
package/src/hooks/index.ts
CHANGED
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
|
}
|