@lookiero/checkout 0.8.7 → 0.8.8

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.
@@ -7,6 +7,6 @@ const useViewBookedProductsVariantsForCheckoutItem = ({ checkoutItemId, }) => us
7
7
  query: viewBookedProductsVariantsForCheckoutItem({ checkoutItemId }),
8
8
  contextId: MESSAGING_CONTEXT_ID,
9
9
  invalidation: isCheckoutBookingBooked,
10
- options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
10
+ options: { refetchOnMount: "always", staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
11
11
  });
12
12
  export { useViewBookedProductsVariantsForCheckoutItem };
@@ -1,6 +1,7 @@
1
1
  import { useQuery } from "@lookiero/messaging-react";
2
2
  import { CHECKOUT_STARTED } from "../../../../domain/checkout/model/checkoutStarted";
3
3
  import { CHECKOUT_SUBMITTED } from "../../../../domain/checkout/model/checkoutSubmitted";
4
+ import { CHECKOUT_BOOKING_BOOKED } from "../../../../domain/checkoutBooking/model/checkoutBookingBooked";
4
5
  import { CHECKOUT_BOOKING_EXPIRED, } from "../../../../domain/checkoutBooking/model/checkoutBookingExpired";
5
6
  import { CHECKOUT_FEEDBACK_GIVEN, } from "../../../../domain/checkoutFeedback/model/checkoutFeedbackGiven";
6
7
  import { CHECKOUT_ITEM_KEPT } from "../../../../domain/checkoutItem/model/checkoutItemKept";
@@ -14,6 +15,7 @@ const isCheckoutItemReplaced = (event) => event.name === CHECKOUT_ITEM_REPLACED;
14
15
  const isCheckoutStarted = (event) => event.name === CHECKOUT_STARTED;
15
16
  const isCheckoutSubmitted = (event) => event.name === CHECKOUT_SUBMITTED;
16
17
  const isCheckoutFeedbackGiven = (event) => event.name === CHECKOUT_FEEDBACK_GIVEN;
18
+ const isCheckoutBookingBooked = (event) => event.name === CHECKOUT_BOOKING_BOOKED;
17
19
  const isCheckoutBookingExpired = (event) => event.name === CHECKOUT_BOOKING_EXPIRED;
18
20
  const shouldInvalidate = (event) => isCheckoutItemKept(event) ||
19
21
  isCheckoutItemReplaced(event) ||
@@ -21,11 +23,17 @@ const shouldInvalidate = (event) => isCheckoutItemKept(event) ||
21
23
  isCheckoutStarted(event) ||
22
24
  isCheckoutSubmitted(event) ||
23
25
  isCheckoutFeedbackGiven(event) ||
26
+ isCheckoutBookingBooked(event) ||
24
27
  isCheckoutBookingExpired(event);
25
28
  const useViewFirstAvailableCheckoutByCustomerId = ({ customerId }) => useQuery({
26
29
  query: viewFirstAvailableCheckoutByCustomerId({ customerId }),
27
30
  contextId: MESSAGING_CONTEXT_ID,
28
31
  invalidation: shouldInvalidate,
29
- options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
32
+ options: {
33
+ refetchOnMount: "always",
34
+ staleTime: Infinity,
35
+ retry: false,
36
+ refetchOnWindowFocus: false,
37
+ },
30
38
  });
31
39
  export { useViewFirstAvailableCheckoutByCustomerId };
@@ -4,6 +4,6 @@ import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
4
4
  const useViewFiveItemsDiscountByCustomerId = ({ customerId }) => useQuery({
5
5
  query: viewFiveItemsDiscountByCustomerId({ customerId }),
6
6
  contextId: MESSAGING_CONTEXT_ID,
7
- options: { staleTime: Infinity },
7
+ options: { refetchOnMount: "always", staleTime: Infinity },
8
8
  });
9
9
  export { useViewFiveItemsDiscountByCustomerId };
@@ -7,6 +7,12 @@ const useViewIsCheckoutAccessibleByCustomerId = ({ customerId }) => useQuery({
7
7
  query: viewIsCheckoutAccessibleByCustomerId({ customerId }),
8
8
  contextId: MESSAGING_CONTEXT_ID,
9
9
  invalidation: isCheckoutFeedbackGiven,
10
- options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
10
+ options: {
11
+ refetchOnMount: "always",
12
+ staleTime: Infinity,
13
+ retry: false,
14
+ refetchOnWindowFocus: false,
15
+ cacheTime: 0,
16
+ },
11
17
  });
12
18
  export { useViewIsCheckoutAccessibleByCustomerId };
@@ -4,6 +4,6 @@ import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
4
4
  const useListCheckoutQuestionsByCheckoutId = ({ checkoutId }) => useQuery({
5
5
  query: listCheckoutQuestionsByCheckoutId({ checkoutId }),
6
6
  contextId: MESSAGING_CONTEXT_ID,
7
- options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
7
+ options: { refetchOnMount: "always", staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
8
8
  });
9
9
  export { useListCheckoutQuestionsByCheckoutId };
@@ -12,6 +12,6 @@ const useViewPaymentFlowPayloadByCheckoutId = ({ checkoutId }) => useQuery({
12
12
  query: viewPaymentFlowPayloadByCheckoutId({ checkoutId: checkoutId }),
13
13
  contextId: MESSAGING_CONTEXT_ID,
14
14
  invalidation: shouldInvalidate,
15
- options: { enabled: Boolean(checkoutId) },
15
+ options: { refetchOnMount: "always", enabled: Boolean(checkoutId) },
16
16
  });
17
17
  export { useViewPaymentFlowPayloadByCheckoutId };
@@ -12,6 +12,11 @@ const useViewPricingByCheckoutId = ({ checkoutId }) => useQuery({
12
12
  query: viewPricingByCheckoutId({ checkoutId }),
13
13
  contextId: MESSAGING_CONTEXT_ID,
14
14
  invalidation: shouldInvalidate,
15
- options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false, refetchOnMount: "always" },
15
+ options: {
16
+ refetchOnMount: "always",
17
+ staleTime: Infinity,
18
+ retry: false,
19
+ refetchOnWindowFocus: false,
20
+ },
16
21
  });
17
22
  export { useViewPricingByCheckoutId };
@@ -4,6 +4,6 @@ import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
4
4
  const useListReturnQuestionsByCheckoutItemId = ({ checkoutItemId }) => useQuery({
5
5
  query: listReturnQuestionsByCheckoutItemId({ checkoutItemId }),
6
6
  contextId: MESSAGING_CONTEXT_ID,
7
- options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
7
+ options: { refetchOnMount: "always", staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
8
8
  });
9
9
  export { useListReturnQuestionsByCheckoutItemId };
@@ -7,6 +7,6 @@ const useViewUiSettingByKey = ({ key }) => useQuery({
7
7
  query: viewUiSettingByKey({ key }),
8
8
  contextId: MESSAGING_CONTEXT_ID,
9
9
  invalidation: isUiSettingUpdated,
10
- options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
10
+ options: { refetchOnMount: "always", staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
11
11
  });
12
12
  export { useViewUiSettingByKey };
@@ -107,31 +107,16 @@ const Item = ({ customerId, country }) => {
107
107
  const handleOnEditFeedback = useCallback(() => handleOnShowReturnQuestions(), [handleOnShowReturnQuestions]);
108
108
  const handleOnSubmit = useCallback(async (feedbacks) => {
109
109
  handleOnHideReturnQuestions();
110
- try {
111
- await returnCheckoutItem({ feedbacks });
112
- navigateToNextView();
113
- }
114
- catch (e) {
115
- // TODO show an error Notification?
116
- }
110
+ await returnCheckoutItem({ feedbacks });
111
+ navigateToNextView();
117
112
  }, [handleOnHideReturnQuestions, navigateToNextView, returnCheckoutItem]);
118
113
  const handleOnKeep = useCallback(async () => {
119
- try {
120
- await keepCheckoutItem();
121
- navigateToNextView();
122
- }
123
- catch (e) {
124
- // TODO show an error Notification?
125
- }
114
+ await keepCheckoutItem();
115
+ navigateToNextView();
126
116
  }, [keepCheckoutItem, navigateToNextView]);
127
117
  const handleOnReplace = useCallback(async (replacedForId) => {
128
- try {
129
- await replaceCheckoutItem({ replacedForId });
130
- handleOnShowSizeChangeModal();
131
- }
132
- catch (e) {
133
- // TODO show an error Notification?
134
- }
118
+ await replaceCheckoutItem({ replacedForId });
119
+ handleOnShowSizeChangeModal();
135
120
  }, [handleOnShowSizeChangeModal, replaceCheckoutItem]);
136
121
  const handleOnReturn = useCallback(() => handleOnShowReturnQuestions(), [handleOnShowReturnQuestions]);
137
122
  const productVariantSelected = useMemo(() => checkoutItem.status === CheckoutItemStatus.REPLACED && checkoutItem.replacedFor
@@ -139,7 +124,8 @@ const Item = ({ customerId, country }) => {
139
124
  : { id: checkoutItem.productVariant.id, size: checkoutItem.productVariant.size }, [checkoutItem.productVariant.id, checkoutItem.productVariant.size, checkoutItem.replacedFor, checkoutItem.status]);
140
125
  const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
141
126
  const dependenciesLoaded = dependenciesLoadedStatuses.includes(returnQuestionsStatus) &&
142
- (dependenciesLoadedStatuses.includes(checkoutStatus) || checkout) &&
127
+ // This will ensure that the view is not shown until bookCheckoutBooking use-case is dispatched
128
+ (dependenciesLoadedStatuses.includes(checkoutStatus) || (checkout && checkout.checkoutBookingId)) &&
143
129
  dependenciesLoadedStatuses.includes(bookedProductsVariantsStatus) &&
144
130
  bookedProductsVariants;
145
131
  if (!dependenciesLoaded)
@@ -9,6 +9,6 @@ const useListNotifications = ({ contextId }) => useQuery({
9
9
  query: listNotifications(),
10
10
  contextId,
11
11
  invalidation: shouldInvalidate,
12
- options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
12
+ options: { refetchOnMount: "always", staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
13
13
  });
14
14
  export { useListNotifications };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.8.7",
3
+ "version": "0.8.8",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [