@lookiero/checkout 0.2.39 → 0.2.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/domain/checkoutItem/command/returnCheckoutItem.d.ts +15 -0
  2. package/dist/domain/checkoutItem/command/returnCheckoutItem.js +7 -0
  3. package/dist/domain/checkoutItem/model/checkoutItem.d.ts +5 -1
  4. package/dist/domain/checkoutItem/model/checkoutItem.js +11 -1
  5. package/dist/domain/checkoutItem/model/checkoutItemReturned.d.ts +13 -0
  6. package/dist/domain/checkoutItem/model/checkoutItemReturned.js +4 -0
  7. package/dist/domain/checkoutItem/model/feedbacks.d.ts +3 -0
  8. package/dist/domain/checkoutItem/model/feedbacks.js +1 -0
  9. package/dist/infrastructure/delivery/baseBootstrap.js +3 -1
  10. package/dist/infrastructure/delivery/http/fetchHttpClient.js +2 -1
  11. package/dist/infrastructure/delivery/mock/dataSourceCheckoutItems.js +2 -1
  12. package/dist/infrastructure/domain/checkout/model/httpCheckoutsStart.js +1 -1
  13. package/dist/infrastructure/domain/checkoutBooking/model/httpCheckoutBookingsBook.js +4 -4
  14. package/dist/infrastructure/domain/checkoutItem/model/httpCheckoutItems.js +7 -2
  15. package/dist/infrastructure/domain/checkoutItem/model/httpCheckoutItemsKeep.js +1 -1
  16. package/dist/infrastructure/domain/checkoutItem/model/httpCheckoutItemsReturn.d.ts +5 -0
  17. package/dist/infrastructure/domain/checkoutItem/model/httpCheckoutItemsReturn.js +13 -0
  18. package/dist/infrastructure/domain/checkoutItem/react/useReturnCheckoutItem.d.ts +17 -0
  19. package/dist/infrastructure/domain/checkoutItem/react/useReturnCheckoutItem.js +13 -0
  20. package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/httpBookedSizeChangeProductsVariantsForCheckoutItemView.js +1 -4
  21. package/dist/infrastructure/projection/checkout/checkout.d.ts +6 -6
  22. package/dist/infrastructure/projection/checkout/checkout.js +2 -45
  23. package/dist/infrastructure/projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId.js +5 -0
  24. package/dist/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.js +1 -2
  25. package/dist/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.js +2 -3
  26. package/dist/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.js +2 -3
  27. package/dist/infrastructure/ui/shared/components/molecules/inputField/InputField.style.js +2 -2
  28. package/dist/infrastructure/ui/views/item/Item.js +4 -4
  29. package/dist/infrastructure/ui/views/item/components/banner/CustomerDecissionBanner.d.ts +3 -2
  30. package/dist/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.d.ts +1 -1
  31. package/dist/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.js +3 -2
  32. package/dist/projection/checkoutItem/checkoutItem.d.ts +1 -1
  33. package/package.json +1 -1
  34. package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants.d.ts +0 -27
  35. package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants.js +0 -21
  36. package/dist/infrastructure/projection/checkoutBooking/checkoutBooking.d.ts +0 -12
  37. package/dist/infrastructure/projection/checkoutBooking/checkoutBooking.js +0 -6
  38. package/dist/infrastructure/projection/checkoutItem/checkoutItem.d.ts +0 -45
  39. package/dist/infrastructure/projection/checkoutItem/checkoutItem.js +0 -40
  40. package/dist/infrastructure/projection/returnQuestion/returnQuestion.d.ts +0 -14
  41. package/dist/infrastructure/projection/returnQuestion/returnQuestion.js +0 -9
@@ -0,0 +1,15 @@
1
+ import { Command } from "@lookiero/messaging";
2
+ import { Feedbacks } from "../model/feedbacks";
3
+ declare const RETURN_CHECKOUT_ITEM = "return_checkout_item";
4
+ interface ReturnCheckoutItemPayload {
5
+ readonly aggregateId: string;
6
+ readonly feedbacks: Feedbacks;
7
+ }
8
+ interface ReturnCheckoutItem extends Command<typeof RETURN_CHECKOUT_ITEM>, ReturnCheckoutItemPayload {
9
+ }
10
+ interface ReturnCheckoutItemFunction {
11
+ (payload: ReturnCheckoutItemPayload): ReturnCheckoutItem;
12
+ }
13
+ declare const returnCheckoutItem: ReturnCheckoutItemFunction;
14
+ export type { ReturnCheckoutItem };
15
+ export { RETURN_CHECKOUT_ITEM, returnCheckoutItem };
@@ -0,0 +1,7 @@
1
+ import { command } from "@lookiero/messaging";
2
+ const RETURN_CHECKOUT_ITEM = "return_checkout_item";
3
+ const returnCheckoutItem = ({ aggregateId, ...payload }) => ({
4
+ ...command({ aggregateId, name: RETURN_CHECKOUT_ITEM }),
5
+ ...payload,
6
+ });
7
+ export { RETURN_CHECKOUT_ITEM, returnCheckoutItem };
@@ -1,5 +1,7 @@
1
1
  import { AggregateRoot, CommandHandlerFunction } from "@lookiero/messaging";
2
2
  import { KeepCheckoutItem } from "../command/keepCheckoutItem";
3
+ import { ReturnCheckoutItem } from "../command/returnCheckoutItem";
4
+ import { Feedbacks } from "./feedbacks";
3
5
  import { Price } from "./price";
