@lookiero/checkout 0.8.4-beta.2 → 0.8.4
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/domain/checkout/model/checkout.js +1 -0
- package/dist/infrastructure/delivery/http/fetchHttpClient.js +36 -19
- package/dist/infrastructure/delivery/http/httpClient.d.ts +9 -3
- package/dist/infrastructure/domain/checkout/react/useStartCheckout.d.ts +3 -1
- package/dist/infrastructure/domain/checkout/react/useStartCheckout.js +11 -4
- 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 +20 -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/projection/bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView.js +9 -8
- package/dist/infrastructure/projection/checkout/httpCheckoutByIdView.js +9 -8
- package/dist/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.js +9 -8
- package/dist/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.js +8 -7
- package/dist/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.js +8 -7
- package/dist/infrastructure/projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId.js +1 -4
- package/dist/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.js +9 -8
- package/dist/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.js +9 -8
- package/dist/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.js +9 -8
- package/dist/infrastructure/projection/payment/httpPaymentFlowPayloadByCheckoutIdView.js +9 -8
- package/dist/infrastructure/projection/pricing/httpPricingByCheckoutIdView.js +9 -8
- package/dist/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.js +9 -8
- package/dist/infrastructure/ui/Root.js +2 -1
- package/dist/infrastructure/ui/hooks/usePaymentInstrumentEvents.d.ts +8 -1
- package/dist/infrastructure/ui/hooks/usePaymentInstrumentEvents.js +2 -2
- package/dist/infrastructure/ui/hooks/useSubmitCheckout.d.ts +2 -0
- package/dist/infrastructure/ui/hooks/useSubmitCheckout.js +9 -10
- 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/components/checkoutPaymentModal/CheckoutPaymentModal.js +3 -0
- package/dist/infrastructure/ui/views/checkout/components/paymentInstrument/PaymentInstrument.js +3 -1
- package/dist/infrastructure/ui/views/feedback/Feedback.js +3 -0
- package/dist/infrastructure/ui/views/item/Item.js +6 -1
- package/dist/infrastructure/ui/views/item/components/productVariant/ProductVariant.js +2 -2
- package/dist/shared/logging/Logger.d.ts +7 -0
- package/dist/shared/logging/Logger.js +1 -0
- package/dist/shared/logging/SentryLogger.d.ts +3 -8
- package/dist/shared/logging/SentryLogger.js +27 -33
- package/dist/shared/logging/SentryLoggerHOC.d.ts +15 -0
- package/dist/shared/logging/SentryLoggerHOC.js +24 -0
- 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/dist/shared/ui/components/layouts/slider/Slider.js +12 -47
- package/package.json +2 -1
- package/dist/infrastructure/domain/uiSetting/react/useIncrementIntroShownCount.d.ts +0 -10
- package/dist/infrastructure/domain/uiSetting/react/useIncrementIntroShownCount.js +0 -11
- package/dist/infrastructure/projection/uiSetting/react/useShouldIntroBeShown.d.ts +0 -6
- package/dist/infrastructure/projection/uiSetting/react/useShouldIntroBeShown.js +0 -7
- package/dist/infrastructure/projection/uiSetting/react/useViewIntroShownCount.d.ts +0 -6
- package/dist/infrastructure/projection/uiSetting/react/useViewIntroShownCount.js +0 -9
- package/dist/infrastructure/ui/hooks/usePaymentInstrumentUpdateEvents.d.ts +0 -2
- package/dist/infrastructure/ui/hooks/usePaymentInstrumentUpdateEvents.js +0 -28
- package/dist/infrastructure/ui/views/intro/Intro.d.ts +0 -6
- package/dist/infrastructure/ui/views/intro/Intro.js +0 -52
- package/dist/infrastructure/ui/views/intro/Intro.style.d.ts +0 -52
- package/dist/infrastructure/ui/views/intro/Intro.style.js +0 -55
|
@@ -11,6 +11,7 @@ var CheckoutStatus;
|
|
|
11
11
|
})(CheckoutStatus || (CheckoutStatus = {}));
|
|
12
12
|
const startCheckoutHandler = () => async ({ aggregateRoot, command }) => {
|
|
13
13
|
const { aggregateId } = command;
|
|
14
|
+
invariant(aggregateRoot.status !== CheckoutStatus.STARTED, "Checkout is already started");
|
|
14
15
|
invariant(aggregateRoot.status !== CheckoutStatus.SUBMITTED, "Checkout is already submitted");
|
|
15
16
|
invariant(aggregateRoot.status !== CheckoutStatus.COMPLETED, "Checkout is already completed");
|
|
16
17
|
return {
|
|
@@ -1,20 +1,37 @@
|
|
|
1
|
-
const fetchHttpPost = ({ apiUrl, getAuthToken }) => async ({ endpoint, body, signal }) =>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
const fetchHttpPost = ({ apiUrl, getAuthToken }) => async ({ endpoint, body, signal, result }) => {
|
|
2
|
+
const response = await fetch(`${apiUrl}${endpoint}`, {
|
|
3
|
+
method: "POST",
|
|
4
|
+
headers: {
|
|
5
|
+
["Content-Type"]: "application/json",
|
|
6
|
+
authorization: `Bearer ${await getAuthToken()}`,
|
|
7
|
+
},
|
|
8
|
+
body: JSON.stringify(body),
|
|
9
|
+
signal,
|
|
10
|
+
});
|
|
11
|
+
return await processResponse({ response, result });
|
|
12
|
+
};
|
|
13
|
+
const fetchHttpGet = ({ apiUrl, getAuthToken }) => async ({ endpoint, signal, result }) => {
|
|
14
|
+
const response = await fetch(`${apiUrl}${endpoint}`, {
|
|
15
|
+
method: "GET",
|
|
16
|
+
credentials: "include",
|
|
17
|
+
headers: {
|
|
18
|
+
Authorization: `Bearer ${await getAuthToken()}`,
|
|
19
|
+
["Content-Type"]: "application/json",
|
|
20
|
+
},
|
|
21
|
+
referrer: "",
|
|
22
|
+
signal,
|
|
23
|
+
});
|
|
24
|
+
return await processResponse({ response, result });
|
|
25
|
+
};
|
|
26
|
+
const processResponse = async ({ response, result }) => {
|
|
27
|
+
if (response.ok) {
|
|
28
|
+
const responseText = await response.text();
|
|
29
|
+
const responseResult = responseText ? JSON.parse(responseText) : responseText;
|
|
30
|
+
return result?.success(responseResult) ?? responseResult;
|
|
31
|
+
}
|
|
32
|
+
if (result?.error !== undefined) {
|
|
33
|
+
return result.error;
|
|
34
|
+
}
|
|
35
|
+
throw new Error(response.statusText);
|
|
36
|
+
};
|
|
20
37
|
export { fetchHttpGet, fetchHttpPost };
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
+
interface HttpFunctionResult {
|
|
2
|
+
readonly error: any;
|
|
3
|
+
readonly success: (response: any) => any;
|
|
4
|
+
}
|
|
1
5
|
interface HttpGetFunctionArgs {
|
|
2
6
|
readonly endpoint: string;
|
|
3
7
|
readonly signal?: AbortSignal;
|
|
8
|
+
readonly result?: HttpFunctionResult;
|
|
4
9
|
}
|
|
5
10
|
interface HttpGetFunction {
|
|
6
|
-
(args: HttpGetFunctionArgs): Promise<
|
|
11
|
+
(args: HttpGetFunctionArgs): Promise<any>;
|
|
7
12
|
}
|
|
8
13
|
interface HttpPostFunctionArgs {
|
|
9
14
|
readonly endpoint: string;
|
|
10
15
|
readonly body: Record<string, unknown>;
|
|
11
16
|
readonly signal?: AbortSignal;
|
|
17
|
+
readonly result?: HttpFunctionResult;
|
|
12
18
|
}
|
|
13
19
|
interface HttpPostFunction {
|
|
14
|
-
(args: HttpPostFunctionArgs): Promise<
|
|
20
|
+
(args: HttpPostFunctionArgs): Promise<any>;
|
|
15
21
|
}
|
|
16
|
-
export type { HttpGetFunction, HttpPostFunction };
|
|
22
|
+
export type { HttpGetFunction, HttpPostFunction, HttpFunctionResult };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
|
+
import { Logger } from "../../../../shared/logging/Logger";
|
|
2
3
|
interface StartCheckoutFunction {
|
|
3
|
-
(): Promise<void
|
|
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,12 +3,19 @@ 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
|
-
const start = useCallback(() => {
|
|
8
|
+
const start = useCallback(async () => {
|
|
9
9
|
invariant(checkoutId, "CheckoutId must be defined in order to start checkout");
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
try {
|
|
11
|
+
return await commandBus(startCheckout({ aggregateId: checkoutId }));
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
if (!error?.message?.includes("Checkout is already started")) {
|
|
15
|
+
logger.captureException(error);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}, [checkoutId, commandBus, logger]);
|
|
12
19
|
return [start, status];
|
|
13
20
|
};
|
|
14
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,28 @@
|
|
|
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
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
}, [checkoutBookingId, commandBus, createNotification, logger]);
|
|
10
26
|
return [blockCheckoutBooking, status];
|
|
11
27
|
};
|
|
12
28
|
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 };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
const httpBookedProductsVariantsForCheckoutItemView = ({ httpPost }) => async ({ checkoutItemId, signal }) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
1
|
+
const httpBookedProductsVariantsForCheckoutItemView = ({ httpPost }) => async ({ checkoutItemId, signal }) => await httpPost({
|
|
2
|
+
endpoint: "/view-booked-product-variants-for-checkout-item",
|
|
3
|
+
body: { checkoutItemId },
|
|
4
|
+
signal,
|
|
5
|
+
result: {
|
|
6
|
+
error: null,
|
|
7
|
+
success: (response) => response.result,
|
|
8
|
+
},
|
|
9
|
+
});
|
|
9
10
|
export { httpBookedProductsVariantsForCheckoutItemView };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { toCheckoutProjection } from "./checkout";
|
|
2
|
-
const httpCheckoutByIdView = ({ httpPost }) => async ({ checkoutId, signal }) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
2
|
+
const httpCheckoutByIdView = ({ httpPost }) => async ({ checkoutId, signal }) => await httpPost({
|
|
3
|
+
endpoint: "/view-checkout-by-id",
|
|
4
|
+
body: { checkoutId },
|
|
5
|
+
signal,
|
|
6
|
+
result: {
|
|
7
|
+
error: null,
|
|
8
|
+
success: (response) => toCheckoutProjection(response.result),
|
|
9
|
+
},
|
|
10
|
+
});
|
|
10
11
|
export { httpCheckoutByIdView };
|
package/dist/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { toCheckoutProjection } from "./checkout";
|
|
2
|
-
const httpFirstAvailableCheckoutByCustomerIdView = ({ httpPost }) => async ({ customerId, signal }) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
2
|
+
const httpFirstAvailableCheckoutByCustomerIdView = ({ httpPost }) => async ({ customerId, signal }) => await httpPost({
|
|
3
|
+
endpoint: "/view-first-available-checkout-by-customer-id",
|
|
4
|
+
body: { customerId },
|
|
5
|
+
signal,
|
|
6
|
+
result: {
|
|
7
|
+
error: null,
|
|
8
|
+
success: (response) => toCheckoutProjection(response.result),
|
|
9
|
+
},
|
|
10
|
+
});
|
|
10
11
|
export { httpFirstAvailableCheckoutByCustomerIdView };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
const httpFiveItemsDiscountByCustomerIdView = ({ httpGet }) => async ({ customerId, signal }) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
1
|
+
const httpFiveItemsDiscountByCustomerIdView = ({ httpGet }) => async ({ customerId, signal }) => await httpGet({
|
|
2
|
+
endpoint: `/view-five-items-discount-by-customer-id/${customerId}`,
|
|
3
|
+
signal,
|
|
4
|
+
result: {
|
|
5
|
+
error: 0,
|
|
6
|
+
success: (response) => response,
|
|
7
|
+
},
|
|
8
|
+
});
|
|
8
9
|
export { httpFiveItemsDiscountByCustomerIdView };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
const httpIsCheckoutEnabledByCustomerIdView = ({ httpGet }) => async ({ customerId, signal }) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
1
|
+
const httpIsCheckoutEnabledByCustomerIdView = ({ httpGet }) => async ({ customerId, signal }) => await httpGet({
|
|
2
|
+
endpoint: `/is-new-checkout-enabled/${customerId}`,
|
|
3
|
+
signal,
|
|
4
|
+
result: {
|
|
5
|
+
error: false,
|
|
6
|
+
success: (response) => response,
|
|
7
|
+
},
|
|
8
|
+
});
|
|
8
9
|
export { httpIsCheckoutEnabledByCustomerIdView };
|