@wf-financing/ui 4.7.6 → 4.8.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/CHANGELOG.md +18 -0
- package/README.md +2 -0
- package/dist/index.es.js +9635 -9752
- package/package.json +4 -4
- package/src/CtaWidgetContainer.tsx +1 -1
- package/src/hooks/useCopy.ts +14 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wf-financing/ui",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.1",
|
|
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/embedded-types": "1.1.1",
|
|
40
41
|
"@wf-financing/headless": "3.3.4",
|
|
41
|
-
"@wf-financing/
|
|
42
|
-
"@wf-financing/
|
|
43
|
-
"@wf-financing/embedded-types": "1.1.1"
|
|
42
|
+
"@wf-financing/ui-assets": "1.2.1",
|
|
43
|
+
"@wf-financing/logger": "2.2.3"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
@@ -7,7 +7,7 @@ import { useCopy, useCtaBanner, usePartnerContext, usePreloadImage } from './hoo
|
|
|
7
7
|
|
|
8
8
|
export const CtaWidgetContainer = () => {
|
|
9
9
|
const { isLoading, data: cta } = useCtaBanner();
|
|
10
|
-
const
|
|
10
|
+
const copy = useCopy();
|
|
11
11
|
const { onWidgetClose, isWidgetDismissed, options } = usePartnerContext();
|
|
12
12
|
const [skipAnimation] = useState(() => !!options?.skipAnimations || !isLoading);
|
|
13
13
|
usePreloadImage(copy);
|
package/src/hooks/useCopy.ts
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { Logger } from '@wf-financing/logger';
|
|
3
|
+
import { type Copy, filterCopy, getCopyBundleForPartner } from '@wf-financing/ui-assets';
|
|
3
4
|
|
|
4
5
|
import { usePartnerContext } from './usePartnerContext.ts';
|
|
5
|
-
import { APPLICATION_VERSION } from '../config';
|
|
6
6
|
import { getPartnerIdFromToken } from '../utils';
|
|
7
7
|
|
|
8
|
-
export const useCopy = () => {
|
|
8
|
+
export const useCopy = (): Copy | undefined => {
|
|
9
9
|
const { options, companyToken } = usePartnerContext();
|
|
10
|
-
const language = options?.language;
|
|
11
|
-
|
|
12
10
|
const partnerId = getPartnerIdFromToken(companyToken);
|
|
11
|
+
const language = options?.language;
|
|
13
12
|
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
13
|
+
return useMemo(() => {
|
|
14
|
+
try {
|
|
15
|
+
return filterCopy(getCopyBundleForPartner(partnerId), { language });
|
|
16
|
+
} catch (error) {
|
|
17
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
18
|
+
Logger.logError(`Failed to filter CTA copy: ${message}`);
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
}, [partnerId, language]);
|
|
24
22
|
};
|