@lookiero/checkout 0.3.25 → 0.3.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.3.25",
3
+ "version": "0.3.26",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -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 replacedFor: string;
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 replacedFor?: string;
18
+ readonly replacedForId?: string;
19
19
  }
20
20
  declare const keepCheckoutItemHandler: CommandHandlerFunction<KeepCheckoutItem, CheckoutItem>;
21
21
  declare const returnCheckoutItemHandler: CommandHandlerFunction<ReturnCheckoutItem, CheckoutItem>;
@@ -29,10 +29,10 @@ const returnCheckoutItemHandler = () => async ({ aggregateRoot, command }) => {
29
29
  };
30
30
  };
31
31
  const replaceCheckoutItemHandler = () => async ({ aggregateRoot, command }) => {
32
- const { aggregateId, replacedFor } = command;
32
+ const { aggregateId, replacedForId } = command;
33
33
  return {
34
34
  ...aggregateRoot,
35
- replacedFor,
35
+ replacedForId,
36
36
  status: CheckoutItemStatus.REPLACED,
37
37
  domainEvents: [checkoutItemReplaced({ aggregateId })],
38
38
  };
@@ -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
  };
@@ -10,7 +10,7 @@ const toDomain = (checkoutItem) => {
10
10
  status: checkoutItem.status,
11
11
  price: checkoutItem.price,
12
12
  feedbacks: checkoutItem.feedbacks,
13
- replacedFor: checkoutItem.replacedFor,
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, replacedFor, domainEvents }) => {
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 replacedFor: string;
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(({ replacedFor }) => commandBus(replaceCheckoutItem({
7
+ const replace = useCallback(({ replacedForId }) => commandBus(replaceCheckoutItem({
8
8
  aggregateId: checkoutItemId,
9
- replacedFor,
9
+ replacedForId,
10
10
  })), [checkoutItemId, commandBus]);
11
11
  return [replace, status];
12
12
  };
@@ -94,20 +94,14 @@ const Item = ({ customerId }) => {
94
94
  handleOnHideReturnQuestions();
95
95
  returnCheckoutItem({ feedbacks });
96
96
  }, [handleOnHideReturnQuestions, returnCheckoutItem]);
97
- const handleOnReplace = useCallback((replacedFor) => {
97
+ const handleOnReplace = useCallback((replacedForId) => {
98
98
  handleOnShowSizeChangeModal();
99
- replaceCheckoutItem({ replacedFor });
99
+ replaceCheckoutItem({ replacedForId });
100
100
  }, [handleOnShowSizeChangeModal, replaceCheckoutItem]);
101
101
  const handleOnReturn = useCallback(() => handleOnShowReturnQuestions(), [handleOnShowReturnQuestions]);
102
102
  const productVariantSelected = useMemo(() => checkoutItem.status === CheckoutItemStatus.REPLACED && checkoutItem.replacedFor
103
- ? bookedSizeChangeProductsVariants?.productVariants.find((productVariant) => productVariant.id === checkoutItem.replacedFor)
104
- : { id: checkoutItem.productVariant.id, size: checkoutItem.productVariant.size }, [
105
- bookedSizeChangeProductsVariants?.productVariants,
106
- checkoutItem.productVariant.id,
107
- checkoutItem.productVariant.size,
108
- checkoutItem.replacedFor,
109
- checkoutItem.status,
110
- ]);
103
+ ? { id: checkoutItem.replacedFor.id, size: checkoutItem.replacedFor.size }
104
+ : { id: checkoutItem.productVariant.id, size: checkoutItem.productVariant.size }, [checkoutItem.productVariant.id, checkoutItem.productVariant.size, checkoutItem.replacedFor, checkoutItem.status]);
111
105
  const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
112
106
  const dependenciesLoaded = dependenciesLoadedStatuses.includes(returnQuestionsStatus) &&
113
107
  (dependenciesLoadedStatuses.includes(checkoutStatus) || checkout) &&
@@ -2,12 +2,13 @@ import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Tex
2
2
  import { useI18nMessage } from "@lookiero/i18n-react";
3
3
  import React, { useCallback } from "react";
4
4
  import { View } from "react-native";
5
+ import { CheckoutItemStatus } from "../../../../../../domain/checkoutItem/model/checkoutItem";
5
6
  import { Tabs } from "../../../../components/layouts/tabs/Tabs";
6
7
  import { I18nMessages } from "../../../../i18n/i18n";
7
8
  import { ProductVariant } from "../../../item/components/productVariant/ProductVariant";
8
9
  import { style } from "./CheckoutItemsTabs.style";
9
- const CheckoutItem = ({ checkoutItem, discarded = false, testID, style: customStyle, onPress, }) => (React.createElement(View, { style: style.checkoutItem, testID: testID },
10
- React.createElement(ProductVariant, { brand: checkoutItem.productVariant.brand, color: checkoutItem.productVariant.color, discarded: discarded, media: checkoutItem.productVariant.media, name: checkoutItem.productVariant.name, price: checkoutItem.price, size: checkoutItem.productVariant.size, status: checkoutItem.status, style: customStyle, onPress: onPress })));
10
+ const CheckoutItem = ({ checkoutItemStatus, checkoutItemProductVariant, checkoutItemPrice, discarded = false, testID, style: customStyle, onPress, }) => (React.createElement(View, { style: style.checkoutItem, testID: testID },
11
+ React.createElement(ProductVariant, { brand: checkoutItemProductVariant.brand, color: checkoutItemProductVariant.color, discarded: discarded, media: checkoutItemProductVariant.media, name: checkoutItemProductVariant.name, price: checkoutItemPrice, size: checkoutItemProductVariant.size, status: checkoutItemStatus, style: customStyle, onPress: onPress })));
11
12
  const CheckoutItemsTabs = ({ checkoutItemsKept, checkoutItemsReturned, onPressItem }) => {
12
13
  const keepTabText = useI18nMessage({ id: I18nMessages.SUMMARY_KEEP_TAB });
13
14
  const returnTabText = useI18nMessage({ id: I18nMessages.SUMMARY_RETURN_TAB });
@@ -15,7 +16,9 @@ const CheckoutItemsTabs = ({ checkoutItemsKept, checkoutItemsReturned, onPressIt
15
16
  const returnEmptyText = useI18nMessage({ id: I18nMessages.SUMMARY_RETURN_EMPTY });
16
17
  const handleOnPressItem = useCallback((checkoutItemId) => onPressItem(checkoutItemId), [onPressItem]);
17
18
  return (React.createElement(Tabs, { style: { sliderContainer: style.sliderContainer }, tabLabels: [`${keepTabText} (${checkoutItemsKept.length})`, `${returnTabText} (${checkoutItemsReturned.length})`] },
18
- React.createElement(React.Fragment, null, checkoutItemsKept.length === 0 ? (React.createElement(Text, null, keepEmptyText)) : (checkoutItemsKept.map((checkoutItem) => (React.createElement(CheckoutItem, { key: checkoutItem.id, checkoutItem: checkoutItem, testID: "keep-checkout-item", onPress: () => handleOnPressItem(checkoutItem.id) }))))),
19
- React.createElement(React.Fragment, null, checkoutItemsReturned.length === 0 ? (React.createElement(Text, null, returnEmptyText)) : (checkoutItemsReturned.map((checkoutItem) => (React.createElement(CheckoutItem, { key: checkoutItem.id, checkoutItem: checkoutItem, style: { image: style.returnCheckoutItem }, testID: "return-checkout-item", discarded: true, onPress: () => handleOnPressItem(checkoutItem.id) })))))));
19
+ React.createElement(React.Fragment, null, checkoutItemsKept.length === 0 ? (React.createElement(Text, null, keepEmptyText)) : (checkoutItemsKept.map((checkoutItem) => (React.createElement(CheckoutItem, { key: checkoutItem.id, checkoutItemPrice: checkoutItem.price, checkoutItemStatus: checkoutItem.status, testID: "keep-checkout-item", checkoutItemProductVariant: checkoutItem.status === CheckoutItemStatus.REPLACED && checkoutItem.replacedFor
20
+ ? checkoutItem.replacedFor
21
+ : checkoutItem.productVariant, onPress: () => handleOnPressItem(checkoutItem.id) }))))),
22
+ React.createElement(React.Fragment, null, checkoutItemsReturned.length === 0 ? (React.createElement(Text, null, returnEmptyText)) : (checkoutItemsReturned.map((checkoutItem) => (React.createElement(CheckoutItem, { key: checkoutItem.id, checkoutItemPrice: checkoutItem.price, checkoutItemProductVariant: checkoutItem.productVariant, checkoutItemStatus: checkoutItem.status, style: { image: style.returnCheckoutItem }, testID: "return-checkout-item", discarded: true, onPress: () => handleOnPressItem(checkoutItem.id) })))))));
20
23
  };
21
24
  export { CheckoutItemsTabs };
@@ -37,7 +37,7 @@ interface CheckoutItemProjection {
37
37
  readonly id: string;
38
38
  readonly status: CheckoutItemStatus;
39
39
  readonly price: PriceProjection;
40
- readonly replacedFor?: string;
40
+ readonly replacedFor: CheckoutItemProductVariantProjection | null;
41
41
  readonly productVariant: CheckoutItemProductVariantProjection;
42
42
  readonly feedbacks: FeedbackProjection;
43
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.3.25",
3
+ "version": "0.3.26",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [