@lookiero/checkout 0.8.4-beta.1 → 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/domain/checkout/command/markCheckoutAsPaid.d.ts +13 -0
- package/dist/domain/checkout/command/markCheckoutAsPaid.js +4 -0
- package/dist/domain/checkout/model/checkout.js +1 -0
- package/dist/domain/checkout/model/checkoutPaid.d.ts +13 -0
- package/dist/domain/checkout/model/checkoutPaid.js +4 -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/model/httpCheckoutsMarkAsPaid.d.ts +5 -0
- package/dist/infrastructure/domain/checkout/model/httpCheckoutsMarkAsPaid.js +13 -0
- package/dist/infrastructure/domain/checkout/react/useMarkCheckoutAsPaid.d.ts +13 -0
- package/dist/infrastructure/domain/checkout/react/useMarkCheckoutAsPaid.js +16 -0
- 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 +19 -4
- package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckouBookingForCheckoutItem.d.ts +13 -0
- package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckouBookingForCheckoutItem.js +14 -0
- 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/bookedSizeChangeProductsVariants/httpBookedSizeChangeProductsVariantsForCheckoutItemView.d.ts +12 -0
- package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/httpBookedSizeChangeProductsVariantsForCheckoutItemView.js +9 -0
- package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/react/useViewBookedSizeChangeProductsVariantsForCheckoutItem.d.ts +10 -0
- package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/react/useViewBookedSizeChangeProductsVariantsForCheckoutItem.js +12 -0
- 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/checkoutFeedback/httpCheckoutFeedbackByCheckoutIdView.d.ts +12 -0
- package/dist/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByCheckoutIdView.js +9 -0
- 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 +7 -13
- 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/App.style.d.ts +4 -0
- package/dist/infrastructure/ui/views/App.style.js +16 -0
- 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/header/Header.d.ts +15 -0
- package/dist/infrastructure/ui/views/header/Header.js +90 -0
- package/dist/infrastructure/ui/views/header/Header.style.d.ts +35 -0
- package/dist/infrastructure/ui/views/header/Header.style.js +38 -0
- package/dist/infrastructure/ui/views/header/components/Logo.d.ts +7 -0
- package/dist/infrastructure/ui/views/header/components/Logo.js +11 -0
- package/dist/infrastructure/ui/views/header/components/Logo.style.d.ts +7 -0
- package/dist/infrastructure/ui/views/header/components/Logo.style.js +8 -0
- package/dist/infrastructure/ui/views/intro/Intro.js +1 -1
- package/dist/infrastructure/ui/views/intro/Intro.style.d.ts +3 -0
- package/dist/infrastructure/ui/views/intro/Intro.style.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/projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants.d.ts +10 -0
- package/dist/projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants.js +1 -0
- package/dist/projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem.d.ts +25 -0
- package/dist/projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem.js +8 -0
- package/dist/projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId.d.ts +25 -0
- package/dist/projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId.js +8 -0
- 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/location.d.ts +3 -0
- package/dist/shared/logging/location.js +5 -0
- package/dist/shared/logging/matchRoutes.d.ts +3 -0
- package/dist/shared/logging/matchRoutes.js +7 -0
- package/dist/shared/logging/reactRouterV6Instrumentation/reactRouterV6Instrumentation.native.d.ts +29 -0
- package/dist/shared/logging/reactRouterV6Instrumentation/reactRouterV6Instrumentation.native.js +134 -0
- package/dist/shared/logging/reactRouterV6Instrumentation/transactionContext.d.ts +22 -0
- package/dist/shared/logging/reactRouterV6Instrumentation/transactionContext.js +15 -0
- package/dist/shared/logging/reactRouterV6Instrumentation.native.d.ts +27 -0
- package/dist/shared/logging/reactRouterV6Instrumentation.native.js +115 -0
- package/dist/shared/logging/useLogger.d.ts +12 -0
- package/dist/shared/logging/useLogger.js +10 -0
- package/dist/shared/notifications/domain/notification/command/removeNotification.tes.d.ts +1 -0
- package/dist/shared/notifications/domain/notification/command/removeNotification.tes.js +9 -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 +2 -1
- package/dist/infrastructure/ui/hooks/usePaymentInstrumentUpdateEvents.d.ts +0 -2
- package/dist/infrastructure/ui/hooks/usePaymentInstrumentUpdateEvents.js +0 -28
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from "@lookiero/messaging";
|
|
2
|
+
declare const MARK_CHECKOUT_AS_PAID = "mark_checkout_as_paid";
|
|
3
|
+
interface MarkCheckoutAsPaidPayload {
|
|
4
|
+
readonly aggregateId: string;
|
|
5
|
+
}
|
|
6
|
+
interface MarkCheckoutAsPaid extends Command<typeof MARK_CHECKOUT_AS_PAID>, MarkCheckoutAsPaidPayload {
|
|
7
|
+
}
|
|
8
|
+
interface MarkCheckoutAsPaidFunction {
|
|
9
|
+
(payload: MarkCheckoutAsPaidPayload): MarkCheckoutAsPaid;
|
|
10
|
+
}
|
|
11
|
+
declare const markCheckoutAsPaid: MarkCheckoutAsPaidFunction;
|
|
12
|
+
export type { MarkCheckoutAsPaid };
|
|
13
|
+
export { MARK_CHECKOUT_AS_PAID, markCheckoutAsPaid };
|
|
@@ -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 {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DomainEvent } from "@lookiero/messaging";
|
|
2
|
+
declare const CHECKOUT_PAID = "checkout_paid";
|
|
3
|
+
interface CheckoutPaidPayload {
|
|
4
|
+
readonly aggregateId: string;
|
|
5
|
+
}
|
|
6
|
+
interface CheckoutPaid extends DomainEvent<typeof CHECKOUT_PAID>, CheckoutPaidPayload {
|
|
7
|
+
}
|
|
8
|
+
interface CheckoutPaidFunction {
|
|
9
|
+
(payload: CheckoutPaidPayload): CheckoutPaid;
|
|
10
|
+
}
|
|
11
|
+
declare const checkoutPaid: CheckoutPaidFunction;
|
|
12
|
+
export type { CheckoutPaid };
|
|
13
|
+
export { CHECKOUT_PAID, checkoutPaid };
|
|
@@ -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 };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CHECKOUT_PAID } from "../../../../domain/checkout/model/checkoutPaid";
|
|
2
|
+
const isCheckoutPaid = (event) => event.name === CHECKOUT_PAID;
|
|
3
|
+
const httpCheckoutsMarkAsPaid = ({ httpPost }) => async ({ aggregateId, domainEvents }) => {
|
|
4
|
+
const checkoutPaid = domainEvents.find(isCheckoutPaid);
|
|
5
|
+
if (!checkoutPaid) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
await httpPost({
|
|
9
|
+
endpoint: "/mark-checkout-as-paid",
|
|
10
|
+
body: { checkoutId: aggregateId },
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
export { httpCheckoutsMarkAsPaid };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
|
+
interface MarkAsPaidFunction {
|
|
3
|
+
(): Promise<void>;
|
|
4
|
+
}
|
|
5
|
+
type UseMarkCheckoutAsPaid = [markAsPaid: MarkAsPaidFunction, status: CommandStatus];
|
|
6
|
+
interface UseMarkCheckoutAsPaidFunctionArgs {
|
|
7
|
+
readonly checkoutId?: string;
|
|
8
|
+
}
|
|
9
|
+
interface UseMarkCheckoutAsPaidFunction {
|
|
10
|
+
(args: UseMarkCheckoutAsPaidFunctionArgs): UseMarkCheckoutAsPaid;
|
|
11
|
+
}
|
|
12
|
+
declare const useMarkCheckoutAsPaid: UseMarkCheckoutAsPaidFunction;
|
|
13
|
+
export { useMarkCheckoutAsPaid };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useCommand } from "@lookiero/messaging-react";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import invariant from "tiny-invariant";
|
|
4
|
+
import { markCheckoutAsPaid } from "../../../../domain/checkout/command/markCheckoutAsPaid";
|
|
5
|
+
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
6
|
+
const useMarkCheckoutAsPaid = ({ checkoutId }) => {
|
|
7
|
+
const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
|
|
8
|
+
const markAsPaid = useCallback(() => {
|
|
9
|
+
invariant(checkoutId, "CheckoutId must be defined in order to mark the checkout as paid");
|
|
10
|
+
return commandBus(markCheckoutAsPaid({
|
|
11
|
+
aggregateId: checkoutId,
|
|
12
|
+
}));
|
|
13
|
+
}, [checkoutId, commandBus]);
|
|
14
|
+
return [markAsPaid, status];
|
|
15
|
+
};
|
|
16
|
+
export { useMarkCheckoutAsPaid };
|
|
@@ -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,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/useBookCheckouBookingForCheckoutItem.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
|
+
interface BookFunction {
|
|
3
|
+
(): Promise<void>;
|
|
4
|
+
}
|
|
5
|
+
type UseBookCheckouBookingForCheckoutItem = [book: BookFunction, status: CommandStatus];
|
|
6
|
+
interface UseBookCheckouBookingForCheckoutItemFunctionArgs {
|
|
7
|
+
readonly checkoutItemId: string;
|
|
8
|
+
}
|
|
9
|
+
interface UseBookCheckouBookingForCheckoutItemFunction {
|
|
10
|
+
(args: UseBookCheckouBookingForCheckoutItemFunctionArgs): UseBookCheckouBookingForCheckoutItem;
|
|
11
|
+
}
|
|
12
|
+
declare const useBookCheckouBookingForCheckoutItem: UseBookCheckouBookingForCheckoutItemFunction;
|
|
13
|
+
export { useBookCheckouBookingForCheckoutItem };
|
package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckouBookingForCheckoutItem.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useCommand } from "@lookiero/messaging-react";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { v4 as uuid } from "uuid";
|
|
4
|
+
import { bookCheckoutBookingForCheckoutItem } from "../../../../domain/checkoutBooking/command/bookCheckoutBookingForCheckoutItem";
|
|
5
|
+
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
6
|
+
const useBookCheckouBookingForCheckoutItem = ({ checkoutItemId }) => {
|
|
7
|
+
const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
|
|
8
|
+
const book = useCallback(() => commandBus(bookCheckoutBookingForCheckoutItem({
|
|
9
|
+
aggregateId: uuid(),
|
|
10
|
+
checkoutItemId,
|
|
11
|
+
})), [checkoutItemId, commandBus]);
|
|
12
|
+
return [book, status];
|
|
13
|
+
};
|
|
14
|
+
export { useBookCheckouBookingForCheckoutItem };
|
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 };
|