@lookiero/checkout 8.14.0-beta.2 → 8.14.0-beta.3

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.
Files changed (125) hide show
  1. package/dist/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.d.ts +10 -0
  2. package/dist/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.js +17 -0
  3. package/dist/src/infrastructure/ui/Root.d.ts +2 -3
  4. package/dist/src/infrastructure/ui/Root.js +4 -2
  5. package/dist/src/infrastructure/ui/components/layouts/layout/Layout.d.ts +21 -0
  6. package/dist/src/infrastructure/ui/components/layouts/layout/Layout.js +1 -0
  7. package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.d.ts +6 -0
  8. package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.js +4 -0
  9. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.d.ts +6 -0
  10. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.js +5 -0
  11. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.d.ts +4 -0
  12. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.js +19 -0
  13. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.d.ts +3 -0
  14. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.js +18 -0
  15. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.d.ts +12 -0
  16. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.js +13 -0
  17. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestion.d.ts +0 -5
  18. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestion.js +3 -3
  19. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestions.d.ts +0 -5
  20. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestions.js +1 -1
  21. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/ReturnQuestionItem.d.ts +0 -5
  22. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.js +4 -3
  23. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/form/HostStackReturnQuestionItem.js +1 -1
  24. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem.js +2 -2
  25. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems.d.ts +1 -3
  26. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems.js +5 -4
  27. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem.js +4 -4
  28. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.d.ts +6 -0
  29. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.js +11 -0
  30. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.d.ts +8 -0
  31. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.js +11 -0
  32. package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.d.ts +11 -0
  33. package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.js +49 -0
  34. package/dist/src/infrastructure/ui/i18n/fetchTranslations.d.ts +9 -0
  35. package/dist/src/infrastructure/ui/i18n/fetchTranslations.js +9 -0
  36. package/dist/src/infrastructure/ui/i18n/translationEndpoint.d.ts +19 -0
  37. package/dist/src/infrastructure/ui/i18n/translationEndpoint.js +21 -0
  38. package/dist/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.d.ts +9 -0
  39. package/dist/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +21 -0
  40. package/dist/src/infrastructure/ui/routing/Routing.d.ts +0 -7
  41. package/dist/src/infrastructure/ui/routing/Routing.js +5 -5
  42. package/dist/src/infrastructure/ui/test/render.js +3 -1
  43. package/dist/src/infrastructure/ui/views/App.d.ts +0 -8
  44. package/dist/src/infrastructure/ui/views/App.js +10 -7
  45. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.d.ts +7 -0
  46. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.js +10 -0
  47. package/dist/src/infrastructure/ui/views/item/Item.d.ts +0 -5
  48. package/dist/src/infrastructure/ui/views/item/Item.js +3 -3
  49. package/dist/src/infrastructure/ui/views/item/components/getOutOfCheckoutModal/GetOutOfCheckoutModal.d.ts +0 -2
  50. package/dist/src/infrastructure/ui/views/item/components/getOutOfCheckoutModal/GetOutOfCheckoutModal.js +4 -3
  51. package/dist/src/infrastructure/ui/views/item/components/itemActions/ItemActions.d.ts +1 -5
  52. package/dist/src/infrastructure/ui/views/item/components/itemActions/ItemActions.js +2 -2
  53. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.d.ts +0 -5
  54. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.js +2 -2
  55. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.d.ts +11 -0
  56. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.js +40 -0
  57. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts +12 -0
  58. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.js +15 -0
  59. package/dist/src/infrastructure/ui/views/item/components/selectModal/SelectModal.d.ts +0 -7
  60. package/dist/src/infrastructure/ui/views/item/components/selectModal/SelectModal.js +6 -5
  61. package/dist/src/infrastructure/ui/views/item/components/sizeWithoutStockModal/SizeWithoutStockModal.d.ts +0 -2
  62. package/dist/src/infrastructure/ui/views/item/components/sizeWithoutStockModal/SizeWithoutStockModal.js +4 -3
  63. package/dist/src/infrastructure/ui/views/item/views/itemWithCustomerDecission/ItemWithCustomerDecission.d.ts +0 -5
  64. package/dist/src/infrastructure/ui/views/item/views/itemWithCustomerDecission/ItemWithCustomerDecission.js +2 -2
  65. package/dist/src/infrastructure/ui/views/item/views/itemWithoutCustomerDecission/ItemWithoutCustomerDecission.d.ts +0 -5
  66. package/dist/src/infrastructure/ui/views/item/views/itemWithoutCustomerDecission/ItemWithoutCustomerDecission.js +2 -2
  67. package/dist/src/infrastructure/ui/views/return/Return.d.ts +0 -5
  68. package/dist/src/infrastructure/ui/views/return/Return.js +2 -2
  69. package/dist/src/infrastructure/ui/views/return/Return.style.d.ts +40 -0
  70. package/dist/src/infrastructure/ui/views/return/Return.style.js +43 -0
  71. package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.d.ts +0 -5
  72. package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.js +11 -10
  73. package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts +6 -2
  74. package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.style.js +6 -2
  75. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.d.ts +13 -0
  76. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.js +9 -0
  77. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.d.ts +7 -0
  78. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.js +10 -0
  79. package/dist/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.d.ts +17 -0
  80. package/dist/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.js +13 -0
  81. package/dist/src/projection/shared/country.d.ts +14 -0
  82. package/dist/src/projection/shared/country.js +15 -0
  83. package/dist/src/projection/shared/customer.d.ts +8 -0
  84. package/dist/src/projection/shared/customer.js +1 -0
  85. package/dist/src/projection/shared/locale.d.ts +12 -0
  86. package/dist/src/projection/shared/locale.js +13 -0
  87. package/dist/src/projection/shared/order.d.ts +6 -0
  88. package/dist/src/projection/shared/order.js +1 -0
  89. package/dist/src/projection/shared/price.d.ts +10 -0
  90. package/dist/src/projection/shared/price.js +1 -0
  91. package/dist/src/projection/shared/size.d.ts +20 -0
  92. package/dist/src/projection/shared/size.js +3 -0
  93. package/dist/src/projection/shared/subscription.d.ts +2 -0
  94. package/dist/src/projection/shared/subscription.js +1 -0
  95. package/dist/src/shared/ui/components/atoms/error/Error.d.ts +10 -0
  96. package/dist/src/shared/ui/components/atoms/error/Error.js +4 -0
  97. package/dist/src/version.d.ts +1 -1
  98. package/dist/src/version.js +1 -1
  99. package/package.json +2 -2
  100. package/src/infrastructure/ui/Root.tsx +22 -21
  101. package/src/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestion.tsx +1 -14
  102. package/src/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestions.tsx +1 -8
  103. package/src/infrastructure/ui/components/organisms/returnQuestions/components/ReturnQuestionItem.ts +0 -6
  104. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.tsx +3 -3
  105. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/form/HostStackReturnQuestionItem.tsx +0 -2
  106. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem.tsx +0 -2
  107. package/src/infrastructure/ui/components/organisms/returnQuestions/components/modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems.tsx +4 -6
  108. package/src/infrastructure/ui/components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem.tsx +2 -3
  109. package/src/infrastructure/ui/routing/Routing.tsx +5 -13
  110. package/src/infrastructure/ui/test/render.tsx +4 -1
  111. package/src/infrastructure/ui/views/App.tsx +23 -26
  112. package/src/infrastructure/ui/views/item/Item.tsx +2 -8
  113. package/src/infrastructure/ui/views/item/components/getOutOfCheckoutModal/GetOutOfCheckoutModal.tsx +5 -10
  114. package/src/infrastructure/ui/views/item/components/getOutOfCheckoutModal/__snapshots__/GetOutOfCheckoutModal.test.tsx.snap +6 -3
  115. package/src/infrastructure/ui/views/item/components/itemActions/ItemActions.tsx +2 -8
  116. package/src/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.tsx +3 -12
  117. package/src/infrastructure/ui/views/item/components/selectModal/SelectModal.tsx +6 -17
  118. package/src/infrastructure/ui/views/item/components/selectModal/__snapshots__/SelecModal.test.tsx.snap +5 -8
  119. package/src/infrastructure/ui/views/item/components/sizeWithoutStockModal/SizeWithoutStockModal.tsx +6 -5
  120. package/src/infrastructure/ui/views/item/components/sizeWithoutStockModal/__snapshots__/SizeWithoutStockModal.test.tsx.snap +6 -3
  121. package/src/infrastructure/ui/views/item/views/itemWithCustomerDecission/ItemWithCustomerDecission.tsx +2 -12
  122. package/src/infrastructure/ui/views/item/views/itemWithoutCustomerDecission/ItemWithoutCustomerDecission.tsx +2 -12
  123. package/src/infrastructure/ui/views/return/Return.tsx +1 -8
  124. package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.style.ts +6 -2
  125. package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.tsx +30 -31
@@ -0,0 +1,10 @@
1
+ import { UseQueryFunctionResult } from "@lookiero/messaging-react";
2
+ import { IsCheckoutAccessibleByCustomerIdProjection } from "../../../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
3
+ interface UseViewIsCheckoutAccessibleByCustomerIdFunctionArgs {
4
+ readonly customerId: string | undefined;
5
+ }
6
+ interface UseViewIsCheckoutAccessibleByCustomerIdFunction {
7
+ (args: UseViewIsCheckoutAccessibleByCustomerIdFunctionArgs): UseQueryFunctionResult<IsCheckoutAccessibleByCustomerIdProjection>;
8
+ }
9
+ declare const useViewIsCheckoutAccessibleByCustomerId: UseViewIsCheckoutAccessibleByCustomerIdFunction;
10
+ export { useViewIsCheckoutAccessibleByCustomerId };
@@ -0,0 +1,17 @@
1
+ import { useQuery } from "@lookiero/messaging-react";
2
+ import { isCheckoutFeedbackGiven } from "../../../../domain/checkoutFeedback/model/checkoutFeedbackGiven";
3
+ import { viewIsCheckoutAccessibleByCustomerId, } from "../../../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
4
+ import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
5
+ const useViewIsCheckoutAccessibleByCustomerId = ({ customerId }) => useQuery({
6
+ query: viewIsCheckoutAccessibleByCustomerId({ customerId }),
7
+ contextId: MESSAGING_CONTEXT_ID,
8
+ invalidation: isCheckoutFeedbackGiven,
9
+ options: {
10
+ refetchOnMount: "always",
11
+ staleTime: Infinity,
12
+ retry: false,
13
+ refetchOnWindowFocus: false,
14
+ cacheTime: 0,
15
+ },
16
+ });
17
+ export { useViewIsCheckoutAccessibleByCustomerId };
@@ -4,12 +4,11 @@ import { I18n } from "@lookiero/i18n-react";
4
4
  import { MessagingRoot } from "@lookiero/messaging-react/bootstrap";
5
5
  import { Locale } from "@lookiero/sty-psp-locale";
6
6
  import { SentryEnvironment, SentryLoggerFunctionArgs } from "@lookiero/sty-psp-logging";
7
- import { Layout } from "@lookiero/sty-psp-ui";
7
+ import { EnvironmentStyle, Layout } from "@lookiero/sty-psp-ui";
8
8
  import { Customer } from "../../projection/customer/customer";
9
9
  import { Order } from "../../projection/order/order";
10
10
  import { Subscription } from "../../projection/subscription/subscription";
11
11
  import { KameleoonEnvironment } from "../ab-testing/kameleoonEnvironment";
12
- import { RoutingStyle } from "./routing/Routing";
13
12
  interface RootFunctionArgs {
14
13
  readonly Messaging: MessagingRoot;
15
14
  readonly I18n: I18n;
@@ -28,7 +27,7 @@ interface RootProps {
28
27
  readonly order: Order | undefined;
29
28
  readonly subscription: Subscription | undefined;
30
29
  readonly layout: Layout;
31
- readonly style?: Partial<RoutingStyle>;
30
+ readonly style?: EnvironmentStyle;
32
31
  readonly onNotAccessible: () => void;
33
32
  readonly onCheckoutSubmitted?: () => void;
34
33
  readonly useRedirect: () => Record<string, string>;
@@ -4,15 +4,17 @@ import { Platform } from "react-native";
4
4
  import { useRoutes as reactRouterUseRoutes } from "react-router-native";
5
5
  import { Locale } from "@lookiero/sty-psp-locale";
6
6
  import { sentryLogger, sentryLoggerHOC } from "@lookiero/sty-psp-logging";
7
+ import { EnvironmentStyleProvider } from "@lookiero/sty-psp-ui";
7
8
  import { Routing } from "./routing/Routing";
8
9
  const root = ({ Messaging, I18n, getAuthToken, development, sentry, kameleoon: kameleoonConfig }) => {
9
10
  const logger = sentryLogger(sentry);
10
11
  const kameleoon = kameleoonConfig();
11
12
  // eslint-disable-next-line react/display-name, react/prop-types
12
- const Root = ({ basePath, locale = Locale.en_GB, customer, order, subscription, layout, style: customStyle, onNotAccessible, onCheckoutSubmitted, useRedirect, useRoutes = reactRouterUseRoutes, }) => {
13
+ const Root = ({ basePath, locale = Locale.en_GB, customer, order, subscription, layout, style, onNotAccessible, onCheckoutSubmitted, useRedirect, useRoutes = reactRouterUseRoutes, }) => {
13
14
  const handleOnI18nError = useCallback((error) => logger.captureException(error), []);
14
15
  return (React.createElement(Messaging, { includeReactQueryDevTools: Platform.OS === "web" },
15
- React.createElement(Routing, { I18n: I18n, basePath: basePath, customer: customer, getAuthToken: getAuthToken, kameleoon: kameleoon, layout: layout, locale: locale, order: order, style: customStyle, subscription: subscription, useRedirect: useRedirect, useRoutes: useRoutes, onCheckoutSubmitted: onCheckoutSubmitted, onI18nError: development ? undefined : handleOnI18nError, onNotAccessible: onNotAccessible })));
16
+ React.createElement(EnvironmentStyleProvider, { style: style },
17
+ React.createElement(Routing, { I18n: I18n, basePath: basePath, customer: customer, getAuthToken: getAuthToken, kameleoon: kameleoon, layout: layout, locale: locale, order: order, subscription: subscription, useRedirect: useRedirect, useRoutes: useRoutes, onCheckoutSubmitted: onCheckoutSubmitted, onI18nError: development ? undefined : handleOnI18nError, onNotAccessible: onNotAccessible }))));
16
18
  };
17
19
  const hoc = sentryLoggerHOC({ logger });
18
20
  /**
@@ -0,0 +1,21 @@
1
+ import { FC, ReactNode, RefObject } from "react";
2
+ import { LayoutChangeEvent, ScrollView, StyleProp, ViewStyle } from "react-native";
3
+ interface LayoutStyle {
4
+ readonly safeAreaView: StyleProp<ViewStyle>;
5
+ readonly scrollView: StyleProp<ViewStyle>;
6
+ readonly header: StyleProp<ViewStyle>;
7
+ }
8
+ interface LayoutProps {
9
+ readonly children: ReactNode;
10
+ readonly header?: JSX.Element | null;
11
+ readonly footer?: JSX.Element | null;
12
+ readonly panel?: JSX.Element | null;
13
+ readonly stickyHeader?: boolean;
14
+ readonly stickyHeaderHiddenOnScroll?: boolean;
15
+ readonly scrollRef?: RefObject<ScrollView>;
16
+ readonly scrollEnabled?: boolean;
17
+ readonly style?: Partial<LayoutStyle>;
18
+ readonly onLayout?: (event: LayoutChangeEvent) => void;
19
+ }
20
+ type Layout = FC<LayoutProps>;
21
+ export type { Layout };
@@ -0,0 +1,6 @@
1
+ import { FC, ReactNode } from "react";
2
+ interface FooterProps {
3
+ readonly children: ReactNode;
4
+ }
5
+ declare const Footer: FC<FooterProps>;
6
+ export { Footer };
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { Platform } from "react-native";
3
+ const Footer = ({ children }) => (Platform.OS !== "web" ? React.createElement(React.Fragment, null, children) : null);
4
+ export { Footer };
@@ -0,0 +1,6 @@
1
+ import { FC, ReactNode } from "react";
2
+ interface HeaderProps {
3
+ readonly children: ReactNode;
4
+ }
5
+ declare const Header: FC<HeaderProps>;
6
+ export { Header };
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ import { View } from "react-native";
3
+ import { style } from "./Header.style";
4
+ const Header = ({ children }) => React.createElement(View, { style: style.header }, children);
5
+ export { Header };
@@ -0,0 +1,4 @@
1
+ declare const style: {
2
+ header: {};
3
+ };
4
+ export { style };
@@ -0,0 +1,19 @@
1
+ import { Platform, StyleSheet } from "react-native";
2
+ import { HEADER_HEIGHT } from "../../../../templates/header/Header.style";
3
+ const style = StyleSheet.create({
4
+ header: {
5
+ ...Platform.select({
6
+ web: {
7
+ position: "sticky",
8
+ top: 0,
9
+ zIndex: 10,
10
+ height: HEADER_HEIGHT,
11
+ },
12
+ native: {
13
+ position: "relative",
14
+ height: HEADER_HEIGHT,
15
+ },
16
+ }),
17
+ },
18
+ });
19
+ export { style };
@@ -0,0 +1,3 @@
1
+ import { Layout } from "../Layout";
2
+ declare const DummyLayout: Layout;
3
+ export { DummyLayout };
@@ -0,0 +1,18 @@
1
+ /* eslint-disable react/prop-types */
2
+ import React from "react";
3
+ import { View } from "react-native";
4
+ import { GestureHandlerRootView, ScrollView as RNGHScrollView } from "react-native-gesture-handler";
5
+ import { SafeAreaView } from "react-native-safe-area-context";
6
+ import { Footer as DefaultFooter } from "../../../templates/footer/Footer";
7
+ import { DefaultHeader } from "../../../templates/header/defaultHeader/DefaultHeader";
8
+ import { Footer } from "../components/footer/Footer";
9
+ import { Header } from "../components/header/Header";
10
+ import { style } from "./DummyLayout.style";
11
+ const DummyLayout = ({ children, header = React.createElement(DefaultHeader, null), footer = React.createElement(DefaultFooter, null), panel, style: customStyle, scrollEnabled, onLayout, }) => (React.createElement(SafeAreaView, { style: [style.safeAreaView, customStyle?.safeAreaView] },
12
+ React.createElement(GestureHandlerRootView, { style: { flex: 1 } },
13
+ React.createElement(RNGHScrollView, { contentContainerStyle: [style.scrollView, customStyle?.scrollView], scrollEnabled: scrollEnabled, scrollEventThrottle: 16, showsVerticalScrollIndicator: false, stickyHeaderIndices: [0] },
14
+ React.createElement(Header, null, header),
15
+ panel,
16
+ React.createElement(View, { style: style.children, onLayout: onLayout }, children))),
17
+ React.createElement(Footer, null, footer)));
18
+ export { DummyLayout };
@@ -0,0 +1,12 @@
1
+ declare const style: {
2
+ children: {
3
+ flex: number;
4
+ };
5
+ safeAreaView: {
6
+ flex: number;
7
+ };
8
+ scrollView: {
9
+ flexGrow: number;
10
+ };
11
+ };
12
+ export { style };
@@ -0,0 +1,13 @@
1
+ import { StyleSheet } from "react-native";
2
+ const style = StyleSheet.create({
3
+ children: {
4
+ flex: 1,
5
+ },
6
+ safeAreaView: {
7
+ flex: 1,
8
+ },
9
+ scrollView: {
10
+ flexGrow: 1,
11
+ },
12
+ });
13
+ export { style };
@@ -1,14 +1,9 @@
1
1
  import React from "react";
2
- import { StyleProp, ViewStyle } from "react-native";
3
2
  import { ReturnQuestionProjection } from "../../../../../projection/returnQuestion/returnQuestion";
4
- interface ReturnQuestionStyle {
5
- readonly modal: StyleProp<ViewStyle>;
6
- }
7
3
  interface ReturnQuestionProps {
8
4
  readonly returnQuestionParent: ReturnQuestionProjection;
9
5
  readonly returnQuestion: ReturnQuestionProjection;
10
6
  readonly portalHostName?: string;
11
- readonly style?: Partial<ReturnQuestionStyle>;
12
7
  }
13
8
  declare const _default: React.NamedExoticComponent<ReturnQuestionProps>;
14
9
  export default _default;
@@ -1,8 +1,8 @@
1
1
  import React, { memo } from "react";
2
2
  import { useReturnQuestionItem } from "./behaviors/useReturnQuestionItem";
3
- const ReturnQuestion = ({ returnQuestionParent, returnQuestion, portalHostName, style: customStyle, }) => {
3
+ const ReturnQuestion = ({ returnQuestionParent, returnQuestion, portalHostName }) => {
4
4
  const Item = useReturnQuestionItem({ type: returnQuestion.type });
5
- return (React.createElement(Item, { portalHostName: portalHostName, returnQuestion: returnQuestion, returnQuestionParent: returnQuestionParent, style: customStyle, testID: returnQuestion.id },
6
- React.createElement(React.Fragment, null, returnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, portalHostName: portalHostName, returnQuestion: childReturnQuestion, returnQuestionParent: returnQuestion, style: customStyle }))))));
5
+ return (React.createElement(Item, { portalHostName: portalHostName, returnQuestion: returnQuestion, returnQuestionParent: returnQuestionParent, testID: returnQuestion.id },
6
+ React.createElement(React.Fragment, null, returnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, portalHostName: portalHostName, returnQuestion: childReturnQuestion, returnQuestionParent: returnQuestion }))))));
7
7
  };
8
8
  export default memo(ReturnQuestion);
@@ -1,13 +1,8 @@
1
1
  import { FC } from "react";
2
- import { StyleProp, ViewStyle } from "react-native";
3
2
  import { ReturnQuestionProjection } from "../../../../../projection/returnQuestion/returnQuestion";
4
- interface ReturnQuestionsStyle {
5
- readonly modal: StyleProp<ViewStyle>;
6
- }
7
3
  interface ReturnQuestionsProps {
8
4
  readonly returnQuestions: ReturnQuestionProjection[];
9
5
  readonly portalHostName?: string;
10
- readonly style?: Partial<ReturnQuestionsStyle>;
11
6
  }
12
7
  declare const ReturnQuestions: FC<ReturnQuestionsProps>;
13
8
  export { ReturnQuestions };
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
2
  import ReturnQuestion from "./ReturnQuestion";
3
- const ReturnQuestions = ({ returnQuestions, portalHostName, style: customStyle }) => (React.createElement(React.Fragment, null, returnQuestions.map((returnQuestion) => (React.createElement(ReturnQuestion, { key: returnQuestion.id, portalHostName: portalHostName, returnQuestion: returnQuestion, returnQuestionParent: {}, style: customStyle })))));
3
+ const ReturnQuestions = ({ returnQuestions, portalHostName }) => (React.createElement(React.Fragment, null, returnQuestions.map((returnQuestion) => (React.createElement(ReturnQuestion, { key: returnQuestion.id, portalHostName: portalHostName, returnQuestion: returnQuestion, returnQuestionParent: {} })))));
4
4
  export { ReturnQuestions };
@@ -1,16 +1,11 @@
1
1
  import { FC, ReactNode } from "react";
2
- import { StyleProp, ViewStyle } from "react-native";
3
2
  import { ReturnQuestionProjection } from "../../../../../../projection/returnQuestion/returnQuestion";
4
- interface ReturnQuestionItemStyle {
5
- readonly modal: StyleProp<ViewStyle>;
6
- }
7
3
  interface ReturnQuestionItemProps {
8
4
  readonly returnQuestionParent: ReturnQuestionProjection;
9
5
  readonly returnQuestion: ReturnQuestionProjection;
10
6
  readonly children?: ReactNode;
11
7
  readonly portalHostName?: string;
12
8
  readonly testID?: string;
13
- readonly style?: Partial<ReturnQuestionItemStyle>;
14
9
  }
15
10
  type ReturnQuestionItem = FC<ReturnQuestionItemProps>;
16
11
  export type { ReturnQuestionItem, ReturnQuestionItemProps };
@@ -2,12 +2,13 @@ import React, { useCallback, useEffect, useMemo, useState } from "react";
2
2
  import { TouchableHighlight, View } from "react-native";
3
3
  import { ButtonIcon } from "@lookiero/aurora";
4
4
  import { useIntl } from "@lookiero/i18n-react";
5
- import { Modal } from "@lookiero/sty-psp-ui";
5
+ import { Modal, useEnvironmentStyle } from "@lookiero/sty-psp-ui";
6
6
  import { InputField } from "../../../../../../../shared/ui/components/molecules/inputField/InputField";
7
7
  import { useReturnQuestionFeedback, useReturnQuestionFeedbackForReturnQuestion, } from "../../behaviors/useReturnQuestionFeedback";
8
8
  import { deepestReturnQuestionWithFeedbackForReturnQuestion, feedbackForReturnQuestion, } from "../../util/returnQuestionFeedback";
9
9
  import { style, containerUnderlayColor } from "./HostSelectReturnQuestionItem.style";
10
- const HostSelectReturnQuestionItem = ({ returnQuestion, children, portalHostName, testID, style: customStyle, }) => {
10
+ const HostSelectReturnQuestionItem = ({ returnQuestion, children, portalHostName, testID, }) => {
11
+ const { modal } = useEnvironmentStyle();
11
12
  const { formatMessage } = useIntl();
12
13
  const placeholderText = useMemo(() => (returnQuestion.placeholder ? formatMessage({ id: returnQuestion.placeholder }) : ""), [formatMessage, returnQuestion.placeholder]);
13
14
  const [modalVisible, setModalVisible] = useState(false);
@@ -35,6 +36,6 @@ const HostSelectReturnQuestionItem = ({ returnQuestion, children, portalHostName
35
36
  React.createElement(View, { pointerEvents: "none" },
36
37
  React.createElement(InputField, { editable: false, icon: "arrow_down", label: placeholderText, value: inputValue }))),
37
38
  React.createElement(Modal, { portalHostName: portalHostName, style: deepestReturnQuestionWithFeedback && { header: style.header }, visible: modalVisible, header: deepestReturnQuestionWithFeedback && (React.createElement(ButtonIcon, { name: "arrow_left", style: style.backButton, testID: "modal-back-button", onPress: handleOnBackButtonPress })), scroll: true, showCloseButton: true, onClose: handleOnModalClose },
38
- React.createElement(View, { style: [style.modal, customStyle?.modal] }, children))));
39
+ React.createElement(View, { style: [style.modal, modal?.content] }, children))));
39
40
  };
40
41
  export { HostSelectReturnQuestionItem };
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
2
  import ReturnQuestion from "../../../ReturnQuestion";
3
- const HostStackReturnQuestionItem = ({ returnQuestion, portalHostName, style: customStyle, }) => (React.createElement(React.Fragment, null, returnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, portalHostName: portalHostName, returnQuestion: childReturnQuestion, returnQuestionParent: returnQuestion, style: customStyle })))));
3
+ const HostStackReturnQuestionItem = ({ returnQuestion, portalHostName, }) => (React.createElement(React.Fragment, null, returnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, portalHostName: portalHostName, returnQuestion: childReturnQuestion, returnQuestionParent: returnQuestion })))));
4
4
  export { HostStackReturnQuestionItem };
@@ -6,7 +6,7 @@ import { useIntl } from "@lookiero/i18n-react";
6
6
  import ReturnQuestion from "../../../ReturnQuestion";
7
7
  import { useReturnQuestionFeedbackForReturnQuestion } from "../../../behaviors/useReturnQuestionFeedback";
8
8
  import { style } from "./HostStackReturnQuestionItem.style";
9
- const HostStackReturnQuestionItem = ({ returnQuestion, children, portalHostName, style: customStyle, }) => {
9
+ const HostStackReturnQuestionItem = ({ returnQuestion, children, portalHostName, }) => {
10
10
  const { formatMessage } = useIntl();
11
11
  const { feedback } = useReturnQuestionFeedbackForReturnQuestion({ returnQuestion });
12
12
  const feedbackReturnQuestion = feedback
@@ -22,6 +22,6 @@ const HostStackReturnQuestionItem = ({ returnQuestion, children, portalHostName,
22
22
  titleText && (React.createElement(Text, { level: 3, style: style.title, heading: true }, titleText)),
23
23
  feedbackReturnQuestion ? (React.createElement(React.Fragment, null,
24
24
  React.createElement(Text, { color: COLOR.TEXT_MEDIUM, level: 3 }, feedbackText),
25
- feedbackReturnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, portalHostName: portalHostName, returnQuestion: childReturnQuestion, returnQuestionParent: feedbackReturnQuestion, style: customStyle }))))) : (children))));
25
+ feedbackReturnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, portalHostName: portalHostName, returnQuestion: childReturnQuestion, returnQuestionParent: feedbackReturnQuestion }))))) : (children))));
26
26
  };
27
27
  export { HostStackReturnQuestionItem };
@@ -1,13 +1,11 @@
1
1
  import React from "react";
2
- import { StyleProp, ViewStyle } from "react-native";
3
2
  import { ReturnQuestionProjection } from "../../../../../../../projection/returnQuestion/returnQuestion";
4
3
  interface ModalOptionReturnQuestionItemsProps {
5
4
  readonly portalHostName?: string;
6
5
  readonly returnQuestion: ReturnQuestionProjection;
7
6
  readonly returnQuestionParent: ReturnQuestionProjection;
8
7
  readonly visible: boolean;
9
- readonly style?: StyleProp<ViewStyle>;
10
8
  readonly onClose: () => void;
11
9
  }
12
- declare const ModalOptionReturnQuestionItems: ({ portalHostName, returnQuestion, visible, style: customStyle, onClose, }: ModalOptionReturnQuestionItemsProps) => React.JSX.Element;
10
+ declare const ModalOptionReturnQuestionItems: ({ portalHostName, returnQuestion, visible, onClose, }: ModalOptionReturnQuestionItemsProps) => React.JSX.Element;
13
11
  export { ModalOptionReturnQuestionItems };
@@ -2,15 +2,16 @@ import React from "react";
2
2
  import { View } from "react-native";
3
3
  import { COLOR, Text } from "@lookiero/aurora";
4
4
  import { useIntl } from "@lookiero/i18n-react";
5
- import { Modal } from "@lookiero/sty-psp-ui";
5
+ import { Modal, useEnvironmentStyle } from "@lookiero/sty-psp-ui";
6
6
  import ReturnQuestion from "../../ReturnQuestion";
7
7
  import { style } from "./ModalOptionReturnQuestionItems.style";
8
- const ModalOptionReturnQuestionItems = ({ portalHostName, returnQuestion, visible, style: customStyle, onClose, }) => {
8
+ const ModalOptionReturnQuestionItems = ({ portalHostName, returnQuestion, visible, onClose, }) => {
9
+ const { modal } = useEnvironmentStyle();
9
10
  const { formatMessage } = useIntl();
10
11
  const title = formatMessage({ id: returnQuestion.name });
11
12
  return (React.createElement(Modal, { portalHostName: portalHostName, visible: visible, scroll: true, showCloseButton: true, onClose: onClose },
12
- React.createElement(View, { style: [style.modalContent, customStyle] },
13
+ React.createElement(View, { style: [style.modalContent, modal?.content] },
13
14
  React.createElement(Text, { color: COLOR.TEXT_MEDIUM, level: 2, style: style.optionText }, title),
14
- React.createElement(React.Fragment, null, returnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, portalHostName: "", returnQuestion: childReturnQuestion, returnQuestionParent: returnQuestion, style: { modal: customStyle } })))))));
15
+ React.createElement(React.Fragment, null, returnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, portalHostName: "", returnQuestion: childReturnQuestion, returnQuestionParent: returnQuestion })))))));
15
16
  };
16
17
  export { ModalOptionReturnQuestionItems };
@@ -1,11 +1,11 @@
1
1
  import React, { useCallback, useEffect, useState } from "react";
2
- import { View, Option, OPTION_VARIANT } from "@lookiero/aurora";
2
+ import { View, Option, OPTION_VARIANT, SIZE } from "@lookiero/aurora";
3
3
  import { useIntl } from "@lookiero/i18n-react";
4
4
  import { useReturnQuestionFeedback, useReturnQuestionFeedbackForReturnQuestion, } from "../../behaviors/useReturnQuestionFeedback";
5
5
  import { deepestReturnQuestionWithFeedbackForReturnQuestion, feedbackForReturnQuestion, } from "../../util/returnQuestionFeedback";
6
6
  import { ModalOptionReturnQuestionItems } from "../modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems";
7
7
  import { style } from "./RadioReturnQuestionItem.style";
8
- const RadioReturnQuestionItem = ({ returnQuestion, returnQuestionParent, testID, portalHostName, style: customStyle, }) => {
8
+ const RadioReturnQuestionItem = ({ returnQuestion, returnQuestionParent, testID, portalHostName, }) => {
9
9
  const intl = useIntl();
10
10
  const [modalVisible, setModalVisible] = useState(false);
11
11
  const { feedback: feedbackId, onChange, clear, } = useReturnQuestionFeedbackForReturnQuestion({ returnQuestion: returnQuestionParent });
@@ -43,7 +43,7 @@ const RadioReturnQuestionItem = ({ returnQuestion, returnQuestionParent, testID,
43
43
  */
44
44
  return (React.createElement(React.Fragment, null,
45
45
  React.createElement(View, { style: style.wrapper, testID: testID },
46
- React.createElement(Option, { checked: returnQuestion.id === feedbackId, name: returnQuestion.id, title: inputValue ? `${optionText} / ${inputValue}` : `${optionText}`, value: returnQuestion.id, variant: OPTION_VARIANT.BUTTON, onChange: handleOnPress })),
47
- hasChildren ? (React.createElement(ModalOptionReturnQuestionItems, { portalHostName: portalHostName, returnQuestion: returnQuestion, returnQuestionParent: returnQuestion, style: customStyle?.modal, visible: modalVisible, onClose: handleOnModalClose })) : null));
46
+ React.createElement(Option, { checked: returnQuestion.id === feedbackId, flex: SIZE.XS, name: returnQuestion.id, title: inputValue ? `${optionText} / ${inputValue}` : `${optionText}`, value: returnQuestion.id, variant: OPTION_VARIANT.BUTTON, onChange: handleOnPress })),
47
+ hasChildren ? (React.createElement(ModalOptionReturnQuestionItems, { portalHostName: portalHostName, returnQuestion: returnQuestion, returnQuestionParent: returnQuestion, visible: modalVisible, onClose: handleOnModalClose })) : null));
48
48
  };
49
49
  export { RadioReturnQuestionItem };
@@ -0,0 +1,6 @@
1
+ import { FC } from "react";
2
+ interface DefaultHeaderProps {
3
+ readonly onPressMenu?: () => void;
4
+ }
5
+ declare const DefaultHeader: FC<DefaultHeaderProps>;
6
+ export { DefaultHeader };
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import { ButtonIcon } from "@lookiero/aurora";
3
+ import { Header } from "../Header";
4
+ import { ButtonIconPlaceholder } from "../buttonIconPlaceholder/ButtonIconPlaceholder";
5
+ import { Logo } from "../logo/Logo";
6
+ import { style } from "./DefaultHeader.style";
7
+ const DefaultHeader = ({ onPressMenu }) => (React.createElement(Header, { testID: "default-header" },
8
+ React.createElement(Logo, null),
9
+ React.createElement(ButtonIconPlaceholder, null),
10
+ React.createElement(ButtonIcon, { name: "menu", style: style.button, testID: "menu-button-icon", onPress: onPressMenu })));
11
+ export { DefaultHeader };
@@ -0,0 +1,8 @@
1
+ declare const style: {
2
+ button: {
3
+ alignSelf: "auto";
4
+ height: number;
5
+ width: number;
6
+ };
7
+ };
8
+ export { style };
@@ -0,0 +1,11 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "@lookiero/sty-psp-ui";
3
+ const { space10 } = theme();
4
+ const style = StyleSheet.create({
5
+ button: {
6
+ alignSelf: "auto",
7
+ height: space10,
8
+ width: space10,
9
+ },
10
+ });
11
+ export { style };
@@ -0,0 +1,11 @@
1
+ import { FC, ReactNode } from "react";
2
+ declare enum NewFeedbackExperimentVariation {
3
+ CONTROL = "control",
4
+ RETURN_PAGE = "return_page"
5
+ }
6
+ interface NewFeedbackExperimentProviderProps {
7
+ readonly children: ReactNode;
8
+ }
9
+ declare const NewFeedbackExperimentProvider: FC<NewFeedbackExperimentProviderProps>;
10
+ declare const useNewFeedbackExperiment: () => NewFeedbackExperimentVariation;
11
+ export { useNewFeedbackExperiment, NewFeedbackExperimentProvider, NewFeedbackExperimentVariation };
@@ -0,0 +1,49 @@
1
+ import React, { createContext, useContext, useEffect, useMemo, useRef } from "react";
2
+ import invariant from "tiny-invariant";
3
+ import { Spinner } from "@lookiero/aurora";
4
+ import { useAssignedVariationByExperimentId } from "@lookiero/sty-psp-ab-testing";
5
+ import { useViewFirstAvailableCheckoutByCustomerId } from "../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
6
+ import { useTrackAssignedVariationByExperiment } from "../../tracking/useTrackAssignedVariationByExperiment";
7
+ import { useStaticInfo } from "./useStaticInfo";
8
+ var NewFeedbackExperimentVariation;
9
+ (function (NewFeedbackExperimentVariation) {
10
+ NewFeedbackExperimentVariation["CONTROL"] = "control";
11
+ NewFeedbackExperimentVariation["RETURN_PAGE"] = "return_page";
12
+ })(NewFeedbackExperimentVariation || (NewFeedbackExperimentVariation = {}));
13
+ const NewFeedbackExperimentContext = createContext(null);
14
+ const NewFeedbackExperimentProvider = ({ children }) => {
15
+ const { kameleoon: { experiments: { newFeedback: { id: newFeedbackId, variations }, }, }, customer: { customerId, country, segment }, } = useStaticInfo();
16
+ const [checkout] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
17
+ const { assignedVariation: newFeedbackVariation } = useAssignedVariationByExperimentId({
18
+ experimentId: newFeedbackId,
19
+ });
20
+ const trackAssignedVariation = useTrackAssignedVariationByExperiment({
21
+ checkoutId: checkout?.id,
22
+ country,
23
+ segment,
24
+ experimentId: newFeedbackId,
25
+ });
26
+ const value = useMemo(() => ({
27
+ variation: newFeedbackVariation?.id === Number(variations.v1)
28
+ ? NewFeedbackExperimentVariation.RETURN_PAGE
29
+ : NewFeedbackExperimentVariation.CONTROL,
30
+ }), [newFeedbackVariation?.id, variations.v1]);
31
+ const assignedVariantTracked = useRef(false);
32
+ useEffect(() => {
33
+ if (assignedVariantTracked.current || !newFeedbackVariation || !checkout?.id) {
34
+ return;
35
+ }
36
+ trackAssignedVariation({ assignedVariation: newFeedbackVariation });
37
+ assignedVariantTracked.current = true;
38
+ }, [checkout?.id, newFeedbackVariation, trackAssignedVariation]);
39
+ if (!checkout) {
40
+ return React.createElement(Spinner, null);
41
+ }
42
+ return React.createElement(NewFeedbackExperimentContext.Provider, { value: value }, children);
43
+ };
44
+ const useNewFeedbackExperiment = () => {
45
+ const newFeedbackExperiment = useContext(NewFeedbackExperimentContext);
46
+ invariant(newFeedbackExperiment, "Your are trying to use the useNewFeedbackExperiment hook without wrapping your app with the <NewFeedbackExperimentProvider>.");
47
+ return newFeedbackExperiment.variation;
48
+ };
49
+ export { useNewFeedbackExperiment, NewFeedbackExperimentProvider, NewFeedbackExperimentVariation };
@@ -0,0 +1,9 @@
1
+ import { EndpointFunction, FetchTranslationFuction } from "@lookiero/i18n";
2
+ interface FetchTranslationsFuntionArgs {
3
+ readonly translations: EndpointFunction[];
4
+ }
5
+ interface FetchTranslationsFuntion {
6
+ (args: FetchTranslationsFuntionArgs): FetchTranslationFuction;
7
+ }
8
+ declare const fetchTranslations: FetchTranslationsFuntion;
9
+ export { fetchTranslations };
@@ -0,0 +1,9 @@
1
+ import { fetchFetchTranslation } from "@lookiero/i18n";
2
+ const fetchTranslations = ({ translations }) => async ({ locale }) => {
3
+ const translationsMessages = await Promise.all(translations.map((endpoint) => fetchFetchTranslation({ endpoint })({ locale })));
4
+ return translationsMessages.reduce((acc, translationMessages) => ({
5
+ ...acc,
6
+ ...translationMessages,
7
+ }), {});
8
+ };
9
+ export { fetchTranslations };
@@ -0,0 +1,19 @@
1
+ import { EndpointFunction } from "@lookiero/i18n";
2
+ interface TranslationEndpointFunctionArgs {
3
+ readonly translationsUrl: string;
4
+ readonly translationsApiKey: string;
5
+ }
6
+ interface TranslationEndpointFunction {
7
+ (args: TranslationEndpointFunctionArgs): EndpointFunction;
8
+ }
9
+ declare const translationEndpoint: TranslationEndpointFunction;
10
+ type Project = "user-area-front" | "inventory-catalog" | "checkout";
11
+ interface TranslationExternalEndpointFunctionArgs {
12
+ readonly translationsUrl: string;
13
+ readonly projects: [project: Project, filter?: string][];
14
+ }
15
+ interface TranslationExternalEndpointFunction {
16
+ (args: TranslationExternalEndpointFunctionArgs): EndpointFunction;
17
+ }
18
+ declare const translationExternalEndpoint: TranslationExternalEndpointFunction;
19
+ export { translationEndpoint, translationExternalEndpoint };
@@ -0,0 +1,21 @@
1
+ import { Country } from "../../../projection/shared/country";
2
+ import { Locale } from "../../../projection/shared/locale";
3
+ const translationEndpoint = ({ translationsUrl, translationsApiKey }) => (locale) => `${translationsUrl}/${locale}?key=${translationsApiKey}&no-folding=true`;
4
+ const COUNTRY = {
5
+ [Locale.ES]: Country.ES,
6
+ [Locale.FR]: Country.FR,
7
+ [Locale.EN]: Country.GB,
8
+ [Locale.IT]: Country.IT,
9
+ [Locale.PT]: Country.PT,
10
+ [Locale.DE]: Country.DE,
11
+ [Locale.AT]: Country.AT,
12
+ [Locale.NL]: Country.NL,
13
+ [Locale.SE]: Country.SE,
14
+ };
15
+ const translationExternalEndpoint = ({ translationsUrl, projects }) => (locale) => {
16
+ const projectsQueryParam = projects
17
+ .map(([project, filter]) => `projectFilter=${project}${filter ? `:${filter}` : ""}`)
18
+ .join("&");
19
+ return `${translationsUrl}/${locale}/${COUNTRY[locale]}?${projectsQueryParam}`;
20
+ };
21
+ export { translationEndpoint, translationExternalEndpoint };
@@ -0,0 +1,9 @@
1
+ import { FC } from "react";
2
+ interface CheckoutAccessibilityMiddlewareProps {
3
+ readonly customerId: string | undefined;
4
+ readonly onNotAccessible: () => void;
5
+ readonly loader?: JSX.Element;
6
+ readonly children: JSX.Element;
7
+ }
8
+ declare const CheckoutAccessibilityMiddleware: FC<CheckoutAccessibilityMiddlewareProps>;
9
+ export { CheckoutAccessibilityMiddleware };
@@ -0,0 +1,21 @@
1
+ import React, { useEffect, useRef } from "react";
2
+ import { Spinner } from "@lookiero/aurora";
3
+ import { QueryStatus } from "@lookiero/messaging-react";
4
+ import { useViewIsCheckoutAccessibleByCustomerId } from "../../projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId";
5
+ const CheckoutAccessibilityMiddleware = ({ customerId, onNotAccessible, loader = React.createElement(Spinner, null), children, }) => {
6
+ const [accessible, status] = useViewIsCheckoutAccessibleByCustomerId({ customerId });
7
+ const onNotAccessibleRef = useRef(onNotAccessible);
8
+ onNotAccessibleRef.current = onNotAccessible;
9
+ const notAccessible = accessible === false || status === QueryStatus.ERROR;
10
+ useEffect(() => {
11
+ if (notAccessible) {
12
+ onNotAccessibleRef.current();
13
+ }
14
+ }, [notAccessible]);
15
+ return accessible === undefined && [QueryStatus.IDLE, QueryStatus.LOADING].includes(status)
16
+ ? loader
17
+ : accessible
18
+ ? children
19
+ : null;
20
+ };
21
+ export { CheckoutAccessibilityMiddleware };