4
6
  declare enum CheckoutItemStatus {
5
7
  INITIAL = "INITIAL",
@@ -11,7 +13,9 @@ declare enum CheckoutItemStatus {
11
13
  interface CheckoutItem extends AggregateRoot {
12
14
  readonly status: CheckoutItemStatus;
13
15
  readonly price: Price;
16
+ readonly feedbacks: Feedbacks;
14
17
  }
15
18
  declare const keepCheckoutItemHandler: CommandHandlerFunction<KeepCheckoutItem, CheckoutItem>;
19
+ declare const returnCheckoutItemHandler: CommandHandlerFunction<ReturnCheckoutItem, CheckoutItem>;
16
20
  export type { CheckoutItem };
17
- export { CheckoutItemStatus, keepCheckoutItemHandler };
21
+ export { CheckoutItemStatus, keepCheckoutItemHandler, returnCheckoutItemHandler };
@@ -1,5 +1,6 @@
1
1
  import invariant from "tiny-invariant";
2
2
  import { checkoutItemKept } from "./checkoutItemKept";
3
+ import { checkoutItemReturned } from "./checkoutItemReturned";
3
4
  var CheckoutItemStatus;
4
5
  (function (CheckoutItemStatus) {
5
6
  CheckoutItemStatus["INITIAL"] = "INITIAL";
@@ -17,4 +18,13 @@ const keepCheckoutItemHandler = () => async ({ aggregateRoot, command }) => {
17
18
  domainEvents: [checkoutItemKept({ aggregateId })],
18
19
  };
19
20
  };
20
- export { CheckoutItemStatus, keepCheckoutItemHandler };
21
+ const returnCheckoutItemHandler = () => async ({ aggregateRoot, command }) => {
22
+ const { aggregateId } = command;
23
+ invariant(aggregateRoot.status !== CheckoutItemStatus.RETURNED, "CheckoutItem is already returned");
24
+ return {
25
+ ...aggregateRoot,
26
+ status: CheckoutItemStatus.RETURNED,
27
+ domainEvents: [checkoutItemReturned({ aggregateId })],
28
+ };
29
+ };
30
+ export { CheckoutItemStatus, keepCheckoutItemHandler, returnCheckoutItemHandler };
@@ -0,0 +1,13 @@
1
+ import { DomainEvent } from "@lookiero/messaging";
2
+ declare const CHECKOUT_ITEM_RETURNED = "checkout_item_returned";
3
+ interface CheckoutItemReturnedPayload {
4
+ readonly aggregateId: string;
5
+ }
6
+ interface CheckoutItemReturned extends DomainEvent<typeof CHECKOUT_ITEM_RETURNED>, CheckoutItemReturnedPayload {
7
+ }
8
+ interface CheckoutItemReturnedFunction {
9
+ (payload: CheckoutItemReturnedPayload): CheckoutItemReturned;
10
+ }
11
+ declare const checkoutItemReturned: CheckoutItemReturnedFunction;
12
+ export type { CheckoutItemReturned };
13
+ export { CHECKOUT_ITEM_RETURNED, checkoutItemReturned };
@@ -0,0 +1,4 @@
1
+ import { domainEvent } from "@lookiero/messaging";
2
+ const CHECKOUT_ITEM_RETURNED = "checkout_item_returned";
3
+ const checkoutItemReturned = ({ aggregateId }) => domainEvent({ aggregateId, name: CHECKOUT_ITEM_RETURNED });
4
+ export { CHECKOUT_ITEM_RETURNED, checkoutItemReturned };
@@ -0,0 +1,3 @@
1
+ declare type ReturnQuestionId = string;
2
+ declare type Feedbacks = Record<ReturnQuestionId, ReturnQuestionId | string>;
3
+ export type { Feedbacks };
@@ -0,0 +1 @@
1
+ export {};
@@ -4,7 +4,8 @@ import { startCheckoutHandler } from "../../domain/checkout/model/checkout";
4
4
  import { BOOK_CHECKOUT_BOOKING_FOR_CHECKOUT_ITEM } from "../../domain/checkoutBooking/command/bookCheckoutBookingForCheckoutItem";
5
5
  import { bookCheckoutBookingForCheckoutItemHandler, } from "../../domain/checkoutBooking/model/checkoutBooking";
6
6
  import { KEEP_CHECKOUT_ITEM } from "../../domain/checkoutItem/command/keepCheckoutItem";
7
- import { keepCheckoutItemHandler } from "../../domain/checkoutItem/model/checkoutItem";
7
+ import { RETURN_CHECKOUT_ITEM } from "../../domain/checkoutItem/command/returnCheckoutItem";
8
+ import { keepCheckoutItemHandler, returnCheckoutItemHandler, } from "../../domain/checkoutItem/model/checkoutItem";
8
9
  import { UPDATE_UI_SETTING } from "../../domain/uiSetting/command/updateUiSetting";
9
10
  import { updateUiSettingHandler } from "../../domain/uiSetting/model/uiSetting";
10
11
  import { viewBookedSizeChangeProductsVariantsForCheckoutItemHandler, VIEW_BOOKED_SIZE_CHANGE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, } from "../../projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem";
@@ -39,6 +40,7 @@ const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdVie
39
40
  view: returnQuestionsByCheckoutItemIdView,
40
41
  })
41
42
  .command(KEEP_CHECKOUT_ITEM, keepCheckoutItemHandler)(getCheckoutItem, saveCheckoutItem, ...checkoutItemsDependencies)
43
+ .command(RETURN_CHECKOUT_ITEM, returnCheckoutItemHandler)(getCheckoutItem, saveCheckoutItem, ...checkoutItemsDependencies)
42
44
  .query(VIEW_BOOKED_SIZE_CHANGE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, viewBookedSizeChangeProductsVariantsForCheckoutItemHandler, {
43
45
  view: bookedSizeChangeProductsVariantsForCheckoutItemView,
44
46
  })
@@ -11,7 +11,8 @@ const fetchHttpGet = ({ apiUrl, getAuthToken }) => async ({ endpoint, signal })
11
11
  method: "GET",
12
12
  credentials: "include",
13
13
  headers: {
14
- authorization: `Bearer ${await getAuthToken()}`,
14
+ Authorization: `Bearer ${await getAuthToken()}`,
15
+ ["Content-Type"]: "application/json",
15
16
  },
16
17
  referrer: "",
17
18
  signal,
@@ -10,10 +10,11 @@ const toCheckoutItemProjection = (checkoutItem) => ({
10
10
  const toCheckoutItemDomain = (checkoutItem) => {
11
11
  invariant(checkoutItem, "No checkoutItem found!");
12
12
  return {
13
+ aggregateId: checkoutItem.id,
13
14
  id: checkoutItem.id,
14
15
  status: checkoutItem.status,
15
- aggregateId: checkoutItem.id,
16
16
  price: checkoutItem.price,
17
+ feedbacks: checkoutItem.feedback,
17
18
  domainEvents: [],
18
19
  };
19
20
  };
@@ -7,7 +7,7 @@ const httpCheckoutsStart = ({ httpPost }) => async ({ aggregateId, domainEvents
7
7
  }
8
8
  httpPost({
9
9
  endpoint: "/start-checkout",
10
- body: { checkout_id: aggregateId },
10
+ body: { checkoutId: aggregateId },
11
11
  });
12
12
  };
13
13
  export { httpCheckoutsStart };
@@ -7,11 +7,11 @@ const httpCheckoutBookingsBook = ({ httpPost }) => async ({ aggregateId, checkou
7
7
  }
8
8
  const { checkoutItemId } = checkoutBookingBooked;
9
9
  httpPost({
10
- endpoint: "/book-size-replaceable-product-variants-for-checkout-item",
10
+ endpoint: "/book-size-change-product-variants-for-checkout-item",
11
11
  body: {
12
- checkout_id: checkoutId,
13
- checkout_item_id: checkoutItemId,
14
- checkout_booking_id: aggregateId,
12
+ checkoutId,
13
+ checkoutItemId,
14
+ checkoutBookingId: aggregateId,
15
15
  },
16
16
  });
17
17
  };
@@ -1,18 +1,23 @@
1
1
  import invariant from "tiny-invariant";
2
2
  import { viewCheckoutItemById, } from "../../../../projection/checkoutItem/viewCheckoutItemById";
3
3
  import { httpCheckoutItemsKeep } from "./httpCheckoutItemsKeep";
4
+ import { httpCheckoutItemsReturn } from "./httpCheckoutItemsReturn";
4
5
  const toDomain = (checkoutItem) => {
5
6
  invariant(checkoutItem, "No checkoutItem found!");
6
7
  return {
7
8
  id: checkoutItem.id,
8
9
  status: checkoutItem.status,
9
- aggregateId: checkoutItem.id,
10
10
  price: checkoutItem.price,
11
+ feedbacks: checkoutItem.feedback,
12
+ aggregateId: checkoutItem.id,
11
13
  domainEvents: [],
12
14
  };
13
15
  };
14
16
  const getCheckoutItem = ({ queryBus }) => async (aggregateId) => toDomain(await queryBus(viewCheckoutItemById({ checkoutItemId: aggregateId })));
15
17
  const saveCheckoutItem = ({ httpPost }) => async (aggregateRoot) => {
16
- await httpCheckoutItemsKeep({ httpPost })(aggregateRoot);
18
+ await Promise.all([
19
+ httpCheckoutItemsKeep({ httpPost })(aggregateRoot),
20
+ httpCheckoutItemsReturn({ httpPost })(aggregateRoot),
21
+ ]);
17
22
  };
18
23
  export { getCheckoutItem, saveCheckoutItem };
@@ -7,7 +7,7 @@ const httpCheckoutItemsKeep = ({ httpPost }) => async ({ aggregateId, domainEven
7
7
  }
8
8
  httpPost({
9
9
  endpoint: "/keep-checkout-item",
10
- body: { checkout_item_id: aggregateId },
10
+ body: { checkoutItemId: aggregateId },
11
11
  });
12
12
  };
13
13
  export { httpCheckoutItemsKeep };
@@ -0,0 +1,5 @@
1
+ import { HttpCheckoutItemsSaveFunction } from "./httpCheckoutItems";
2
+ interface HttpCheckoutItemsReturnFunction extends HttpCheckoutItemsSaveFunction {
3
+ }
4
+ declare const httpCheckoutItemsReturn: HttpCheckoutItemsReturnFunction;
5
+ export { httpCheckoutItemsReturn };
@@ -0,0 +1,13 @@
1
+ import { CHECKOUT_ITEM_RETURNED, } from "../../../../domain/checkoutItem/model/checkoutItemReturned";
2
+ const isCheckoutItemReturned = (event) => event.name === CHECKOUT_ITEM_RETURNED;
3
+ const httpCheckoutItemsReturn = ({ httpPost }) => async ({ aggregateId, feedbacks, domainEvents }) => {
4
+ const checkoutItemReturned = domainEvents.find(isCheckoutItemReturned);
5
+ if (!checkoutItemReturned) {
6
+ return;
7
+ }
8
+ httpPost({
9
+ endpoint: "/return-checkout-item",
10
+ body: { checkoutItemId: aggregateId, feedbacks },
11
+ });
12
+ };
13
+ export { httpCheckoutItemsReturn };
@@ -0,0 +1,17 @@
1
+ import { CommandStatus } from "@lookiero/messaging-react";
2
+ import { Feedbacks } from "../../../../domain/checkoutItem/model/feedbacks";
3
+ interface ReturnCheckoutItemFunctionArgs {
4
+ readonly feedbacks: Feedbacks;
5
+ }
6
+ interface ReturnCheckoutItemFunction {
7
+ (args: ReturnCheckoutItemFunctionArgs): Promise<void>;
8
+ }
9
+ interface UseReturnCheckoutItemFunctionArgs {
10
+ readonly checkoutItemId: string;
11
+ }
12
+ declare type UseReturnCheckoutItemResult = [returnCheckoutItem: ReturnCheckoutItemFunction, status: CommandStatus];
13
+ interface UseReturnCheckoutItemFunction {
14
+ (args: UseReturnCheckoutItemFunctionArgs): UseReturnCheckoutItemResult;
15
+ }
16
+ declare const useReturnCheckoutItem: UseReturnCheckoutItemFunction;
17
+ export { useReturnCheckoutItem };
@@ -0,0 +1,13 @@
1
+ import { useCommand } from "@lookiero/messaging-react";
2
+ import { useCallback } from "react";
3
+ import { returnCheckoutItem as returnCheckoutItemCommand } from "../../../../domain/checkoutItem/command/returnCheckoutItem";
4
+ import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
5
+ const useReturnCheckoutItem = ({ checkoutItemId }) => {
6
+ const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
7
+ const returnCheckoutItem = useCallback(async ({ feedbacks }) => await commandBus(returnCheckoutItemCommand({
8
+ aggregateId: checkoutItemId,
9
+ feedbacks,
10
+ })), [checkoutItemId, commandBus]);
11
+ return [returnCheckoutItem, status];
12
+ };
13
+ export { useReturnCheckoutItem };
@@ -1,12 +1,9 @@
1
- import { toBookedSizeChangeProductsVariantsProjection } from "./bookedSizeChangeProductsVariants";
2
1
  const httpBookedSizeChangeProductsVariantsForCheckoutItemView = ({ httpPost }) => async ({ checkoutItemId, signal }) => {
3
2
  const response = await httpPost({
4
3
  endpoint: "/view-booked-size-change-product-variants-for-checkout-item",
5
4
  body: { checkoutItemId },
6
5
  signal,
7
6
  });
8
- return !response.ok || response.status === 404
9
- ? null
10
- : toBookedSizeChangeProductsVariantsProjection((await response.json()).result);
7
+ return !response.ok || response.status === 404 ? null : (await response.json()).result;
11
8
  };
12
9
  export { httpBookedSizeChangeProductsVariantsForCheckoutItemView };
@@ -1,14 +1,14 @@
1
1
  import { CheckoutStatus } from "../../../domain/checkout/model/checkout";
2
2
  import { CheckoutProjection } from "../../../projection/checkout/checkout";
3
- import { CheckoutItemDto } from "../checkoutItem/checkoutItem";
3
+ import { CheckoutItemProjection } from "../../../projection/checkoutItem/checkoutItem";
4
4
  interface CheckoutDto {
5
5
  readonly id: string;
6
- readonly customer_id: string;
7
- readonly box_id: string;
8
- readonly booking_id: string;
6
+ readonly customerId: string;
7
+ readonly boxId: string;
8
+ readonly bookingId: string;
9
9
  readonly status: CheckoutStatus;
10
- readonly expires_on: string;
11
- readonly items: CheckoutItemDto[];
10
+ readonly expiresOn: string;
11
+ readonly items: CheckoutItemProjection[];
12
12
  }
13
13
  interface ToCheckoutProjectionFunction {
14
14
  (checkoutDto: CheckoutDto): CheckoutProjection;
@@ -1,48 +1,5 @@
1
1
  const toCheckoutProjection = (checkoutDto) => ({
2
- id: checkoutDto.id,
3
- customerId: checkoutDto.customer_id,
4
- boxId: checkoutDto.box_id,
5
- bookingId: checkoutDto.booking_id,
6
- status: checkoutDto.status,
7
- expiresOn: new Date(checkoutDto.expires_on),
8
- items: checkoutDto.items.map((item) => ({
9
- id: item.id,
10
- status: item.status,
11
- price: {
12
- amount: item.price.amount,
13
- currency: item.price.currency,
14
- discountedPrice: item.price.discounted_price
15
- ? {
16
- amount: item.price.discounted_price.amount,
17
- percentage: item.price.discounted_price.percentage,
18
- }
19
- : undefined,
20
- },
21
- replacedFor: item.replaced_for,
22
- feedback: {},
23
- productVariant: {
24
- id: item.product_variant.id,
25
- media: item.product_variant.media.map((media) => ({
26
- id: media.id,
27
- url: media.url,
28
- perspective: media.perspective,
29
- })),
30
- brand: item.product_variant.brand,
31
- name: item.product_variant.name,
32
- size: {
33
- id: item.product_variant.size.id,
34
- lookiero: item.product_variant.size.lookiero,
35
- uk: item.product_variant.size.uk,
36
- it: item.product_variant.size.it,
37
- europe: item.product_variant.size.europe,
38
- unique: item.product_variant.size.unique,
39
- visualOrder: item.product_variant.size.visual_order,
40
- },
41
- color: {
42
- id: item.product_variant.color.id,
43
- label: item.product_variant.color.label,
44
- },
45
- },
46
- })),
2
+ ...checkoutDto,
3
+ expiresOn: new Date(checkoutDto.expiresOn),
47
4
  });
48
5
  export { toCheckoutProjection };
@@ -1,9 +1,14 @@
1
1
  import { useQuery } from "@lookiero/messaging-react";
2
+ import { CHECKOUT_ITEM_KEPT } from "../../../../domain/checkoutItem/model/checkoutItemKept";
3
+ import { CHECKOUT_ITEM_RETURNED, } from "../../../../domain/checkoutItem/model/checkoutItemReturned";
2
4
  import { viewFirstAvailableCheckoutByCustomerId } from "../../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
3
5
  import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
6
+ const isCheckoutItemKept = (event) => event.name === CHECKOUT_ITEM_KEPT;
7
+ const isCheckoutItemReturned = (event) => event.name === CHECKOUT_ITEM_RETURNED;
4
8
  const useViewFirstAvailableCheckoutByCustomerId = ({ customerId }) => useQuery({
5
9
  query: viewFirstAvailableCheckoutByCustomerId({ customerId }),
6
10
  contextId: MESSAGING_CONTEXT_ID,
11
+ invalidation: isCheckoutItemKept || isCheckoutItemReturned,
7
12
  options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
8
13
  });
9
14
  export { useViewFirstAvailableCheckoutByCustomerId };
@@ -1,10 +1,9 @@
1
- import { toCheckoutBookingProjection } from "./checkoutBooking";
2
1
  const httpCheckoutBookingByIdView = ({ httpPost }) => async ({ checkoutBookingId, signal }) => {
3
2
  const response = await httpPost({
4
3
  endpoint: "/view-checkout-booking-by-id",
5
4
  body: { checkoutBookingId },
6
5
  signal,
7
6
  });
8
- return !response.ok || response.status === 404 ? null : toCheckoutBookingProjection((await response.json()).result);
7
+ return !response.ok || response.status === 404 ? null : (await response.json()).result;
9
8
  };
10
9
  export { httpCheckoutBookingByIdView };
@@ -1,10 +1,9 @@
1
- import { toCheckoutItemProjection } from "./checkoutItem";
2
1
  const httpCheckoutItemByIdView = ({ httpPost }) => async ({ checkoutItemId, signal }) => {
3
2
  const response = await httpPost({
4
3
  endpoint: "/view-checkout-item-by-id",
5
- body: { checkout_item_id: checkoutItemId },
4
+ body: { checkoutItemId },
6
5
  signal,
7
6
  });
8
- return !response.ok || response.status === 404 ? null : toCheckoutItemProjection((await response.json()).result);
7
+ return !response.ok || response.status === 404 ? null : (await response.json()).result;
9
8
  };
10
9
  export { httpCheckoutItemByIdView };
@@ -1,10 +1,9 @@
1
- import { toReturnQuestionsProjection } from "./returnQuestion";
2
1
  const httpReturnQuestionsByCheckoutItemIdView = ({ httpPost }) => async ({ checkoutItemId, signal }) => {
3
2
  const response = await httpPost({
4
3
  endpoint: "/list-return-questions-by-checkout-item-id",
5
- body: { checkout_item_id: checkoutItemId },
4
+ body: { checkoutItemId },
6
5
  signal,
7
6
  });
8
- return !response.ok || response.status === 404 ? null : toReturnQuestionsProjection((await response.json()).result);
7
+ return !response.ok || response.status === 404 ? null : (await response.json()).result;
9
8
  };
10
9
  export { httpReturnQuestionsByCheckoutItemIdView };
@@ -1,6 +1,6 @@
1
1
  import { StyleSheet } from "react-native";
2
2
  import { theme } from "../../../../theme/theme";
3
- const { spaceXS, spaceM, spaceL } = theme();
3
+ const { spaceXS, spaceS, spaceM, spaceL } = theme();
4
4
  const style = StyleSheet.create({
5
5
  error: {
6
6
  marginLeft: spaceL,
@@ -12,7 +12,7 @@ const style = StyleSheet.create({
12
12
  },
13
13
  icon: {
14
14
  position: "absolute",
15
- right: spaceM,
15
+ right: spaceS,
16
16
  top: spaceM,
17
17
  zIndex: 4,
18
18
  },
@@ -23,6 +23,7 @@ const Item = ({ customerId }) => {
23
23
  const { id } = useParams();
24
24
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
25
25
  const checkoutItem = checkout?.items.find((checkoutItem) => checkoutItem.id === id);
26
+ const [customerDecissionMade, setCustomerDecissionMade] = useState(() => checkoutItem.status === CheckoutItemStatus.INITIAL || checkoutItem.status === CheckoutItemStatus.EXPIRED);
26
27
  const [bookedSizeChangeProductsVariants, bookedSizeChangeProductsVariantsStatus] = useViewBookedSizeChangeProductsVariantsForCheckoutItem({
27
28
  checkoutItemId: checkoutItem.id,
28
29
  });
@@ -43,11 +44,11 @@ const Item = ({ customerId }) => {
43
44
  const [returnQuestionsVisible, setReturnQuestionsVisible] = useState(false);
44
45
  const handleOnShowReturnQuestions = useCallback(() => setReturnQuestionsVisible(true), []);
45
46
  const handleOnHideReturnQuestions = useCallback(() => setReturnQuestionsVisible(false), []);
46
- const handleOnEditFeedback = useCallback(() => void 0, []);
47
+ const handleOnEditFeedback = useCallback(() => handleOnShowReturnQuestions(), [handleOnShowReturnQuestions]);
47
48
  const handleOnSubmit = useCallback(() => handleOnHideReturnQuestions(), [handleOnHideReturnQuestions]);
48
49
  const handleOnReplace = useCallback(() => void 0, []);
49
50
  const handleOnReturn = useCallback(() => handleOnShowReturnQuestions(), [handleOnShowReturnQuestions]);
50
- const handleOnBannerPress = useCallback(() => void 0, []);
51
+ const handleOnBannerPress = useCallback(() => setCustomerDecissionMade(!customerDecissionMade), [customerDecissionMade]);
51
52
  const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
52
53
  const dependenciesLoaded = dependenciesLoadedStatuses.includes(returnQuestionsStatus) &&
53
54
  dependenciesLoadedStatuses.includes(checkoutStatus) &&
@@ -56,7 +57,6 @@ const Item = ({ customerId }) => {
56
57
  return React.createElement(Spinner, null);
57
58
  const { price } = checkoutItem;
58
59
  const { media, brand, name, size, color } = checkoutItem.productVariant;
59
- const customerDecissionMade = checkoutItem.status === CheckoutItemStatus.INITIAL || checkoutItem.status === CheckoutItemStatus.EXPIRED;
60
60
  const sizes = bookedSizeChangeProductsVariants?.productVariants
61
61
  .map((productVariant) => productVariant.size)
62
62
  .concat(checkoutItem.productVariant.size) || [];
@@ -69,7 +69,7 @@ const Item = ({ customerId }) => {
69
69
  React.createElement(ProductVariantSlider, { producVariantMedia: media })),
70
70
  React.createElement(ProductVariantDescription, { brand: brand, color: color, name: name, price: price, size: size }),
71
71
  checkoutItem.feedback && (React.createElement(View, { style: style.feedbackContainer },
72
- React.createElement(ReturnQuestionsFeedback, { feedback: checkoutItem.feedback, returnQuestions: returnQuestions || [], onEditFeedback: handleOnEditFeedback })))))),
72
+ React.createElement(ReturnQuestionsFeedback, { feedback: checkoutItem.feedback || {}, returnQuestions: returnQuestions || [], onEditFeedback: handleOnEditFeedback })))))),
73
73
  customerDecissionMade && (React.createElement(ItemActions, { size: checkoutItem.productVariant.size, sizes: sizes, onKeep: keepCheckoutItem, onLayout: handleOnStickyLayout, onReplace: handleOnReplace, onReturn: handleOnReturn })),
74
74
  React.createElement(ReturnQuestionsForm, { checkoutItemPrice: checkoutItem.price, feedback: checkoutItem.feedback || {}, productVariant: checkoutItem.productVariant, returnQuestions: returnQuestions || [], visible: returnQuestionsVisible, onClose: handleOnHideReturnQuestions, onSubmit: handleOnSubmit })));
75
75
  };
