@lookiero/checkout 13.0.0 → 14.0.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/cypress/support/e2e.ts +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.js +4 -10
- package/dist/src/ExpoRoot.js +0 -25
- package/dist/src/infrastructure/ui/Root.d.ts +0 -2
- package/dist/src/infrastructure/ui/Root.js +17 -2
- package/dist/src/version.d.ts +2 -2
- package/dist/src/version.js +2 -2
- package/index.ts +4 -12
- package/package.json +4 -2
- package/proxy-server.js +0 -10
- package/src/ExpoRoot.tsx +1 -29
- package/src/infrastructure/ui/Root.tsx +20 -12
package/cypress/support/e2e.ts
CHANGED
|
@@ -3,7 +3,7 @@ Cypress.Commands.add("getByTestId", (selector, ...args) => cy.get(`[data-testid=
|
|
|
3
3
|
Cypress.Commands.add("shouldIncludePathInUrl", (path) => cy.url().should("include", path));
|
|
4
4
|
|
|
5
5
|
beforeEach(() => {
|
|
6
|
-
cy.intercept("GET", "
|
|
6
|
+
cy.intercept("GET", "https://cdn.loco.free/**", { fixture: "es-external-translations.json" }).as(
|
|
7
7
|
"external-translations",
|
|
8
8
|
);
|
|
9
9
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ComponentType } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { translationEndpoint, translationExternalEndpoint, Project } from "@lookiero/sty-psp-i18n";
|
|
2
|
+
import { Project, translationEndpoints } from "@lookiero/sty-psp-i18n";
|
|
4
3
|
import { Country, Locale } from "@lookiero/sty-psp-locale";
|
|
5
4
|
import { SentryEnvironment, SentryLoggerFunctionArgs } from "@lookiero/sty-psp-logging";
|
|
6
5
|
import { Segment } from "@lookiero/sty-psp-segment";
|
|
@@ -21,7 +20,6 @@ interface BootstrapFunctionArgs {
|
|
|
21
20
|
readonly getAuthToken: () => Promise<string>;
|
|
22
21
|
readonly apiUrl: () => string;
|
|
23
22
|
readonly sentry: () => SentryEnvironment;
|
|
24
|
-
readonly translations: EndpointFunction[];
|
|
25
23
|
readonly kameleoon: () => KameleoonEnvironment;
|
|
26
24
|
}
|
|
27
25
|
interface BootstrapFunctionReturn {
|
|
@@ -32,5 +30,5 @@ interface BootstrapFunction {
|
|
|
32
30
|
(args: BootstrapFunctionArgs): BootstrapFunctionReturn;
|
|
33
31
|
}
|
|
34
32
|
declare const bootstrap: BootstrapFunction;
|
|
35
|
-
export { bootstrap,
|
|
33
|
+
export { bootstrap, translationEndpoints, Country, Segment, CheckoutStatus, Tradename };
|
|
36
34
|
export type { Project, SentryEnvironment, KameleoonEnvironment, Customer, Locale, OnSuccessFunction as OnCheckoutFlowSuccessFunction, };
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { fetchTranslations, translationEndpoint, translationExternalEndpoint } from "@lookiero/sty-psp-i18n";
|
|
1
|
+
import { translationEndpoints } from "@lookiero/sty-psp-i18n";
|
|
3
2
|
import { Country } from "@lookiero/sty-psp-locale";
|
|
4
3
|
import { Segment } from "@lookiero/sty-psp-segment";
|
|
5
4
|
import { Tradename } from "@lookiero/sty-sp-tradename";
|
|
6
5
|
import { CheckoutStatus } from "./src/domain/checkout/model/checkout";
|
|
7
6
|
import { bootstrap as checkoutBootstrap } from "./src/infrastructure/delivery/bootstrap";
|
|
8
7
|
import { root } from "./src/infrastructure/ui/Root";
|
|
9
|
-
import { DOMAIN } from "./src/infrastructure/ui/i18n/i18n";
|
|
10
8
|
import { viewFirstAvailableCheckoutByCustomerId } from "./src/projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
11
|
-
const bootstrap = ({ apiUrl, getAuthToken,
|
|
9
|
+
const bootstrap = ({ apiUrl, getAuthToken, sentry, kameleoon }) => {
|
|
12
10
|
const { Component: Messaging, queryBus } = checkoutBootstrap({ apiUrl, getAuthToken });
|
|
13
|
-
const I18n = i18n({
|
|
14
|
-
fetchTranslation: fetchTranslations({ translations }),
|
|
15
|
-
domain: DOMAIN,
|
|
16
|
-
});
|
|
17
11
|
const firstAvailableCheckoutByCustomerId = ({ customerId }) => queryBus(viewFirstAvailableCheckoutByCustomerId({ customerId: customerId }));
|
|
18
12
|
return {
|
|
19
|
-
root: root({ Messaging,
|
|
13
|
+
root: root({ Messaging, queryBus, getAuthToken, sentry, kameleoon }),
|
|
20
14
|
firstAvailableCheckoutByCustomerId,
|
|
21
15
|
};
|
|
22
16
|
};
|
|
23
|
-
export { bootstrap,
|
|
17
|
+
export { bootstrap, translationEndpoints, Country, Segment, CheckoutStatus, Tradename };
|
package/dist/src/ExpoRoot.js
CHANGED
|
@@ -5,9 +5,7 @@ import { Platform, ScrollView } from "react-native";
|
|
|
5
5
|
import { Navigate, Route, Routes } from "react-router-native";
|
|
6
6
|
import { Aurora, Text } from "@lookiero/aurora";
|
|
7
7
|
import { EventProvider } from "@lookiero/event";
|
|
8
|
-
import { i18n } from "@lookiero/i18n-react";
|
|
9
8
|
import { PaymentsQueryProvider, setPaymentsBridge } from "@lookiero/payments-front";
|
|
10
|
-
import { fetchTranslations, translationExternalEndpoint } from "@lookiero/sty-psp-i18n";
|
|
11
9
|
import { Country, Locale } from "@lookiero/sty-psp-locale";
|
|
12
10
|
import { Segment } from "@lookiero/sty-psp-segment";
|
|
13
11
|
import { DummyLayout, themeByTradename } from "@lookiero/sty-psp-ui";
|
|
@@ -15,7 +13,6 @@ import { Tradename } from "@lookiero/sty-sp-tradename";
|
|
|
15
13
|
import { bootstrap as checkoutBootstrap } from "./infrastructure/delivery/bootstrap";
|
|
16
14
|
import { bootstrap as checkoutMockBootstrap } from "./infrastructure/delivery/bootstrap.mock";
|
|
17
15
|
import { root } from "./infrastructure/ui/Root";
|
|
18
|
-
import { DOMAIN } from "./infrastructure/ui/i18n/i18n";
|
|
19
16
|
import { Router } from "./infrastructure/ui/routing/router/Router";
|
|
20
17
|
import { RELEASE } from "./version";
|
|
21
18
|
const tradename = Tradename.LOOKIERO;
|
|
@@ -45,23 +42,6 @@ const apiUrl = Platform.OS !== "web"
|
|
|
45
42
|
: "/checkout/api";
|
|
46
43
|
const authToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjIyMDgzMTMsImV4cCI6MTc3MDQ1NzEzMCwiZGlzcGxheU5hbWUiOiJtYWlsLmRlditCRlUtLTIwMzc0MjExMTYiLCJjb3VudHJ5X2NvZGUiOiJOTCIsImFjY2Vzc1ZpYSI6ImVtYWlsIiwic3Vic2NyaXB0aW9uU3RhcnRpbmdEYXRlIjoiMjAyMC0xMC0wMSIsImltcGVyc29uYXRlZCI6ZmFsc2UsInV1aWQiOiIwMDA0YTA0OS1mZWY2LTRiYWMtYTQ1ZC1iM2E5MDRiNGVlNGIiLCJ0cmFkZW5hbWUiOiJMT09LSUVSTyIsImlhdCI6MTc2Nzc3ODczMH0.5x6bj95AAh2c4zoQaR5AMrTO6xAkW73KHyYbFKnYzD8";
|
|
47
44
|
const getAuthToken = () => Promise.resolve(authToken);
|
|
48
|
-
const externalTranslationsUrl = Platform.OS !== "web"
|
|
49
|
-
? "https://web2.sp.dev.aws.lookiero.es/api/v2/translations"
|
|
50
|
-
: __DEV__
|
|
51
|
-
? process.env.EXPO_PUBLIC_CI
|
|
52
|
-
? "/local-to-external-i18n"
|
|
53
|
-
: "http://localhost:3004/local-to-external-i18n"
|
|
54
|
-
: "/external-i18n";
|
|
55
|
-
const translationProjectsByTradename = {
|
|
56
|
-
[Tradename.LOOKIERO]: [["checkout"], ["inventory-catalog"]],
|
|
57
|
-
[Tradename.OUTFITTERY]: [["outfittery-checkout"], ["inventory-catalog"]],
|
|
58
|
-
};
|
|
59
|
-
const translations = [
|
|
60
|
-
(locale) => translationExternalEndpoint({
|
|
61
|
-
translationsUrl: externalTranslationsUrl,
|
|
62
|
-
projects: translationProjectsByTradename[tradename],
|
|
63
|
-
})(locale),
|
|
64
|
-
];
|
|
65
45
|
const useRedirect = () => ({
|
|
66
46
|
returnUrl: "https://web2.dev.aws.lookiero.es/user/",
|
|
67
47
|
});
|
|
@@ -94,13 +74,8 @@ const kameleoonConfig = {
|
|
|
94
74
|
const { Component: Messaging, queryBus } = process.env.EXPO_PUBLIC_APP_VARIANT === "test"
|
|
95
75
|
? checkoutMockBootstrap()
|
|
96
76
|
: checkoutBootstrap({ apiUrl: () => apiUrl, getAuthToken });
|
|
97
|
-
const I18n = i18n({
|
|
98
|
-
fetchTranslation: fetchTranslations({ translations }),
|
|
99
|
-
domain: DOMAIN,
|
|
100
|
-
});
|
|
101
77
|
const Root = root({
|
|
102
78
|
Messaging,
|
|
103
|
-
I18n,
|
|
104
79
|
queryBus,
|
|
105
80
|
getAuthToken,
|
|
106
81
|
development: false,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ComponentType } from "react";
|
|
2
2
|
import { useRoutes as reactRouterUseRoutes } from "react-router-native";
|
|
3
|
-
import { I18n } from "@lookiero/i18n-react";
|
|
4
3
|
import { QueryBus } from "@lookiero/messaging";
|
|
5
4
|
import { MessagingRoot } from "@lookiero/messaging-react/bootstrap";
|
|
6
5
|
import { Locale } from "@lookiero/sty-psp-locale";
|
|
@@ -12,7 +11,6 @@ import { KameleoonEnvironment } from "../ab-testing/kameleoonEnvironment";
|
|
|
12
11
|
import { OnSuccessFunction as OnCheckoutFlowSuccessFunction } from "./hooks/useCheckoutFlow";
|
|
13
12
|
interface RootFunctionArgs {
|
|
14
13
|
readonly Messaging: MessagingRoot;
|
|
15
|
-
readonly I18n: I18n;
|
|
16
14
|
readonly development?: boolean;
|
|
17
15
|
readonly queryBus: QueryBus;
|
|
18
16
|
readonly sentry: () => SentryEnvironment;
|
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
// TODO properly export MessagingRoot from @lookiero/messaging-react
|
|
2
|
-
import React, { useCallback } from "react";
|
|
2
|
+
import React, { useCallback, useMemo } from "react";
|
|
3
3
|
import { Platform } from "react-native";
|
|
4
4
|
import { useRoutes as reactRouterUseRoutes } from "react-router-native";
|
|
5
|
+
import { i18n } from "@lookiero/i18n-react";
|
|
6
|
+
import { fetchTranslations, translationEndpoints } from "@lookiero/sty-psp-i18n";
|
|
5
7
|
import { sentryLogger, sentryLoggerHOC } from "@lookiero/sty-psp-logging";
|
|
6
8
|
import { QueryBusProvider } from "./hooks/useQueryBus";
|
|
9
|
+
import { DOMAIN } from "./i18n/i18n";
|
|
7
10
|
import { Routing } from "./routing/Routing";
|
|
8
|
-
const root = ({ Messaging,
|
|
11
|
+
const root = ({ Messaging, queryBus, getAuthToken, development, sentry, kameleoon: kameleoonConfig }) => {
|
|
9
12
|
const logger = sentryLogger(sentry);
|
|
10
13
|
const kameleoon = kameleoonConfig();
|
|
11
14
|
// eslint-disable-next-line react/display-name, react/prop-types
|
|
12
15
|
const Root = ({ basePath, locale, customer, layout, tradename, onNotAccessible, onCheckoutFlowSuccess, useRedirect, useRoutes = reactRouterUseRoutes, }) => {
|
|
16
|
+
const I18n = useMemo(() => {
|
|
17
|
+
const translations = [
|
|
18
|
+
(locale) => translationEndpoints({
|
|
19
|
+
projects: ["checkout", "inventory-catalog"],
|
|
20
|
+
tradename,
|
|
21
|
+
})(locale),
|
|
22
|
+
];
|
|
23
|
+
return i18n({
|
|
24
|
+
fetchTranslation: fetchTranslations({ translations }),
|
|
25
|
+
domain: DOMAIN,
|
|
26
|
+
});
|
|
27
|
+
}, [tradename]);
|
|
13
28
|
const handleOnI18nError = useCallback((error) => logger.captureException(error), []);
|
|
14
29
|
return (React.createElement(Messaging, { includeReactQueryDevTools: Platform.OS === "web" },
|
|
15
30
|
React.createElement(QueryBusProvider, { queryBus: queryBus },
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "
|
|
2
|
-
export declare const RELEASE = "checkout@
|
|
1
|
+
export declare const VERSION = "14.0.1";
|
|
2
|
+
export declare const RELEASE = "checkout@14.0.1";
|
package/dist/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = "
|
|
2
|
-
export const RELEASE = "checkout@
|
|
1
|
+
export const VERSION = "14.0.1";
|
|
2
|
+
export const RELEASE = "checkout@14.0.1";
|
package/index.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { ComponentType } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { i18n } from "@lookiero/i18n-react";
|
|
4
|
-
import { fetchTranslations, translationEndpoint, translationExternalEndpoint, Project } from "@lookiero/sty-psp-i18n";
|
|
2
|
+
import { Project, translationEndpoints } from "@lookiero/sty-psp-i18n";
|
|
5
3
|
import { Country, Locale } from "@lookiero/sty-psp-locale";
|
|
6
4
|
import { SentryEnvironment, SentryLoggerFunctionArgs } from "@lookiero/sty-psp-logging";
|
|
7
5
|
import { Segment } from "@lookiero/sty-psp-segment";
|
|
@@ -11,7 +9,6 @@ import { KameleoonEnvironment } from "./src/infrastructure/ab-testing/kameleoonE
|
|
|
11
9
|
import { bootstrap as checkoutBootstrap } from "./src/infrastructure/delivery/bootstrap";
|
|
12
10
|
import { root, RootProps } from "./src/infrastructure/ui/Root";
|
|
13
11
|
import { OnSuccessFunction } from "./src/infrastructure/ui/hooks/useCheckoutFlow";
|
|
14
|
-
import { DOMAIN } from "./src/infrastructure/ui/i18n/i18n";
|
|
15
12
|
import { CheckoutProjection } from "./src/projection/checkout/checkout";
|
|
16
13
|
import { viewFirstAvailableCheckoutByCustomerId } from "./src/projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
17
14
|
import { Customer } from "./src/projection/customer/customer";
|
|
@@ -28,7 +25,6 @@ interface BootstrapFunctionArgs {
|
|
|
28
25
|
readonly getAuthToken: () => Promise<string>;
|
|
29
26
|
readonly apiUrl: () => string;
|
|
30
27
|
readonly sentry: () => SentryEnvironment;
|
|
31
|
-
readonly translations: EndpointFunction[];
|
|
32
28
|
readonly kameleoon: () => KameleoonEnvironment;
|
|
33
29
|
}
|
|
34
30
|
|
|
@@ -41,23 +37,19 @@ interface BootstrapFunction {
|
|
|
41
37
|
(args: BootstrapFunctionArgs): BootstrapFunctionReturn;
|
|
42
38
|
}
|
|
43
39
|
|
|
44
|
-
const bootstrap: BootstrapFunction = ({ apiUrl, getAuthToken,
|
|
40
|
+
const bootstrap: BootstrapFunction = ({ apiUrl, getAuthToken, sentry, kameleoon }) => {
|
|
45
41
|
const { Component: Messaging, queryBus } = checkoutBootstrap({ apiUrl, getAuthToken });
|
|
46
|
-
const I18n = i18n({
|
|
47
|
-
fetchTranslation: fetchTranslations({ translations }),
|
|
48
|
-
domain: DOMAIN,
|
|
49
|
-
});
|
|
50
42
|
|
|
51
43
|
const firstAvailableCheckoutByCustomerId: FirstAvailableCheckoutByCustomerIdFunction = ({ customerId }) =>
|
|
52
44
|
queryBus(viewFirstAvailableCheckoutByCustomerId({ customerId: customerId as string }));
|
|
53
45
|
|
|
54
46
|
return {
|
|
55
|
-
root: root({ Messaging,
|
|
47
|
+
root: root({ Messaging, queryBus, getAuthToken, sentry, kameleoon }),
|
|
56
48
|
firstAvailableCheckoutByCustomerId,
|
|
57
49
|
};
|
|
58
50
|
};
|
|
59
51
|
|
|
60
|
-
export { bootstrap,
|
|
52
|
+
export { bootstrap, translationEndpoints, Country, Segment, CheckoutStatus, Tradename };
|
|
61
53
|
export type {
|
|
62
54
|
Project,
|
|
63
55
|
SentryEnvironment,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lookiero/checkout",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"sideEffects": "false",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@lookiero/sty-psp-ab-testing": "^0.4",
|
|
26
26
|
"@lookiero/sty-psp-expo-config": "^2.0",
|
|
27
27
|
"@lookiero/sty-psp-http": "^2.1",
|
|
28
|
-
"@lookiero/sty-psp-i18n": "^
|
|
28
|
+
"@lookiero/sty-psp-i18n": "^2.0",
|
|
29
29
|
"@lookiero/sty-psp-locale": "^2.1",
|
|
30
30
|
"@lookiero/sty-psp-logging": "^2.2",
|
|
31
31
|
"@lookiero/sty-psp-notifications": "^2.14",
|
|
@@ -59,8 +59,10 @@
|
|
|
59
59
|
"@types/jest-when": ">=3",
|
|
60
60
|
"apollo-boost": "0.4.4",
|
|
61
61
|
"buffer": "5.6.0",
|
|
62
|
+
"cors": "^2.8.5",
|
|
62
63
|
"cypress": "^13.14.2",
|
|
63
64
|
"detox": "^20.11.0",
|
|
65
|
+
"express": "^5.2.1",
|
|
64
66
|
"http-proxy-middleware": "^2.0.9",
|
|
65
67
|
"jest-mock-extended": ">=3",
|
|
66
68
|
"jest-when": ">=3",
|
package/proxy-server.js
CHANGED
|
@@ -29,16 +29,6 @@ app.use(
|
|
|
29
29
|
}),
|
|
30
30
|
);
|
|
31
31
|
|
|
32
|
-
app.use(
|
|
33
|
-
"/local-to-external-i18n",
|
|
34
|
-
createProxyMiddleware({
|
|
35
|
-
target: DEV_UAF_SP,
|
|
36
|
-
pathRewrite: { "^/local-to-external-i18n": "/api/v2/translations" },
|
|
37
|
-
changeOrigin: true,
|
|
38
|
-
logLevel: "debug",
|
|
39
|
-
}),
|
|
40
|
-
);
|
|
41
|
-
|
|
42
32
|
// Payments
|
|
43
33
|
app.use(
|
|
44
34
|
"/web",
|
package/src/ExpoRoot.tsx
CHANGED
|
@@ -5,10 +5,7 @@ import { Platform, ScrollView } from "react-native";
|
|
|
5
5
|
import { Navigate, Route, Routes } from "react-router-native";
|
|
6
6
|
import { Aurora, Text } from "@lookiero/aurora";
|
|
7
7
|
import { EventProvider } from "@lookiero/event";
|
|
8
|
-
import { EndpointFunction } from "@lookiero/i18n";
|
|
9
|
-
import { i18n } from "@lookiero/i18n-react";
|
|
10
8
|
import { FeatureFlags, PaymentsQueryProvider, setPaymentsBridge } from "@lookiero/payments-front";
|
|
11
|
-
import { fetchTranslations, Project, translationExternalEndpoint } from "@lookiero/sty-psp-i18n";
|
|
12
9
|
import { Country, Locale } from "@lookiero/sty-psp-locale";
|
|
13
10
|
import { SentryEnvironment } from "@lookiero/sty-psp-logging";
|
|
14
11
|
import { Segment } from "@lookiero/sty-psp-segment";
|
|
@@ -18,7 +15,6 @@ import { KameleoonEnvironment } from "./infrastructure/ab-testing/kameleoonEnvir
|
|
|
18
15
|
import { bootstrap as checkoutBootstrap } from "./infrastructure/delivery/bootstrap";
|
|
19
16
|
import { bootstrap as checkoutMockBootstrap } from "./infrastructure/delivery/bootstrap.mock";
|
|
20
17
|
import { root } from "./infrastructure/ui/Root";
|
|
21
|
-
import { DOMAIN } from "./infrastructure/ui/i18n/i18n";
|
|
22
18
|
import { Router } from "./infrastructure/ui/routing/router/Router";
|
|
23
19
|
import { Customer } from "./projection/customer/customer";
|
|
24
20
|
import { RELEASE } from "./version";
|
|
@@ -56,26 +52,6 @@ const authToken =
|
|
|
56
52
|
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjIyMDgzMTMsImV4cCI6MTc3MDQ1NzEzMCwiZGlzcGxheU5hbWUiOiJtYWlsLmRlditCRlUtLTIwMzc0MjExMTYiLCJjb3VudHJ5X2NvZGUiOiJOTCIsImFjY2Vzc1ZpYSI6ImVtYWlsIiwic3Vic2NyaXB0aW9uU3RhcnRpbmdEYXRlIjoiMjAyMC0xMC0wMSIsImltcGVyc29uYXRlZCI6ZmFsc2UsInV1aWQiOiIwMDA0YTA0OS1mZWY2LTRiYWMtYTQ1ZC1iM2E5MDRiNGVlNGIiLCJ0cmFkZW5hbWUiOiJMT09LSUVSTyIsImlhdCI6MTc2Nzc3ODczMH0.5x6bj95AAh2c4zoQaR5AMrTO6xAkW73KHyYbFKnYzD8";
|
|
57
53
|
const getAuthToken = () => Promise.resolve(authToken);
|
|
58
54
|
|
|
59
|
-
const externalTranslationsUrl =
|
|
60
|
-
Platform.OS !== "web"
|
|
61
|
-
? "https://web2.sp.dev.aws.lookiero.es/api/v2/translations"
|
|
62
|
-
: __DEV__
|
|
63
|
-
? process.env.EXPO_PUBLIC_CI
|
|
64
|
-
? "/local-to-external-i18n"
|
|
65
|
-
: "http://localhost:3004/local-to-external-i18n"
|
|
66
|
-
: "/external-i18n";
|
|
67
|
-
const translationProjectsByTradename: Record<Tradename, [project: Project, filter?: string][]> = {
|
|
68
|
-
[Tradename.LOOKIERO]: [["checkout"], ["inventory-catalog"]],
|
|
69
|
-
[Tradename.OUTFITTERY]: [["outfittery-checkout"], ["inventory-catalog"]],
|
|
70
|
-
};
|
|
71
|
-
const translations: EndpointFunction[] = [
|
|
72
|
-
(locale) =>
|
|
73
|
-
translationExternalEndpoint({
|
|
74
|
-
translationsUrl: externalTranslationsUrl,
|
|
75
|
-
projects: translationProjectsByTradename[tradename],
|
|
76
|
-
})(locale),
|
|
77
|
-
];
|
|
78
|
-
|
|
79
55
|
const useRedirect: () => Record<string, string> = () => ({
|
|
80
56
|
returnUrl: "https://web2.dev.aws.lookiero.es/user/",
|
|
81
57
|
});
|
|
@@ -113,13 +89,9 @@ const { Component: Messaging, queryBus } =
|
|
|
113
89
|
process.env.EXPO_PUBLIC_APP_VARIANT === "test"
|
|
114
90
|
? checkoutMockBootstrap()
|
|
115
91
|
: checkoutBootstrap({ apiUrl: () => apiUrl, getAuthToken });
|
|
116
|
-
|
|
117
|
-
fetchTranslation: fetchTranslations({ translations }),
|
|
118
|
-
domain: DOMAIN,
|
|
119
|
-
});
|
|
92
|
+
|
|
120
93
|
const Root = root({
|
|
121
94
|
Messaging,
|
|
122
|
-
I18n,
|
|
123
95
|
queryBus,
|
|
124
96
|
getAuthToken,
|
|
125
97
|
development: false,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// TODO properly export MessagingRoot from @lookiero/messaging-react
|
|
2
|
-
import React, { ComponentType, useCallback } from "react";
|
|
2
|
+
import React, { ComponentType, useCallback, useMemo } from "react";
|
|
3
3
|
import { Platform } from "react-native";
|
|
4
4
|
import { useRoutes as reactRouterUseRoutes } from "react-router-native";
|
|
5
|
-
import {
|
|
5
|
+
import { i18n } from "@lookiero/i18n-react";
|
|
6
6
|
import { QueryBus } from "@lookiero/messaging";
|
|
7
7
|
import { MessagingRoot } from "@lookiero/messaging-react/bootstrap";
|
|
8
|
+
import { EndpointFunction, fetchTranslations, translationEndpoints } from "@lookiero/sty-psp-i18n";
|
|
8
9
|
import { Locale } from "@lookiero/sty-psp-locale";
|
|
9
10
|
import { SentryEnvironment, SentryLoggerFunctionArgs, sentryLogger, sentryLoggerHOC } from "@lookiero/sty-psp-logging";
|
|
10
11
|
import { Layout } from "@lookiero/sty-psp-ui";
|
|
@@ -13,11 +14,11 @@ import { Customer } from "../../projection/customer/customer";
|
|
|
13
14
|
import { KameleoonEnvironment } from "../ab-testing/kameleoonEnvironment";
|
|
14
15
|
import { OnSuccessFunction as OnCheckoutFlowSuccessFunction } from "./hooks/useCheckoutFlow";
|
|
15
16
|
import { QueryBusProvider } from "./hooks/useQueryBus";
|
|
17
|
+
import { DOMAIN } from "./i18n/i18n";
|
|
16
18
|
import { Routing } from "./routing/Routing";
|
|
17
19
|
|
|
18
20
|
interface RootFunctionArgs {
|
|
19
21
|
readonly Messaging: MessagingRoot;
|
|
20
|
-
readonly I18n: I18n;
|
|
21
22
|
readonly development?: boolean;
|
|
22
23
|
readonly queryBus: QueryBus;
|
|
23
24
|
readonly sentry: () => SentryEnvironment;
|
|
@@ -41,15 +42,7 @@ interface RootProps {
|
|
|
41
42
|
readonly useRoutes?: typeof reactRouterUseRoutes;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
const root: RootFunction = ({
|
|
45
|
-
Messaging,
|
|
46
|
-
I18n,
|
|
47
|
-
queryBus,
|
|
48
|
-
getAuthToken,
|
|
49
|
-
development,
|
|
50
|
-
sentry,
|
|
51
|
-
kameleoon: kameleoonConfig,
|
|
52
|
-
}) => {
|
|
45
|
+
const root: RootFunction = ({ Messaging, queryBus, getAuthToken, development, sentry, kameleoon: kameleoonConfig }) => {
|
|
53
46
|
const logger = sentryLogger(sentry);
|
|
54
47
|
const kameleoon = kameleoonConfig();
|
|
55
48
|
|
|
@@ -65,6 +58,21 @@ const root: RootFunction = ({
|
|
|
65
58
|
useRedirect,
|
|
66
59
|
useRoutes = reactRouterUseRoutes,
|
|
67
60
|
}: RootProps) => {
|
|
61
|
+
const I18n = useMemo(() => {
|
|
62
|
+
const translations: EndpointFunction[] = [
|
|
63
|
+
(locale) =>
|
|
64
|
+
translationEndpoints({
|
|
65
|
+
projects: ["checkout", "inventory-catalog"],
|
|
66
|
+
tradename,
|
|
67
|
+
})(locale),
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
return i18n({
|
|
71
|
+
fetchTranslation: fetchTranslations({ translations }),
|
|
72
|
+
domain: DOMAIN,
|
|
73
|
+
});
|
|
74
|
+
}, [tradename]);
|
|
75
|
+
|
|
68
76
|
const handleOnI18nError = useCallback((error: Error) => logger.captureException(error), []);
|
|
69
77
|
|
|
70
78
|
return (
|