@lookiero/checkout 0.8.28 → 1.1.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.
@@ -1,5 +1,5 @@
1
1
  import { useI18nMessage, useIntl } from "@lookiero/i18n-react";
2
- import React, { useCallback, useState } from "react";
2
+ import React, { useCallback, useEffect, useState } from "react";
3
3
  import { TouchableHighlight, View } from "react-native";
4
4
  import { Modal } from "../../../../../../../shared/ui/components/layouts/modal/Modal";
5
5
  import { ButtonIcon } from "../../../../../../../shared/ui/components/molecules/buttonIcon/ButtonIcon";
@@ -17,12 +17,18 @@ const HostSelectReturnQuestionItem = ({ returnQuestion, children, portalHostName
17
17
  const intl = useIntl();
18
18
  const translate = useCallback((returnQuestionName) => intl.formatMessage({ id: returnQuestionName, defaultMessage: returnQuestionName }), [intl]);
19
19
  const inputValue = feedbackForReturnQuestion({ feedback, returnQuestion, translate }).join(" / ");
20
- const deepestReturnQuestionWithFeedback = deepestReturnQuestionWithFeedbackForReturnQuestion({
20
+ const [deepestReturnQuestionWithFeedback, isLeaf] = deepestReturnQuestionWithFeedbackForReturnQuestion({
21
21
  feedback,
22
22
  returnQuestion,
23
23
  });
24
24
  const handleOnBackButtonPress = useCallback(() => deepestReturnQuestionWithFeedback &&
25
25
  onChange({ returnQuestionId: deepestReturnQuestionWithFeedback.id, returnQuestionFeedback: undefined }), [deepestReturnQuestionWithFeedback, onChange]);
26
+ useEffect(() => {
27
+ if (isLeaf) {
28
+ handleOnModalClose();
29
+ }
30
+ // deepestReturnQuestionWithFeedback needs to be as a dependency in order to be re-evaluated whenever it changes
31
+ }, [handleOnModalClose, deepestReturnQuestionWithFeedback, isLeaf]);
26
32
  return (React.createElement(React.Fragment, null,
27
33
  React.createElement(TouchableHighlight, { style: style.container, underlayColor: containerUnderlayColor, onPress: handleOnPress },
28
34
  React.createElement(View, { pointerEvents: "none" },
@@ -1,7 +1,7 @@
1
1
  import { FeedbackProjection } from "../../../../../../projection/feedback/feedback";
2
2
  import { ReturnQuestionProjection } from "../../../../../../projection/returnQuestion/returnQuestion";
3
3
  interface RecursiveFeedbackForReturnQuestionFunctionArgs {
4
- readonly feedback: FeedbackProjection | undefined;
4
+ readonly feedback: FeedbackProjection;
5
5
  readonly returnQuestion: ReturnQuestionProjection;
6
6
  readonly translate: (i18nString: string) => string;
7
7
  readonly acc?: string[];
@@ -11,12 +11,15 @@ interface RecursiveFeedbackForReturnQuestionFunction {
11
11
  }
12
12
  declare const feedbackForReturnQuestion: RecursiveFeedbackForReturnQuestionFunction;
13
13
  interface RecursiveDeepestReturnQuestionWithFeedbackFunctionArgs {
14
- readonly feedback: FeedbackProjection | undefined;
14
+ readonly feedback: FeedbackProjection;
15
15
  readonly returnQuestion: ReturnQuestionProjection;
16
16
  readonly deepestReturnQuestion?: ReturnQuestionProjection;
17
17
  }
18
18
  interface RecursiveDeepestReturnQuestionWithFeedbackFunction {
19
- (args: RecursiveDeepestReturnQuestionWithFeedbackFunctionArgs): ReturnQuestionProjection | undefined;
19
+ (args: RecursiveDeepestReturnQuestionWithFeedbackFunctionArgs): [
20
+ question: ReturnQuestionProjection | undefined,
21
+ isLeaf: boolean
22
+ ];
20
23
  }
21
24
  declare const deepestReturnQuestionWithFeedbackForReturnQuestion: RecursiveDeepestReturnQuestionWithFeedbackFunction;
22
25
  export { feedbackForReturnQuestion, deepestReturnQuestionWithFeedbackForReturnQuestion };
@@ -1,9 +1,6 @@
1
1
  import { validate } from "uuid";
2
2
  const isUuid = (value) => validate(value);
3
3
  const feedbackForReturnQuestion = ({ feedback, returnQuestion, translate, acc = [], }) => {
4
- if (!feedback) {
5
- return [];
6
- }
7
4
  const returnQuestionId = Object.keys(feedback).find((id) => id === returnQuestion.id);
8
5
  if (returnQuestionId) {
9
6
  const returnQuestionFeedback = feedback[returnQuestionId];
@@ -26,9 +23,6 @@ const feedbackForReturnQuestion = ({ feedback, returnQuestion, translate, acc =
26
23
  ], []) || []);
27
24
  };
28
25
  const deepestReturnQuestionWithFeedbackForReturnQuestion = ({ feedback, returnQuestion, deepestReturnQuestion, }) => {
29
- if (!feedback) {
30
- return;
31
- }
32
26
  const returnQuestionId = Object.keys(feedback).find((id) => id === returnQuestion.id);
33
27
  if (returnQuestionId) {
34
28
  const returnQuestionFeedback = feedback[returnQuestionId];
@@ -41,9 +35,9 @@ const deepestReturnQuestionWithFeedbackForReturnQuestion = ({ feedback, returnQu
41
35
  deepestReturnQuestion: returnQuestion,
42
36
  });
43
37
  }
44
- return returnQuestion;
38
+ return [returnQuestion, false];
45
39
  }
46
- return returnQuestion;
40
+ return [returnQuestion, false];
47
41
  }
48
42
  const feebackReturnQuestionChild = returnQuestion.children?.find((childReturnQuestion) => Object.keys(feedback).find((id) => id === childReturnQuestion.id));
49
43
  if (feebackReturnQuestionChild) {
@@ -53,6 +47,6 @@ const deepestReturnQuestionWithFeedbackForReturnQuestion = ({ feedback, returnQu
53
47
  deepestReturnQuestion: feebackReturnQuestionChild,
54
48
  });
55
49
  }
56
- return deepestReturnQuestion;
50
+ return [deepestReturnQuestion, !returnQuestion.children || returnQuestion.children.length === 0];
57
51
  };
58
52
  export { feedbackForReturnQuestion, deepestReturnQuestionWithFeedbackForReturnQuestion };
@@ -160,7 +160,8 @@ const Item = ({ customerId, country }) => {
160
160
  dependenciesLoadedStatuses.includes(sizeChangeEnabledStatus) &&
161
161
  // This will ensure that the view is not shown until bookCheckoutBooking use-case is dispatched (if required)
162
162
  (isBookingRequired ? checkout?.checkoutBookingId && bookedProductsVariants : true) &&
163
- (dependenciesLoadedStatuses.includes(checkoutStatus) || checkout);
163
+ (dependenciesLoadedStatuses.includes(checkoutStatus) || checkout) &&
164
+ resetCheckoutItemStatus !== CommandStatus.LOADING;
164
165
  if (!dependenciesLoaded)
165
166
  return React.createElement(Spinner, null);
166
167
  const { price } = checkoutItem;
@@ -169,7 +170,7 @@ const Item = ({ customerId, country }) => {
169
170
  React.createElement(SizeWithoutStockModal, { visible: sizeWithoutStockModalVisible, onDismiss: handleOnHideSizeWithoutStockModal }),
170
171
  React.createElement(SafeAreaScrollView, { scrollerPaddingTop: Platform.OS === "web" || Platform.OS === "android" ? HEADER_HEIGHT : 0, footer: !customerDecissionMade && (React.createElement(ItemActions, { country: country, keepButtonLoading: keepCheckoutItemStatus === CommandStatus.LOADING, productVariantSelected: productVariantSelected, productVariants: bookedProductsVariants?.productVariants, returnButtonLoading: returnCheckoutItemStatus === CommandStatus.LOADING, sizeSelectorDisabled: replaceCheckoutItemStatus === CommandStatus.LOADING, onKeep: handleOnKeep, onLayout: handleOnStickyLayout, onReplace: handleOnReplace, onReturn: handleOnReturn, onSizeSelectorPress: handleOnShowSizeWithoutStockModal })) },
171
172
  React.createElement(Body, null,
172
- customerDecissionMade && (React.createElement(CustomerDecissionBanner, { changingDecission: resetCheckoutItemStatus === CommandStatus.LOADING, checkoutItemStatus: checkoutItem.status, onPress: handleOnPressCustomerDecissionBanner })),
173
+ customerDecissionMade && (React.createElement(CustomerDecissionBanner, { checkoutItemStatus: checkoutItem.status, onPress: handleOnPressCustomerDecissionBanner })),
173
174
  React.createElement(View, { style: [style.content, { paddingBottom: Platform.OS === "web" ? spaceXL : stickyHeight }] },
174
175
  React.createElement(View, { style: style.sliderContainer },
175
176
  React.createElement(ProductVariantSlider, { producVariantMedia: media, onChanged: handleOnChangedProductVariantSlider })),
@@ -4,7 +4,6 @@ type CustomerDecissionBannerStatus = Exclude<CheckoutItemStatus, CheckoutItemSta
4
4
  interface CustomerDecissionBannerProps {
5
5
  readonly checkoutItemStatus: CustomerDecissionBannerStatus;
6
6
  readonly onPress: () => void;
7
- readonly changingDecission: boolean;
8
7
  }
9
8
  declare const CustomerDecissionBanner: FC<CustomerDecissionBannerProps>;
10
9
  export type { CustomerDecissionBannerStatus };
@@ -1,27 +1,21 @@
1
1
  import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
2
2
  import { useI18nMessage } from "@lookiero/i18n-react";
3
3
  import React from "react";
4
- import { Pressable, View } from "react-native";
4
+ import { Pressable } from "react-native";
5
5
  import { CheckoutItemStatus } from "../../../../../../domain/checkoutItem/model/checkoutItem";
6
- import { Spinner } from "../../../../../../shared/ui/components/atoms/spinner/Spinner";
7
6
  import { Banner } from "../../../../components/layouts/banner/Banner";
8
7
  import { I18nMessages } from "../../../../i18n/i18n";
9
- import { theme } from "../../../../theme/theme";
10
8
  import { style } from "./CustomerDecissionBanner.style";
11
- const { colorContent } = theme();
12
9
  const i18nMessageForCheckoutItemStatus = {
13
10
  [CheckoutItemStatus.KEPT]: I18nMessages.ITEM_BANNER_CUSTOMER_KEPT_DECISSION,
14
11
  [CheckoutItemStatus.REPLACED]: I18nMessages.ITEM_BANNER_CUSTOMER_REPLACED_DECISSION,
15
12
  [CheckoutItemStatus.RETURNED]: I18nMessages.ITEM_BANNER_CUSTOMER_RETURNED_DECISSION,
16
13
  };
17
- const CustomerDecissionBanner = ({ checkoutItemStatus, onPress, changingDecission, }) => {
14
+ const CustomerDecissionBanner = ({ checkoutItemStatus, onPress }) => {
18
15
  const decissionText = useI18nMessage({ id: i18nMessageForCheckoutItemStatus[checkoutItemStatus] }) || "";
19
16
  const bannerButtonText = useI18nMessage({ id: I18nMessages.ITEM_BANNER_BUTTON });
20
17
  return (React.createElement(Banner, { text: decissionText },
21
- React.createElement(View, { style: style.actions },
22
- React.createElement(View, { style: style.placeholder }),
23
- React.createElement(Pressable, { onPress: changingDecission ? undefined : onPress },
24
- React.createElement(Text, { level: 2, style: style.buttonText, detail: true }, bannerButtonText)),
25
- React.createElement(View, { style: style.placeholder }, changingDecission && React.createElement(Spinner, { color: colorContent, size: 20 })))));
18
+ React.createElement(Pressable, { style: style.button, onPress: onPress },
19
+ React.createElement(Text, { level: 2, style: style.buttonText, detail: true }, bannerButtonText))));
26
20
  };
27
21
  export { CustomerDecissionBanner };
@@ -1,16 +1,10 @@
1
1
  declare const style: {
2
- actions: {
3
- flexDirection: "row";
4
- justifyContent: "space-between";
2
+ button: {
3
+ alignItems: "center";
5
4
  marginTop: number;
6
- minHeight: number;
7
- width: string;
8
5
  };
9
6
  buttonText: {
10
7
  textDecorationLine: "underline";
11
8
  };
12
- placeholder: {
13
- width: number;
14
- };
15
9
  };
16
10
  export { style };
@@ -2,18 +2,12 @@ import { StyleSheet } from "react-native";
2
2
  import { theme } from "../../../../theme/theme";
3
3
  const { spaceM } = theme();
4
4
  const style = StyleSheet.create({
5
- actions: {
6
- flexDirection: "row",
7
- justifyContent: "space-between",
5
+ button: {
6
+ alignItems: "center",
8
7
  marginTop: spaceM,
9
- minHeight: 20,
10
- width: "100%",
11
8
  },
12
9
  buttonText: {
13
10
  textDecorationLine: "underline",
14
11
  },
15
- placeholder: {
16
- width: 20,
17
- },
18
12
  });
19
13
  export { style };
@@ -1,8 +1,3 @@
1
1
  import { FC } from "react";
2
- import { ColorValue } from "react-native";
3
- interface SpinnerProps {
4
- readonly color?: ColorValue;
5
- readonly size?: number | "large" | "small";
6
- }
7
- declare const Spinner: FC<SpinnerProps>;
2
+ declare const Spinner: FC;
8
3
  export { Spinner };
@@ -1,8 +1,7 @@
1
+ import { Spinner as AuroraSpinner } from "@lookiero/aurora-next/build/components/atoms/Spinner/Spinner";
1
2
  import React from "react";
2
- import { ActivityIndicator, View } from "react-native";
3
- import { theme } from "../../../../../infrastructure/ui/theme/theme";
3
+ import { View } from "react-native";
4
4
  import { style } from "./Spinner.style";
5
- const { colorPrimary } = theme();
6
- const Spinner = ({ color = colorPrimary, size = "large" }) => (React.createElement(View, { style: style.container },
7
- React.createElement(ActivityIndicator, { color: color, size: size })));
5
+ const Spinner = () => (React.createElement(View, { style: style.container },
6
+ React.createElement(AuroraSpinner, null)));
8
7
  export { Spinner };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.8.28",
3
+ "version": "1.1.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -45,7 +45,7 @@
45
45
  "peerDependencies": {
46
46
  "@lookiero/aurora-fonts": "^1.0.6",
47
47
  "@lookiero/aurora-iconfont": "^2.0.37",
48
- "@lookiero/aurora-next": "^3.0.185",
48
+ "@lookiero/aurora-next": "^3.0.191",
49
49
  "@lookiero/data-sources": "^0.3",
50
50
  "@lookiero/event": "^0.3",
51
51
  "@lookiero/locale": "^0.3",
@@ -67,7 +67,7 @@
67
67
  "@expo/webpack-config": "^0.17.2",
68
68
  "@lookiero/aurora-fonts": "^1.0.6",
69
69
  "@lookiero/aurora-iconfont": "^2.0.37",
70
- "@lookiero/aurora-next": "^3.0.185",
70
+ "@lookiero/aurora-next": "^3.0.191",
71
71
  "@lookiero/data-sources": "^0.3",
72
72
  "@lookiero/event": "^0.3",
73
73
  "@lookiero/locale": "^0.3",