@lookiero/checkout 0.3.0 → 0.3.1

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 (19) hide show
  1. package/dist/domain/checkoutItem/model/checkoutItem.js +4 -4
  2. package/dist/infrastructure/delivery/mock/dataSourceCheckoutBookings.js +2 -3
  3. package/dist/infrastructure/delivery/mock/dataSourceCheckoutItems.js +2 -2
  4. package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckouBookingForCheckoutItem.d.ts +0 -1
  5. package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckouBookingForCheckoutItem.js +3 -3
  6. package/dist/infrastructure/domain/checkoutItem/model/httpCheckoutItems.js +1 -1
  7. package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/react/useViewBookedSizeChangeProductsVariantsForCheckoutItem.js +3 -0
  8. package/dist/infrastructure/projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId.js +4 -1
  9. package/dist/infrastructure/ui/components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback.js +2 -1
  10. package/dist/infrastructure/ui/views/item/Item.js +21 -13
  11. package/dist/infrastructure/ui/views/item/components/itemActions/ItemActions.d.ts +1 -2
  12. package/dist/infrastructure/ui/views/item/components/itemActions/ItemActions.js +1 -3
  13. package/dist/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.d.ts +0 -2
  14. package/dist/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.js +4 -6
  15. package/dist/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.d.ts +0 -1
  16. package/dist/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.js +10 -10
  17. package/dist/projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants.d.ts +1 -4
  18. package/dist/projection/checkoutItem/checkoutItem.d.ts +1 -1
  19. package/package.json +1 -1
@@ -20,19 +20,19 @@ const keepCheckoutItemHandler = () => async ({ aggregateRoot, command }) => {
20
20
  };
21
21
  };
22
22
  const returnCheckoutItemHandler = () => async ({ aggregateRoot, command }) => {
23
- const { aggregateId } = command;
24
- invariant(aggregateRoot.status !== CheckoutItemStatus.RETURNED, "CheckoutItem is already returned");
23
+ const { aggregateId, feedbacks } = command;
25
24
  return {
26
25
  ...aggregateRoot,
26
+ feedbacks,
27
27
  status: CheckoutItemStatus.RETURNED,
28
28
  domainEvents: [checkoutItemReturned({ aggregateId })],
29
29
  };
30
30
  };
31
31
  const replaceCheckoutItemHandler = () => async ({ aggregateRoot, command }) => {
32
- const { aggregateId } = command;
33
- invariant(aggregateRoot.status !== CheckoutItemStatus.REPLACED, "CheckoutItem is already replaced");
32
+ const { aggregateId, replacedFor } = command;
34
33
  return {
35
34
  ...aggregateRoot,
35
+ replacedFor,
36
36
  status: CheckoutItemStatus.REPLACED,
37
37
  domainEvents: [checkoutItemReplaced({ aggregateId })],
38
38
  };
@@ -3,9 +3,8 @@ import { viewBookedSizeChangeProductsVariantsForCheckoutItem, } from "../../../p
3
3
  const toCheckoutBookingDomain = (checkoutBooking) => {
4
4
  invariant(checkoutBooking, "No checkoutBooking found!");
5
5
  return {
6
- aggregateId: checkoutBooking.id,
7
- checkoutId: checkoutBooking.checkoutId,
8
- checkoutItemIds: [checkoutBooking.checkoutItemId],
6
+ aggregateId: checkoutBooking.bookingId,
7
+ checkoutItemIds: checkoutBooking.productVariants.map((productVariant) => productVariant.id),
9
8
  domainEvents: [],
10
9
  };
11
10
  };
@@ -4,7 +4,7 @@ const toCheckoutItemProjection = (checkoutItem) => ({
4
4
  id: checkoutItem.aggregateId,
5
5
  status: checkoutItem.status,
6
6
  productVariant: {},
7
- feedback: {},
7
+ feedbacks: {},
8
8
  price: checkoutItem.price,
9
9
  });
10
10
  const toCheckoutItemDomain = (checkoutItem) => {
@@ -14,7 +14,7 @@ const toCheckoutItemDomain = (checkoutItem) => {
14
14
  id: checkoutItem.id,
15
15
  status: checkoutItem.status,
16
16
  price: checkoutItem.price,
17
- feedbacks: checkoutItem.feedback,
17
+ feedbacks: checkoutItem.feedbacks,
18
18
  domainEvents: [],
19
19
  };
20
20
  };
@@ -5,7 +5,6 @@ interface BookFunction {
5
5
  declare type UseBookCheckouBookingForCheckoutItem = [book: BookFunction, status: CommandStatus];
6
6
  interface UseBookCheckouBookingForCheckoutItemFunctionArgs {
7
7
  readonly checkoutItemId: string;
8
- readonly checkoutBookingId: string | undefined;
9
8
  }
10
9
  interface UseBookCheckouBookingForCheckoutItemFunction {
11
10
  (args: UseBookCheckouBookingForCheckoutItemFunctionArgs): UseBookCheckouBookingForCheckoutItem;
@@ -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 useBookCheckouBookingForCheckoutItem = ({ checkoutItemId, checkoutBookingId, }) => {
6
+ const useBookCheckouBookingForCheckoutItem = ({ checkoutItemId }) => {
7
7
  const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
8
8
  const book = useCallback(() => commandBus(bookCheckoutBookingForCheckoutItem({
9
- aggregateId: checkoutBookingId || uuid(),
9
+ aggregateId: uuid(),
10
10
  checkoutItemId,
11
- })), [checkoutBookingId, checkoutItemId, commandBus]);
11
+ })), [checkoutItemId, commandBus]);
12
12
  return [book, status];
13
13
  };
14
14
  export { useBookCheckouBookingForCheckoutItem };
@@ -9,7 +9,7 @@ const toDomain = (checkoutItem) => {
9
9
  id: checkoutItem.id,
10
10
  status: checkoutItem.status,
11
11
  price: checkoutItem.price,
12
- feedbacks: checkoutItem.feedback,
12
+ feedbacks: checkoutItem.feedbacks,
13
13
  replacedFor: checkoutItem.replacedFor,
14
14
  aggregateId: checkoutItem.id,
15
15
  domainEvents: [],
@@ -1,9 +1,12 @@
1
1
  import { useQuery } from "@lookiero/messaging-react";
2
+ import { CHECKOUT_BOOKING_BOOKED, } from "../../../../domain/checkoutBooking/model/checkoutBookingBooked";
2
3
  import { viewBookedSizeChangeProductsVariantsForCheckoutItem } from "../../../../projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem";
3
4
  import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
5
+ const isCheckoutBookingBooked = (event) => event.name === CHECKOUT_BOOKING_BOOKED;
4
6
  const useViewBookedSizeChangeProductsVariantsForCheckoutItem = ({ checkoutItemId }) => useQuery({
5
7
  query: viewBookedSizeChangeProductsVariantsForCheckoutItem({ checkoutItemId }),
6
8
  contextId: MESSAGING_CONTEXT_ID,
9
+ invalidation: isCheckoutBookingBooked,
7
10
  options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
8
11
  });
9
12
  export { useViewBookedSizeChangeProductsVariantsForCheckoutItem };
@@ -1,14 +1,17 @@
1
1
  import { useQuery } from "@lookiero/messaging-react";
2
2
  import { CHECKOUT_ITEM_KEPT } from "../../../../domain/checkoutItem/model/checkoutItemKept";
3
+ import { CHECKOUT_ITEM_REPLACED, } from "../../../../domain/checkoutItem/model/checkoutItemReplaced";
3
4
  import { CHECKOUT_ITEM_RETURNED, } from "../../../../domain/checkoutItem/model/checkoutItemReturned";
4
5
  import { viewFirstAvailableCheckoutByCustomerId } from "../../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
5
6
  import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
6
7
  const isCheckoutItemKept = (event) => event.name === CHECKOUT_ITEM_KEPT;
7
8
  const isCheckoutItemReturned = (event) => event.name === CHECKOUT_ITEM_RETURNED;
9
+ const isCheckoutItemReplaced = (event) => event.name === CHECKOUT_ITEM_REPLACED;
10
+ const shouldInvalidate = (event) => isCheckoutItemKept(event) || isCheckoutItemReplaced(event) || isCheckoutItemReturned(event);
8
11
  const useViewFirstAvailableCheckoutByCustomerId = ({ customerId }) => useQuery({
9
12
  query: viewFirstAvailableCheckoutByCustomerId({ customerId }),
10
13
  contextId: MESSAGING_CONTEXT_ID,
11
- invalidation: isCheckoutItemKept || isCheckoutItemReturned,
14
+ invalidation: shouldInvalidate,
12
15
  options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
13
16
  });
14
17
  export { useViewFirstAvailableCheckoutByCustomerId };
@@ -1,4 +1,4 @@
1
- import React, { createContext, useCallback, useContext, useMemo, useState } from "react";
1
+ import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
2
2
  import invariant from "tiny-invariant";
3
3
  const ReturnQuestionFeedbackContext = createContext(null);
4
4
  const ReturnQuestionFeedbackProvider = ({ feedback = {}, children, }) => {
@@ -6,6 +6,7 @@ const ReturnQuestionFeedbackProvider = ({ feedback = {}, children, }) => {
6
6
  const onChange = useCallback(({ returnQuestionId, returnQuestionFeedback }) => setContextFeedback((feedback) => returnQuestionFeedback
7
7
  ? { ...feedback, [returnQuestionId]: returnQuestionFeedback }
8
8
  : Object.entries(feedback).reduce((acc, [id, feedback]) => (id !== returnQuestionId ? { ...acc, [id]: feedback } : acc), {})), []);
9
+ useEffect(() => setContextFeedback(feedback), [feedback]);
9
10
  const value = useMemo(() => ({
10
11
  feedback: contextFeedback,
11
12
  onChange,
@@ -1,5 +1,5 @@
1
1
  import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
2
- import React, { useCallback, useEffect, useState } from "react";
2
+ import React, { useCallback, useEffect, useMemo, useState } from "react";
3
3
  import { View } from "react-native";
4
4
  import { useParams } from "react-router-native";
5
5
  import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
@@ -12,6 +12,7 @@ import { useViewBookedSizeChangeProductsVariantsForCheckoutItem } from "../../..
12
12
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
13
13
  import { useListReturnQuestionsByCheckoutItemId } from "../../../projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId";
14
14
  import { Body } from "../../components/layouts/body/Body";
15
+ import { ReturnQuestionFeedbackProvider } from "../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
15
16
  import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
16
17
  import { Spinner } from "../../shared/components/atoms/spinner/Spinner";
17
18
  import { style } from "./Item.style";
@@ -39,7 +40,6 @@ const Item = ({ customerId }) => {
39
40
  checkoutItemId: checkoutItem.id,
40
41
  });
41
42
  const [bookCheckouBooking] = useBookCheckouBookingForCheckoutItem({
42
- checkoutBookingId: bookedSizeChangeProductsVariants?.id,
43
43
  checkoutItemId: checkoutItem.id,
44
44
  });
45
45
  const [returnQuestions, returnQuestionsStatus] = useListReturnQuestionsByCheckoutItemId({
@@ -55,21 +55,29 @@ const Item = ({ customerId }) => {
55
55
  const [stickyHeight, setStickyHeight] = useState(0);
56
56
  const handleOnStickyLayout = useCallback(({ height }) => setStickyHeight(height), []);
57
57
  useEffect(() => {
58
- checkout?.bookingId === undefined && bookCheckouBooking();
59
- }, [bookCheckouBooking, checkout?.bookingId]);
58
+ bookedSizeChangeProductsVariants === null && bookCheckouBooking();
59
+ }, [bookCheckouBooking, bookedSizeChangeProductsVariants, bookedSizeChangeProductsVariants?.bookingId]);
60
60
  const [returnQuestionsVisible, setReturnQuestionsVisible] = useState(false);
61
61
  const handleOnShowReturnQuestions = useCallback(() => setReturnQuestionsVisible(true), []);
62
62
  const handleOnHideReturnQuestions = useCallback(() => setReturnQuestionsVisible(false), []);
63
63
  const handleOnEditFeedback = useCallback(() => handleOnShowReturnQuestions(), [handleOnShowReturnQuestions]);
64
- const handleOnSubmit = useCallback((feedback) => {
64
+ const handleOnSubmit = useCallback((feedbacks) => {
65
65
  handleOnHideReturnQuestions();
66
- returnCheckoutItem({ feedbacks: feedback });
66
+ returnCheckoutItem({ feedbacks });
67
67
  }, [handleOnHideReturnQuestions, returnCheckoutItem]);
68
68
  const handleOnReplace = useCallback((replacedFor) => {
69
69
  handleOnShowSizeChangeModal();
70
70
  replaceCheckoutItem({ replacedFor });
71
71
  }, [handleOnShowSizeChangeModal, replaceCheckoutItem]);
72
72
  const handleOnReturn = useCallback(() => handleOnShowReturnQuestions(), [handleOnShowReturnQuestions]);
73
+ const productVariantSelected = useMemo(() => checkoutItem.replacedFor
74
+ ? bookedSizeChangeProductsVariants?.productVariants.find((productVariant) => productVariant.id === checkoutItem.replacedFor)
75
+ : { id: checkoutItem.productVariant.id, size: checkoutItem.productVariant.size }, [
76
+ bookedSizeChangeProductsVariants?.productVariants,
77
+ checkoutItem.productVariant.id,
78
+ checkoutItem.productVariant.size,
79
+ checkoutItem.replacedFor,
80
+ ]);
73
81
  const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
74
82
  const dependenciesLoaded = dependenciesLoadedStatuses.includes(returnQuestionsStatus) &&
75
83
  dependenciesLoadedStatuses.includes(checkoutStatus) &&
@@ -77,8 +85,8 @@ const Item = ({ customerId }) => {
77
85
  if (!dependenciesLoaded)
78
86
  return React.createElement(Spinner, null);
79
87
  const { price } = checkoutItem;
80
- const { media, brand, name, size, color } = checkoutItem.productVariant;
81
- return (React.createElement(React.Fragment, null,
88
+ const { media, brand, name, color } = checkoutItem.productVariant;
89
+ return (React.createElement(ReturnQuestionFeedbackProvider, { feedback: checkoutItem.feedbacks || {} },
82
90
  React.createElement(SizeWithoutStockModal, { visible: sizeWithoutStockModalVisible, onDismiss: handleOnHideSizeWithoutStockModal }),
83
91
  React.createElement(SizeChangeModal, { visible: sizeChangeModalVisible, onDismiss: handleOnHideSizeChangeModal }),
84
92
  React.createElement(SafeAreaScrollView, null,
@@ -87,10 +95,10 @@ const Item = ({ customerId }) => {
87
95
  React.createElement(View, { style: [style.container, { paddingBottom: stickyHeight }] },
88
96
  React.createElement(View, { style: style.sliderContainer },
89
97
  React.createElement(ProductVariantSlider, { producVariantMedia: media })),
90
- React.createElement(ProductVariantDescription, { brand: brand, color: color, name: name, price: price, size: size }),
91
- checkoutItem.feedback && (React.createElement(View, { style: style.feedbackContainer },
92
- React.createElement(ReturnQuestionsFeedback, { feedback: checkoutItem.feedback || {}, returnQuestions: returnQuestions || [], onEditFeedback: handleOnEditFeedback })))))),
93
- customerDecissionMade && (React.createElement(ItemActions, { keepButtonLoading: keepCheckoutItemStatus === CommandStatus.LOADING, productVariantSelected: checkoutItem.productVariant, productVariants: bookedSizeChangeProductsVariants?.productVariants || [], returnButtonLoading: returnCheckoutItemStatus === CommandStatus.LOADING, sizeSelectorDisabled: replaceCheckoutItemStatus === CommandStatus.LOADING, onKeep: keepCheckoutItem, onLayout: handleOnStickyLayout, onReplace: handleOnReplace, onReturn: handleOnReturn, onSizeSelectorPress: handleOnShowSizeWithoutStockModal })),
94
- React.createElement(ReturnQuestionsForm, { checkoutItemPrice: checkoutItem.price, feedback: checkoutItem.feedback || {}, productVariant: checkoutItem.productVariant, returnQuestions: returnQuestions || [], visible: returnQuestionsVisible, onClose: handleOnHideReturnQuestions, onSubmit: handleOnSubmit })));
98
+ React.createElement(ProductVariantDescription, { brand: brand, color: color, name: name, price: price, size: productVariantSelected.size }),
99
+ checkoutItem.status === CheckoutItemStatus.RETURNED && (React.createElement(View, { style: style.feedbackContainer },
100
+ React.createElement(ReturnQuestionsFeedback, { returnQuestions: returnQuestions || [], onEditFeedback: handleOnEditFeedback })))))),
101
+ customerDecissionMade && (React.createElement(ItemActions, { keepButtonLoading: keepCheckoutItemStatus === CommandStatus.LOADING, productVariantSelected: productVariantSelected, productVariants: bookedSizeChangeProductsVariants?.productVariants || [], returnButtonLoading: returnCheckoutItemStatus === CommandStatus.LOADING, sizeSelectorDisabled: replaceCheckoutItemStatus === CommandStatus.LOADING, onKeep: keepCheckoutItem, onLayout: handleOnStickyLayout, onReplace: handleOnReplace, onReturn: handleOnReturn, onSizeSelectorPress: handleOnShowSizeWithoutStockModal })),
102
+ React.createElement(ReturnQuestionsForm, { checkoutItemPrice: checkoutItem.price, productVariant: checkoutItem.productVariant, returnQuestions: returnQuestions || [], visible: returnQuestionsVisible, onClose: handleOnHideReturnQuestions, onSubmit: handleOnSubmit })));
95
103
  };
96
104
  export { Item };
@@ -1,10 +1,9 @@
1
1
  import { FC } from "react";
2
2
  import { ProductVariantProjection } from "../../../../../../projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants";
3
- import { CheckoutItemProductVariantProjection } from "../../../../../../projection/checkoutItem/checkoutItem";
4
3
  import { Layout } from "../../../../shared/components/layouts/sticky/Sticky";
5
4
  interface ItemActionsProps {
6
5
  readonly productVariants: ProductVariantProjection[];
7
- readonly productVariantSelected: CheckoutItemProductVariantProjection;
6
+ readonly productVariantSelected: ProductVariantProjection;
8
7
  readonly keepButtonLoading?: boolean;
9
8
  readonly returnButtonLoading?: boolean;
10
9
  readonly sizeSelectorDisabled?: boolean;
@@ -12,9 +12,7 @@ const ItemActions = ({ productVariants, productVariantSelected, keepButtonLoadin
12
12
  const sizeSelectorLabelText = useI18nMessage({ id: I18nMessages.ITEM_SIZES_LABEL });
13
13
  const keepButtonText = useI18nMessage({ id: I18nMessages.ITEM_KEEP_BUTTON });
14
14
  const returnButtonText = useI18nMessage({ id: I18nMessages.ITEM_RETURN_BUTTON });
15
- const sizeSelectorOptions = useMemo(() => productVariants
16
- .map((productVariant) => ({ label: productVariant.size.lookiero, value: productVariant.id }))
17
- .concat({ label: productVariantSelected.size.lookiero, value: productVariantSelected.id }), [productVariantSelected.id, productVariantSelected.size.lookiero, productVariants]);
15
+ const sizeSelectorOptions = useMemo(() => productVariants.map((productVariant) => ({ label: productVariant.size.lookiero, value: productVariant.id })), [productVariants]);
18
16
  const disabledSizeSelector = useMemo(() => sizeSelectorOptions.length === 1 && sizeSelectorOptions[0]?.value === productVariantSelected.id, [sizeSelectorOptions, productVariantSelected.id]);
19
17
  const handleOnPressSizeSelector = useCallback(() => onSizeSelectorPress(), [onSizeSelectorPress]);
20
18
  return (React.createElement(Sticky, { onLayout: onLayout },
@@ -1,8 +1,6 @@
1
1
  import { FC } from "react";
2
- import { FeedbackProjection } from "../../../../../../projection/feedback/feedback";
3
2
  import { ReturnQuestionProjection } from "../../../../../../projection/returnQuestion/returnQuestion";
4
3
  interface ReturnQuestionsFeedbackProps {
5
- readonly feedback: FeedbackProjection;
6
4
  readonly returnQuestions: ReturnQuestionProjection[];
7
5
  readonly onEditFeedback: () => void;
8
6
  }
@@ -4,7 +4,6 @@ import React from "react";
4
4
  import { View } from "react-native";
5
5
  import { ReturnQuestionType, } from "../../../../../../projection/returnQuestion/returnQuestion";
6
6
  import { ReturnQuestions } from "../../../../components/organisms/returnQuestions/ReturnQuestions";
7
- import { ReturnQuestionFeedbackProvider } from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
8
7
  import { ReturnQuestionItemProvider, } from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionItem";
9
8
  import { HostDefaultReturnQuestionFeedbackItem } from "../../../../components/organisms/returnQuestions/components/hostDefaultReturnQuestionFeedbackItem/HostDefaultReturnQuestionFeedbackItem";
10
9
  import { ReturnQuestionFeedbackItem } from "../../../../components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem";
@@ -13,20 +12,19 @@ import { ButtonIcon } from "../../../../shared/components/molecules/buttonIcon/B
13
12
  import { style } from "./ReturnQuestionsFeedback.style";
14
13
  const returnQuestionItems = {
15
14
  [ReturnQuestionType.HOST_DEFAULT]: HostDefaultReturnQuestionFeedbackItem,
16
- [ReturnQuestionType.HOST_TEXTAREA]: HostDefaultReturnQuestionFeedbackItem,
15
+ [ReturnQuestionType.HOST_TEXTAREA]: ReturnQuestionFeedbackItem,
17
16
  [ReturnQuestionType.HOST_SELECT]: ReturnQuestionFeedbackItem,
18
17
  [ReturnQuestionType.HOST_STACK]: ReturnQuestionFeedbackItem,
19
18
  [ReturnQuestionType.TEXTAREA]: ReturnQuestionFeedbackItem,
20
19
  [ReturnQuestionType.OPTION]: ReturnQuestionFeedbackItem,
21
20
  };
22
- const ReturnQuestionsFeedback = ({ feedback, returnQuestions, onEditFeedback }) => {
21
+ const ReturnQuestionsFeedback = ({ returnQuestions, onEditFeedback }) => {
23
22
  const titleText = useI18nMessage({ id: I18nMessages.FEEDBACK_TITLE, prefix: RETURN_QUESTIONS_FEEDBACK_PREFIX });
24
23
  return (React.createElement(View, null,
25
24
  React.createElement(View, { style: style.titleContainer },
26
25
  React.createElement(Text, { level: 2, style: style.title }, titleText),
27
26
  React.createElement(ButtonIcon, { name: "pencil", onPress: onEditFeedback })),
28
- React.createElement(ReturnQuestionFeedbackProvider, { feedback: feedback },
29
- React.createElement(ReturnQuestionItemProvider, { returnQuestionItems: returnQuestionItems },
30
- React.createElement(ReturnQuestions, { returnQuestions: returnQuestions })))));
27
+ React.createElement(ReturnQuestionItemProvider, { returnQuestionItems: returnQuestionItems },
28
+ React.createElement(ReturnQuestions, { returnQuestions: returnQuestions }))));
31
29
  };
32
30
  export { ReturnQuestionsFeedback };
@@ -5,7 +5,6 @@ import { ReturnQuestionProjection } from "../../../../../../projection/returnQue
5
5
  import { PriceProjection } from "../../../../../../projection/shared/price";
6
6
  interface ReturnQuestionsFormProps {
7
7
  readonly visible: boolean;
8
- readonly feedback: FeedbackProjection;
9
8
  readonly returnQuestions: ReturnQuestionProjection[];
10
9
  readonly checkoutItemPrice: PriceProjection;
11
10
  readonly productVariant: CheckoutItemProductVariantProjection;
@@ -6,7 +6,7 @@ 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";
9
- import { ReturnQuestionFeedbackProvider } from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
9
+ import { useReturnQuestionFeedback } from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
10
10
  import { ReturnQuestionItemProvider, } from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionItem";
11
11
  import { HostDefaultReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem";
12
12
  import { HostSelectReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem";
@@ -26,21 +26,21 @@ const returnQuestionItems = {
26
26
  [ReturnQuestionType.TEXTAREA]: TextareaReturnQuestionItem,
27
27
  [ReturnQuestionType.OPTION]: OptionReturnQuestionItem,
28
28
  };
29
- const ReturnQuestionsForm = ({ feedback, returnQuestions, checkoutItemPrice, productVariant, visible, onSubmit, onClose, }) => {
29
+ const ReturnQuestionsForm = ({ returnQuestions, checkoutItemPrice, productVariant, visible, onSubmit, onClose, }) => {
30
30
  const titleText = useI18nMessage({ id: I18nMessages.RETURN_QUESTIONS_TITLE, prefix: RETURN_QUESTIONS_PREFIX });
31
31
  const submitButtonText = useI18nMessage({
32
32
  id: I18nMessages.RETURN_QUESTIONS_SUBMIT_BUTTON,
33
33
  prefix: RETURN_QUESTIONS_PREFIX,
34
34
  });
35
35
  const { media, brand, name, size, color } = productVariant;
36
+ const feedback = useReturnQuestionFeedback();
36
37
  const handleOnSubmit = useCallback(() => onSubmit(feedback), [feedback, onSubmit]);
37
- return (React.createElement(ReturnQuestionFeedbackProvider, { feedback: feedback },
38
- React.createElement(ReturnQuestionItemProvider, { returnQuestionItems: returnQuestionItems },
39
- React.createElement(PortalHost, { name: RETURN_QUESTION_FORM_PORTAL_HOST_NAME }),
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 },
41
- React.createElement(View, { style: style.returnQuestionsContainer },
42
- React.createElement(Text, { level: 2, style: style.title }, titleText),
43
- React.createElement(ProductVariant, { brand: brand, color: color, media: media, name: name, price: checkoutItemPrice, size: size }),
44
- React.createElement(ReturnQuestions, { portalHostName: RETURN_QUESTION_FORM_PORTAL_HOST_NAME, returnQuestions: returnQuestions }))))));
38
+ return (React.createElement(ReturnQuestionItemProvider, { returnQuestionItems: returnQuestionItems },
39
+ React.createElement(PortalHost, { name: RETURN_QUESTION_FORM_PORTAL_HOST_NAME }),
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 },
41
+ React.createElement(View, { style: style.returnQuestionsContainer },
42
+ React.createElement(Text, { level: 2, style: style.title }, titleText),
43
+ React.createElement(ProductVariant, { brand: brand, color: color, media: media, name: name, price: checkoutItemPrice, size: size }),
44
+ React.createElement(ReturnQuestions, { portalHostName: RETURN_QUESTION_FORM_PORTAL_HOST_NAME, returnQuestions: returnQuestions })))));
45
45
  };
46
46
  export { ReturnQuestionsForm };
@@ -4,10 +4,7 @@ interface ProductVariantProjection {
4
4
  readonly size: SizeProjection;
5
5
  }
6
6
  interface BookedSizeChangeProductsVariantsProjection {
7
- readonly id: string;
8
- readonly checkoutId: string;
9
- readonly checkoutItemId: string;
10
- readonly booking: string | null;
7
+ readonly bookingId: string;
11
8
  readonly productVariants: ProductVariantProjection[];
12
9
  }
13
10
  export type { BookedSizeChangeProductsVariantsProjection, ProductVariantProjection };
@@ -39,7 +39,7 @@ interface CheckoutItemProjection {
39
39
  readonly price: PriceProjection;
40
40
  readonly replacedFor?: string;
41
41
  readonly productVariant: CheckoutItemProductVariantProjection;
42
- readonly feedback: FeedbackProjection;
42
+ readonly feedbacks: FeedbackProjection;
43
43
  }
44
44
  export type { CheckoutItemProjection, CheckoutItemProductVariantProjection, ColorProjection, MediaProjection };
45
45
  export { MediaPerspective };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [