@lookiero/checkout 12.2.0-beta.0 → 12.2.0

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 (83) hide show
  1. package/dist/src/infrastructure/delivery/baseBootstrap.d.ts +2 -11
  2. package/dist/src/infrastructure/delivery/baseBootstrap.js +3 -8
  3. package/dist/src/infrastructure/delivery/bootstrap.js +0 -7
  4. package/dist/src/infrastructure/delivery/bootstrap.mock.js +0 -7
  5. package/dist/src/infrastructure/ui/Root.d.ts +1 -2
  6. package/dist/src/infrastructure/ui/hooks/useCheckoutFlow.d.ts +0 -2
  7. package/dist/src/infrastructure/ui/hooks/useCheckoutFlow.js +5 -5
  8. package/dist/src/infrastructure/ui/routing/Routing.d.ts +1 -2
  9. package/dist/src/infrastructure/ui/views/checkout/Checkout.d.ts +1 -2
  10. package/dist/src/infrastructure/ui/views/checkout/Checkout.js +0 -1
  11. package/dist/src/infrastructure/ui/views/checkout/components/paymentInstrument/PaymentInstrument.d.ts +1 -2
  12. package/dist/src/infrastructure/ui/views/checkout/components/paymentInstrument/PaymentInstrument.js +1 -1
  13. package/dist/src/version.d.ts +1 -1
  14. package/dist/src/version.js +1 -1
  15. package/package.json +1 -1
  16. package/src/ExpoRoot.tsx +1 -2
  17. package/src/infrastructure/delivery/baseBootstrap.ts +3 -28
  18. package/src/infrastructure/delivery/bootstrap.mock.ts +0 -7
  19. package/src/infrastructure/delivery/bootstrap.ts +0 -7
  20. package/src/infrastructure/ui/Root.tsx +1 -2
  21. package/src/infrastructure/ui/hooks/useCheckoutFlow.test.tsx +7 -12
  22. package/src/infrastructure/ui/hooks/useCheckoutFlow.tsx +4 -6
  23. package/src/infrastructure/ui/routing/Routing.tsx +1 -2
  24. package/src/infrastructure/ui/views/checkout/Checkout.tsx +1 -3
  25. package/src/infrastructure/ui/views/checkout/components/paymentInstrument/PaymentInstrument.tsx +2 -3
  26. package/dist/public/public/assets/adaptive-icon.png +0 -0
  27. package/dist/public/public/assets/favicon.png +0 -0
  28. package/dist/public/public/assets/icon.png +0 -0
  29. package/dist/public/public/assets/splash.png +0 -0
  30. package/dist/public/public/images/not-found.png +0 -0
  31. package/dist/src/domain/uiSetting/command/updateUiSetting.d.ts +0 -15
  32. package/dist/src/domain/uiSetting/command/updateUiSetting.js +0 -10
  33. package/dist/src/domain/uiSetting/model/uiSetting.d.ts +0 -9
  34. package/dist/src/domain/uiSetting/model/uiSetting.js +0 -11
  35. package/dist/src/domain/uiSetting/model/uiSettingUpdated.d.ts +0 -15
  36. package/dist/src/domain/uiSetting/model/uiSettingUpdated.js +0 -8
  37. package/dist/src/domain/uiSetting/model/uiSettings.d.ts +0 -7
  38. package/dist/src/domain/uiSetting/model/uiSettings.js +0 -1
  39. package/dist/src/infrastructure/domain/uiSetting/model/storageUiSettings.d.ts +0 -17
  40. package/dist/src/infrastructure/domain/uiSetting/model/storageUiSettings.js +0 -20
  41. package/dist/src/infrastructure/domain/uiSetting/react/useUpdateUiSetting.d.ts +0 -18
  42. package/dist/src/infrastructure/domain/uiSetting/react/useUpdateUiSetting.js +0 -22
  43. package/dist/src/infrastructure/integration/useRedirect.d.ts +0 -7
  44. package/dist/src/infrastructure/integration/useRedirect.js +0 -1
  45. package/dist/src/infrastructure/persistence/asyncStorageStorage.d.ts +0 -5
  46. package/dist/src/infrastructure/persistence/asyncStorageStorage.js +0 -7
  47. package/dist/src/infrastructure/persistence/uiSettingData.d.ts +0 -6
  48. package/dist/src/infrastructure/persistence/uiSettingData.js +0 -1
  49. package/dist/src/infrastructure/projection/uiSetting/react/useViewUiSettingByKey.d.ts +0 -10
  50. package/dist/src/infrastructure/projection/uiSetting/react/useViewUiSettingByKey.js +0 -11
  51. package/dist/src/infrastructure/projection/uiSetting/storageUiSettingByKeyView.d.ts +0 -13
  52. package/dist/src/infrastructure/projection/uiSetting/storageUiSettingByKeyView.js +0 -15
  53. package/dist/src/infrastructure/ui/hooks/useSubmitCheckout.d.ts +0 -27
  54. package/dist/src/infrastructure/ui/hooks/useSubmitCheckout.js +0 -97
  55. package/dist/src/infrastructure/ui/routing/useBasePath.d.ts +0 -8
  56. package/dist/src/infrastructure/ui/routing/useBasePath.js +0 -9
  57. package/dist/src/infrastructure/ui/settings/UISettings.d.ts +0 -3
  58. package/dist/src/infrastructure/ui/settings/UISettings.js +0 -4
  59. package/dist/src/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.d.ts +0 -12
  60. package/dist/src/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.js +0 -90
  61. package/dist/src/projection/uiSetting/viewUiSettingByKey.d.ts +0 -29
  62. package/dist/src/projection/uiSetting/viewUiSettingByKey.js +0 -8
  63. package/src/domain/uiSetting/command/updateUiSetting.test.ts +0 -18
  64. package/src/domain/uiSetting/command/updateUiSetting.ts +0 -26
  65. package/src/domain/uiSetting/model/uiSetting.test.ts +0 -25
  66. package/src/domain/uiSetting/model/uiSetting.ts +0 -24
  67. package/src/domain/uiSetting/model/uiSettingUpdated.test.ts +0 -16
  68. package/src/domain/uiSetting/model/uiSettingUpdated.ts +0 -25
  69. package/src/domain/uiSetting/model/uiSettings.ts +0 -15
  70. package/src/infrastructure/domain/uiSetting/model/storageUiSettings.test.ts +0 -50
  71. package/src/infrastructure/domain/uiSetting/model/storageUiSettings.ts +0 -49
  72. package/src/infrastructure/domain/uiSetting/react/useUpdateUiSetting.test.ts +0 -62
  73. package/src/infrastructure/domain/uiSetting/react/useUpdateUiSetting.ts +0 -50
  74. package/src/infrastructure/integration/useRedirect.ts +0 -9
  75. package/src/infrastructure/persistence/asyncStorageStorage.ts +0 -13
  76. package/src/infrastructure/persistence/uiSettingData.ts +0 -7
  77. package/src/infrastructure/projection/uiSetting/react/useViewUiSettingByKey.test.ts +0 -33
  78. package/src/infrastructure/projection/uiSetting/react/useViewUiSettingByKey.ts +0 -22
  79. package/src/infrastructure/projection/uiSetting/storageUiSettingByKeyView.test.ts +0 -36
  80. package/src/infrastructure/projection/uiSetting/storageUiSettingByKeyView.ts +0 -37
  81. package/src/infrastructure/ui/settings/UISettings.ts +0 -3
  82. package/src/projection/uiSetting/viewUiSettingByKey.test.ts +0 -23
  83. package/src/projection/uiSetting/viewUiSettingByKey.ts +0 -50
@@ -15,12 +15,12 @@ import { SubscriptionProjection } from "../../../projection/subscription/subscri
15
15
  import { MESSAGING_CONTEXT_ID } from "../../delivery/baseBootstrap";
16
16
  import { useSubmitCheckout } from "../../domain/checkout/react/useSubmitCheckout";
17
17
  import { useBlockCheckoutBooking } from "../../domain/checkoutBooking/react/useBlockCheckoutBooking";
18
- import { UseRedirectFunction } from "../../integration/useRedirect";
19
18
  import { useViewIsSizeChangeEnabledByCheckoutId } from "../../projection/checkout/react/useViewIsSizeChangeEnabledByCheckoutId";
20
19
  import { useViewPaymentFlowPayloadByCheckoutId } from "../../projection/payment/react/useViewPaymentFlowPayloadByCheckoutId";
21
20
  import { useViewPricingByCheckoutId } from "../../projection/pricing/react/useViewPricingByCheckoutId";
22
21
  import { useTrackCheckout } from "../../tracking/useTrackCheckout";
23
22
  import { I18nMessages } from "../i18n/i18n";
23
+ import { Routes } from "../routing/routes";
24
24
  import { usePaymentInstrumentEvents } from "./usePaymentInstrumentEvents";
25
25
  import { useQueryBus } from "./useQueryBus";
26
26
  import { useStaticInfo } from "./useStaticInfo";
@@ -43,7 +43,6 @@ interface UseCheckoutFlowArgs {
43
43
  readonly subscription: SubscriptionProjection;
44
44
  readonly getAuthToken: () => Promise<string>;
45
45
  readonly onSuccess: () => void;
46
- readonly useRedirect: UseRedirectFunction;
47
46
  }
48
47
 
49
48
  interface UseCheckoutFlowFunction {
@@ -56,15 +55,14 @@ const useCheckoutFlow: UseCheckoutFlowFunction = ({
56
55
  subscription: subscriptionProjection,
57
56
  getAuthToken,
58
57
  onSuccess,
59
- useRedirect,
60
58
  }) => {
61
59
  const logger = useLogger();
62
60
  const queryBus = useQueryBus();
63
61
  const {
64
62
  customer: { customerId, country, segment, name, email },
63
+ basePath,
65
64
  tradename,
66
65
  } = useStaticInfo();
67
- const { returnUrl } = useRedirect();
68
66
  const paymentFlowRef = useRef<PaymentFlowRef>(null);
69
67
  const [paymentFlowPayload] = useViewPaymentFlowPayloadByCheckoutId({
70
68
  checkoutId: checkoutProjection?.id as string,
@@ -124,14 +122,14 @@ const useCheckoutFlow: UseCheckoutFlowFunction = ({
124
122
  paymentFlowRef.current?.startLegacyBoxCheckout({
125
123
  ...paymentFlowPayload,
126
124
  userInformation: { email, name },
127
- returnUrl,
125
+ returnUrl: `${basePath}/${Routes.CHECKOUT}`,
128
126
  } as unknown as LegacyBoxCheckoutStrategyPayload);
129
127
  }, [
130
128
  checkoutProjection?.checkoutBookingId,
131
129
  paymentFlowPayload,
132
130
  email,
133
131
  name,
134
- returnUrl,
132
+ basePath,
135
133
  sizeChangeEnabled,
136
134
  blockCheckoutBooking,
137
135
  queryBus,
@@ -10,7 +10,6 @@ import { Customer } from "../../../projection/customer/customer";
10
10
  import { OrderProjection } from "../../../projection/order/order";
11
11
  import { SubscriptionProjection } from "../../../projection/subscription/subscription";
12
12
  import { KameleoonEnvironment } from "../../ab-testing/kameleoonEnvironment";
13
- import { UseRedirectFunction } from "../../integration/useRedirect";
14
13
  import { StaticInfoProvider } from "../hooks/useStaticInfo";
15
14
  import { App } from "../views/App";
16
15
  import { Checkout } from "../views/checkout/Checkout";
@@ -36,7 +35,7 @@ interface RoutingProps {
36
35
  readonly onNotAccessible: () => void;
37
36
  readonly onCheckoutFlowSuccess: () => void;
38
37
  readonly onI18nError?: (err: Error) => void;
39
- readonly useRedirect: UseRedirectFunction;
38
+ readonly useRedirect: () => Record<string, string>;
40
39
  readonly useRoutes: typeof reactRouterUseRoutes;
41
40
  }
42
41
 
@@ -9,7 +9,6 @@ import { Layout as UiLayout, Sticky, useScreenSize } from "@lookiero/sty-psp-ui"
9
9
  import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
10
10
  import { OrderProjection } from "../../../../projection/order/order";
11
11
  import { SubscriptionProjection } from "../../../../projection/subscription/subscription";
12
- import { UseRedirectFunction } from "../../../integration/useRedirect";
13
12
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
14
13
  import { useViewPricingByCheckoutId } from "../../../projection/pricing/react/useViewPricingByCheckoutId";
15
14
  import { TrackingPage } from "../../../tracking/tracking";
@@ -34,7 +33,7 @@ interface CheckoutProps {
34
33
  readonly subscription: SubscriptionProjection;
35
34
  readonly getAuthToken: () => Promise<string>;
36
35
  readonly onCheckoutFlowSuccess: () => void;
37
- readonly useRedirect: UseRedirectFunction;
36
+ readonly useRedirect: () => Record<string, string>;
38
37
  }
39
38
 
40
39
  const Checkout: FC<CheckoutProps> = ({
@@ -69,7 +68,6 @@ const Checkout: FC<CheckoutProps> = ({
69
68
  subscription,
70
69
  getAuthToken,
71
70
  onSuccess: onCheckoutFlowSuccess,
72
- useRedirect,
73
71
  });
74
72
 
75
73
  useTrackPageView({
@@ -1,10 +1,9 @@
1
1
  import React, { FC } from "react";
2
2
  import { PaymentInstrumentSelect, Section } from "@lookiero/payments-front";
3
- import { UseRedirectFunction } from "../../../../../integration/useRedirect";
4
3
  import { useStaticInfo } from "../../../../hooks/useStaticInfo";
5
4
 
6
5
  interface PaymentInstrumentProps {
7
- readonly useRedirect: UseRedirectFunction;
6
+ readonly useRedirect: () => Record<string, string>;
8
7
  }
9
8
  const PaymentInstrument: FC<PaymentInstrumentProps> = ({ useRedirect }) => {
10
9
  const { returnUrl } = useRedirect();
@@ -12,7 +11,7 @@ const PaymentInstrument: FC<PaymentInstrumentProps> = ({ useRedirect }) => {
12
11
 
13
12
  return (
14
13
  <PaymentInstrumentSelect
15
- beforeRedirect={() => Promise.resolve(returnUrl)}
14
+ beforeRedirect={returnUrl ? () => Promise.resolve(returnUrl) : undefined}
16
15
  hasError={false}
17
16
  section={Section.BOX_CHECKOUT}
18
17
  userInformation={{
Binary file
@@ -1,15 +0,0 @@
1
- import { Command } from "@lookiero/messaging";
2
- declare const UPDATE_UI_SETTING = "update_ui_setting";
3
- interface UpdateUiSettingPayload {
4
- readonly aggregateId: string;
5
- readonly key: string;
6
- readonly value: unknown;
7
- }
8
- interface UpdateUiSetting extends Command<typeof UPDATE_UI_SETTING>, UpdateUiSettingPayload {
9
- }
10
- interface UpdateUiSettingFunction {
11
- (payload: UpdateUiSettingPayload): UpdateUiSetting;
12
- }
13
- declare const updateUiSetting: UpdateUiSettingFunction;
14
- export type { UpdateUiSetting };
15
- export { UPDATE_UI_SETTING, updateUiSetting };
@@ -1,10 +0,0 @@
1
- import { command } from "@lookiero/messaging";
2
- const UPDATE_UI_SETTING = "update_ui_setting";
3
- const updateUiSetting = ({ aggregateId, ...payload }) => ({
4
- ...command({
5
- aggregateId,
6
- name: UPDATE_UI_SETTING,
7
- }),
8
- ...payload,
9
- });
10
- export { UPDATE_UI_SETTING, updateUiSetting };
@@ -1,9 +0,0 @@
1
- import { AggregateRoot, CommandHandlerFunction } from "@lookiero/messaging";
2
- import { UpdateUiSetting } from "../command/updateUiSetting";
3
- interface UiSetting extends AggregateRoot {
4
- readonly key: string;
5
- readonly value: unknown;
6
- }
7
- declare const updateUiSettingHandler: CommandHandlerFunction<UpdateUiSetting, UiSetting>;
8
- export type { UiSetting };
9
- export { updateUiSettingHandler };
@@ -1,11 +0,0 @@
1
- import { uiSettingUpdated } from "./uiSettingUpdated";
2
- const updateUiSettingHandler = () => async ({ aggregateRoot, command }) => {
3
- const { aggregateId, key, value } = command;
4
- return {
5
- ...aggregateRoot,
6
- key,
7
- value,
8
- domainEvents: [uiSettingUpdated({ aggregateId, key })],
9
- };
10
- };
11
- export { updateUiSettingHandler };
@@ -1,15 +0,0 @@
1
- import { DomainEvent, MessageName } from "@lookiero/messaging";
2
- declare const UI_SETTING_UPDATED = "ui_setting_updated";
3
- interface UiSettingUpdatedPayload {
4
- readonly aggregateId: string;
5
- readonly key: string;
6
- }
7
- interface UiSettingUpdated extends DomainEvent<typeof UI_SETTING_UPDATED>, UiSettingUpdatedPayload {
8
- }
9
- interface UiSettingUpdatedFunction {
10
- (payload: UiSettingUpdatedPayload): UiSettingUpdated;
11
- }
12
- declare const uiSettingUpdated: UiSettingUpdatedFunction;
13
- declare const isUiSettingUpdated: (event: DomainEvent<MessageName>) => event is UiSettingUpdated;
14
- export type { UiSettingUpdated };
15
- export { UI_SETTING_UPDATED, uiSettingUpdated, isUiSettingUpdated };
@@ -1,8 +0,0 @@
1
- import { domainEvent } from "@lookiero/messaging";
2
- const UI_SETTING_UPDATED = "ui_setting_updated";
3
- const uiSettingUpdated = ({ aggregateId, key }) => ({
4
- ...domainEvent({ aggregateId, name: UI_SETTING_UPDATED }),
5
- key,
6
- });
7
- const isUiSettingUpdated = (event) => event.name === UI_SETTING_UPDATED;
8
- export { UI_SETTING_UPDATED, uiSettingUpdated, isUiSettingUpdated };
@@ -1,7 +0,0 @@
1
- import { RepositoryGetFunction, RepositoryGetFunctionArgs, RepositorySaveFunction, RepositorySaveFunctionArgs } from "@lookiero/messaging";
2
- import { UiSetting } from "./uiSetting";
3
- interface UiSettingGetFunction<UiSettingGetFunctionArgs extends RepositoryGetFunctionArgs> extends RepositoryGetFunction<UiSetting, UiSettingGetFunctionArgs> {
4
- }
5
- interface UiSettingSaveFunction<UiSettingSaveFunctionArgs extends RepositorySaveFunctionArgs> extends RepositorySaveFunction<UiSetting, UiSettingSaveFunctionArgs> {
6
- }
7
- export type { UiSettingGetFunction, UiSettingSaveFunction };
@@ -1 +0,0 @@
1
- export {};
@@ -1,17 +0,0 @@
1
- import { RepositoryGetFunctionArgs, RepositorySaveFunctionArgs } from "@lookiero/messaging";
2
- import { UiSettingGetFunction, UiSettingSaveFunction } from "../../../../domain/uiSetting/model/uiSettings";
3
- import { ReadFunction, WriteFunction } from "../../../persistence/storage";
4
- import { UiSettingDto } from "../../../persistence/uiSettingData";
5
- interface StorageUiSettingsGetFunctionArgs extends RepositoryGetFunctionArgs {
6
- readonly read: ReadFunction<UiSettingDto>;
7
- }
8
- interface StorageUiSettingsGetFunction extends UiSettingGetFunction<StorageUiSettingsGetFunctionArgs> {
9
- }
10
- declare const getUiSetting: StorageUiSettingsGetFunction;
11
- interface StorageUiSettingsSaveFunctionArgs extends RepositorySaveFunctionArgs {
12
- readonly write: WriteFunction<UiSettingDto>;
13
- }
14
- interface StorageUiSettingsSaveFunction extends UiSettingSaveFunction<StorageUiSettingsSaveFunctionArgs> {
15
- }
16
- declare const saveUiSetting: StorageUiSettingsSaveFunction;
17
- export { getUiSetting, saveUiSetting };
@@ -1,20 +0,0 @@
1
- const toDomain = (uiSettingDto) => ({
2
- aggregateId: uiSettingDto.id,
3
- key: uiSettingDto.key,
4
- value: uiSettingDto.value,
5
- domainEvents: [],
6
- });
7
- const fromDomain = (uiSetting) => ({
8
- id: uiSetting.aggregateId,
9
- key: uiSetting.key,
10
- value: uiSetting.value,
11
- });
12
- const getUiSetting = ({ read }) => async (uiSettingKey) => {
13
- const uiSettingDto = await read(uiSettingKey);
14
- if (!uiSettingDto) {
15
- throw new Error(`UiSetting not found: ${uiSettingKey}`);
16
- }
17
- return toDomain(uiSettingDto);
18
- };
19
- const saveUiSetting = ({ write }) => async (aggregateRoot) => await write(aggregateRoot.key, fromDomain(aggregateRoot));
20
- export { getUiSetting, saveUiSetting };
@@ -1,18 +0,0 @@
1
- import { CommandStatus } from "@lookiero/messaging-react";
2
- import { Logger } from "@lookiero/sty-psp-logging";
3
- interface UpdateFunctionArgs {
4
- readonly key: string;
5
- readonly value: unknown;
6
- }
7
- interface UpdateFunction {
8
- (args: UpdateFunctionArgs): Promise<void>;
9
- }
10
- type UseUpdateUiSetting = [update: UpdateFunction, status: CommandStatus];
11
- interface UseUpdateUiSettingArgs {
12
- readonly logger: Logger;
13
- }
14
- interface UseUpdateUiSettingFunction {
15
- (args: UseUpdateUiSettingArgs): UseUpdateUiSetting;
16
- }
17
- declare const useUpdateUiSetting: UseUpdateUiSettingFunction;
18
- export { useUpdateUiSetting };
@@ -1,22 +0,0 @@
1
- import { useCallback } from "react";
2
- import { v4 as uuid } from "uuid";
3
- import { useCommand } from "@lookiero/messaging-react";
4
- import { updateUiSetting } from "../../../../domain/uiSetting/command/updateUiSetting";
5
- import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
6
- const useUpdateUiSetting = ({ logger }) => {
7
- const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
8
- const update = useCallback(async ({ key, value }) => {
9
- try {
10
- await commandBus(updateUiSetting({
11
- aggregateId: uuid(),
12
- key,
13
- value,
14
- }));
15
- }
16
- catch (error) {
17
- logger.captureException(error);
18
- }
19
- }, [commandBus, logger]);
20
- return [update, status];
21
- };
22
- export { useUpdateUiSetting };
@@ -1,7 +0,0 @@
1
- interface UseRedirectFunctionReturn {
2
- readonly returnUrl: string;
3
- }
4
- interface UseRedirectFunction {
5
- (): UseRedirectFunctionReturn;
6
- }
7
- export type { UseRedirectFunction };
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import { ReadFunction, WriteFunction } from "./storage";
2
- import { UiSettingDto } from "./uiSettingData";
3
- declare const read: ReadFunction<UiSettingDto>;
4
- declare const write: WriteFunction<UiSettingDto>;
5
- export { read, write };
@@ -1,7 +0,0 @@
1
- import AsyncStorage from "@react-native-async-storage/async-storage";
2
- const read = async (key) => {
3
- const value = await AsyncStorage.getItem(key);
4
- return value ? JSON.parse(value) : null;
5
- };
6
- const write = async (key, value) => AsyncStorage.setItem(key, JSON.stringify(value));
7
- export { read, write };
@@ -1,6 +0,0 @@
1
- interface UiSettingDto {
2
- readonly id: string;
3
- readonly key: string;
4
- readonly value: unknown;
5
- }
6
- export type { UiSettingDto };
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- import { UseQueryFunctionResult } from "@lookiero/messaging-react";
2
- import { UiSettingProjection } from "../../../../projection/uiSetting/viewUiSettingByKey";
3
- interface UseViewUiSettingByKeyFunctionArgs {
4
- readonly key: string;
5
- }
6
- interface UseViewUiSettingByKeyFunction {
7
- (args: UseViewUiSettingByKeyFunctionArgs): UseQueryFunctionResult<UiSettingProjection>;
8
- }
9
- declare const useViewUiSettingByKey: UseViewUiSettingByKeyFunction;
10
- export { useViewUiSettingByKey };
@@ -1,11 +0,0 @@
1
- import { useQuery } from "@lookiero/messaging-react";
2
- import { isUiSettingUpdated } from "../../../../domain/uiSetting/model/uiSettingUpdated";
3
- import { viewUiSettingByKey } from "../../../../projection/uiSetting/viewUiSettingByKey";
4
- import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
5
- const useViewUiSettingByKey = ({ key }) => useQuery({
6
- query: viewUiSettingByKey({ key }),
7
- contextId: MESSAGING_CONTEXT_ID,
8
- invalidation: isUiSettingUpdated,
9
- options: { refetchOnMount: "always", staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
10
- });
11
- export { useViewUiSettingByKey };
@@ -1,13 +0,0 @@
1
- import { UiSettingByKeyView } from "../../../projection/uiSetting/viewUiSettingByKey";
2
- import { ReadFunction } from "../../persistence/storage";
3
- import { UiSettingDto } from "../../persistence/uiSettingData";
4
- interface StorageUiSettingByKeyView extends UiSettingByKeyView {
5
- }
6
- interface StorageUiSettingByKeyViewFunctionArgs {
7
- readonly read: ReadFunction<UiSettingDto>;
8
- }
9
- interface StorageUiSettingByKeyViewFunction {
10
- (args: StorageUiSettingByKeyViewFunctionArgs): StorageUiSettingByKeyView;
11
- }
12
- declare const storageUiSettingByKeyView: StorageUiSettingByKeyViewFunction;
13
- export { storageUiSettingByKeyView };
@@ -1,15 +0,0 @@
1
- const toUiSettingProjection = (uiSettingDto) => ({
2
- id: uiSettingDto.id,
3
- key: uiSettingDto.key,
4
- value: uiSettingDto.value,
5
- });
6
- const storageUiSettingByKeyView = ({ read }) => async ({ key }) => {
7
- try {
8
- const uiSettingDto = await read(key);
9
- return uiSettingDto ? toUiSettingProjection(uiSettingDto) : null;
10
- }
11
- catch (ignored) {
12
- throw new Error("Could not fetch the uiSetting");
13
- }
14
- };
15
- export { storageUiSettingByKeyView };
@@ -1,27 +0,0 @@
1
- import { RefObject } from "react";
2
- import { PaymentFlowRef } from "@lookiero/payments-front";
3
- import { Logger } from "@lookiero/sty-psp-logging";
4
- import { PaymentFlowPayloadProjection } from "../../../projection/payment/paymentFlowPayload";
5
- type Status = "idle" | "loading" | "success" | "error";
6
- interface SubmitCheckoutFunctionArgs {
7
- readonly paymentFlowPayload: PaymentFlowPayloadProjection;
8
- readonly sizeChangeEnabled: boolean;
9
- }
10
- interface SubmitCheckoutFunction {
11
- (args: SubmitCheckoutFunctionArgs): Promise<void>;
12
- }
13
- type UseSubmitCheckoutResult = [submitCheckout: SubmitCheckoutFunction, status: Status];
14
- interface UseSubmitCheckoutFunctionArgs {
15
- readonly checkoutId: string;
16
- readonly checkoutBookingId: string;
17
- readonly paymentFlowRef: RefObject<PaymentFlowRef>;
18
- readonly onError: () => void;
19
- readonly onSuccess?: () => void;
20
- readonly logger: Logger;
21
- }
22
- interface UseSubmitCheckoutFunction {
23
- (args: UseSubmitCheckoutFunctionArgs): UseSubmitCheckoutResult;
24
- }
25
- declare const useSubmitCheckout: UseSubmitCheckoutFunction;
26
- export type { Status, SubmitCheckoutFunction };
27
- export { useSubmitCheckout };
@@ -1,97 +0,0 @@
1
- import { useCallback, useMemo, useState } from "react";
2
- import { CommandStatus } from "@lookiero/messaging-react";
3
- import { NotificationLevel, useCreateToastNotification } from "@lookiero/sty-psp-notifications";
4
- import { viewCheckoutBookingById, } from "../../../projection/checkoutBooking/viewCheckoutBookingById";
5
- import { MESSAGING_CONTEXT_ID } from "../../delivery/baseBootstrap";
6
- import { useSubmitCheckout as useSubmitCheckoutCommand } from "../../domain/checkout/react/useSubmitCheckout";
7
- import { useBlockCheckoutBooking } from "../../domain/checkoutBooking/react/useBlockCheckoutBooking";
8
- import { I18nMessages } from "../i18n/i18n";
9
- import { useQueryBus } from "./useQueryBus";
10
- var ChargeStatus;
11
- (function (ChargeStatus) {
12
- ChargeStatus["EXECUTED"] = "EXECUTED";
13
- ChargeStatus["REQUIRES_ACTION"] = "REQUIRES_ACTION";
14
- ChargeStatus["REQUIRED_ACTION_CANCELLED"] = "REQUIRED_ACTION_CANCELLED";
15
- ChargeStatus["REJECTED"] = "REJECTED";
16
- ChargeStatus["CANCELLED"] = "CANCELLED";
17
- ChargeStatus["TO_CONFIRM"] = "TO_CONFIRM";
18
- ChargeStatus["ERROR"] = "ERROR";
19
- ChargeStatus["UNKNOWN"] = "UNKNOWN";
20
- })(ChargeStatus || (ChargeStatus = {}));
21
- const useSubmitCheckout = ({ checkoutId, checkoutBookingId, paymentFlowRef, onError, onSuccess, logger, }) => {
22
- const queryBus = useQueryBus();
23
- const [submitCheckoutCommand, submitCheckoutCommandStatus] = useSubmitCheckoutCommand({ checkoutId, logger });
24
- const [blockCheckoutBooking, blockCheckoutBookingStatus] = useBlockCheckoutBooking({ checkoutBookingId, logger });
25
- const [createNotification] = useCreateToastNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
26
- const [checkoutBookingExpired, setCheckoutBookingExpired] = useState(false);
27
- const [startLegacyBoxCheckoutStatus, setStartLegacyBoxCheckoutStatus] = useState("idle");
28
- const submitCheckout = useCallback(async ({ paymentFlowPayload, sizeChangeEnabled }) => {
29
- try {
30
- sizeChangeEnabled && (await blockCheckoutBooking());
31
- }
32
- catch (error) {
33
- return;
34
- }
35
- const checkoutBooking = await queryBus(viewCheckoutBookingById({ checkoutBookingId }));
36
- if (checkoutBooking?.isExpired) {
37
- setCheckoutBookingExpired(true);
38
- return;
39
- }
40
- paymentFlowRef.current?.startLegacyBoxCheckout(
41
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
42
- // @ts-ignore
43
- paymentFlowPayload, async ({ status, toaster, final }) => {
44
- setStartLegacyBoxCheckoutStatus("loading");
45
- if (final) {
46
- if (status === ChargeStatus.EXECUTED) {
47
- setStartLegacyBoxCheckoutStatus("success");
48
- await submitCheckoutCommand();
49
- onSuccess?.();
50
- }
51
- else {
52
- createNotification({
53
- level: NotificationLevel.ERROR,
54
- bodyI18nKey: toaster?.id || I18nMessages.CHECKOUT_TOAST_PAYMENT_ERROR,
55
- });
56
- setStartLegacyBoxCheckoutStatus("error");
57
- }
58
- }
59
- });
60
- }, [
61
- queryBus,
62
- checkoutBookingId,
63
- paymentFlowRef,
64
- blockCheckoutBooking,
65
- submitCheckoutCommand,
66
- onSuccess,
67
- createNotification,
68
- ]);
69
- const status = useMemo(() => {
70
- if (blockCheckoutBookingStatus === CommandStatus.LOADING ||
71
- startLegacyBoxCheckoutStatus === "loading" ||
72
- submitCheckoutCommandStatus === CommandStatus.LOADING) {
73
- return "loading";
74
- }
75
- if (blockCheckoutBookingStatus === CommandStatus.SUCCESS &&
76
- startLegacyBoxCheckoutStatus === "success" &&
77
- submitCheckoutCommandStatus === CommandStatus.SUCCESS) {
78
- return "success";
79
- }
80
- if (blockCheckoutBookingStatus === CommandStatus.ERROR ||
81
- startLegacyBoxCheckoutStatus === "error" ||
82
- submitCheckoutCommandStatus === CommandStatus.ERROR ||
83
- checkoutBookingExpired) {
84
- onError();
85
- return "error";
86
- }
87
- return "idle";
88
- }, [
89
- blockCheckoutBookingStatus,
90
- startLegacyBoxCheckoutStatus,
91
- submitCheckoutCommandStatus,
92
- checkoutBookingExpired,
93
- onError,
94
- ]);
95
- return [submitCheckout, status];
96
- };
97
- export { useSubmitCheckout };
@@ -1,8 +0,0 @@
1
- import { FC } from "react";
2
- interface BasePathProviderProps {
3
- readonly children: JSX.Element;
4
- readonly basePath: string;
5
- }
6
- export declare const BasePathProvider: FC<BasePathProviderProps>;
7
- export declare const useBasePath: () => string;
8
- export {};
@@ -1,9 +0,0 @@
1
- import React, { createContext, useContext } from "react";
2
- import invariant from "tiny-invariant";
3
- const BasePathContext = createContext(null);
4
- export const BasePathProvider = ({ basePath, children }) => (React.createElement(BasePathContext.Provider, { value: basePath }, children));
5
- export const useBasePath = () => {
6
- const basePath = useContext(BasePathContext);
7
- invariant(basePath !== null, "Your are trying to use the useBasePath hook without wrapping your app with the <BasePathProvider>.");
8
- return basePath;
9
- };
@@ -1,3 +0,0 @@
1
- declare enum UISettings {
2
- }
3
- export { UISettings };
@@ -1,4 +0,0 @@
1
- var UISettings;
2
- (function (UISettings) {
3
- })(UISettings || (UISettings = {}));
4
- export { UISettings };
@@ -1,12 +0,0 @@
1
- import { FC } from "react";
2
- import { Subscription } from "../../../../../../projection/subscription/subscription";
3
- interface CheckoutPaymentModalProps {
4
- readonly coupon: string | null;
5
- readonly orderNumber: number;
6
- readonly isFirstOrder: boolean;
7
- readonly subscription: Subscription;
8
- readonly getAuthToken: () => Promise<string>;
9
- readonly onCheckoutSubmitted?: () => void;
10
- }
11
- declare const CheckoutPaymentModal: FC<CheckoutPaymentModalProps>;
12
- export { CheckoutPaymentModal };