@lookiero/checkout 0.2.48 → 0.2.50

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 (27) hide show
  1. package/dist/infrastructure/ui/components/atoms/price/Price.d.ts +1 -1
  2. package/dist/infrastructure/ui/i18n/i18n.d.ts +12 -1
  3. package/dist/infrastructure/ui/i18n/i18n.js +11 -0
  4. package/dist/infrastructure/ui/views/item/components/productVariant/ProductVariant.d.ts +12 -1
  5. package/dist/infrastructure/ui/views/item/components/productVariant/ProductVariant.js +28 -17
  6. package/dist/infrastructure/ui/views/item/components/productVariant/ProductVariant.style.d.ts +22 -0
  7. package/dist/infrastructure/ui/views/item/components/productVariant/ProductVariant.style.js +23 -1
  8. package/dist/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.d.ts +2 -1
  9. package/dist/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.d.ts +2 -1
  10. package/dist/infrastructure/ui/views/summary/Summary.js +9 -2
  11. package/dist/infrastructure/ui/views/summary/components/checkoutItemsTabs/CheckoutItemsTabs.d.ts +1 -0
  12. package/dist/infrastructure/ui/views/summary/components/checkoutItemsTabs/CheckoutItemsTabs.js +10 -6
  13. package/dist/infrastructure/ui/views/summary/components/checkoutItemsTabs/CheckoutItemsTabs.style.d.ts +3 -0
  14. package/dist/infrastructure/ui/views/summary/components/checkoutItemsTabs/CheckoutItemsTabs.style.js +4 -1
  15. package/dist/infrastructure/ui/views/summary/components/pricing/Pricing.d.ts +18 -0
  16. package/dist/infrastructure/ui/views/summary/components/pricing/Pricing.js +57 -0
  17. package/dist/infrastructure/ui/views/summary/components/pricing/Pricing.style.d.ts +32 -0
  18. package/dist/infrastructure/ui/views/summary/components/pricing/Pricing.style.js +35 -0
  19. package/dist/projection/checkoutItem/checkoutItem.d.ts +3 -11
  20. package/dist/projection/checkoutItem/checkoutItem.js +1 -2
  21. package/dist/projection/pricing/pricing.d.ts +17 -0
  22. package/dist/projection/pricing/pricing.js +1 -0
  23. package/dist/projection/pricing/pricing.mock.d.ts +3 -0
  24. package/dist/projection/pricing/pricing.mock.js +37 -0
  25. package/dist/projection/shared/price.d.ts +10 -0
  26. package/dist/projection/shared/price.js +1 -0
  27. package/package.json +2 -1
@@ -1,6 +1,6 @@
1
1
  import { FC } from "react";
2
2
  import { TextProps } from "react-native";
3
- import { PriceProjection } from "../../../../../projection/checkoutItem/checkoutItem";
3
+ import { PriceProjection } from "../../../../../projection/shared/price";
4
4
  declare type PriceStyle = "priceText" | "discountedText";
5
5
  declare type PriceVariant = "default" | "detail" | "subtotal" | "total";
6
6
  interface PriceProps {
@@ -34,6 +34,17 @@ declare enum I18nMessages {
34
34
  RETURN_QUESTIONS_TITLE = "return_questions.title",
35
35
  RETURN_QUESTIONS_SUBMIT_BUTTON = "return_questions.submit_button",
36
36
  SUMMARY_KEEP_TAB = "summary.keep_tab",
37
- SUMMARY_RETURN_TAB = "summary.return_tab"
37
+ SUMMARY_RETURN_TAB = "summary.return_tab",
38
+ SUMMARY_KEEP_EMPTY = "summary.keep_empty",
39
+ SUMMARY_RETURN_EMPTY = "summary.return_empty",
40
+ SUMMARY_TOTAL = "summary.total",
41
+ SUMMARY_SUBTOTAL = "summary.subtotal",
42
+ SUMMARY_SUBMIT_BUTTON = "summary.submit_button",
43
+ SUMMARY_FREE = "summary.free",
44
+ SUMMARY_DISCOUNT = "summary.discount",
45
+ SUMMARY_TOTAL_ITEMS_KEPT = "summary.total_items_kept",
46
+ SUMMARY_CREDIT = "summary.credit",
47
+ SUMMARY_FEE = "summary.fee",
48
+ PRODUCT_VARIANT_SIZE_CHANGE = "product_variant.size_change"
38
49
  }
39
50
  export { I18nMessages, COLOR_I18N_PREFIX, RETURN_QUESTIONS_PREFIX, RETURN_QUESTIONS_FEEDBACK_PREFIX };
@@ -36,5 +36,16 @@ var I18nMessages;
36
36
  I18nMessages["RETURN_QUESTIONS_SUBMIT_BUTTON"] = "return_questions.submit_button";
37
37
  I18nMessages["SUMMARY_KEEP_TAB"] = "summary.keep_tab";
38
38
  I18nMessages["SUMMARY_RETURN_TAB"] = "summary.return_tab";
39
+ I18nMessages["SUMMARY_KEEP_EMPTY"] = "summary.keep_empty";
40
+ I18nMessages["SUMMARY_RETURN_EMPTY"] = "summary.return_empty";
41
+ I18nMessages["SUMMARY_TOTAL"] = "summary.total";
42
+ I18nMessages["SUMMARY_SUBTOTAL"] = "summary.subtotal";
43
+ I18nMessages["SUMMARY_SUBMIT_BUTTON"] = "summary.submit_button";
44
+ I18nMessages["SUMMARY_FREE"] = "summary.free";
45
+ I18nMessages["SUMMARY_DISCOUNT"] = "summary.discount";
46
+ I18nMessages["SUMMARY_TOTAL_ITEMS_KEPT"] = "summary.total_items_kept";
47
+ I18nMessages["SUMMARY_CREDIT"] = "summary.credit";
48
+ I18nMessages["SUMMARY_FEE"] = "summary.fee";
49
+ I18nMessages["PRODUCT_VARIANT_SIZE_CHANGE"] = "product_variant.size_change";
39
50
  })(I18nMessages || (I18nMessages = {}));
40
51
  export { I18nMessages, COLOR_I18N_PREFIX, RETURN_QUESTIONS_PREFIX, RETURN_QUESTIONS_FEEDBACK_PREFIX };
@@ -1,6 +1,12 @@
1
1
  import { FC } from "react";
2
- import { ColorProjection, MediaProjection, PriceProjection } from "../../../../../../projection/checkoutItem/checkoutItem";
2
+ import { ImageStyle, StyleProp } from "react-native";
3
+ import { CheckoutItemStatus } from "../../../../../../domain/checkoutItem/model/checkoutItem";
4
+ import { ColorProjection, MediaProjection } from "../../../../../../projection/checkoutItem/checkoutItem";
5
+ import { PriceProjection } from "../../../../../../projection/shared/price";
3
6
  import { SizeProjection } from "../../../../../../projection/shared/size";
7
+ interface ProductVariantStyle {
8
+ readonly image: StyleProp<ImageStyle>;
9
+ }
4
10
  interface ProductVariantProps {
5
11
  readonly media: MediaProjection[];
6
12
  readonly brand: string;
@@ -8,6 +14,11 @@ interface ProductVariantProps {
8
14
  readonly price: PriceProjection;
9
15
  readonly size: SizeProjection;
10
16
  readonly color: ColorProjection;
17
+ readonly status?: CheckoutItemStatus;
18
+ readonly discarded?: boolean;
19
+ readonly style?: Partial<ProductVariantStyle>;
20
+ readonly onPress?: () => void;
11
21
  }
12
22
  declare const ProductVariant: FC<ProductVariantProps>;
23
+ export type { ProductVariantStyle };
13
24
  export { ProductVariant };
@@ -1,30 +1,41 @@
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 { Image, View } from "react-native";
4
+ import { Image, Pressable, View } from "react-native";
5
+ import Svg, { Line } from "react-native-svg";
6
+ import { CheckoutItemStatus } from "../../../../../../domain/checkoutItem/model/checkoutItem";
5
7
  import { Price } from "../../../../components/atoms/price/Price";
6
8
  import { useMediaImage } from "../../../../hooks/useMediaImage";
7
9
  import { COLOR_I18N_PREFIX, I18nMessages } from "../../../../i18n/i18n";
10
+ import { ButtonIcon } from "../../../../shared/components/molecules/buttonIcon/ButtonIcon";
8
11
  import { IMAGE_WIDTH, style } from "./ProductVariant.style";
9
- const ProductVariant = ({ media, brand, name, price, size, color }) => {
12
+ const ProductVariant = ({ media, brand, name, price, size, color, status, discarded, style: customStyle, onPress, }) => {
10
13
  const uniqueText = useI18nMessage({ id: I18nMessages.ITEM_UNIQUE });
11
14
  const colorLabel = useI18nMessage({ id: color.label, prefix: COLOR_I18N_PREFIX });
15
+ const sizeChangeText = useI18nMessage({ id: I18nMessages.PRODUCT_VARIANT_SIZE_CHANGE });
12
16
  const cdnImageUrl = useMediaImage();
13
- return (React.createElement(View, { style: style.container },
14
- React.createElement(Image, { resizeMode: "contain", style: style.media, testID: "product-variant-media", source: {
15
- uri: cdnImageUrl({
16
- url: media[0]?.url,
17
- width: IMAGE_WIDTH,
18
- }),
19
- } }),
20
- React.createElement(View, { style: style.descriptionContainer },
17
+ return (React.createElement(Pressable, { style: style.container, testID: "product-variant", onPress: onPress },
18
+ React.createElement(View, { style: style.row },
21
19
  React.createElement(View, null,
22
- React.createElement(Text, { level: 2, style: style.brand, detail: true }, brand),
23
- React.createElement(Text, { level: 2, detail: true }, name),
24
- React.createElement(Text, { level: 2, style: style.priceAndColor, detail: true },
25
- size.unique ? uniqueText : size.lookiero,
26
- " / ",
27
- colorLabel)),
28
- React.createElement(Price, { price: price, variant: "detail" }))));
20
+ React.createElement(Image, { resizeMode: "contain", style: [style.media, customStyle?.image], testID: "product-variant-media", source: {
21
+ uri: cdnImageUrl({
22
+ url: media[0]?.url,
23
+ width: IMAGE_WIDTH,
24
+ }),
25
+ } }),
26
+ discarded && (React.createElement(Svg, { preserveAspectRatio: "none", style: style.discarded, testID: "discarded", viewBox: "0 0 100 100" },
27
+ React.createElement(Line, { vectorEffect: "non-scaling-stroke", x1: "100", x2: "0", y1: "0", y2: "100" })))),
28
+ React.createElement(View, { style: style.descriptionContainer },
29
+ React.createElement(View, null,
30
+ React.createElement(Text, { level: 2, style: style.brand, detail: true }, brand),
31
+ React.createElement(Text, { level: 2, detail: true }, name),
32
+ React.createElement(Text, { level: 2, style: style.priceAndColor, detail: true },
33
+ size.unique ? uniqueText : size.lookiero,
34
+ " / ",
35
+ colorLabel),
36
+ status === CheckoutItemStatus.REPLACED && (React.createElement(View, { style: style.sizeChange },
37
+ React.createElement(Text, { level: 3, style: style.sizeChangeText, detail: true }, sizeChangeText)))),
38
+ React.createElement(Price, { price: price, variant: "detail" }))),
39
+ onPress && React.createElement(ButtonIcon, { name: "arrow-right" })));
29
40
  };
30
41
  export { ProductVariant };
@@ -5,11 +5,21 @@ declare const style: {
5
5
  };
6
6
  container: {
7
7
  flexDirection: "row";
8
+ justifyContent: "space-between";
8
9
  };
9
10
  descriptionContainer: {
10
11
  justifyContent: "space-between";
11
12
  marginLeft: number;
12
13
  };
14
+ discarded: {
15
+ height: string;
16
+ left: number;
17
+ position: "absolute";
18
+ stroke: string;
19
+ top: number;
20
+ width: string;
21
+ zIndex: number;
22
+ };
13
23
  media: {
14
24
  borderColor: string;
15
25
  borderWidth: number;
@@ -19,5 +29,17 @@ declare const style: {
19
29
  priceAndColor: {
20
30
  color: string;
21
31
  };
32
+ row: {
33
+ flexDirection: "row";
34
+ };
35
+ sizeChange: {
36
+ backgroundColor: string;
37
+ marginTop: number;
38
+ paddingHorizontal: number;
39
+ paddingVertical: number;
40
+ };
41
+ sizeChangeText: {
42
+ textTransform: "uppercase";
43
+ };
22
44
  };
23
45
  export { style, IMAGE_WIDTH };
@@ -1,6 +1,6 @@
1
1
  import { StyleSheet } from "react-native";
2
2
  import { theme } from "../../../../theme/theme";
3
- const { borderSize, colorGrayscaleL, spaceS } = theme();
3
+ const { borderSize, colorContent, colorGrayscaleL, colorInfo, spaceXS, spaceS, spaceM } = theme();
4
4
  const IMAGE_WIDTH = 96;
5
5
  const IMAGE_HEIGHT = 120;
6
6
  const style = StyleSheet.create({
@@ -9,11 +9,21 @@ const style = StyleSheet.create({
9
9
  },
10
10
  container: {
11
11
  flexDirection: "row",
12
+ justifyContent: "space-between",
12
13
  },
13
14
  descriptionContainer: {
14
15
  justifyContent: "space-between",
15
16
  marginLeft: spaceS,
16
17
  },
18
+ discarded: {
19
+ height: "100%",
20
+ left: 0,
21
+ position: "absolute",
22
+ stroke: colorContent,
23
+ top: 0,
24
+ width: "100%",
25
+ zIndex: 10,
26
+ },
17
27
  media: {
18
28
  borderColor: colorGrayscaleL,
19
29
  borderWidth: borderSize,
@@ -23,5 +33,17 @@ const style = StyleSheet.create({
23
33
  priceAndColor: {
24
34
  color: colorGrayscaleL,
25
35
  },
36
+ row: {
37
+ flexDirection: "row",
38
+ },
39
+ sizeChange: {
40
+ backgroundColor: colorInfo,
41
+ marginTop: spaceM,
42
+ paddingHorizontal: spaceS,
43
+ paddingVertical: spaceXS,
44
+ },
45
+ sizeChangeText: {
46
+ textTransform: "uppercase",
47
+ },
26
48
  });
27
49
  export { style, IMAGE_WIDTH };
@@ -1,5 +1,6 @@
1
1
  import { FC } from "react";
2
- import { ColorProjection, PriceProjection } from "../../../../../../projection/checkoutItem/checkoutItem";
2
+ import { ColorProjection } from "../../../../../../projection/checkoutItem/checkoutItem";
3
+ import { PriceProjection } from "../../../../../../projection/shared/price";
3
4
  import { SizeProjection } from "../../../../../../projection/shared/size";
4
5
  interface ProductVariantDescriptionProps {
5
6
  readonly brand: string;
@@ -1,7 +1,8 @@
1
1
  import { FC } from "react";
2
- import { CheckoutItemProductVariantProjection, PriceProjection } from "../../../../../../projection/checkoutItem/checkoutItem";
2
+ import { CheckoutItemProductVariantProjection } from "../../../../../../projection/checkoutItem/checkoutItem";
3
3
  import { FeedbackProjection } from "../../../../../../projection/feedback/feedback";
4
4
  import { ReturnQuestionProjection } from "../../../../../../projection/returnQuestion/returnQuestion";
5
+ import { PriceProjection } from "../../../../../../projection/shared/price";
5
6
  interface ReturnQuestionsFormProps {
6
7
  readonly visible: boolean;
7
8
  readonly feedback: FeedbackProjection;
@@ -1,18 +1,25 @@
1
1
  import { QueryStatus } from "@lookiero/messaging-react";
2
- import React from "react";
2
+ import React, { useCallback, useState } from "react";
3
+ import { pricing } from "../../../../projection/pricing/pricing.mock";
3
4
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
4
5
  import { Body } from "../../components/layouts/body/Body";
5
6
  import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
6
7
  import { Spinner } from "../../shared/components/atoms/spinner/Spinner";
7
8
  import { CheckoutItemsTabs } from "./components/checkoutItemsTabs/CheckoutItemsTabs";
9
+ import { Pricing } from "./components/pricing/Pricing";
8
10
  const Summary = ({ customerId }) => {
9
11
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
12
+ const [pricingCollapsed, setPricingCollapsed] = useState(true);
13
+ const handleOnPressPricing = useCallback(() => setPricingCollapsed(!pricingCollapsed), [pricingCollapsed]);
14
+ const handleOnSubmit = useCallback(() => void 0, []);
15
+ const handleOnPressItem = useCallback(() => void 0, []);
10
16
  const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
11
17
  const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus);
12
18
  if (!dependenciesLoaded)
13
19
  return React.createElement(Spinner, null);
14
20
  return (React.createElement(SafeAreaScrollView, null,
15
21
  React.createElement(Body, null,
16
- React.createElement(CheckoutItemsTabs, { checkoutItems: checkout?.items || [] }))));
22
+ React.createElement(CheckoutItemsTabs, { checkoutItems: checkout?.items || [], onPressItem: handleOnPressItem }),
23
+ React.createElement(Pricing, { balanceDiscount: pricing.balanceDiscount, collapsed: pricingCollapsed, discount: pricing.discount, discountPercentage: pricing.discountPercentage, orderTotal: pricing.orderTotal, service: pricing.service, subtotal: pricing.subtotal, totalItemsKept: 3, onPress: handleOnPressPricing, onSubmit: handleOnSubmit }))));
17
24
  };
18
25
  export { Summary };
@@ -2,6 +2,7 @@ import { FC } from "react";
2
2
  import { CheckoutItemProjection } from "../../../../../../projection/checkoutItem/checkoutItem";
3
3
  interface CheckoutItemsTabsProps {
4
4
  readonly checkoutItems: CheckoutItemProjection[];
5
+ readonly onPressItem: (checkoutItemId: string) => void;
5
6
  }
6
7
  declare const CheckoutItemsTabs: FC<CheckoutItemsTabsProps>;
7
8
  export { CheckoutItemsTabs };
@@ -1,20 +1,24 @@
1
+ import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
1
2
  import { useI18nMessage } from "@lookiero/i18n-react";
2
- import React, { useMemo } from "react";
3
+ import React, { useCallback, useMemo } from "react";
3
4
  import { View } from "react-native";
4
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, testID }) => (React.createElement(View, { style: style.checkoutItem, testID: testID },
10
- React.createElement(ProductVariant, { brand: checkoutItem.productVariant.brand, color: checkoutItem.productVariant.color, media: checkoutItem.productVariant.media, name: checkoutItem.productVariant.name, price: checkoutItem.price, size: checkoutItem.productVariant.size })));
11
- const CheckoutItemsTabs = ({ checkoutItems }) => {
10
+ const CheckoutItem = ({ checkoutItem, discarded = false, testID, style: customStyle, onPress, }) => (React.createElement(View, { style: style.checkoutItem, testID: testID },
11
+ 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 })));
12
+ const CheckoutItemsTabs = ({ checkoutItems, onPressItem }) => {
12
13
  const keepTabText = useI18nMessage({ id: I18nMessages.SUMMARY_KEEP_TAB });
13
14
  const returnTabText = useI18nMessage({ id: I18nMessages.SUMMARY_RETURN_TAB });
15
+ const keepEmptyText = useI18nMessage({ id: I18nMessages.SUMMARY_KEEP_EMPTY });
16
+ const returnEmptyText = useI18nMessage({ id: I18nMessages.SUMMARY_RETURN_EMPTY });
14
17
  const keepCheckoutItems = useMemo(() => checkoutItems.filter((checkoutItem) => checkoutItem.status === CheckoutItemStatus.KEPT || checkoutItem.status === CheckoutItemStatus.REPLACED), [checkoutItems]);
15
18
  const returnCheckoutItems = useMemo(() => checkoutItems.filter((checkoutItem) => checkoutItem.status === CheckoutItemStatus.RETURNED || checkoutItem.status === CheckoutItemStatus.REPLACED), [checkoutItems]);
19
+ const handleOnPressItem = useCallback((checkoutItemId) => onPressItem(checkoutItemId), [onPressItem]);
16
20
  return (React.createElement(Tabs, { style: { sliderContainer: style.sliderContainer }, tabLabels: [`${keepTabText} (${keepCheckoutItems.length})`, `${returnTabText} (${returnCheckoutItems.length})`] },
17
- React.createElement(React.Fragment, null, keepCheckoutItems.map((checkoutItem) => (React.createElement(CheckoutItem, { key: checkoutItem.id, checkoutItem: checkoutItem, testID: "keep-checkout-item" })))),
18
- React.createElement(React.Fragment, null, returnCheckoutItems.map((checkoutItem) => (React.createElement(CheckoutItem, { key: checkoutItem.id, checkoutItem: checkoutItem, testID: "return-checkout-item" }))))));
21
+ React.createElement(React.Fragment, null, keepCheckoutItems.length === 0 ? (React.createElement(Text, null, keepEmptyText)) : (keepCheckoutItems.map((checkoutItem) => (React.createElement(CheckoutItem, { key: checkoutItem.id, checkoutItem: checkoutItem, testID: "keep-checkout-item", onPress: () => handleOnPressItem(checkoutItem.id) }))))),
22
+ React.createElement(React.Fragment, null, returnCheckoutItems.length === 0 ? (React.createElement(Text, null, returnEmptyText)) : (returnCheckoutItems.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
23
  };
20
24
  export { CheckoutItemsTabs };
@@ -2,6 +2,9 @@ declare const style: {
2
2
  checkoutItem: {
3
3
  paddingVertical: number;
4
4
  };
5
+ returnCheckoutItem: {
6
+ borderColor: string;
7
+ };
5
8
  sliderContainer: {
6
9
  paddingHorizontal: number;
7
10
  };
@@ -1,10 +1,13 @@
1
1
  import { StyleSheet } from "react-native";
2
2
  import { theme } from "../../../../theme/theme";
3
- const { spaceM, spaceXL } = theme();
3
+ const { colorContent, spaceM, spaceXL } = theme();
4
4
  const style = StyleSheet.create({
5
5
  checkoutItem: {
6
6
  paddingVertical: spaceM,
7
7
  },
8
+ returnCheckoutItem: {
9
+ borderColor: colorContent,
10
+ },
8
11
  sliderContainer: {
9
12
  paddingHorizontal: spaceXL,
10
13
  },
@@ -0,0 +1,18 @@
1
+ import { FC } from "react";
2
+ import { ServiceProjection } from "../../../../../../projection/pricing/pricing";
3
+ import { PriceProjection } from "../../../../../../projection/shared/price";
4
+ interface PricingProps {
5
+ readonly orderTotal: PriceProjection;
6
+ readonly subtotal: PriceProjection;
7
+ readonly balanceDiscount?: PriceProjection;
8
+ readonly discount?: PriceProjection;
9
+ readonly discountPercentage?: number;
10
+ readonly totalItemsKept: number;
11
+ readonly service: ServiceProjection;
12
+ readonly collapsible?: boolean;
13
+ readonly collapsed?: boolean;
14
+ readonly onPress?: () => void;
15
+ readonly onSubmit: () => void;
16
+ }
17
+ declare const Pricing: FC<PricingProps>;
18
+ export { Pricing };
@@ -0,0 +1,57 @@
1
+ import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
2
+ import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
3
+ import { useI18nMessage } from "@lookiero/i18n-react";
4
+ import { animated, useSpring } from "@react-spring/native";
5
+ import React from "react";
6
+ import { Pressable, View } from "react-native";
7
+ import { Price } from "../../../../components/atoms/price/Price";
8
+ import { I18nMessages } from "../../../../i18n/i18n";
9
+ import { Icon } from "../../../../shared/components/atoms/icon/Icon";
10
+ import { style } from "./Pricing.style";
11
+ const PS_SERVICE_FREE_INDICATOR = 100;
12
+ const Row = ({ text, level = 3, children }) => (React.createElement(View, { style: style.row },
13
+ React.createElement(Text, { level: level, style: style.uppercase, action: true }, text),
14
+ children));
15
+ const Pricing = ({ orderTotal, subtotal, balanceDiscount, discount, discountPercentage = 0, totalItemsKept, service, collapsible = true, collapsed = false, onPress = () => void 0, onSubmit, }) => {
16
+ const totalText = useI18nMessage({ id: I18nMessages.SUMMARY_TOTAL }) || "";
17
+ const totalItemsKeptText = useI18nMessage({
18
+ id: I18nMessages.SUMMARY_TOTAL_ITEMS_KEPT,
19
+ values: { items: totalItemsKept.toString() },
20
+ });
21
+ const subtotalText = useI18nMessage({ id: I18nMessages.SUMMARY_SUBTOTAL });
22
+ const submitButtonText = useI18nMessage({ id: I18nMessages.SUMMARY_SUBMIT_BUTTON });
23
+ const freeText = useI18nMessage({ id: I18nMessages.SUMMARY_FREE });
24
+ const discountText = useI18nMessage({
25
+ id: I18nMessages.SUMMARY_DISCOUNT,
26
+ values: { discount: discountPercentage?.toString() },
27
+ }) || "";
28
+ const creditText = useI18nMessage({ id: I18nMessages.SUMMARY_CREDIT }) || "";
29
+ const feeText = useI18nMessage({ id: I18nMessages.SUMMARY_FEE }) || "";
30
+ const isPSServiceFree = service.discount.amount === PS_SERVICE_FREE_INDICATOR;
31
+ const collapsedStyle = useSpring({ opacitiy: collapsed ? 1 : 0 });
32
+ const notCollapsedStyle = useSpring({ opacitiy: collapsed ? 0 : 1 });
33
+ return (React.createElement(Pressable, { disabled: !collapsible, style: style.container, testID: "pricing", onPress: onPress },
34
+ collapsible && (React.createElement(View, { style: style.iconContainer },
35
+ React.createElement(Icon, { name: collapsed ? "arrow-up" : "arrow-down" }))),
36
+ collapsed && collapsible ? (React.createElement(animated.View, { style: [style.collapsed, { opacity: collapsedStyle.opacitiy }] },
37
+ React.createElement(View, null,
38
+ React.createElement(Text, { level: 1, style: style.totalCollapsed, detail: true },
39
+ totalText,
40
+ " ",
41
+ totalItemsKeptText),
42
+ React.createElement(Price, { price: orderTotal, variant: "detail" })),
43
+ React.createElement(View, null,
44
+ React.createElement(Button, { small: true, onPress: onSubmit }, submitButtonText)))) : (React.createElement(animated.View, { style: { opacity: notCollapsedStyle.opacitiy } },
45
+ React.createElement(Row, { text: `${subtotalText} ${totalItemsKeptText}` },
46
+ React.createElement(Price, { price: subtotal, variant: "subtotal" })),
47
+ discount && (React.createElement(Row, { text: discountText },
48
+ React.createElement(Price, { price: discount, variant: "subtotal" }))),
49
+ balanceDiscount && (React.createElement(Row, { text: creditText },
50
+ React.createElement(Price, { price: balanceDiscount, variant: "subtotal" }))),
51
+ React.createElement(Row, { text: feeText }, isPSServiceFree ? (React.createElement(Text, { level: 3, style: style.uppercase, action: true }, freeText)) : (React.createElement(Price, { price: service.finalPrice, variant: "subtotal" }))),
52
+ React.createElement(View, { style: style.divider }),
53
+ React.createElement(Row, { level: 2, text: totalText },
54
+ React.createElement(Price, { price: orderTotal, variant: "total" })),
55
+ React.createElement(Button, { onPress: onSubmit }, submitButtonText)))));
56
+ };
57
+ export { Pricing };
@@ -0,0 +1,32 @@
1
+ declare const style: {
2
+ collapsed: {
3
+ flexDirection: "row";
4
+ justifyContent: "space-between";
5
+ };
6
+ container: {
7
+ paddingBottom: number;
8
+ paddingHorizontal: number;
9
+ paddingTop: number;
10
+ };
11
+ divider: {
12
+ backgroundColor: string;
13
+ height: number;
14
+ marginBottom: number;
15
+ };
16
+ iconContainer: {
17
+ alignItems: "center";
18
+ marginBottom: number;
19
+ };
20
+ row: {
21
+ flexDirection: "row";
22
+ justifyContent: "space-between";
23
+ marginBottom: number;
24
+ };
25
+ totalCollapsed: {
26
+ marginBottom: number;
27
+ };
28
+ uppercase: {
29
+ textTransform: "uppercase";
30
+ };
31
+ };
32
+ export { style };
@@ -0,0 +1,35 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "../../../../theme/theme";
3
+ const { colorContent, spaceXS, spaceM, spaceL, spaceXL } = theme();
4
+ const style = StyleSheet.create({
5
+ collapsed: {
6
+ flexDirection: "row",
7
+ justifyContent: "space-between",
8
+ },
9
+ container: {
10
+ paddingBottom: spaceXL,
11
+ paddingHorizontal: spaceXL,
12
+ paddingTop: spaceM,
13
+ },
14
+ divider: {
15
+ backgroundColor: colorContent,
16
+ height: 1,
17
+ marginBottom: 19,
18
+ },
19
+ iconContainer: {
20
+ alignItems: "center",
21
+ marginBottom: spaceL,
22
+ },
23
+ row: {
24
+ flexDirection: "row",
25
+ justifyContent: "space-between",
26
+ marginBottom: 19,
27
+ },
28
+ totalCollapsed: {
29
+ marginBottom: spaceXS,
30
+ },
31
+ uppercase: {
32
+ textTransform: "uppercase",
33
+ },
34
+ });
35
+ export { style };
@@ -1,6 +1,6 @@
1
1
  import { CheckoutItemStatus } from "../../domain/checkoutItem/model/checkoutItem";
2
- import { Currency } from "../../domain/checkoutItem/model/currency";
3
2
  import { FeedbackProjection } from "../feedback/feedback";
3
+ import { PriceProjection } from "../shared/price";
4
4
  import { SizeProjection } from "../shared/size";
5
5
  declare enum MediaPerspective {
6
6
  BACK = "BACK",
@@ -21,14 +21,6 @@ interface MediaProjection {
21
21
  readonly url: string;
22
22
  readonly perspective: MediaPerspective;
23
23
  }
24
- interface PriceProjection {
25
- readonly amount: number;
26
- readonly currency: Currency;
27
- readonly discountedPrice?: {
28
- readonly amount: number;
29
- readonly percentage: number;
30
- };
31
- }
32
24
  interface ColorProjection {
33
25
  readonly id: string;
34
26
  readonly label: string;
@@ -49,5 +41,5 @@ interface CheckoutItemProjection {
49
41
  readonly productVariant: CheckoutItemProductVariantProjection;
50
42
  readonly feedback: FeedbackProjection;
51
43
  }
52
- export type { CheckoutItemProjection, CheckoutItemProductVariantProjection, ColorProjection, MediaProjection, PriceProjection, };
53
- export { Currency, MediaPerspective };
44
+ export type { CheckoutItemProjection, CheckoutItemProductVariantProjection, ColorProjection, MediaProjection };
45
+ export { MediaPerspective };
@@ -1,4 +1,3 @@
1
- import { Currency } from "../../domain/checkoutItem/model/currency";
2
1
  var MediaPerspective;
3
2
  (function (MediaPerspective) {
4
3
  MediaPerspective["BACK"] = "BACK";
@@ -14,4 +13,4 @@ var MediaPerspective;
14
13
  MediaPerspective["OTHER"] = "OTHER";
15
14
  MediaPerspective["SIDE"] = "SIDE";
16
15
  })(MediaPerspective || (MediaPerspective = {}));
17
- export { Currency, MediaPerspective };
16
+ export { MediaPerspective };
@@ -0,0 +1,17 @@
1
+ import { PriceProjection } from "../shared/price";
2
+ interface ServiceProjection {
3
+ readonly reference: string;
4
+ readonly originalPrice: PriceProjection;
5
+ readonly discount: PriceProjection;
6
+ readonly finalPrice: PriceProjection;
7
+ readonly prepaid: boolean;
8
+ }
9
+ interface PricingProjection {
10
+ readonly orderTotal: PriceProjection;
11
+ readonly subtotal: PriceProjection;
12
+ readonly balanceDiscount?: PriceProjection;
13
+ readonly discount?: PriceProjection;
14
+ readonly discountPercentage?: number;
15
+ readonly service: ServiceProjection;
16
+ }
17
+ export type { PricingProjection, ServiceProjection };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { PricingProjection } from "./pricing";
2
+ declare const pricing: PricingProjection;
3
+ export { pricing };
@@ -0,0 +1,37 @@
1
+ import { Currency } from "../../domain/checkoutItem/model/currency";
2
+ const pricing = {
3
+ orderTotal: {
4
+ amount: 14323,
5
+ currency: Currency.EUR,
6
+ },
7
+ subtotal: {
8
+ amount: 21801,
9
+ currency: Currency.EUR,
10
+ },
11
+ discount: {
12
+ amount: -2500,
13
+ currency: Currency.EUR,
14
+ },
15
+ discountPercentage: 25,
16
+ balanceDiscount: {
17
+ amount: 1000,
18
+ currency: Currency.EUR,
19
+ },
20
+ service: {
21
+ reference: "LK-service",
22
+ originalPrice: {
23
+ amount: 10.0,
24
+ currency: Currency.EUR,
25
+ },
26
+ discount: {
27
+ amount: 0,
28
+ currency: Currency.EUR,
29
+ },
30
+ finalPrice: {
31
+ amount: -1000,
32
+ currency: Currency.EUR,
33
+ },
34
+ prepaid: true,
35
+ },
36
+ };
37
+ export { pricing };
@@ -0,0 +1,10 @@
1
+ import { Currency } from "../../domain/checkoutItem/model/currency";
2
+ interface PriceProjection {
3
+ readonly amount: number;
4
+ readonly currency: Currency;
5
+ readonly discountedPrice?: {
6
+ readonly amount: number;
7
+ readonly percentage: number;
8
+ };
9
+ }
10
+ export type { PriceProjection };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.2.48",
3
+ "version": "0.2.50",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -33,6 +33,7 @@
33
33
  "@lookiero/messaging-react": "^8.0.0",
34
34
  "@react-spring/native": "^9.5.5",
35
35
  "react-native-safe-area-context": "^4.4.1",
36
+ "react-native-svg": "^13.5.0",
36
37
  "react-router-dom": "^6.4.2",
37
38
  "react-router-native": "^6.4.2",
38
39
  "tiny-invariant": "^1.2.0",