@@ -1,9 +1,10 @@
1
1
  import { FC } from "react";
2
2
  import { CheckoutItemStatus } from "../../../../../../domain/checkoutItem/model/checkoutItem";
3
- declare type Status = Exclude<CheckoutItemStatus, CheckoutItemStatus.INITIAL | CheckoutItemStatus.EXPIRED>;
3
+ declare type CustomerDecissionBannerStatus = Exclude<CheckoutItemStatus, CheckoutItemStatus.INITIAL | CheckoutItemStatus.EXPIRED>;
4
4
  interface CustomerDecissionBannerProps {
5
- readonly checkoutItemStatus: Status;
5
+ readonly checkoutItemStatus: CustomerDecissionBannerStatus;
6
6
  readonly onPress: () => void;
7
7
  }
8
8
  declare const CustomerDecissionBanner: FC<CustomerDecissionBannerProps>;
9
+ export type { CustomerDecissionBannerStatus };
9
10
  export { CustomerDecissionBanner };
@@ -8,7 +8,7 @@ interface ReturnQuestionsFormProps {
8
8
  readonly returnQuestions: ReturnQuestionProjection[];
9
9
  readonly checkoutItemPrice: PriceProjection;
10
10
  readonly productVariant: CheckoutItemProductVariantProjection;
11
- readonly onSubmit: () => void;
11
+ readonly onSubmit: (feedback: FeedbackProjection) => void;
12
12
  readonly onClose: () => void;
13
13
  }
14
14
  declare const ReturnQuestionsForm: FC<ReturnQuestionsFormProps>;
@@ -2,7 +2,7 @@ import { PortalHost } from "@gorhom/portal";
2
2
  import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
3
3
  import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
4
4
  import { useI18nMessage } from "@lookiero/i18n-react";
5
- import React from "react";
5
+ import React, { useCallback } from "react";
6
6
  import { View } from "react-native";
7
7
  import { ReturnQuestionType, } from "../../../../../../projection/returnQuestion/returnQuestion";
8
8
  import { ReturnQuestions } from "../../../../components/organisms/returnQuestions/ReturnQuestions";
@@ -33,10 +33,11 @@ const ReturnQuestionsForm = ({ feedback, returnQuestions, checkoutItemPrice, pro
33
33
  prefix: RETURN_QUESTIONS_PREFIX,
34
34
  });
35
35
  const { media, brand, name, size, color } = productVariant;
36
+ const handleOnSubmit = useCallback(() => onSubmit(feedback), [feedback, onSubmit]);
36
37
  return (React.createElement(ReturnQuestionFeedbackProvider, { feedback: feedback },
37
38
  React.createElement(ReturnQuestionItemProvider, { returnQuestionItems: returnQuestionItems },
38
39
  React.createElement(PortalHost, { name: RETURN_QUESTION_FORM_PORTAL_HOST_NAME }),
39
- React.createElement(Modal, { footer: React.createElement(Button, { onPress: onSubmit }, submitButtonText), portalHostName: RETURN_QUESTION_FORM_PORTAL_HOST_NAME, visible: visible, scroll: true, showCloseButton: true, onClose: onClose },
40
+ React.createElement(Modal, { footer: React.createElement(Button, { onPress: handleOnSubmit }, submitButtonText), portalHostName: RETURN_QUESTION_FORM_PORTAL_HOST_NAME, visible: visible, scroll: true, showCloseButton: true, onClose: onClose },
40
41
  React.createElement(View, { style: style.returnQuestionsContainer },
41
42
  React.createElement(Text, { level: 2, style: style.title }, titleText),
42
43
  React.createElement(ProductVariant, { brand: brand, color: color, media: media, name: name, price: checkoutItemPrice, size: size }),
@@ -47,7 +47,7 @@ interface CheckoutItemProjection {
47
47
  readonly price: PriceProjection;
48
48
  readonly replacedFor?: string;
49
49
  readonly productVariant: CheckoutItemProductVariantProjection;
50
- readonly feedback: FeedbackProjection | null;
50
+ readonly feedback: FeedbackProjection;
51
51
  }
52
52
  export type { CheckoutItemProjection, CheckoutItemProductVariantProjection, ColorProjection, MediaProjection, PriceProjection, };
53
53
  export { Currency, MediaPerspective };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.2.39",
3
+ "version": "0.2.41",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -1,27 +0,0 @@
1
- import { BookedSizeChangeProductsVariantsProjection } from "../../../projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants";
2
- interface SizeDto {
3
- readonly id: string;
4
- readonly lookiero: string;
5
- readonly uk: string;
6
- readonly it: string;
7
- readonly europe: string;
8
- readonly unique: boolean;
9
- readonly visual_order?: number;
10
- }
11
- interface ProductVariantDto {
12
- readonly id: string;
13
- readonly size: SizeDto;
14
- }
15
- interface BookedSizeChangeProductsVariantsDto {
16
- readonly id: string;
17
- readonly checkoutId: string;
18
- readonly checkoutItemId: string;
19
- readonly booking: string | null;
20
- readonly product_variants: ProductVariantDto[];
21
- }
22
- interface ToBookedSizeChangeProductsVariantsProjectionFunction {
23
- (bookedSizeChangeProductsVariantsDto: BookedSizeChangeProductsVariantsDto): BookedSizeChangeProductsVariantsProjection;
24
- }
25
- declare const toBookedSizeChangeProductsVariantsProjection: ToBookedSizeChangeProductsVariantsProjectionFunction;
26
- export type { BookedSizeChangeProductsVariantsDto };
27
- export { toBookedSizeChangeProductsVariantsProjection };
@@ -1,21 +0,0 @@
1
- const toSizeProjection = (size) => ({
2
- id: size.id,
3
- lookiero: size.lookiero,
4
- uk: size.uk,
5
- it: size.it,
6
- europe: size.europe,
7
- unique: size.unique,
8
- visualOrder: size.visual_order,
9
- });
10
- const toProductVariantProjection = (productVariant) => ({
11
- id: productVariant.id,
12
- size: toSizeProjection(productVariant.size),
13
- });
14
- const toBookedSizeChangeProductsVariantsProjection = (bookedSizeChangeProductsVariantsDto) => ({
15
- id: bookedSizeChangeProductsVariantsDto.id,
16
- checkoutId: bookedSizeChangeProductsVariantsDto.checkoutId,
17
- checkoutItemId: bookedSizeChangeProductsVariantsDto.checkoutItemId,
18
- booking: bookedSizeChangeProductsVariantsDto.booking,
19
- productVariants: bookedSizeChangeProductsVariantsDto.product_variants.map(toProductVariantProjection),
20
- });
21
- export { toBookedSizeChangeProductsVariantsProjection };
@@ -1,12 +0,0 @@
1
- import { CheckoutBookingProjection } from "../../../projection/checkoutBooking/checkoutBooking";
2
- interface CheckoutBookingDto {
3
- readonly id: string;
4
- readonly checkoutId: string;
5
- readonly checkoutItemIds: string[];
6
- }
7
- interface ToCheckoutBookingProjectionFunction {
8
- (checkoutBookingDto: CheckoutBookingDto): CheckoutBookingProjection;
9
- }
10
- declare const toCheckoutBookingProjection: ToCheckoutBookingProjectionFunction;
11
- export type { CheckoutBookingDto };
12
- export { toCheckoutBookingProjection };
@@ -1,6 +0,0 @@
1
- const toCheckoutBookingProjection = (checkoutBookingDto) => ({
2
- id: checkoutBookingDto.id,
3
- checkoutId: checkoutBookingDto.checkoutId,
4
- checkoutItemIds: checkoutBookingDto.checkoutItemIds,
5
- });
6
- export { toCheckoutBookingProjection };
@@ -1,45 +0,0 @@
1
- import { CheckoutItemStatus } from "../../../domain/checkoutItem/model/checkoutItem";
2
- import { CheckoutItemProjection, Currency, MediaPerspective } from "../../../projection/checkoutItem/checkoutItem";
3
- interface CheckoutItemDto {
4
- readonly id: string;
5
- readonly status: CheckoutItemStatus;
6
- readonly price: {
7
- readonly amount: number;
8
- readonly currency: Currency;
9
- readonly discounted_price?: {
10
- readonly amount: number;
11
- readonly percentage: number;
12
- };
13
- };
14
- readonly replaced_for?: string;
15
- readonly feedback: Record<string, string>;
16
- readonly product_variant: {
17
- readonly id: string;
18
- readonly media: {
19
- readonly id: string;
20
- readonly url: string;
21
- readonly perspective: MediaPerspective;
22
- }[];
23
- readonly brand: string;
24
- readonly name: string;
25
- readonly size: {
26
- readonly id: string;
27
- readonly lookiero: string;
28
- readonly uk: string;
29
- readonly it: string;
30
- readonly europe: string;
31
- readonly unique: boolean;
32
- readonly visual_order?: number;
33
- };
34
- readonly color: {
35
- readonly id: string;
36
- readonly label: string;
37
- };
38
- };
39
- }
40
- interface ToCheckoutItemProjectionFunction {
41
- (checkoutItemDto: CheckoutItemDto): CheckoutItemProjection;
42
- }
43
- declare const toCheckoutItemProjection: ToCheckoutItemProjectionFunction;
44
- export type { CheckoutItemDto };
45
- export { toCheckoutItemProjection };
@@ -1,40 +0,0 @@
1
- const toCheckoutItemProjection = (checkoutItemDto) => ({
2
- id: checkoutItemDto.id,
3
- status: checkoutItemDto.status,
4
- price: {
5
- amount: checkoutItemDto.price.amount,
6
- currency: checkoutItemDto.price.currency,
7
- discountedPrice: checkoutItemDto.price.discounted_price
8
- ? {
9
- amount: checkoutItemDto.price.discounted_price.amount,
10
- percentage: checkoutItemDto.price.discounted_price.percentage,
11
- }
12
- : undefined,
13
- },
14
- replacedFor: checkoutItemDto.replaced_for,
15
- feedback: checkoutItemDto.feedback,
16
- productVariant: {
17
- id: checkoutItemDto.product_variant.id,
18
- media: checkoutItemDto.product_variant.media.map((media) => ({
19
- id: media.id,
20
- url: media.url,
21
- perspective: media.perspective,
22
- })),
23
- brand: checkoutItemDto.product_variant.brand,
24
- name: checkoutItemDto.product_variant.name,
25
- size: {
26
- id: checkoutItemDto.product_variant.size.id,
27
- lookiero: checkoutItemDto.product_variant.size.lookiero,
28
- uk: checkoutItemDto.product_variant.size.uk,
29
- it: checkoutItemDto.product_variant.size.it,
30
- europe: checkoutItemDto.product_variant.size.europe,
31
- unique: checkoutItemDto.product_variant.size.unique,
32
- visualOrder: checkoutItemDto.product_variant.size.visual_order,
33
- },
34
- color: {
35
- id: checkoutItemDto.product_variant.color.id,
36
- label: checkoutItemDto.product_variant.color.label,
37
- },
38
- },
39
- });
40
- export { toCheckoutItemProjection };
@@ -1,14 +0,0 @@
1
- import { ReturnQuestionProjection, ReturnQuestionType } from "../../../projection/returnQuestion/returnQuestion";
2
- interface ReturnQuestionDto {
3
- readonly id: string;
4
- readonly name: string;
5
- readonly placeholder?: string;
6
- readonly type: ReturnQuestionType;
7
- readonly children?: ReturnQuestionDto[];
8
- }
9
- interface ToReturnQuestionsProjectionFunction {
10
- (returnQuestionsDto: ReturnQuestionDto[]): ReturnQuestionProjection[];
11
- }
12
- declare const toReturnQuestionsProjection: ToReturnQuestionsProjectionFunction;
13
- export type { ReturnQuestionDto };
14
- export { toReturnQuestionsProjection };
@@ -1,9 +0,0 @@
1
- const toReturnQuestionProjection = (returnQuestionDto) => ({
2
- id: returnQuestionDto.id,
3
- name: returnQuestionDto.name,
4
- placeholder: returnQuestionDto.placeholder,
5
- type: returnQuestionDto.type,
6
- children: returnQuestionDto.children ? toReturnQuestionsProjection(returnQuestionDto.children) : undefined,
7
- });
8
- const toReturnQuestionsProjection = (returnQuestionsDto) => returnQuestionsDto.map(toReturnQuestionProjection);
9
- export { toReturnQuestionsProjection };