@lookiero/checkout 0.4.0-beta.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/domain/checkout/model/checkout.d.ts +3 -2
- package/dist/domain/checkout/model/checkout.js +1 -1
- package/dist/domain/checkoutBooking/command/blockCheckoutBooking.d.ts +13 -0
- package/dist/domain/checkoutBooking/command/blockCheckoutBooking.js +4 -0
- package/dist/domain/checkoutBooking/model/checkoutBooking.d.ts +5 -1
- package/dist/domain/checkoutBooking/model/checkoutBooking.js +17 -1
- package/dist/domain/checkoutBooking/model/checkoutBookingBlocked.d.ts +13 -0
- package/dist/domain/checkoutBooking/model/checkoutBookingBlocked.js +4 -0
- package/dist/domain/checkoutBooking/model/checkoutBookingExpired.d.ts +13 -0
- package/dist/domain/checkoutBooking/model/checkoutBookingExpired.js +4 -0
- package/dist/domain/checkoutItem/command/replaceCheckoutItem.d.ts +1 -1
- package/dist/domain/checkoutItem/model/checkoutItem.d.ts +1 -1
- package/dist/domain/checkoutItem/model/checkoutItem.js +2 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -4
- package/dist/infrastructure/delivery/baseBootstrap.d.ts +2 -0
- package/dist/infrastructure/delivery/baseBootstrap.js +8 -2
- package/dist/infrastructure/delivery/bootstrap.d.ts +1 -1
- package/dist/infrastructure/delivery/bootstrap.js +5 -3
- package/dist/infrastructure/delivery/http/fetchHttpClient.d.ts +1 -1
- package/dist/infrastructure/delivery/http/fetchHttpClient.js +4 -4
- package/dist/infrastructure/delivery/mock/dataSourceCheckoutBookings.js +5 -1
- package/dist/infrastructure/delivery/mock/dataSourceCheckoutItems.js +2 -0
- package/dist/infrastructure/delivery/mock/dataSourceCheckouts.js +2 -2
- package/dist/infrastructure/domain/checkout/model/httpCheckouts.js +1 -1
- package/dist/infrastructure/domain/checkout/react/useMarkCheckoutAsPaid.d.ts +1 -1
- package/dist/infrastructure/domain/checkout/react/useMarkCheckoutAsPaid.js +1 -1
- package/dist/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.js +9 -2
- package/dist/infrastructure/domain/checkoutBooking/model/httpCheckoutBookingsBlock.d.ts +5 -0
- package/dist/infrastructure/domain/checkoutBooking/model/httpCheckoutBookingsBlock.js +15 -0
- package/dist/infrastructure/domain/checkoutBooking/react/useBlockCheckoutBooking.d.ts +13 -0
- package/dist/infrastructure/domain/checkoutBooking/react/useBlockCheckoutBooking.js +12 -0
- package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckoutBookingForCheckoutItem.d.ts +14 -0
- package/dist/infrastructure/domain/checkoutBooking/react/{useBookCheckouBookingForCheckoutItem.js → useBookCheckoutBookingForCheckoutItem.js} +4 -4
- package/dist/infrastructure/domain/checkoutItem/model/httpCheckoutItems.js +1 -1
- package/dist/infrastructure/domain/checkoutItem/model/httpCheckoutItemsReplace.js +2 -2
- package/dist/infrastructure/domain/checkoutItem/react/useReplaceCheckoutItem.d.ts +1 -1
- package/dist/infrastructure/domain/checkoutItem/react/useReplaceCheckoutItem.js +2 -2
- package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/httpBookedSizeChangeProductsVariantsForCheckoutItemView.js +1 -1
- package/dist/infrastructure/projection/checkout/checkout.d.ts +1 -1
- package/dist/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.js +3 -0
- package/dist/infrastructure/projection/pricing/react/useViewPricingByCheckoutId.js +9 -1
- package/dist/infrastructure/ui/Root.d.ts +1 -1
- package/dist/infrastructure/ui/Root.js +2 -2
- package/dist/infrastructure/ui/routing/CheckoutMiddleware.js +11 -11
- package/dist/infrastructure/ui/routing/Routing.d.ts +1 -1
- package/dist/infrastructure/ui/routing/Routing.js +2 -2
- package/dist/infrastructure/ui/views/App.style.d.ts +1 -0
- package/dist/infrastructure/ui/views/App.style.js +1 -0
- package/dist/infrastructure/ui/views/checkout/Checkout.d.ts +1 -1
- package/dist/infrastructure/ui/views/checkout/Checkout.js +23 -10
- package/dist/infrastructure/ui/views/feedback/Feedback.js +6 -1
- package/dist/infrastructure/ui/views/item/Item.js +77 -33
- package/dist/infrastructure/ui/views/summary/components/checkoutItemsTabs/CheckoutItemsTabs.js +7 -4
- package/dist/infrastructure/ui/views/summary/components/pricing/Pricing.js +2 -2
- package/dist/projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants.d.ts +0 -1
- package/dist/projection/checkout/checkout.d.ts +1 -1
- package/dist/projection/checkoutBooking/checkoutBooking.d.ts +2 -0
- package/dist/projection/checkoutItem/checkoutItem.d.ts +1 -1
- package/dist/projection/pricing/pricing.d.ts +3 -3
- package/package.json +1 -1
- package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckouBookingForCheckoutItem.d.ts +0 -13
|
@@ -6,13 +6,14 @@ declare enum CheckoutStatus {
|
|
|
6
6
|
NOTIFIED = "NOTIFIED",
|
|
7
7
|
STARTED = "STARTED",
|
|
8
8
|
COMPLETED = "COMPLETED",
|
|
9
|
-
PAID = "PAID"
|
|
9
|
+
PAID = "PAID",
|
|
10
|
+
EXPIRED = "EXPIRED"
|
|
10
11
|
}
|
|
11
12
|
interface Checkout extends AggregateRoot {
|
|
12
13
|
readonly status: CheckoutStatus;
|
|
13
14
|
readonly customerId: string;
|
|
14
15
|
readonly boxId: string;
|
|
15
|
-
readonly
|
|
16
|
+
readonly checkoutBookingId: string;
|
|
16
17
|
readonly expiresOn: Date;
|
|
17
18
|
}
|
|
18
19
|
declare const startCheckoutHandler: CommandHandlerFunction<StartCheckout, Checkout>;
|
|
@@ -8,6 +8,7 @@ var CheckoutStatus;
|
|
|
8
8
|
CheckoutStatus["STARTED"] = "STARTED";
|
|
9
9
|
CheckoutStatus["COMPLETED"] = "COMPLETED";
|
|
10
10
|
CheckoutStatus["PAID"] = "PAID";
|
|
11
|
+
CheckoutStatus["EXPIRED"] = "EXPIRED";
|
|
11
12
|
})(CheckoutStatus || (CheckoutStatus = {}));
|
|
12
13
|
const startCheckoutHandler = () => async ({ aggregateRoot, command }) => {
|
|
13
14
|
const { aggregateId } = command;
|
|
@@ -21,7 +22,6 @@ const startCheckoutHandler = () => async ({ aggregateRoot, command }) => {
|
|
|
21
22
|
};
|
|
22
23
|
const markCheckoutAsPaidHandler = () => async ({ aggregateRoot, command }) => {
|
|
23
24
|
const { aggregateId } = command;
|
|
24
|
-
invariant(aggregateRoot.status !== CheckoutStatus.PAID, "Checkout is already paid");
|
|
25
25
|
invariant(aggregateRoot.status !== CheckoutStatus.COMPLETED, "Checkout is already completed");
|
|
26
26
|
return {
|
|
27
27
|
...aggregateRoot,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from "@lookiero/messaging";
|
|
2
|
+
declare const BLOCK_CHECKOUT_BOOKING = "block_checkout_booking";
|
|
3
|
+
interface BlockCheckoutBookingPayload {
|
|
4
|
+
readonly aggregateId: string;
|
|
5
|
+
}
|
|
6
|
+
interface BlockCheckoutBooking extends Command<typeof BLOCK_CHECKOUT_BOOKING>, BlockCheckoutBookingPayload {
|
|
7
|
+
}
|
|
8
|
+
interface BlockCheckoutBookingFunction {
|
|
9
|
+
(payload: BlockCheckoutBookingPayload): BlockCheckoutBooking;
|
|
10
|
+
}
|
|
11
|
+
declare const blockCheckoutBooking: BlockCheckoutBookingFunction;
|
|
12
|
+
export type { BlockCheckoutBooking };
|
|
13
|
+
export { BLOCK_CHECKOUT_BOOKING, blockCheckoutBooking };
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { AggregateRoot, CommandHandlerFunction } from "@lookiero/messaging";
|
|
2
|
+
import { CheckoutStatus } from "../../checkout/model/checkout";
|
|
3
|
+
import { BlockCheckoutBooking } from "../command/blockCheckoutBooking";
|
|
2
4
|
import { BookCheckoutBookingForCheckoutItem } from "../command/bookCheckoutBookingForCheckoutItem";
|
|
3
5
|
interface CheckoutBooking extends AggregateRoot {
|
|
4
6
|
readonly checkoutItemIds: string[];
|
|
7
|
+
readonly checkoutStatus: CheckoutStatus;
|
|
5
8
|
}
|
|
6
9
|
declare const bookCheckoutBookingForCheckoutItemHandler: CommandHandlerFunction<BookCheckoutBookingForCheckoutItem, CheckoutBooking>;
|
|
10
|
+
declare const blockCheckoutBookingHandler: CommandHandlerFunction<BlockCheckoutBooking, CheckoutBooking>;
|
|
7
11
|
export type { CheckoutBooking };
|
|
8
|
-
export { bookCheckoutBookingForCheckoutItemHandler };
|
|
12
|
+
export { bookCheckoutBookingForCheckoutItemHandler, blockCheckoutBookingHandler };
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { CheckoutStatus } from "../../checkout/model/checkout";
|
|
2
|
+
import { checkoutBookingBlocked } from "./checkoutBookingBlocked";
|
|
1
3
|
import { checkoutBookingBooked } from "./checkoutBookingBooked";
|
|
4
|
+
import { checkoutBookingExpired } from "./checkoutBookingExpired";
|
|
2
5
|
const bookCheckoutBookingForCheckoutItemHandler = () => async ({ aggregateRoot, command }) => {
|
|
3
6
|
const { aggregateId, checkoutItemId } = command;
|
|
4
7
|
return {
|
|
@@ -6,4 +9,17 @@ const bookCheckoutBookingForCheckoutItemHandler = () => async ({ aggregateRoot,
|
|
|
6
9
|
domainEvents: [checkoutBookingBooked({ aggregateId, checkoutItemId })],
|
|
7
10
|
};
|
|
8
11
|
};
|
|
9
|
-
|
|
12
|
+
const blockCheckoutBookingHandler = () => async ({ aggregateRoot, command }) => {
|
|
13
|
+
const { aggregateId } = command;
|
|
14
|
+
if (aggregateRoot.checkoutStatus === CheckoutStatus.EXPIRED) {
|
|
15
|
+
return {
|
|
16
|
+
...aggregateRoot,
|
|
17
|
+
domainEvents: [checkoutBookingExpired({ aggregateId })],
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
...aggregateRoot,
|
|
22
|
+
domainEvents: [checkoutBookingBlocked({ aggregateId })],
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export { bookCheckoutBookingForCheckoutItemHandler, blockCheckoutBookingHandler };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DomainEvent } from "@lookiero/messaging";
|
|
2
|
+
declare const CHECKOUT_BOOKING_BLOCKED = "checkout_booking_blocked";
|
|
3
|
+
interface CheckoutBookingBlokedPaylcoad {
|
|
4
|
+
readonly aggregateId: string;
|
|
5
|
+
}
|
|
6
|
+
interface CheckoutBookingBlocked extends DomainEvent<typeof CHECKOUT_BOOKING_BLOCKED>, CheckoutBookingBlokedPaylcoad {
|
|
7
|
+
}
|
|
8
|
+
interface CheckoutBookingBlokedFunctcion {
|
|
9
|
+
(payload: CheckoutBookingBlokedPaylcoad): CheckoutBookingBlocked;
|
|
10
|
+
}
|
|
11
|
+
declare const checkoutBookingBlocked: CheckoutBookingBlokedFunctcion;
|
|
12
|
+
export type { CheckoutBookingBlocked };
|
|
13
|
+
export { CHECKOUT_BOOKING_BLOCKED, checkoutBookingBlocked };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { domainEvent } from "@lookiero/messaging";
|
|
2
|
+
const CHECKOUT_BOOKING_BLOCKED = "checkout_booking_blocked";
|
|
3
|
+
const checkoutBookingBlocked = ({ aggregateId }) => domainEvent({ aggregateId, name: CHECKOUT_BOOKING_BLOCKED });
|
|
4
|
+
export { CHECKOUT_BOOKING_BLOCKED, checkoutBookingBlocked };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DomainEvent } from "@lookiero/messaging";
|
|
2
|
+
declare const CHECKOUT_BOOKING_EXPIRED = "checkout_booking_expired";
|
|
3
|
+
interface CheckoutBookingExpiredPayload {
|
|
4
|
+
readonly aggregateId: string;
|
|
5
|
+
}
|
|
6
|
+
interface CheckoutBookingExpired extends DomainEvent<typeof CHECKOUT_BOOKING_EXPIRED>, CheckoutBookingExpiredPayload {
|
|
7
|
+
}
|
|
8
|
+
interface CheckoutBookingExpiredFunction {
|
|
9
|
+
(payload: CheckoutBookingExpiredPayload): CheckoutBookingExpired;
|
|
10
|
+
}
|
|
11
|
+
declare const checkoutBookingExpired: CheckoutBookingExpiredFunction;
|
|
12
|
+
export type { CheckoutBookingExpired };
|
|
13
|
+
export { CHECKOUT_BOOKING_EXPIRED, checkoutBookingExpired };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { domainEvent } from "@lookiero/messaging";
|
|
2
|
+
const CHECKOUT_BOOKING_EXPIRED = "checkout_booking_expired";
|
|
3
|
+
const checkoutBookingExpired = ({ aggregateId }) => domainEvent({ aggregateId, name: CHECKOUT_BOOKING_EXPIRED });
|
|
4
|
+
export { CHECKOUT_BOOKING_EXPIRED, checkoutBookingExpired };
|
|
@@ -2,7 +2,7 @@ import { Command } from "@lookiero/messaging";
|
|
|
2
2
|
declare const REPLACE_CHECKOUT_ITEM = "replace_checkout_item";
|
|
3
3
|
interface ReplaceCheckoutItemPayload {
|
|
4
4
|
readonly aggregateId: string;
|
|
5
|
-
readonly
|
|
5
|
+
readonly replacedForId: string;
|
|
6
6
|
}
|
|
7
7
|
interface ReplaceCheckoutItem extends Command<typeof REPLACE_CHECKOUT_ITEM>, ReplaceCheckoutItemPayload {
|
|
8
8
|
}
|
|
@@ -15,7 +15,7 @@ interface CheckoutItem extends AggregateRoot {
|
|
|
15
15
|
readonly status: CheckoutItemStatus;
|
|
16
16
|
readonly price: Price;
|
|
17
17
|
readonly feedbacks: Feedbacks;
|
|
18
|
-
readonly
|
|
18
|
+
readonly replacedForId?: string;
|
|
19
19
|
}
|
|
20
20
|
declare const keepCheckoutItemHandler: CommandHandlerFunction<KeepCheckoutItem, CheckoutItem>;
|
|
21
21
|
declare const returnCheckoutItemHandler: CommandHandlerFunction<ReturnCheckoutItem, CheckoutItem>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import invariant from "tiny-invariant";
|
|
2
1
|
import { checkoutItemKept } from "./checkoutItemKept";
|
|
3
2
|
import { checkoutItemReplaced } from "./checkoutItemReplaced";
|
|
4
3
|
import { checkoutItemReturned } from "./checkoutItemReturned";
|
|
@@ -12,7 +11,6 @@ var CheckoutItemStatus;
|
|
|
12
11
|
})(CheckoutItemStatus || (CheckoutItemStatus = {}));
|
|
13
12
|
const keepCheckoutItemHandler = () => async ({ aggregateRoot, command }) => {
|
|
14
13
|
const { aggregateId } = command;
|
|
15
|
-
invariant(aggregateRoot.status !== CheckoutItemStatus.KEPT, "CheckoutItem is already kept");
|
|
16
14
|
return {
|
|
17
15
|
...aggregateRoot,
|
|
18
16
|
status: CheckoutItemStatus.KEPT,
|
|
@@ -29,10 +27,10 @@ const returnCheckoutItemHandler = () => async ({ aggregateRoot, command }) => {
|
|
|
29
27
|
};
|
|
30
28
|
};
|
|
31
29
|
const replaceCheckoutItemHandler = () => async ({ aggregateRoot, command }) => {
|
|
32
|
-
const { aggregateId,
|
|
30
|
+
const { aggregateId, replacedForId } = command;
|
|
33
31
|
return {
|
|
34
32
|
...aggregateRoot,
|
|
35
|
-
|
|
33
|
+
replacedForId,
|
|
36
34
|
status: CheckoutItemStatus.REPLACED,
|
|
37
35
|
domainEvents: [checkoutItemReplaced({ aggregateId })],
|
|
38
36
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ interface BootstrapFunctionReturn {
|
|
|
18
18
|
readonly isCheckoutAccessible: IsCheckoutAccessibleFunction;
|
|
19
19
|
}
|
|
20
20
|
interface BootstrapFunction {
|
|
21
|
-
(args: BootstrapFunctionArgs):
|
|
21
|
+
(args: BootstrapFunctionArgs): BootstrapFunctionReturn;
|
|
22
22
|
}
|
|
23
23
|
declare const bootstrap: BootstrapFunction;
|
|
24
24
|
export { bootstrap };
|
package/dist/index.js
CHANGED
|
@@ -4,15 +4,14 @@ import { bootstrap as checkoutBootstrap } from "./infrastructure/delivery/bootst
|
|
|
4
4
|
import { root } from "./infrastructure/ui/Root";
|
|
5
5
|
import { viewIsCheckoutAccessibleByCustomerId, } from "./projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
6
6
|
import { notificationsRoot } from "./shared/notifications";
|
|
7
|
-
const bootstrap =
|
|
8
|
-
const
|
|
9
|
-
const { Component: Messaging, queryBus } = checkoutBootstrap({ apiUrl, authToken });
|
|
7
|
+
const bootstrap = ({ apiUrl, getAuthToken, translations }) => {
|
|
8
|
+
const { Component: Messaging, queryBus } = checkoutBootstrap({ apiUrl, getAuthToken });
|
|
10
9
|
const I18n = i18n({
|
|
11
10
|
fetchTranslation: fetchFetchTranslation({ endpoint: translations }),
|
|
12
11
|
contextId: "CheckoutI18n",
|
|
13
12
|
});
|
|
14
13
|
const Notifications = notificationsRoot();
|
|
15
|
-
const Root = root({ Messaging, I18n, Notifications,
|
|
14
|
+
const Root = root({ Messaging, I18n, Notifications, getAuthToken });
|
|
16
15
|
const isCheckoutAccessible = ({ customerId }) => queryBus(viewIsCheckoutAccessibleByCustomerId({ customerId }));
|
|
17
16
|
return {
|
|
18
17
|
Root,
|
|
@@ -15,6 +15,7 @@ import { CheckoutByIdView } from "../../projection/checkout/viewCheckoutById";
|
|
|
15
15
|
import { FirstAvailableCheckoutByCustomerIdView } from "../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
16
16
|
import { FiveItemsDiscountByCustomerIdView } from "../../projection/checkout/viewFiveItemsDiscountByCustomerId";
|
|
17
17
|
import { IsCheckoutEnabledByCustomerIdView } from "../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
|
|
18
|
+
import { CheckoutBookingByIdView } from "../../projection/checkoutBooking/viewCheckoutBookingById";
|
|
18
19
|
import { CheckoutItemByIdView } from "../../projection/checkoutItem/viewCheckoutItemById";
|
|
19
20
|
import { CheckoutQuestionsByCheckoutIdView } from "../../projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId";
|
|
20
21
|
import { PaymentFlowPayloadByCheckoutIdView } from "../../projection/payment/viewPaymentFlowPayloadByCheckoutId";
|
|
@@ -31,6 +32,7 @@ interface BaseBootstrapFunctionArgs<UiSettingGetFunctionArgs extends RepositoryG
|
|
|
31
32
|
readonly fiveItemsDiscountByCustomerIdView: FiveItemsDiscountByCustomerIdView;
|
|
32
33
|
readonly uiSettingByKeyView: UiSettingByKeyView;
|
|
33
34
|
readonly checkoutItemByIdView: CheckoutItemByIdView;
|
|
35
|
+
readonly checkoutBookingByIdView: CheckoutBookingByIdView;
|
|
34
36
|
readonly returnQuestionsByCheckoutItemIdView: ReturnQuestionsByCheckoutItemIdView;
|
|
35
37
|
readonly bookedSizeChangeProductsVariantsForCheckoutItemView: BookedSizeChangeProductsVariantsForCheckoutItemView;
|
|
36
38
|
readonly pricingByCheckoutIdView: PricingByCheckoutIdView;
|
|
@@ -2,8 +2,9 @@ import { bootstrap as messagingBootstrap } from "@lookiero/messaging-react";
|
|
|
2
2
|
import { MARK_CHECKOUT_AS_PAID } from "../../domain/checkout/command/markCheckoutAsPaid";
|
|
3
3
|
import { START_CHECKOUT } from "../../domain/checkout/command/startCheckout";
|
|
4
4
|
import { markCheckoutAsPaidHandler, startCheckoutHandler } from "../../domain/checkout/model/checkout";
|
|
5
|
+
import { BLOCK_CHECKOUT_BOOKING } from "../../domain/checkoutBooking/command/blockCheckoutBooking";
|
|
5
6
|
import { BOOK_CHECKOUT_BOOKING_FOR_CHECKOUT_ITEM } from "../../domain/checkoutBooking/command/bookCheckoutBookingForCheckoutItem";
|
|
6
|
-
import { bookCheckoutBookingForCheckoutItemHandler, } from "../../domain/checkoutBooking/model/checkoutBooking";
|
|
7
|
+
import { blockCheckoutBookingHandler, bookCheckoutBookingForCheckoutItemHandler, } from "../../domain/checkoutBooking/model/checkoutBooking";
|
|
7
8
|
import { GIVE_CHECKOUT_FEEDBACK } from "../../domain/checkoutFeedback/command/giveCheckoutFeedback";
|
|
8
9
|
import { giveCheckoutFeedbackHandler } from "../../domain/checkoutFeedback/model/checkoutFeedback";
|
|
9
10
|
import { KEEP_CHECKOUT_ITEM } from "../../domain/checkoutItem/command/keepCheckoutItem";
|
|
@@ -18,6 +19,7 @@ import { viewFirstAvailableCheckoutByCustomerIdHandler, VIEW_FIRST_AVAILABLE_CHE
|
|
|
18
19
|
import { viewFiveItemsDiscountByCustomerIdHandler, VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, } from "../../projection/checkout/viewFiveItemsDiscountByCustomerId";
|
|
19
20
|
import { viewIsCheckoutAccessibleByCustomerIdHandler, VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, } from "../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
20
21
|
import { viewIsCheckoutEnabledByCustomerIdHandler, VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, } from "../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
|
|
22
|
+
import { viewCheckoutBookingByIdHandler, VIEW_CHECKOUT_BOOKING_BY_ID, } from "../../projection/checkoutBooking/viewCheckoutBookingById";
|
|
21
23
|
import { viewCheckoutItemByIdHandler, VIEW_CHECKOUT_ITEM_BY_ID, } from "../../projection/checkoutItem/viewCheckoutItemById";
|
|
22
24
|
import { listCheckoutQuestionsByCheckoutIdHandler, LIST_CHECKOUT_QUESTIONS_BY_CHECKOUT_ID, } from "../../projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId";
|
|
23
25
|
import { viewPaymentFlowPayloadByCheckoutIdHandler, VIEW_PAYMENT_FLOW_PAYLOAD_BY_CHECKOUT_ID, } from "../../projection/payment/viewPaymentFlowPayloadByCheckoutId";
|
|
@@ -25,7 +27,7 @@ import { viewPricingByCheckoutIdHandler, VIEW_PRICING_BY_CHECKOUT_ID, } from "..
|
|
|
25
27
|
import { listReturnQuestionsByCheckoutItemIdHandler, LIST_RETURN_QUESTIONS_BY_CHECKOUT_ITEM_ID, } from "../../projection/returnQuestion/listReturnQuestionsByCheckoutItemId";
|
|
26
28
|
import { viewUiSettingByKeyHandler, VIEW_UI_SETTING_BY_KEY, } from "../../projection/uiSetting/viewUiSettingByKey";
|
|
27
29
|
const MESSAGING_CONTEXT_ID = "Checkout";
|
|
28
|
-
const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdView, isCheckoutEnabledByCustomerIdView, fiveItemsDiscountByCustomerIdView, uiSettingByKeyView, checkoutItemByIdView, returnQuestionsByCheckoutItemIdView, bookedSizeChangeProductsVariantsForCheckoutItemView, pricingByCheckoutIdView, paymentFlowPayloadByCheckoutIdView, checkoutQuestionsByCheckoutIdView, getUiSetting, saveUiSetting, uiSettingsDependencies, getCheckout, saveCheckout, checkoutsDependencies, getCheckoutItem, saveCheckoutItem, checkoutItemsDependencies, getCheckoutBooking, saveCheckoutBooking, checkoutBookingsDependencies, getCheckoutFeedback, saveCheckoutFeedback, checkoutFeedbacksDependencies, }) => messagingBootstrap({ id: MESSAGING_CONTEXT_ID })
|
|
30
|
+
const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdView, isCheckoutEnabledByCustomerIdView, fiveItemsDiscountByCustomerIdView, uiSettingByKeyView, checkoutItemByIdView, returnQuestionsByCheckoutItemIdView, bookedSizeChangeProductsVariantsForCheckoutItemView, checkoutBookingByIdView, pricingByCheckoutIdView, paymentFlowPayloadByCheckoutIdView, checkoutQuestionsByCheckoutIdView, getUiSetting, saveUiSetting, uiSettingsDependencies, getCheckout, saveCheckout, checkoutsDependencies, getCheckoutItem, saveCheckoutItem, checkoutItemsDependencies, getCheckoutBooking, saveCheckoutBooking, checkoutBookingsDependencies, getCheckoutFeedback, saveCheckoutFeedback, checkoutFeedbacksDependencies, }) => messagingBootstrap({ id: MESSAGING_CONTEXT_ID })
|
|
29
31
|
.query(VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, viewFiveItemsDiscountByCustomerIdHandler, {
|
|
30
32
|
view: fiveItemsDiscountByCustomerIdView,
|
|
31
33
|
})
|
|
@@ -58,11 +60,15 @@ const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdVie
|
|
|
58
60
|
})
|
|
59
61
|
.query(LIST_CHECKOUT_QUESTIONS_BY_CHECKOUT_ID, listCheckoutQuestionsByCheckoutIdHandler, {
|
|
60
62
|
view: checkoutQuestionsByCheckoutIdView,
|
|
63
|
+
})
|
|
64
|
+
.query(VIEW_CHECKOUT_BOOKING_BY_ID, viewCheckoutBookingByIdHandler, {
|
|
65
|
+
view: checkoutBookingByIdView,
|
|
61
66
|
})
|
|
62
67
|
.query(VIEW_BOOKED_SIZE_CHANGE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, viewBookedSizeChangeProductsVariantsForCheckoutItemHandler, {
|
|
63
68
|
view: bookedSizeChangeProductsVariantsForCheckoutItemView,
|
|
64
69
|
})
|
|
65
70
|
.command(BOOK_CHECKOUT_BOOKING_FOR_CHECKOUT_ITEM, bookCheckoutBookingForCheckoutItemHandler)(getCheckoutBooking, saveCheckoutBooking, ...checkoutBookingsDependencies)
|
|
71
|
+
.command(BLOCK_CHECKOUT_BOOKING, blockCheckoutBookingHandler)(getCheckoutBooking, saveCheckoutBooking, ...checkoutBookingsDependencies)
|
|
66
72
|
.command(GIVE_CHECKOUT_FEEDBACK, giveCheckoutFeedbackHandler)(getCheckoutFeedback, saveCheckoutFeedback, ...checkoutFeedbacksDependencies)
|
|
67
73
|
.query(VIEW_UI_SETTING_BY_KEY, viewUiSettingByKeyHandler, {
|
|
68
74
|
view: uiSettingByKeyView,
|
|
@@ -9,6 +9,7 @@ import { httpCheckoutByIdView } from "../projection/checkout/httpCheckoutByIdVie
|
|
|
9
9
|
import { httpFirstAvailableCheckoutByCustomerIdView } from "../projection/checkout/httpFirstAvailableCheckoutByCustomerIdView";
|
|
10
10
|
import { httpFiveItemsDiscountByCustomerIdView } from "../projection/checkout/httpFiveItemsDiscountByCustomerIdView";
|
|
11
11
|
import { httpIsCheckoutEnabledByCustomerIdView } from "../projection/checkout/httpIsCheckoutEnabledByCustomerIdView";
|
|
12
|
+
import { httpCheckoutBookingByIdView } from "../projection/checkoutBooking/httpCheckoutBookingByIdView";
|
|
12
13
|
import { httpCheckoutItemByIdView } from "../projection/checkoutItem/httpCheckoutItemByIdView";
|
|
13
14
|
import { httpCheckoutQuestionsByCheckoutIdView } from "../projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView";
|
|
14
15
|
import { httpPaymentFlowPayloadByCheckoutIdView } from "../projection/payment/httpPaymentFlowPayloadByCheckoutIdView";
|
|
@@ -17,9 +18,9 @@ import { httpReturnQuestionsByCheckoutItemIdView } from "../projection/returnQue
|
|
|
17
18
|
import { storageUiSettingByKeyView } from "../projection/uiSetting/storageUiSettingByKeyView";
|
|
18
19
|
import { baseBootstrap } from "./baseBootstrap";
|
|
19
20
|
import { fetchHttpGet, fetchHttpPost } from "./http/fetchHttpClient";
|
|
20
|
-
const bootstrap = ({ apiUrl,
|
|
21
|
-
const httpGet = fetchHttpGet({ apiUrl,
|
|
22
|
-
const httpPost = fetchHttpPost({ apiUrl,
|
|
21
|
+
const bootstrap = ({ apiUrl, getAuthToken }) => {
|
|
22
|
+
const httpGet = fetchHttpGet({ apiUrl, getAuthToken });
|
|
23
|
+
const httpPost = fetchHttpPost({ apiUrl, getAuthToken });
|
|
23
24
|
return baseBootstrap({
|
|
24
25
|
checkoutByIdView: httpCheckoutByIdView({ httpPost }),
|
|
25
26
|
firstAvailableCheckoutByCustomerIdView: httpFirstAvailableCheckoutByCustomerIdView({ httpPost }),
|
|
@@ -28,6 +29,7 @@ const bootstrap = ({ apiUrl, authToken }) => {
|
|
|
28
29
|
uiSettingByKeyView: storageUiSettingByKeyView({ read }),
|
|
29
30
|
checkoutItemByIdView: httpCheckoutItemByIdView({ httpPost }),
|
|
30
31
|
returnQuestionsByCheckoutItemIdView: httpReturnQuestionsByCheckoutItemIdView({ httpPost }),
|
|
32
|
+
checkoutBookingByIdView: httpCheckoutBookingByIdView({ httpPost }),
|
|
31
33
|
bookedSizeChangeProductsVariantsForCheckoutItemView: httpBookedSizeChangeProductsVariantsForCheckoutItemView({
|
|
32
34
|
httpPost,
|
|
33
35
|
}),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HttpGetFunction, HttpPostFunction } from "./httpClient";
|
|
2
2
|
interface FetchHttpFunctionArgs {
|
|
3
3
|
readonly apiUrl: string;
|
|
4
|
-
readonly
|
|
4
|
+
readonly getAuthToken: () => Promise<string>;
|
|
5
5
|
}
|
|
6
6
|
interface FetchHttpPostFunction {
|
|
7
7
|
(args: FetchHttpFunctionArgs): HttpPostFunction;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
const fetchHttpPost = ({ apiUrl,
|
|
1
|
+
const fetchHttpPost = ({ apiUrl, getAuthToken }) => async ({ endpoint, body, signal }) => fetch(`${apiUrl}${endpoint}`, {
|
|
2
2
|
method: "POST",
|
|
3
3
|
headers: {
|
|
4
4
|
["Content-Type"]: "application/json",
|
|
5
|
-
authorization: `Bearer ${
|
|
5
|
+
authorization: `Bearer ${await getAuthToken()}`,
|
|
6
6
|
},
|
|
7
7
|
body: JSON.stringify(body),
|
|
8
8
|
signal,
|
|
9
9
|
});
|
|
10
|
-
const fetchHttpGet = ({ apiUrl,
|
|
10
|
+
const fetchHttpGet = ({ apiUrl, getAuthToken }) => async ({ endpoint, signal }) => fetch(`${apiUrl}${endpoint}`, {
|
|
11
11
|
method: "GET",
|
|
12
12
|
credentials: "include",
|
|
13
13
|
headers: {
|
|
14
|
-
Authorization: `Bearer ${
|
|
14
|
+
Authorization: `Bearer ${await getAuthToken()}`,
|
|
15
15
|
["Content-Type"]: "application/json",
|
|
16
16
|
},
|
|
17
17
|
referrer: "",
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import invariant from "tiny-invariant";
|
|
2
|
+
import { v4 as uuid } from "uuid";
|
|
3
|
+
import { CheckoutStatus } from "../../../domain/checkout/model/checkout";
|
|
2
4
|
import { viewBookedSizeChangeProductsVariantsForCheckoutItem, } from "../../../projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem";
|
|
3
5
|
const toCheckoutBookingDomain = (checkoutBooking) => {
|
|
4
6
|
invariant(checkoutBooking, "No checkoutBooking found!");
|
|
5
7
|
return {
|
|
6
|
-
aggregateId:
|
|
8
|
+
aggregateId: uuid(),
|
|
7
9
|
checkoutItemIds: checkoutBooking.productVariants.map((productVariant) => productVariant.id),
|
|
10
|
+
checkoutStatus: CheckoutStatus.AVAILABLE,
|
|
8
11
|
domainEvents: [],
|
|
9
12
|
};
|
|
10
13
|
};
|
|
11
14
|
const toCheckoutBookingProjection = (checkoutBooking) => ({
|
|
12
15
|
id: checkoutBooking.aggregateId,
|
|
13
16
|
checkoutItemIds: checkoutBooking.checkoutItemIds,
|
|
17
|
+
checkoutStatus: checkoutBooking.checkoutStatus,
|
|
14
18
|
});
|
|
15
19
|
const getCheckoutBooking = ({ queryBus }) => async (aggregateId) => toCheckoutBookingDomain(await queryBus(viewBookedSizeChangeProductsVariantsForCheckoutItem({ checkoutItemId: aggregateId })));
|
|
16
20
|
const saveCheckoutBooking = ({ dataSource }) => async (aggregateRoot) => {
|
|
@@ -5,6 +5,7 @@ const toCheckoutItemProjection = (checkoutItem) => ({
|
|
|
5
5
|
status: checkoutItem.status,
|
|
6
6
|
productVariant: {},
|
|
7
7
|
feedbacks: {},
|
|
8
|
+
replacedFor: null,
|
|
8
9
|
price: checkoutItem.price,
|
|
9
10
|
});
|
|
10
11
|
const toCheckoutItemDomain = (checkoutItem) => {
|
|
@@ -15,6 +16,7 @@ const toCheckoutItemDomain = (checkoutItem) => {
|
|
|
15
16
|
status: checkoutItem.status,
|
|
16
17
|
price: checkoutItem.price,
|
|
17
18
|
feedbacks: checkoutItem.feedbacks,
|
|
19
|
+
replacedForId: checkoutItem.replacedFor?.id,
|
|
18
20
|
domainEvents: [],
|
|
19
21
|
};
|
|
20
22
|
};
|
|
@@ -7,7 +7,7 @@ const toCheckoutDomain = (checkout) => {
|
|
|
7
7
|
status: checkout.status,
|
|
8
8
|
customerId: checkout.customerId,
|
|
9
9
|
boxId: checkout.boxId,
|
|
10
|
-
|
|
10
|
+
checkoutBookingId: checkout.checkoutBookingId,
|
|
11
11
|
expiresOn: checkout.expiresOn,
|
|
12
12
|
aggregateId: checkout.id,
|
|
13
13
|
domainEvents: [],
|
|
@@ -18,7 +18,7 @@ const toCheckoutProjection = (checkout) => ({
|
|
|
18
18
|
status: checkout.status,
|
|
19
19
|
customerId: checkout.customerId,
|
|
20
20
|
boxId: checkout.boxId,
|
|
21
|
-
|
|
21
|
+
checkoutBookingId: checkout.checkoutBookingId,
|
|
22
22
|
expiresOn: checkout.expiresOn,
|
|
23
23
|
items: [],
|
|
24
24
|
});
|
|
@@ -9,7 +9,7 @@ const toDomain = (checkout) => {
|
|
|
9
9
|
status: checkout.status,
|
|
10
10
|
customerId: checkout.customerId,
|
|
11
11
|
boxId: checkout.boxId,
|
|
12
|
-
|
|
12
|
+
checkoutBookingId: checkout.checkoutBookingId,
|
|
13
13
|
expiresOn: checkout.expiresOn,
|
|
14
14
|
aggregateId: checkout.id,
|
|
15
15
|
domainEvents: [],
|
|
@@ -7,7 +7,7 @@ const useMarkCheckoutAsPaid = ({ checkoutId }) => {
|
|
|
7
7
|
const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
|
|
8
8
|
const markAsPaid = useCallback(() => {
|
|
9
9
|
invariant(checkoutId, "CheckoutId must be defined in order to mark the checkout as paid");
|
|
10
|
-
commandBus(markCheckoutAsPaid({
|
|
10
|
+
return commandBus(markCheckoutAsPaid({
|
|
11
11
|
aggregateId: checkoutId,
|
|
12
12
|
}));
|
|
13
13
|
}, [checkoutId, commandBus]);
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import invariant from "tiny-invariant";
|
|
2
2
|
import { viewCheckoutBookingById, } from "../../../../projection/checkoutBooking/viewCheckoutBookingById";
|
|
3
|
+
import { httpCheckoutBookingsBlock } from "./httpCheckoutBookingsBlock";
|
|
3
4
|
import { httpCheckoutBookingsBook } from "./httpCheckoutBookingsBook";
|
|
4
5
|
const toDomain = (checkoutBooking) => {
|
|
5
6
|
invariant(checkoutBooking, "No checkout booking found!");
|
|
6
7
|
return {
|
|
7
|
-
checkoutItemIds: checkoutBooking.checkoutItemIds,
|
|
8
8
|
aggregateId: checkoutBooking.id,
|
|
9
|
+
checkoutItemIds: checkoutBooking.checkoutItemIds,
|
|
10
|
+
checkoutStatus: checkoutBooking.checkoutStatus,
|
|
9
11
|
domainEvents: [],
|
|
10
12
|
};
|
|
11
13
|
};
|
|
12
14
|
const getCheckoutBooking = ({ queryBus }) => async (aggregateId) => toDomain(await queryBus(viewCheckoutBookingById({ checkoutBookingId: aggregateId })));
|
|
13
|
-
const saveCheckoutBooking = ({ httpPost }) => async (aggregateRoot) =>
|
|
15
|
+
const saveCheckoutBooking = ({ httpPost }) => async (aggregateRoot) => {
|
|
16
|
+
await Promise.all([
|
|
17
|
+
httpCheckoutBookingsBook({ httpPost })(aggregateRoot),
|
|
18
|
+
httpCheckoutBookingsBlock({ httpPost })(aggregateRoot),
|
|
19
|
+
]);
|
|
20
|
+
};
|
|
14
21
|
export { getCheckoutBooking, saveCheckoutBooking };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { HttpCheckoutBookingsSaveFunction } from "./httpCheckoutBookings";
|
|
2
|
+
interface HttpCheckoutBookingsBlockFunction extends HttpCheckoutBookingsSaveFunction {
|
|
3
|
+
}
|
|
4
|
+
declare const httpCheckoutBookingsBlock: HttpCheckoutBookingsBlockFunction;
|
|
5
|
+
export { httpCheckoutBookingsBlock };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CHECKOUT_BOOKING_BLOCKED, } from "../../../../domain/checkoutBooking/model/checkoutBookingBlocked";
|
|
2
|
+
const isCheckoutBookingBlocked = (event) => event.name === CHECKOUT_BOOKING_BLOCKED;
|
|
3
|
+
const httpCheckoutBookingsBlock = ({ httpPost }) => async ({ aggregateId, domainEvents }) => {
|
|
4
|
+
const checkoutBookingBlocked = domainEvents.find(isCheckoutBookingBlocked);
|
|
5
|
+
if (!checkoutBookingBlocked) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
await httpPost({
|
|
9
|
+
endpoint: "/block-checkout-booking",
|
|
10
|
+
body: {
|
|
11
|
+
checkoutBookingId: aggregateId,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
export { httpCheckoutBookingsBlock };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
|
+
interface BlockCheckoutBookingFunction {
|
|
3
|
+
(): Promise<void>;
|
|
4
|
+
}
|
|
5
|
+
type UseBlockCheckoutBooking = [blockCheckoutBooking: BlockCheckoutBookingFunction, status: CommandStatus];
|
|
6
|
+
interface UseBlockCheckoutBookingFunctionArgs {
|
|
7
|
+
readonly checkoutBookingId: string;
|
|
8
|
+
}
|
|
9
|
+
interface UseBlockCheckoutBookingFunction {
|
|
10
|
+
(args: UseBlockCheckoutBookingFunctionArgs): UseBlockCheckoutBooking;
|
|
11
|
+
}
|
|
12
|
+
declare const useBlockCheckoutBooking: UseBlockCheckoutBookingFunction;
|
|
13
|
+
export { useBlockCheckoutBooking };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useCommand } from "@lookiero/messaging-react";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { blockCheckoutBooking as blockCheckoutBookingCommand } from "../../../../domain/checkoutBooking/command/blockCheckoutBooking";
|
|
4
|
+
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
5
|
+
const useBlockCheckoutBooking = ({ checkoutBookingId }) => {
|
|
6
|
+
const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
|
|
7
|
+
const blockCheckoutBooking = useCallback(() => commandBus(blockCheckoutBookingCommand({
|
|
8
|
+
aggregateId: checkoutBookingId,
|
|
9
|
+
})), [checkoutBookingId, commandBus]);
|
|
10
|
+
return [blockCheckoutBooking, status];
|
|
11
|
+
};
|
|
12
|
+
export { useBlockCheckoutBooking };
|
package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckoutBookingForCheckoutItem.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
|
+
interface BookFunction {
|
|
3
|
+
(): Promise<void>;
|
|
4
|
+
}
|
|
5
|
+
type UseBookCheckoutBookingForCheckoutItem = [book: BookFunction, status: CommandStatus];
|
|
6
|
+
interface UseBookCheckoutBookingForCheckoutItemFunctionArgs {
|
|
7
|
+
readonly checkoutItemId: string;
|
|
8
|
+
readonly checkoutBookingId: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
interface UseBookCheckoutBookingForCheckoutItemFunction {
|
|
11
|
+
(args: UseBookCheckoutBookingForCheckoutItemFunctionArgs): UseBookCheckoutBookingForCheckoutItem;
|
|
12
|
+
}
|
|
13
|
+
declare const useBookCheckoutBookingForCheckoutItem: UseBookCheckoutBookingForCheckoutItemFunction;
|
|
14
|
+
export { useBookCheckoutBookingForCheckoutItem };
|
|
@@ -3,12 +3,12 @@ import { useCallback } from "react";
|
|
|
3
3
|
import { v4 as uuid } from "uuid";
|
|
4
4
|
import { bookCheckoutBookingForCheckoutItem } from "../../../../domain/checkoutBooking/command/bookCheckoutBookingForCheckoutItem";
|
|
5
5
|
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
6
|
-
const
|
|
6
|
+
const useBookCheckoutBookingForCheckoutItem = ({ checkoutItemId, checkoutBookingId, }) => {
|
|
7
7
|
const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
|
|
8
8
|
const book = useCallback(() => commandBus(bookCheckoutBookingForCheckoutItem({
|
|
9
|
-
aggregateId: uuid(),
|
|
9
|
+
aggregateId: checkoutBookingId || uuid(),
|
|
10
10
|
checkoutItemId,
|
|
11
|
-
})), [checkoutItemId, commandBus]);
|
|
11
|
+
})), [checkoutBookingId, checkoutItemId, commandBus]);
|
|
12
12
|
return [book, status];
|
|
13
13
|
};
|
|
14
|
-
export {
|
|
14
|
+
export { useBookCheckoutBookingForCheckoutItem };
|
|
@@ -10,7 +10,7 @@ const toDomain = (checkoutItem) => {
|
|
|
10
10
|
status: checkoutItem.status,
|
|
11
11
|
price: checkoutItem.price,
|
|
12
12
|
feedbacks: checkoutItem.feedbacks,
|
|
13
|
-
|
|
13
|
+
replacedForId: checkoutItem.replacedFor?.id,
|
|
14
14
|
aggregateId: checkoutItem.id,
|
|
15
15
|
domainEvents: [],
|
|
16
16
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { CHECKOUT_ITEM_REPLACED, } from "../../../../domain/checkoutItem/model/checkoutItemReplaced";
|
|
2
2
|
const isCheckoutItemReplaced = (event) => event.name === CHECKOUT_ITEM_REPLACED;
|
|
3
|
-
const httpCheckoutItemsReplace = ({ httpPost }) => async ({ aggregateId,
|
|
3
|
+
const httpCheckoutItemsReplace = ({ httpPost }) => async ({ aggregateId, replacedForId, domainEvents }) => {
|
|
4
4
|
const checkoutItemReplaced = domainEvents.find(isCheckoutItemReplaced);
|
|
5
5
|
if (!checkoutItemReplaced) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
8
|
await httpPost({
|
|
9
9
|
endpoint: "/replace-checkout-item",
|
|
10
|
-
body: { checkoutItemId: aggregateId, replacedFor },
|
|
10
|
+
body: { checkoutItemId: aggregateId, replacedFor: replacedForId },
|
|
11
11
|
});
|
|
12
12
|
};
|
|
13
13
|
export { httpCheckoutItemsReplace };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
2
|
interface ReplaceCheckoutItemFunctionArgs {
|
|
3
|
-
readonly
|
|
3
|
+
readonly replacedForId: string;
|
|
4
4
|
}
|
|
5
5
|
interface ReplaceCheckoutItemFunction {
|
|
6
6
|
(args: ReplaceCheckoutItemFunctionArgs): Promise<void>;
|
|
@@ -4,9 +4,9 @@ import { replaceCheckoutItem } from "../../../../domain/checkoutItem/command/rep
|
|
|
4
4
|
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
5
5
|
const useReplaceCheckoutItem = ({ checkoutItemId }) => {
|
|
6
6
|
const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
|
|
7
|
-
const replace = useCallback(({
|
|
7
|
+
const replace = useCallback(({ replacedForId }) => commandBus(replaceCheckoutItem({
|
|
8
8
|
aggregateId: checkoutItemId,
|
|
9
|
-
|
|
9
|
+
replacedForId,
|
|
10
10
|
})), [checkoutItemId, commandBus]);
|
|
11
11
|
return [replace, status];
|
|
12
12
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const httpBookedSizeChangeProductsVariantsForCheckoutItemView = ({ httpPost }) => async ({ checkoutItemId, signal }) => {
|
|
2
2
|
const response = await httpPost({
|
|
3
|
-
endpoint: "/view-booked-
|
|
3
|
+
endpoint: "/view-booked-product-variants-for-checkout-item",
|
|
4
4
|
body: { checkoutItemId },
|
|
5
5
|
signal,
|
|
6
6
|
});
|
|
@@ -5,7 +5,7 @@ interface CheckoutDto {
|
|
|
5
5
|
readonly id: string;
|
|
6
6
|
readonly customerId: string;
|
|
7
7
|
readonly boxId: string;
|
|
8
|
-
readonly
|
|
8
|
+
readonly checkoutBookingId: string;
|
|
9
9
|
readonly status: CheckoutStatus;
|
|
10
10
|
readonly expiresOn: string;
|
|
11
11
|
readonly items: CheckoutItemProjection[];
|