@lookiero/checkout 0.8.9 → 0.8.10

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,10 +1,11 @@
1
+ import { toPricingProjection } from "./pricing";
1
2
  const httpPricingByCheckoutIdView = ({ httpPost }) => async ({ checkoutId, signal }) => await httpPost({
2
3
  endpoint: "/view-pricing-by-checkout-id",
3
4
  body: { checkoutId },
4
5
  signal,
5
6
  result: {
6
7
  error: null,
7
- success: (response) => response.result,
8
+ success: (response) => toPricingProjection(response.result),
8
9
  },
9
10
  });
10
11
  export { httpPricingByCheckoutIdView };
@@ -0,0 +1,16 @@
1
+ import { PricingProjection, ServiceProjection } from "../../../projection/pricing/pricing";
2
+ import { PriceProjection } from "../../../projection/shared/price";
3
+ interface PricingDto {
4
+ readonly balanceDiscount: PriceProjection;
5
+ readonly discount: PriceProjection;
6
+ readonly discountPercentage: number;
7
+ readonly orderTotal: PriceProjection;
8
+ readonly pendingToPay: PriceProjection;
9
+ readonly service: ServiceProjection;
10
+ readonly subtotal: PriceProjection;
11
+ }
12
+ interface ToPricingProjectionFunction {
13
+ (pricingDto: PricingDto): PricingProjection;
14
+ }
15
+ declare const toPricingProjection: ToPricingProjectionFunction;
16
+ export { toPricingProjection };
@@ -0,0 +1,12 @@
1
+ const toPricingProjection = (pricingDto) => ({
2
+ ...pricingDto,
3
+ discount: {
4
+ ...pricingDto.discount,
5
+ amount: -Math.abs(pricingDto.discount.amount),
6
+ },
7
+ balanceDiscount: {
8
+ ...pricingDto.balanceDiscount,
9
+ amount: -Math.abs(pricingDto.balanceDiscount.amount),
10
+ },
11
+ });
12
+ export { toPricingProjection };
@@ -54,7 +54,7 @@ const Checkout = ({ children, customerId, country, useRedirect }) => {
54
54
  ? checkoutItem.replacedFor.size
55
55
  : checkoutItem.productVariant.size })))),
56
56
  pricing && (React.createElement(View, { style: style.pricingContainer },
57
- React.createElement(Pricing, { balanceDiscount: pricing.balanceDiscount, collapsible: false, discount: pricing.discount, discountPercentage: pricing.discountPercentage, orderTotal: pricing.orderTotal, service: pricing.service, subtotal: pricing.subtotal, totalCheckoutItemsKept: checkoutItemsKept?.length || 0, onSubmit: handleOnSubmit }))))),
57
+ React.createElement(Pricing, { balanceDiscount: pricing.balanceDiscount, collapsible: false, discount: pricing.discount, discountPercentage: pricing.discountPercentage, pendingToPay: pricing.pendingToPay, service: pricing.service, subtotal: pricing.subtotal, totalCheckoutItemsKept: checkoutItemsKept?.length || 0, onSubmit: handleOnSubmit }))))),
58
58
  children));
59
59
  };
60
60
  export { Checkout };
@@ -2,7 +2,7 @@ import { FC } from "react";
2
2
  import { ServiceProjection } from "../../../../../../projection/pricing/pricing";
3
3
  import { PriceProjection } from "../../../../../../projection/shared/price";
4
4
  interface PricingProps {
5
- readonly orderTotal: PriceProjection;
5
+ readonly pendingToPay: PriceProjection;
6
6
  readonly subtotal: PriceProjection;
7
7
  readonly balanceDiscount?: PriceProjection;
8
8
  readonly discount?: PriceProjection;
@@ -15,7 +15,7 @@ const PS_SERVICE_FREE_INDICATOR = 100;
15
15
  const Row = ({ text, level = 3, children }) => (React.createElement(View, { style: style.row },
16
16
  React.createElement(Text, { level: level, style: style.uppercase, action: true }, text),
17
17
  children));
18
- const Pricing = ({ orderTotal, subtotal, balanceDiscount, discount, discountPercentage = 0, totalCheckoutItemsKept, service, collapsible = true, collapsed = false, busy = false, onPress = () => void 0, onSubmit, }) => {
18
+ const Pricing = ({ pendingToPay, subtotal, balanceDiscount, discount, discountPercentage = 0, totalCheckoutItemsKept, service, collapsible = true, collapsed = false, busy = false, onPress = () => void 0, onSubmit, }) => {
19
19
  const totalText = useI18nMessage({ id: I18nMessages.SUMMARY_TOTAL }) || "";
20
20
  const totalCheckoutItemsKeptText = useI18nMessage({
21
21
  id: I18nMessages.SUMMARY_TOTAL_ITEMS_KEPT,
@@ -41,7 +41,7 @@ const Pricing = ({ orderTotal, subtotal, balanceDiscount, discount, discountPerc
41
41
  totalText,
42
42
  " ",
43
43
  totalCheckoutItemsKeptText),
44
- React.createElement(Price, { price: orderTotal, variant: "detail" })),
44
+ React.createElement(Price, { price: pendingToPay, variant: "detail" })),
45
45
  React.createElement(View, null,
46
46
  React.createElement(Button, { busy: busy, small: true, onPress: onSubmit }, submitButtonText)))) : (React.createElement(animated.View, { style: { opacity: notCollapsedStyle.opacitiy } },
47
47
  React.createElement(Row, { text: `${subtotalText} ${totalCheckoutItemsKeptText}` },
@@ -53,7 +53,7 @@ const Pricing = ({ orderTotal, subtotal, balanceDiscount, discount, discountPerc
53
53
  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" }))),
54
54
  React.createElement(View, { style: style.divider }),
55
55
  React.createElement(Row, { level: 2, text: totalText },
56
- React.createElement(Price, { price: orderTotal, variant: "total" })),
56
+ React.createElement(Price, { price: pendingToPay, variant: "total" })),
57
57
  React.createElement(Button, { busy: busy, onPress: onSubmit }, submitButtonText)))));
58
58
  };
59
59
  export { Pricing };
@@ -5,5 +5,5 @@ import { Pricing } from "../pricing/Pricing";
5
5
  import { style } from "./StickyPricing.style";
6
6
  const StickyPricing = ({ pricing, totalCheckoutItemsKept, collapsed, onPress, onSubmit, onLayout, }) => (React.createElement(Sticky, { onLayout: onLayout },
7
7
  React.createElement(Body, { style: { column: style.container } },
8
- React.createElement(Pricing, { balanceDiscount: pricing.balanceDiscount, collapsed: collapsed, discount: pricing.discount, discountPercentage: pricing.discountPercentage, orderTotal: pricing.orderTotal, service: pricing.service, subtotal: pricing.subtotal, totalCheckoutItemsKept: totalCheckoutItemsKept, onPress: onPress, onSubmit: onSubmit }))));
8
+ React.createElement(Pricing, { balanceDiscount: pricing.balanceDiscount, collapsed: collapsed, discount: pricing.discount, discountPercentage: pricing.discountPercentage, pendingToPay: pricing.pendingToPay, service: pricing.service, subtotal: pricing.subtotal, totalCheckoutItemsKept: totalCheckoutItemsKept, onPress: onPress, onSubmit: onSubmit }))));
9
9
  export { StickyPricing };
@@ -1,17 +1,18 @@
1
1
  import { PriceProjection } from "../shared/price";
2
2
  interface ServiceProjection {
3
- readonly reference: string;
4
- readonly originalPrice: PriceProjection;
5
3
  readonly discount: PriceProjection;
6
4
  readonly finalPrice: PriceProjection;
5
+ readonly originalPrice: PriceProjection;
7
6
  readonly prepaid: boolean;
7
+ readonly reference: string;
8
8
  }
9
9
  interface PricingProjection {
10
- readonly orderTotal: PriceProjection;
11
- readonly subtotal: PriceProjection;
12
10
  readonly balanceDiscount: PriceProjection;
13
11
  readonly discount: PriceProjection;
14
12
  readonly discountPercentage: number;
13
+ readonly orderTotal: PriceProjection;
14
+ readonly pendingToPay: PriceProjection;
15
15
  readonly service: ServiceProjection;
16
+ readonly subtotal: PriceProjection;
16
17
  }
17
18
  export type { PricingProjection, ServiceProjection };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.8.9",
3
+ "version": "0.8.10",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [