@lookiero/checkout 0.8.4-beta.0 → 0.8.4-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/infrastructure/domain/checkout/react/useStartCheckout.d.ts +2 -0
- package/dist/infrastructure/domain/checkout/react/useStartCheckout.js +3 -3
- package/dist/infrastructure/domain/checkout/react/useSubmitCheckout.d.ts +3 -1
- package/dist/infrastructure/domain/checkout/react/useSubmitCheckout.js +19 -6
- package/dist/infrastructure/domain/checkoutBooking/react/useBlockCheckoutBooking.d.ts +2 -0
- package/dist/infrastructure/domain/checkoutBooking/react/useBlockCheckoutBooking.js +19 -4
- package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckoutBookingForCheckoutItem.d.ts +2 -0
- package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckoutBookingForCheckoutItem.js +20 -5
- package/dist/infrastructure/domain/checkoutFeedback/react/useGiveCheckoutFeedback.d.ts +2 -0
- package/dist/infrastructure/domain/checkoutFeedback/react/useGiveCheckoutFeedback.js +20 -5
- package/dist/infrastructure/domain/checkoutItem/react/useKeepCheckoutItem.d.ts +2 -0
- package/dist/infrastructure/domain/checkoutItem/react/useKeepCheckoutItem.js +19 -4
- package/dist/infrastructure/domain/checkoutItem/react/useReplaceCheckoutItem.d.ts +2 -0
- package/dist/infrastructure/domain/checkoutItem/react/useReplaceCheckoutItem.js +20 -5
- package/dist/infrastructure/domain/checkoutItem/react/useReturnCheckoutItem.d.ts +2 -0
- package/dist/infrastructure/domain/checkoutItem/react/useReturnCheckoutItem.js +20 -5
- package/dist/infrastructure/domain/uiSetting/react/useUpdateUiSetting.d.ts +5 -1
- package/dist/infrastructure/domain/uiSetting/react/useUpdateUiSetting.js +13 -6
- package/dist/infrastructure/ui/hooks/usePaymentInstrumentEvents.d.ts +9 -0
- package/dist/infrastructure/ui/hooks/usePaymentInstrumentEvents.js +28 -0
- package/dist/infrastructure/ui/hooks/useSubmitCheckout.d.ts +2 -0
- package/dist/infrastructure/ui/hooks/useSubmitCheckout.js +7 -13
- package/dist/infrastructure/ui/hooks/useToast.d.ts +11 -0
- package/dist/infrastructure/ui/hooks/useToast.js +44 -0
- package/dist/infrastructure/ui/i18n/i18n.d.ts +1 -0
- package/dist/infrastructure/ui/i18n/i18n.js +1 -0
- package/dist/infrastructure/ui/routing/CheckoutMiddleware.js +3 -1
- package/dist/infrastructure/ui/views/checkout/Checkout.js +3 -5
- package/dist/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.js +3 -0
- package/dist/infrastructure/ui/views/checkout/components/paymentInstrument/PaymentInstrument.d.ts +6 -0
- package/dist/infrastructure/ui/views/checkout/components/paymentInstrument/PaymentInstrument.js +12 -0
- package/dist/infrastructure/ui/views/feedback/Feedback.js +3 -0
- package/dist/infrastructure/ui/views/item/Item.js +6 -1
- package/dist/shared/logging/SentryLoggerHOC.js +3 -1
- package/dist/shared/logging/useLogger.d.ts +12 -0
- package/dist/shared/logging/useLogger.js +10 -0
- package/dist/shared/notifications/infrastructure/domain/notification/react/useCreateNotification.d.ts +2 -0
- package/dist/shared/notifications/infrastructure/domain/notification/react/useCreateNotification.js +14 -7
- package/dist/shared/notifications/infrastructure/domain/notification/react/useRemoveNotification.d.ts +2 -0
- package/dist/shared/notifications/infrastructure/domain/notification/react/useRemoveNotification.js +9 -2
- package/dist/shared/notifications/infrastructure/ui/views/Notifications.js +3 -1
- package/package.json +1 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
|
+
import { Logger } from "../../../../shared/logging/Logger";
|
|
2
3
|
interface StartCheckoutFunction {
|
|
3
4
|
(): Promise<void> | undefined;
|
|
4
5
|
}
|
|
5
6
|
interface UseStartCheckoutArgs {
|
|
6
7
|
readonly checkoutId?: string;
|
|
8
|
+
readonly logger: Logger;
|
|
7
9
|
}
|
|
8
10
|
type UseStartCheckoutResult = [start: StartCheckoutFunction, status: CommandStatus];
|
|
9
11
|
interface UseStartCheckout {
|
|
@@ -3,7 +3,7 @@ import { useCallback } from "react";
|
|
|
3
3
|
import invariant from "tiny-invariant";
|
|
4
4
|
import { startCheckout } from "../../../../domain/checkout/command/startCheckout";
|
|
5
5
|
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
6
|
-
const useStartCheckout = ({ checkoutId }) => {
|
|
6
|
+
const useStartCheckout = ({ checkoutId, logger }) => {
|
|
7
7
|
const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
|
|
8
8
|
const start = useCallback(async () => {
|
|
9
9
|
invariant(checkoutId, "CheckoutId must be defined in order to start checkout");
|
|
@@ -12,10 +12,10 @@ const useStartCheckout = ({ checkoutId }) => {
|
|
|
12
12
|
}
|
|
13
13
|
catch (error) {
|
|
14
14
|
if (!error?.message?.includes("Checkout is already started")) {
|
|
15
|
-
|
|
15
|
+
logger.captureException(error);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
}, [checkoutId, commandBus]);
|
|
18
|
+
}, [checkoutId, commandBus, logger]);
|
|
19
19
|
return [start, status];
|
|
20
20
|
};
|
|
21
21
|
export { useStartCheckout };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
|
+
import { Logger } from "../../../../shared/logging/Logger";
|
|
2
3
|
interface SubmitFunction {
|
|
3
|
-
(): Promise<void
|
|
4
|
+
(): Promise<void> | undefined;
|
|
4
5
|
}
|
|
5
6
|
type UseSubmitCheckout = [submit: SubmitFunction, status: CommandStatus];
|
|
6
7
|
interface UseSubmitCheckoutFunctionArgs {
|
|
7
8
|
readonly checkoutId?: string;
|
|
9
|
+
readonly logger: Logger;
|
|
8
10
|
}
|
|
9
11
|
interface UseSubmitCheckoutFunction {
|
|
10
12
|
(args: UseSubmitCheckoutFunctionArgs): UseSubmitCheckout;
|
|
@@ -2,15 +2,28 @@ import { useCommand } from "@lookiero/messaging-react";
|
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import invariant from "tiny-invariant";
|
|
4
4
|
import { submitCheckout } from "../../../../domain/checkout/command/submitCheckout";
|
|
5
|
+
import { useCreateNotification } from "../../../../shared/notifications";
|
|
6
|
+
import { NotificationLevel } from "../../../../shared/notifications/domain/notification/model/notification";
|
|
5
7
|
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
6
|
-
|
|
8
|
+
import { I18nMessages } from "../../../ui/i18n/i18n";
|
|
9
|
+
const useSubmitCheckout = ({ checkoutId, logger }) => {
|
|
7
10
|
const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
|
|
8
|
-
const
|
|
11
|
+
const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
|
|
12
|
+
const submit = useCallback(async () => {
|
|
9
13
|
invariant(checkoutId, "CheckoutId must be defined in order to submit checkout");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
try {
|
|
15
|
+
return await commandBus(submitCheckout({
|
|
16
|
+
aggregateId: checkoutId,
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
logger.captureException(error);
|
|
21
|
+
createNotification({
|
|
22
|
+
level: NotificationLevel.ERROR,
|
|
23
|
+
bodyI18nKey: I18nMessages.TOAST_GENERIC_ERROR,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}, [checkoutId, commandBus, createNotification, logger]);
|
|
14
27
|
return [submit, status];
|
|
15
28
|
};
|
|
16
29
|
export { useSubmitCheckout };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
|
+
import { Logger } from "../../../../shared/logging/Logger";
|
|
2
3
|
interface BlockCheckoutBookingFunction {
|
|
3
4
|
(): Promise<void>;
|
|
4
5
|
}
|
|
5
6
|
type UseBlockCheckoutBooking = [blockCheckoutBooking: BlockCheckoutBookingFunction, status: CommandStatus];
|
|
6
7
|
interface UseBlockCheckoutBookingFunctionArgs {
|
|
7
8
|
readonly checkoutBookingId: string;
|
|
9
|
+
readonly logger: Logger;
|
|
8
10
|
}
|
|
9
11
|
interface UseBlockCheckoutBookingFunction {
|
|
10
12
|
(args: UseBlockCheckoutBookingFunctionArgs): UseBlockCheckoutBooking;
|
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
import { useCommand } from "@lookiero/messaging-react";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import { blockCheckoutBooking as blockCheckoutBookingCommand } from "../../../../domain/checkoutBooking/command/blockCheckoutBooking";
|
|
4
|
+
import { useCreateNotification } from "../../../../shared/notifications";
|
|
5
|
+
import { NotificationLevel } from "../../../../shared/notifications/domain/notification/model/notification";
|
|
4
6
|
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
5
|
-
|
|
7
|
+
import { I18nMessages } from "../../../ui/i18n/i18n";
|
|
8
|
+
const useBlockCheckoutBooking = ({ checkoutBookingId, logger }) => {
|
|
6
9
|
const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
|
|
11
|
+
const blockCheckoutBooking = useCallback(async () => {
|
|
12
|
+
try {
|
|
13
|
+
await commandBus(blockCheckoutBookingCommand({
|
|
14
|
+
aggregateId: checkoutBookingId,
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
logger.captureException(error);
|
|
19
|
+
createNotification({
|
|
20
|
+
level: NotificationLevel.ERROR,
|
|
21
|
+
bodyI18nKey: I18nMessages.TOAST_GENERIC_ERROR,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}, [checkoutBookingId, commandBus, createNotification, logger]);
|
|
10
25
|
return [blockCheckoutBooking, status];
|
|
11
26
|
};
|
|
12
27
|
export { useBlockCheckoutBooking };
|
package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckoutBookingForCheckoutItem.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
|
+
import { Logger } from "../../../../shared/logging/Logger";
|
|
2
3
|
interface BookFunction {
|
|
3
4
|
(): Promise<void>;
|
|
4
5
|
}
|
|
@@ -6,6 +7,7 @@ type UseBookCheckoutBookingForCheckoutItem = [book: BookFunction, status: Comman
|
|
|
6
7
|
interface UseBookCheckoutBookingForCheckoutItemFunctionArgs {
|
|
7
8
|
readonly checkoutItemId: string;
|
|
8
9
|
readonly checkoutBookingId: string | undefined;
|
|
10
|
+
readonly logger: Logger;
|
|
9
11
|
}
|
|
10
12
|
interface UseBookCheckoutBookingForCheckoutItemFunction {
|
|
11
13
|
(args: UseBookCheckoutBookingForCheckoutItemFunctionArgs): UseBookCheckoutBookingForCheckoutItem;
|
package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckoutBookingForCheckoutItem.js
CHANGED
|
@@ -2,13 +2,28 @@ import { useCommand } from "@lookiero/messaging-react";
|
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import { v4 as uuid } from "uuid";
|
|
4
4
|
import { bookCheckoutBookingForCheckoutItem } from "../../../../domain/checkoutBooking/command/bookCheckoutBookingForCheckoutItem";
|
|
5
|
+
import { useCreateNotification } from "../../../../shared/notifications";
|
|
6
|
+
import { NotificationLevel } from "../../../../shared/notifications/domain/notification/model/notification";
|
|
5
7
|
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
6
|
-
|
|
8
|
+
import { I18nMessages } from "../../../ui/i18n/i18n";
|
|
9
|
+
const useBookCheckoutBookingForCheckoutItem = ({ checkoutItemId, checkoutBookingId, logger, }) => {
|
|
7
10
|
const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
|
|
12
|
+
const book = useCallback(async () => {
|
|
13
|
+
try {
|
|
14
|
+
await commandBus(bookCheckoutBookingForCheckoutItem({
|
|
15
|
+
aggregateId: checkoutBookingId || uuid(),
|
|
16
|
+
checkoutItemId,
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
logger.captureException(error);
|
|
21
|
+
createNotification({
|
|
22
|
+
level: NotificationLevel.ERROR,
|
|
23
|
+
bodyI18nKey: I18nMessages.TOAST_GENERIC_ERROR,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}, [checkoutBookingId, checkoutItemId, commandBus, createNotification, logger]);
|
|
12
27
|
return [book, status];
|
|
13
28
|
};
|
|
14
29
|
export { useBookCheckoutBookingForCheckoutItem };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
2
|
import { Feedbacks } from "../../../../domain/checkoutFeedback/model/feedbacks";
|
|
3
|
+
import { Logger } from "../../../../shared/logging/Logger";
|
|
3
4
|
interface GiveCheckoutFeedbackFunctionArgs {
|
|
4
5
|
readonly feedbacks: Feedbacks;
|
|
5
6
|
}
|
|
@@ -9,6 +10,7 @@ interface GiveCheckoutFeedbackFunction {
|
|
|
9
10
|
type UseGiveCheckoutFeedback = [giveCheckoutFeedback: GiveCheckoutFeedbackFunction, status: CommandStatus];
|
|
10
11
|
interface UseGiveCheckoutFeedbackFunctionArgs {
|
|
11
12
|
readonly checkoutId: string;
|
|
13
|
+
readonly logger: Logger;
|
|
12
14
|
}
|
|
13
15
|
interface UseGiveCheckoutFeedbackFunction {
|
|
14
16
|
(args: UseGiveCheckoutFeedbackFunctionArgs): UseGiveCheckoutFeedback;
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
import { useCommand } from "@lookiero/messaging-react";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import { giveCheckoutFeedback as giveCheckoutFeedbackCommand } from "../../../../domain/checkoutFeedback/command/giveCheckoutFeedback";
|
|
4
|
+
import { useCreateNotification } from "../../../../shared/notifications";
|
|
5
|
+
import { NotificationLevel } from "../../../../shared/notifications/domain/notification/model/notification";
|
|
4
6
|
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
5
|
-
|
|
7
|
+
import { I18nMessages } from "../../../ui/i18n/i18n";
|
|
8
|
+
const useGiveCheckoutFeedback = ({ checkoutId, logger }) => {
|
|
6
9
|
const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
|
|
11
|
+
const giveCheckoutFeedback = useCallback(async ({ feedbacks }) => {
|
|
12
|
+
try {
|
|
13
|
+
await commandBus(giveCheckoutFeedbackCommand({
|
|
14
|
+
checkoutId,
|
|
15
|
+
feedbacks,
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
logger.captureException(error);
|
|
20
|
+
createNotification({
|
|
21
|
+
level: NotificationLevel.ERROR,
|
|
22
|
+
bodyI18nKey: I18nMessages.TOAST_GENERIC_ERROR,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}, [checkoutId, commandBus, createNotification, logger]);
|
|
11
26
|
return [giveCheckoutFeedback, status];
|
|
12
27
|
};
|
|
13
28
|
export { useGiveCheckoutFeedback };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
|
+
import { Logger } from "../../../../shared/logging/Logger";
|
|
2
3
|
interface KeepCheckoutItemFunction {
|
|
3
4
|
(): Promise<void>;
|
|
4
5
|
}
|
|
5
6
|
interface UseKeepCheckoutItemFunctionArgs {
|
|
6
7
|
readonly checkoutItemId: string;
|
|
8
|
+
readonly logger: Logger;
|
|
7
9
|
}
|
|
8
10
|
type UseKeepCheckoutItemResult = [keep: KeepCheckoutItemFunction, status: CommandStatus];
|
|
9
11
|
interface UseKeepCheckoutItemFunction {
|
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
import { useCommand } from "@lookiero/messaging-react";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import { keepCheckoutItem } from "../../../../domain/checkoutItem/command/keepCheckoutItem";
|
|
4
|
+
import { useCreateNotification } from "../../../../shared/notifications";
|
|
5
|
+
import { NotificationLevel } from "../../../../shared/notifications/domain/notification/model/notification";
|
|
4
6
|
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
5
|
-
|
|
7
|
+
import { I18nMessages } from "../../../ui/i18n/i18n";
|
|
8
|
+
const useKeepCheckoutItem = ({ checkoutItemId, logger }) => {
|
|
6
9
|
const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
|
|
11
|
+
const keep = useCallback(async () => {
|
|
12
|
+
try {
|
|
13
|
+
await commandBus(keepCheckoutItem({
|
|
14
|
+
aggregateId: checkoutItemId,
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
logger.captureException(error);
|
|
19
|
+
createNotification({
|
|
20
|
+
level: NotificationLevel.ERROR,
|
|
21
|
+
bodyI18nKey: I18nMessages.TOAST_GENERIC_ERROR,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}, [checkoutItemId, commandBus, createNotification, logger]);
|
|
10
25
|
return [keep, status];
|
|
11
26
|
};
|
|
12
27
|
export { useKeepCheckoutItem };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
|
+
import { Logger } from "../../../../shared/logging/Logger";
|
|
2
3
|
interface ReplaceCheckoutItemFunctionArgs {
|
|
3
4
|
readonly replacedForId: string;
|
|
4
5
|
}
|
|
@@ -7,6 +8,7 @@ interface ReplaceCheckoutItemFunction {
|
|
|
7
8
|
}
|
|
8
9
|
interface UseReplaceCheckoutItemFunctionArgs {
|
|
9
10
|
readonly checkoutItemId: string;
|
|
11
|
+
readonly logger: Logger;
|
|
10
12
|
}
|
|
11
13
|
type UseReplaceCheckoutItemResult = [replace: ReplaceCheckoutItemFunction, status: CommandStatus];
|
|
12
14
|
interface UseReplaceCheckoutItemFunction {
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
import { useCommand } from "@lookiero/messaging-react";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import { replaceCheckoutItem } from "../../../../domain/checkoutItem/command/replaceCheckoutItem";
|
|
4
|
+
import { useCreateNotification } from "../../../../shared/notifications";
|
|
5
|
+
import { NotificationLevel } from "../../../../shared/notifications/domain/notification/model/notification";
|
|
4
6
|
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
5
|
-
|
|
7
|
+
import { I18nMessages } from "../../../ui/i18n/i18n";
|
|
8
|
+
const useReplaceCheckoutItem = ({ checkoutItemId, logger }) => {
|
|
6
9
|
const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
|
|
11
|
+
const replace = useCallback(async ({ replacedForId }) => {
|
|
12
|
+
try {
|
|
13
|
+
await commandBus(replaceCheckoutItem({
|
|
14
|
+
aggregateId: checkoutItemId,
|
|
15
|
+
replacedForId,
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
logger.captureException(error);
|
|
20
|
+
createNotification({
|
|
21
|
+
level: NotificationLevel.ERROR,
|
|
22
|
+
bodyI18nKey: I18nMessages.TOAST_GENERIC_ERROR,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}, [checkoutItemId, commandBus, createNotification, logger]);
|
|
11
26
|
return [replace, status];
|
|
12
27
|
};
|
|
13
28
|
export { useReplaceCheckoutItem };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
2
|
import { Feedbacks } from "../../../../domain/checkoutItem/model/feedbacks";
|
|
3
|
+
import { Logger } from "../../../../shared/logging/Logger";
|
|
3
4
|
interface ReturnCheckoutItemFunctionArgs {
|
|
4
5
|
readonly feedbacks: Feedbacks;
|
|
5
6
|
}
|
|
@@ -8,6 +9,7 @@ interface ReturnCheckoutItemFunction {
|
|
|
8
9
|
}
|
|
9
10
|
interface UseReturnCheckoutItemFunctionArgs {
|
|
10
11
|
readonly checkoutItemId: string;
|
|
12
|
+
readonly logger: Logger;
|
|
11
13
|
}
|
|
12
14
|
type UseReturnCheckoutItemResult = [returnCheckoutItem: ReturnCheckoutItemFunction, status: CommandStatus];
|
|
13
15
|
interface UseReturnCheckoutItemFunction {
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
import { useCommand } from "@lookiero/messaging-react";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import { returnCheckoutItem as returnCheckoutItemCommand } from "../../../../domain/checkoutItem/command/returnCheckoutItem";
|
|
4
|
+
import { useCreateNotification } from "../../../../shared/notifications";
|
|
5
|
+
import { NotificationLevel } from "../../../../shared/notifications/domain/notification/model/notification";
|
|
4
6
|
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
5
|
-
|
|
7
|
+
import { I18nMessages } from "../../../ui/i18n/i18n";
|
|
8
|
+
const useReturnCheckoutItem = ({ checkoutItemId, logger }) => {
|
|
6
9
|
const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
|
|
11
|
+
const returnCheckoutItem = useCallback(async ({ feedbacks }) => {
|
|
12
|
+
try {
|
|
13
|
+
await commandBus(returnCheckoutItemCommand({
|
|
14
|
+
aggregateId: checkoutItemId,
|
|
15
|
+
feedbacks,
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
logger.captureException(error);
|
|
20
|
+
createNotification({
|
|
21
|
+
level: NotificationLevel.ERROR,
|
|
22
|
+
bodyI18nKey: I18nMessages.TOAST_GENERIC_ERROR,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}, [checkoutItemId, commandBus, createNotification, logger]);
|
|
11
26
|
return [returnCheckoutItem, status];
|
|
12
27
|
};
|
|
13
28
|
export { useReturnCheckoutItem };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
|
+
import { Logger } from "../../../../shared/logging/Logger";
|
|
2
3
|
interface UpdateFunctionArgs {
|
|
3
4
|
readonly key: string;
|
|
4
5
|
readonly value: unknown;
|
|
@@ -7,8 +8,11 @@ interface UpdateFunction {
|
|
|
7
8
|
(args: UpdateFunctionArgs): Promise<void>;
|
|
8
9
|
}
|
|
9
10
|
type UseUpdateUiSetting = [update: UpdateFunction, status: CommandStatus];
|
|
11
|
+
interface UseUpdateUiSettingArgs {
|
|
12
|
+
readonly logger: Logger;
|
|
13
|
+
}
|
|
10
14
|
interface UseUpdateUiSettingFunction {
|
|
11
|
-
(): UseUpdateUiSetting;
|
|
15
|
+
(args: UseUpdateUiSettingArgs): UseUpdateUiSetting;
|
|
12
16
|
}
|
|
13
17
|
declare const useUpdateUiSetting: UseUpdateUiSettingFunction;
|
|
14
18
|
export { useUpdateUiSetting };
|
|
@@ -3,13 +3,20 @@ import { useCallback } from "react";
|
|
|
3
3
|
import { v4 as uuid } from "uuid";
|
|
4
4
|
import { updateUiSetting } from "../../../../domain/uiSetting/command/updateUiSetting";
|
|
5
5
|
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
6
|
-
const useUpdateUiSetting = () => {
|
|
6
|
+
const useUpdateUiSetting = ({ logger }) => {
|
|
7
7
|
const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
|
|
8
|
-
const update = useCallback(({ key, value }) =>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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]);
|
|
13
20
|
return [update, status];
|
|
14
21
|
};
|
|
15
22
|
export { useUpdateUiSetting };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Logger } from "../../../shared/logging/Logger";
|
|
2
|
+
interface UsePaymentInstrumentEventsFunctionArgs {
|
|
3
|
+
readonly logger: Logger;
|
|
4
|
+
}
|
|
5
|
+
interface UsePaymentInstrumentEventsFunction {
|
|
6
|
+
(args: UsePaymentInstrumentEventsFunctionArgs): void;
|
|
7
|
+
}
|
|
8
|
+
declare const usePaymentInstrumentEvents: UsePaymentInstrumentEventsFunction;
|
|
9
|
+
export { usePaymentInstrumentEvents };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useEvent } from "@lookiero/event";
|
|
2
|
+
import { useCallback, useEffect } from "react";
|
|
3
|
+
import { useCreateNotification } from "../../../shared/notifications";
|
|
4
|
+
import { MESSAGING_CONTEXT_ID } from "../../delivery/baseBootstrap";
|
|
5
|
+
import { I18nMessages } from "../i18n/i18n";
|
|
6
|
+
import { useToast } from "./useToast";
|
|
7
|
+
const PAYMENT_ERROR = "ERROR";
|
|
8
|
+
const PAYMENT_SUCCESS = "PAYMENT_INSTRUMENT_UPDATED";
|
|
9
|
+
const usePaymentInstrumentEvents = ({ logger }) => {
|
|
10
|
+
const { subscribe, unsubscribe } = useEvent();
|
|
11
|
+
const { showError, showSuccess } = useToast();
|
|
12
|
+
const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
|
|
13
|
+
const onSuccess = useCallback(({ message }) => showSuccess({ message: message.id }), [showSuccess]);
|
|
14
|
+
const onError = useCallback(({ error }) => {
|
|
15
|
+
if (error.toaster) {
|
|
16
|
+
showError({ message: error.toaster.id || I18nMessages.CHECKOUT_TOAST_PAYMENT_ERROR });
|
|
17
|
+
}
|
|
18
|
+
}, [showError]);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
subscribe({ event: PAYMENT_ERROR }, onError);
|
|
21
|
+
subscribe({ event: PAYMENT_SUCCESS }, onSuccess);
|
|
22
|
+
return () => {
|
|
23
|
+
unsubscribe({ event: PAYMENT_ERROR }, onError);
|
|
24
|
+
unsubscribe({ event: PAYMENT_SUCCESS }, onSuccess);
|
|
25
|
+
};
|
|
26
|
+
}, [subscribe, unsubscribe, createNotification, onError, onSuccess]);
|
|
27
|
+
};
|
|
28
|
+
export { usePaymentInstrumentEvents };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PaymentFlowRef } from "@lookiero/payments-front";
|
|
2
2
|
import { RefObject } from "react";
|
|
3
3
|
import { PaymentFlowPayloadProjection } from "../../../projection/payment/paymentFlowPayload";
|
|
4
|
+
import { Logger } from "../../../shared/logging/Logger";
|
|
4
5
|
type Status = "idle" | "loading" | "success" | "error";
|
|
5
6
|
interface SubmitCheckoutFunctionArgs {
|
|
6
7
|
readonly paymentFlowPayload: PaymentFlowPayloadProjection;
|
|
@@ -14,6 +15,7 @@ interface UseSubmitCheckoutFunctionArgs {
|
|
|
14
15
|
readonly checkoutBookingId: string;
|
|
15
16
|
readonly paymentFlowRef: RefObject<PaymentFlowRef>;
|
|
16
17
|
readonly onError: () => void;
|
|
18
|
+
readonly logger: Logger;
|
|
17
19
|
}
|
|
18
20
|
interface UseSubmitCheckoutFunction {
|
|
19
21
|
(args: UseSubmitCheckoutFunctionArgs): UseSubmitCheckoutResult;
|
|
@@ -7,16 +7,13 @@ import { MESSAGING_CONTEXT_ID } from "../../delivery/baseBootstrap";
|
|
|
7
7
|
import { useSubmitCheckout as useSubmitCheckoutCommand } from "../../domain/checkout/react/useSubmitCheckout";
|
|
8
8
|
import { useBlockCheckoutBooking } from "../../domain/checkoutBooking/react/useBlockCheckoutBooking";
|
|
9
9
|
import { I18nMessages } from "../i18n/i18n";
|
|
10
|
-
const useSubmitCheckout = ({ checkoutId, checkoutBookingId, paymentFlowRef, onError }) => {
|
|
11
|
-
const [submitCheckoutCommand, submitCheckoutCommandStatus] = useSubmitCheckoutCommand({ checkoutId });
|
|
12
|
-
const [blockCheckoutBooking, blockCheckoutBookingStatus] = useBlockCheckoutBooking({ checkoutBookingId });
|
|
13
|
-
const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID });
|
|
10
|
+
const useSubmitCheckout = ({ checkoutId, checkoutBookingId, paymentFlowRef, onError, logger, }) => {
|
|
11
|
+
const [submitCheckoutCommand, submitCheckoutCommandStatus] = useSubmitCheckoutCommand({ checkoutId, logger });
|
|
12
|
+
const [blockCheckoutBooking, blockCheckoutBookingStatus] = useBlockCheckoutBooking({ checkoutBookingId, logger });
|
|
13
|
+
const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
|
|
14
14
|
const [startLegacyBoxCheckoutStatus, setStartLegacyBoxCheckoutStatus] = useState("idle");
|
|
15
15
|
const submitCheckout = useCallback(async ({ paymentFlowPayload }) => {
|
|
16
|
-
|
|
17
|
-
await blockCheckoutBooking();
|
|
18
|
-
}
|
|
19
|
-
catch (error) { }
|
|
16
|
+
await blockCheckoutBooking();
|
|
20
17
|
paymentFlowRef.current?.startLegacyBoxCheckout(
|
|
21
18
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
22
19
|
// @ts-ignore
|
|
@@ -25,10 +22,7 @@ const useSubmitCheckout = ({ checkoutId, checkoutBookingId, paymentFlowRef, onEr
|
|
|
25
22
|
if (final) {
|
|
26
23
|
if (status === ChargeStatus.EXECUTED) {
|
|
27
24
|
setStartLegacyBoxCheckoutStatus("success");
|
|
28
|
-
|
|
29
|
-
await submitCheckoutCommand();
|
|
30
|
-
}
|
|
31
|
-
catch (error) { }
|
|
25
|
+
await submitCheckoutCommand();
|
|
32
26
|
}
|
|
33
27
|
else {
|
|
34
28
|
createNotification({
|
|
@@ -39,7 +33,7 @@ const useSubmitCheckout = ({ checkoutId, checkoutBookingId, paymentFlowRef, onEr
|
|
|
39
33
|
}
|
|
40
34
|
}
|
|
41
35
|
});
|
|
42
|
-
}, [blockCheckoutBooking, createNotification, submitCheckoutCommand
|
|
36
|
+
}, [paymentFlowRef, blockCheckoutBooking, createNotification, submitCheckoutCommand]);
|
|
43
37
|
const status = useMemo(() => {
|
|
44
38
|
if (blockCheckoutBookingStatus === CommandStatus.LOADING ||
|
|
45
39
|
startLegacyBoxCheckoutStatus === "loading" ||
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface ShowErrorFunctionArgs {
|
|
2
|
+
readonly message: string;
|
|
3
|
+
}
|
|
4
|
+
interface ShowErrorFunction {
|
|
5
|
+
(args: ShowErrorFunctionArgs): void;
|
|
6
|
+
}
|
|
7
|
+
declare const useToast: () => {
|
|
8
|
+
showError: ShowErrorFunction;
|
|
9
|
+
showSuccess: ShowErrorFunction;
|
|
10
|
+
};
|
|
11
|
+
export { useToast };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Notification } from "@lookiero/aurora-next/build/components/molecules/Notification/Notification";
|
|
2
|
+
import { useStack } from "@lookiero/aurora-next/build/contexts/Stack/Stack";
|
|
3
|
+
import { useIntl } from "@lookiero/i18n-react";
|
|
4
|
+
import { useCallback } from "react";
|
|
5
|
+
import { StyleSheet } from "react-native";
|
|
6
|
+
import { v4 as uuid } from "uuid";
|
|
7
|
+
import { theme } from "../theme/theme";
|
|
8
|
+
const { layoutXXS, elevationColor, elevationOffset, elevationOpacityM, elevationRadius } = theme();
|
|
9
|
+
const style = StyleSheet.create({
|
|
10
|
+
container: {
|
|
11
|
+
marginHorizontal: layoutXXS,
|
|
12
|
+
marginTop: layoutXXS,
|
|
13
|
+
shadowColor: elevationColor,
|
|
14
|
+
shadowOffset: elevationOffset,
|
|
15
|
+
shadowOpacity: elevationOpacityM,
|
|
16
|
+
shadowRadius: elevationRadius,
|
|
17
|
+
},
|
|
18
|
+
inAppContainer: {
|
|
19
|
+
top: 75,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
const NOTIFICATION_DEFAULTS = {
|
|
23
|
+
motion: "top",
|
|
24
|
+
timeoutClose: 10000,
|
|
25
|
+
style: style.container,
|
|
26
|
+
};
|
|
27
|
+
const IN_APP_NOTIFICATION_DEFAULTS = {
|
|
28
|
+
...NOTIFICATION_DEFAULTS,
|
|
29
|
+
style: [style.container, style.inAppContainer],
|
|
30
|
+
};
|
|
31
|
+
const iOSInAppBrowser = window.screen?.height > 667 && /FBIOS/.test(navigator.userAgent);
|
|
32
|
+
const getNotificationDefaults = () => (iOSInAppBrowser ? IN_APP_NOTIFICATION_DEFAULTS : NOTIFICATION_DEFAULTS);
|
|
33
|
+
const useToast = () => {
|
|
34
|
+
const Stack = useStack();
|
|
35
|
+
const intl = useIntl();
|
|
36
|
+
const translate = useCallback((message) => intl.formatMessage({ id: message, defaultMessage: message }), [intl]);
|
|
37
|
+
const showError = useCallback(({ message }) => Stack.alert(uuid(), Notification, { ...getNotificationDefaults(), text: translate(message) }), [Stack, translate]);
|
|
38
|
+
const showSuccess = useCallback(({ message }) => Stack.success(uuid(), Notification, { ...getNotificationDefaults(), text: translate(message) }), [Stack, translate]);
|
|
39
|
+
return {
|
|
40
|
+
showError,
|
|
41
|
+
showSuccess,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export { useToast };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const COLOR_I18N_PREFIX = "color.";
|
|
2
2
|
var I18nMessages;
|
|
3
3
|
(function (I18nMessages) {
|
|
4
|
+
I18nMessages["TOAST_GENERIC_ERROR"] = "toast_generic_error";
|
|
4
5
|
I18nMessages["ITEM_SIZE"] = "item.size";
|
|
5
6
|
I18nMessages["ITEM_COLOR"] = "item.color";
|
|
6
7
|
I18nMessages["ITEM_UNIQUE"] = "item.unique";
|
|
@@ -3,17 +3,19 @@ import React, { useEffect, useRef } from "react";
|
|
|
3
3
|
import { generatePath, Navigate, useMatch } from "react-router-native";
|
|
4
4
|
import { CheckoutStatus } from "../../../domain/checkout/model/checkout";
|
|
5
5
|
import { CheckoutItemStatus } from "../../../domain/checkoutItem/model/checkoutItem";
|
|
6
|
+
import { useLogger } from "../../../shared/logging/useLogger";
|
|
6
7
|
import { Spinner } from "../../../shared/ui/components/atoms/spinner/Spinner";
|
|
7
8
|
import { useStartCheckout } from "../../domain/checkout/react/useStartCheckout";
|
|
8
9
|
import { useViewFirstAvailableCheckoutByCustomerId } from "../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
9
10
|
import { Routes } from "./routes";
|
|
10
11
|
import { useBasePath } from "./useBasePath";
|
|
11
12
|
const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner, null), children }) => {
|
|
13
|
+
const logger = useLogger();
|
|
12
14
|
const basePath = useBasePath();
|
|
13
15
|
const navigatedToFirstItemWithoutCustomerDecision = useRef(false);
|
|
14
16
|
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
15
17
|
const firstItemWithoutCustomerDecision = checkout?.items.find((item) => item.status === CheckoutItemStatus.INITIAL);
|
|
16
|
-
const [startCheckout] = useStartCheckout({ checkoutId: checkout?.id });
|
|
18
|
+
const [startCheckout] = useStartCheckout({ checkoutId: checkout?.id, logger });
|
|
17
19
|
useEffect(() => {
|
|
18
20
|
if (checkout?.id) {
|
|
19
21
|
startCheckout();
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
|
|
2
2
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
3
3
|
import { QueryStatus } from "@lookiero/messaging-react";
|
|
4
|
-
import {
|
|
5
|
-
import React, { useCallback, useMemo, useRef } from "react";
|
|
4
|
+
import React, { useCallback, useMemo } from "react";
|
|
6
5
|
import { Platform, View } from "react-native";
|
|
7
6
|
import { useNavigate } from "react-router-native";
|
|
8
7
|
import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
|
|
@@ -21,9 +20,9 @@ import { HEADER_HEIGHT } from "../navigation/components/header/Header.style";
|
|
|
21
20
|
import { Pricing } from "../summary/components/pricing/Pricing";
|
|
22
21
|
import { style } from "./Checkout.style";
|
|
23
22
|
import { DeliveryBanner } from "./components/deliveryBanner/DeliveryBanner";
|
|
23
|
+
import { PaymentInstrument } from "./components/paymentInstrument/PaymentInstrument";
|
|
24
24
|
const Checkout = ({ children, customerId, country, useRedirect }) => {
|
|
25
25
|
const titleText = useI18nMessage({ id: I18nMessages.CHECKOUT_TITLE });
|
|
26
|
-
const paymentInstrumentSelectRef = useRef(null);
|
|
27
26
|
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
28
27
|
const [pricing, pricingStatus] = useViewPricingByCheckoutId({ checkoutId: checkout?.id });
|
|
29
28
|
usePageView({
|
|
@@ -33,7 +32,6 @@ const Checkout = ({ children, customerId, country, useRedirect }) => {
|
|
|
33
32
|
});
|
|
34
33
|
const navigate = useNavigate();
|
|
35
34
|
const basePath = useBasePath();
|
|
36
|
-
const { returnUrl } = useRedirect();
|
|
37
35
|
const handleOnSubmit = useCallback(() => {
|
|
38
36
|
navigate(`${basePath}/${Routes.CHECKOUT}/${Routes.CHECKOUT_PAYMENT}`);
|
|
39
37
|
}, [basePath, navigate]);
|
|
@@ -49,7 +47,7 @@ const Checkout = ({ children, customerId, country, useRedirect }) => {
|
|
|
49
47
|
React.createElement(Body, { style: { column: style.bodyColumn } },
|
|
50
48
|
hasReplacedCheckoutItem && (React.createElement(View, { style: style.deliveryBannerContainer },
|
|
51
49
|
React.createElement(DeliveryBanner, null))),
|
|
52
|
-
React.createElement(
|
|
50
|
+
React.createElement(PaymentInstrument, { useRedirect: useRedirect }),
|
|
53
51
|
React.createElement(Text, { level: 3, style: style.title, heading: true }, titleText),
|
|
54
52
|
checkoutItemsKept?.map((checkoutItem) => (React.createElement(View, { key: checkoutItem.id, style: style.checkoutItemKept, testID: "checkout-items-kept" },
|
|
55
53
|
React.createElement(ProductVariant, { brand: checkoutItem.productVariant.brand, color: checkoutItem.productVariant.color, country: country, media: checkoutItem.productVariant.media, name: checkoutItem.productVariant.name, price: checkoutItem.price, status: checkoutItem.status, size: checkoutItem.status === CheckoutItemStatus.REPLACED && checkoutItem.replacedFor
|
|
@@ -2,6 +2,7 @@ import { QueryStatus } from "@lookiero/messaging-react";
|
|
|
2
2
|
import { PaymentFlow } from "@lookiero/payments-front";
|
|
3
3
|
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { useNavigate } from "react-router-native";
|
|
5
|
+
import { useLogger } from "../../../../../../shared/logging/useLogger";
|
|
5
6
|
import { useViewFirstAvailableCheckoutByCustomerId } from "../../../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
6
7
|
import { useViewPaymentFlowPayloadByCheckoutId } from "../../../../../projection/payment/react/useViewPaymentFlowPayloadByCheckoutId";
|
|
7
8
|
import { useSubmitCheckout } from "../../../../hooks/useSubmitCheckout";
|
|
@@ -10,6 +11,7 @@ import { useBasePath } from "../../../../routing/useBasePath";
|
|
|
10
11
|
import { CheckoutSuccessModal } from "../checkoutSuccessModal/CheckoutSuccessModal";
|
|
11
12
|
const CheckoutPaymentModal = ({ customerId, getAuthToken }) => {
|
|
12
13
|
const paymentFlowRef = useRef(null);
|
|
14
|
+
const logger = useLogger();
|
|
13
15
|
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
14
16
|
const [paymentFlowPayload] = useViewPaymentFlowPayloadByCheckoutId({
|
|
15
17
|
checkoutId: checkout?.id,
|
|
@@ -28,6 +30,7 @@ const CheckoutPaymentModal = ({ customerId, getAuthToken }) => {
|
|
|
28
30
|
checkoutBookingId: checkout?.checkoutBookingId,
|
|
29
31
|
paymentFlowRef,
|
|
30
32
|
onError: handleOnErrorSubmitCheckout,
|
|
33
|
+
logger,
|
|
31
34
|
});
|
|
32
35
|
useEffect(() => {
|
|
33
36
|
if (paymentFlowPayload) {
|
package/dist/infrastructure/ui/views/checkout/components/paymentInstrument/PaymentInstrument.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PaymentInstrumentSelect, PaymentMethod, Section } from "@lookiero/payments-front";
|
|
2
|
+
import React, { useRef } from "react";
|
|
3
|
+
import { useLogger } from "../../../../../../shared/logging/useLogger";
|
|
4
|
+
import { usePaymentInstrumentEvents } from "../../../../hooks/usePaymentInstrumentEvents";
|
|
5
|
+
const PaymentInstrument = ({ useRedirect }) => {
|
|
6
|
+
const paymentInstrumentSelectRef = useRef(null);
|
|
7
|
+
const { returnUrl } = useRedirect();
|
|
8
|
+
const logger = useLogger();
|
|
9
|
+
usePaymentInstrumentEvents({ logger });
|
|
10
|
+
return (React.createElement(PaymentInstrumentSelect, { ref: paymentInstrumentSelectRef, beforeRedirect: returnUrl ? () => Promise.resolve(returnUrl) : undefined, hasError: false, hidePaymentMethods: [PaymentMethod.GOOGLE_PAY], section: Section.BOX_CHECKOUT }));
|
|
11
|
+
};
|
|
12
|
+
export { PaymentInstrument };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
|
|
2
2
|
import React, { useCallback } from "react";
|
|
3
3
|
import { Platform } from "react-native";
|
|
4
|
+
import { useLogger } from "../../../../shared/logging/useLogger";
|
|
4
5
|
import { usePageView } from "../../../../shared/tracking/infrastructure/usePageView";
|
|
5
6
|
import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
|
|
6
7
|
import { useGiveCheckoutFeedback } from "../../../domain/checkoutFeedback/react/useGiveCheckoutFeedback";
|
|
@@ -14,12 +15,14 @@ import { HEADER_HEIGHT } from "../navigation/components/header/Header.style";
|
|
|
14
15
|
import { style } from "./Feedback.style";
|
|
15
16
|
import { CheckoutQuestionsForm } from "./components/checkoutQuestionsForm/CheckoutQuestionsForm";
|
|
16
17
|
const Feedback = ({ customerId, country }) => {
|
|
18
|
+
const logger = useLogger();
|
|
17
19
|
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
18
20
|
const [checkoutQuestions, checkoutQuestionsStatus] = useListCheckoutQuestionsByCheckoutId({
|
|
19
21
|
checkoutId: checkout?.id,
|
|
20
22
|
});
|
|
21
23
|
const [giveCheckoutFeedback, giveCheckoutFeedbackStatus] = useGiveCheckoutFeedback({
|
|
22
24
|
checkoutId: checkout?.id,
|
|
25
|
+
logger,
|
|
23
26
|
});
|
|
24
27
|
const handleOnSubmit = useCallback(async (feedbacks) => {
|
|
25
28
|
try {
|
|
@@ -4,6 +4,7 @@ import { Platform, View } from "react-native";
|
|
|
4
4
|
import { generatePath, useMatch, useNavigate, useParams } from "react-router-native";
|
|
5
5
|
import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
|
|
6
6
|
import "../../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
7
|
+
import { useLogger } from "../../../../shared/logging/useLogger";
|
|
7
8
|
import { usePageView } from "../../../../shared/tracking/infrastructure/usePageView";
|
|
8
9
|
import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
|
|
9
10
|
import { useBookCheckoutBookingForCheckoutItem } from "../../../domain/checkoutBooking/react/useBookCheckoutBookingForCheckoutItem";
|
|
@@ -32,6 +33,7 @@ import { SizeChangeModal } from "./components/sizeChangeModal/SizeChangeModal";
|
|
|
32
33
|
import { SizeWithoutStockModal } from "./components/sizeWithoutStockModal/SizeWithoutStockModal";
|
|
33
34
|
const { spaceXL } = theme();
|
|
34
35
|
const Item = ({ customerId, country }) => {
|
|
36
|
+
const logger = useLogger();
|
|
35
37
|
const { id } = useParams();
|
|
36
38
|
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
37
39
|
const checkoutItem = checkout?.items.find((checkoutItem) => checkoutItem.id === id);
|
|
@@ -63,12 +65,14 @@ const Item = ({ customerId, country }) => {
|
|
|
63
65
|
setCustomerDecissionMade(checkoutItem.status !== CheckoutItemStatus.INITIAL);
|
|
64
66
|
}, [checkoutItem.status, id]);
|
|
65
67
|
const handleOnBannerPress = useCallback(() => setCustomerDecissionMade(false), []);
|
|
66
|
-
const [keepCheckoutItem, keepCheckoutItemStatus] = useKeepCheckoutItem({ checkoutItemId: checkoutItem.id });
|
|
68
|
+
const [keepCheckoutItem, keepCheckoutItemStatus] = useKeepCheckoutItem({ checkoutItemId: checkoutItem.id, logger });
|
|
67
69
|
const [returnCheckoutItem, returnCheckoutItemStatus] = useReturnCheckoutItem({
|
|
68
70
|
checkoutItemId: checkoutItem.id,
|
|
71
|
+
logger,
|
|
69
72
|
});
|
|
70
73
|
const [replaceCheckoutItem, replaceCheckoutItemStatus] = useReplaceCheckoutItem({
|
|
71
74
|
checkoutItemId: checkoutItem.id,
|
|
75
|
+
logger,
|
|
72
76
|
});
|
|
73
77
|
const [sizeWithoutStockModalVisible, setSizeWithoutStockModalVisible] = useState(false);
|
|
74
78
|
const handleOnShowSizeWithoutStockModal = useCallback(() => setSizeWithoutStockModalVisible(true), []);
|
|
@@ -87,6 +91,7 @@ const Item = ({ customerId, country }) => {
|
|
|
87
91
|
const [bookCheckoutBooking] = useBookCheckoutBookingForCheckoutItem({
|
|
88
92
|
checkoutItemId: checkoutItem.id,
|
|
89
93
|
checkoutBookingId: checkout?.checkoutBookingId,
|
|
94
|
+
logger,
|
|
90
95
|
});
|
|
91
96
|
useEffect(() => {
|
|
92
97
|
checkout && bookedProductsVariants === null && bookCheckoutBooking();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useEffect } from "react";
|
|
2
2
|
import { useRoutes as reactRouterUseRoutes } from "react-router-native";
|
|
3
3
|
import { wrapUseRoutes, wrapComponent, ErrorBoundary } from "./SentryDependencies";
|
|
4
|
+
import { LoggerProvider } from "./useLogger";
|
|
4
5
|
const sentryLoggerHOC = ({ logger }) => {
|
|
5
6
|
logger.init();
|
|
6
7
|
const useRoutes = wrapUseRoutes(reactRouterUseRoutes);
|
|
@@ -14,7 +15,8 @@ const sentryLoggerHOC = ({ logger }) => {
|
|
|
14
15
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15
16
|
}, []);
|
|
16
17
|
return (React.createElement(ErrorBoundary, null,
|
|
17
|
-
React.createElement(
|
|
18
|
+
React.createElement(LoggerProvider, { logger: logger },
|
|
19
|
+
React.createElement(WrappedComponent, { ...props, useRoutes: useRoutes }))));
|
|
18
20
|
};
|
|
19
21
|
return SentryLogger;
|
|
20
22
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FC, ReactNode } from "react";
|
|
2
|
+
import { Logger } from "./Logger";
|
|
3
|
+
interface LoggerContextProviderProps {
|
|
4
|
+
readonly logger: Logger;
|
|
5
|
+
readonly children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
declare const LoggerProvider: FC<LoggerContextProviderProps>;
|
|
8
|
+
interface UseLoggerFunction {
|
|
9
|
+
(): Logger;
|
|
10
|
+
}
|
|
11
|
+
declare const useLogger: UseLoggerFunction;
|
|
12
|
+
export { useLogger, LoggerProvider };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { createContext, useContext } from "react";
|
|
2
|
+
import invariant from "tiny-invariant";
|
|
3
|
+
const LoggerContext = createContext(null);
|
|
4
|
+
const LoggerProvider = ({ logger, children }) => (React.createElement(LoggerContext.Provider, { value: logger }, children));
|
|
5
|
+
const useLogger = () => {
|
|
6
|
+
const logger = useContext(LoggerContext);
|
|
7
|
+
invariant(logger, "Your are trying to use the useLogger hook without wrapping your app with the <LoggerProvider>.");
|
|
8
|
+
return logger;
|
|
9
|
+
};
|
|
10
|
+
export { useLogger, LoggerProvider };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
|
+
import { Logger } from "../../../../../logging/Logger";
|
|
2
3
|
import { NotificationLevel } from "../../../../domain/notification/model/notification";
|
|
3
4
|
interface CreateNotificationFunctionArgs {
|
|
4
5
|
readonly aggregateId?: string;
|
|
@@ -11,6 +12,7 @@ interface CreateNotificationFunction {
|
|
|
11
12
|
}
|
|
12
13
|
interface UseCreateNotificationFunctionArgs {
|
|
13
14
|
readonly contextId: string;
|
|
15
|
+
readonly logger: Logger;
|
|
14
16
|
}
|
|
15
17
|
interface UseCreateNotificationFunction {
|
|
16
18
|
(args: UseCreateNotificationFunctionArgs): [create: CreateNotificationFunction, status: CommandStatus];
|
package/dist/shared/notifications/infrastructure/domain/notification/react/useCreateNotification.js
CHANGED
|
@@ -2,14 +2,21 @@ import { useCommand } from "@lookiero/messaging-react";
|
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import { v4 as uuid } from "uuid";
|
|
4
4
|
import { createNotification } from "../../../../domain/notification/command/createNotification";
|
|
5
|
-
const useCreateNotification = ({ contextId }) => {
|
|
5
|
+
const useCreateNotification = ({ contextId, logger }) => {
|
|
6
6
|
const [commandBus, status] = useCommand({ contextId });
|
|
7
|
-
const create = useCallback(({ aggregateId, level, titleI18nKey, bodyI18nKey }) =>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
const create = useCallback(async ({ aggregateId, level, titleI18nKey, bodyI18nKey }) => {
|
|
8
|
+
try {
|
|
9
|
+
await commandBus(createNotification({
|
|
10
|
+
aggregateId: aggregateId || uuid(),
|
|
11
|
+
level,
|
|
12
|
+
titleI18nKey,
|
|
13
|
+
bodyI18nKey,
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
logger.captureException(error);
|
|
18
|
+
}
|
|
19
|
+
}, [commandBus, logger]);
|
|
13
20
|
return [create, status];
|
|
14
21
|
};
|
|
15
22
|
export { useCreateNotification };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
|
+
import { Logger } from "../../../../../logging/Logger";
|
|
2
3
|
interface RemoveNotificationFunctionArgs {
|
|
3
4
|
readonly aggregateId: string;
|
|
4
5
|
}
|
|
@@ -7,6 +8,7 @@ interface RemoveNotificationFunction {
|
|
|
7
8
|
}
|
|
8
9
|
interface UseRemoveNotificationFunctionArgs {
|
|
9
10
|
readonly contextId: string;
|
|
11
|
+
readonly logger: Logger;
|
|
10
12
|
}
|
|
11
13
|
interface UseRemoveNotificationFunction {
|
|
12
14
|
(args: UseRemoveNotificationFunctionArgs): [remove: RemoveNotificationFunction, status: CommandStatus];
|
package/dist/shared/notifications/infrastructure/domain/notification/react/useRemoveNotification.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { useCommand } from "@lookiero/messaging-react";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import { removeNotification } from "../../../../domain/notification/command/removeNotification";
|
|
4
|
-
const useRemoveNotification = ({ contextId }) => {
|
|
4
|
+
const useRemoveNotification = ({ contextId, logger }) => {
|
|
5
5
|
const [commandBus, status] = useCommand({ contextId });
|
|
6
|
-
const remove = useCallback(({ aggregateId }) =>
|
|
6
|
+
const remove = useCallback(async ({ aggregateId }) => {
|
|
7
|
+
try {
|
|
8
|
+
await commandBus(removeNotification({ aggregateId }));
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
logger.captureException(error);
|
|
12
|
+
}
|
|
13
|
+
}, [commandBus, logger]);
|
|
7
14
|
return [remove, status];
|
|
8
15
|
};
|
|
9
16
|
export { useRemoveNotification };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
|
+
import { useLogger } from "../../../../logging/useLogger";
|
|
2
3
|
import { useListNotifications } from "../../../projection/notification/react/useListNotifications";
|
|
3
4
|
import { useRemoveNotification } from "../../domain/notification/react/useRemoveNotification";
|
|
4
5
|
import { Notifications as NotificationsTemplate } from "../components/Notifications";
|
|
5
6
|
const Notifications = ({ contextId }) => {
|
|
7
|
+
const logger = useLogger();
|
|
6
8
|
const [notifications] = useListNotifications({ contextId });
|
|
7
|
-
const [remove] = useRemoveNotification({ contextId });
|
|
9
|
+
const [remove] = useRemoveNotification({ contextId, logger });
|
|
8
10
|
const onRemove = useCallback((id) => remove({ aggregateId: id }), [remove]);
|
|
9
11
|
return React.createElement(NotificationsTemplate, { notifications: notifications, onRemove: onRemove });
|
|
10
12
|
};
|