@lookiero/checkout 0.3.10 → 0.3.12
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.
- package/dist/package.json +3 -3
- package/dist/src/ExpoRoot.js +4 -1
- package/dist/src/infrastructure/ui/Root.d.ts +1 -0
- package/dist/src/infrastructure/ui/Root.js +2 -2
- package/dist/src/infrastructure/ui/routing/Routing.d.ts +1 -0
- package/dist/src/infrastructure/ui/routing/Routing.js +2 -2
- package/dist/src/infrastructure/ui/views/checkout/Checkout.d.ts +1 -0
- package/dist/src/infrastructure/ui/views/checkout/Checkout.js +13 -7
- package/dist/src/infrastructure/ui/views/checkout/Checkout.style.d.ts +4 -0
- package/dist/src/infrastructure/ui/views/checkout/Checkout.style.js +5 -1
- package/dist/src/infrastructure/ui/views/summary/components/pricing/Pricing.d.ts +1 -0
- package/dist/src/infrastructure/ui/views/summary/components/pricing/Pricing.js +4 -4
- package/package.json +3 -3
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lookiero/checkout",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@lookiero/data-sources": "^0.3",
|
|
47
47
|
"@lookiero/event": "^0.3",
|
|
48
48
|
"@lookiero/locale": "^0.3",
|
|
49
|
-
"@lookiero/payments-front": "^0.16.
|
|
49
|
+
"@lookiero/payments-front": "^0.16.5",
|
|
50
50
|
"apollo-boost": "0.4.4",
|
|
51
51
|
"graphql": "14.5.8",
|
|
52
52
|
"graphql-tag": "2.12.6",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@lookiero/data-sources": "^0.3",
|
|
67
67
|
"@lookiero/event": "^0.3",
|
|
68
68
|
"@lookiero/locale": "^0.3",
|
|
69
|
-
"@lookiero/payments-front": "^0.16.
|
|
69
|
+
"@lookiero/payments-front": "^0.16.5",
|
|
70
70
|
"@pact-foundation/pact": "^10.1.4",
|
|
71
71
|
"@pact-foundation/pact-node": "^10.17.6",
|
|
72
72
|
"@testing-library/react": "^13.4.0",
|
package/dist/src/ExpoRoot.js
CHANGED
|
@@ -19,6 +19,9 @@ const authToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjIwOTUxNjAsImV4
|
|
|
19
19
|
const translationsUrl = Platform.OS !== "web" ? "https://web2.ps.dev.aws.lookiero.es/checkout/i18n" : __DEV__ ? "/local-to-i18n" : "/i18n";
|
|
20
20
|
const translationsApiKey = "f2AfMGaPCZGVbAFWz_OV4GWhBDG_NbZJ";
|
|
21
21
|
const translations = (locale) => `${translationsUrl}/${locale}?key=${translationsApiKey}&no-folding=true`;
|
|
22
|
+
const useRedirect = () => ({
|
|
23
|
+
returnUrl: "https://web2.dev.aws.lookiero.es/user/",
|
|
24
|
+
});
|
|
22
25
|
setPaymentsBridge({
|
|
23
26
|
getToken: () => Promise.resolve(authToken),
|
|
24
27
|
stripeKey: "pk_test_6dwdUfkUm7AaUH3oSje9H0kk",
|
|
@@ -88,7 +91,7 @@ const ExpoRoot = () => {
|
|
|
88
91
|
React.createElement(Aurora, { useStack: false },
|
|
89
92
|
isAccessible === false && React.createElement(Text, { heading: true }, "Checkout is not accessible!"),
|
|
90
93
|
React.createElement(Router, null,
|
|
91
|
-
React.createElement(Root, { basePath: "", customerId: "cf7c641f-0e5c-4850-ae07-276747edfd0b", locale: "es", onNotAccessible: onNotAccessible }))),
|
|
94
|
+
React.createElement(Root, { basePath: "", customerId: "cf7c641f-0e5c-4850-ae07-276747edfd0b", locale: "es", useRedirect: useRedirect, onNotAccessible: onNotAccessible }))),
|
|
92
95
|
React.createElement(StatusBar, null))) : null;
|
|
93
96
|
};
|
|
94
97
|
export { ExpoRoot };
|
|
@@ -17,6 +17,7 @@ interface RootProps {
|
|
|
17
17
|
readonly locale?: string;
|
|
18
18
|
readonly customerId: string | undefined;
|
|
19
19
|
readonly onNotAccessible: () => void;
|
|
20
|
+
readonly useRedirect: () => Record<string, string>;
|
|
20
21
|
}
|
|
21
22
|
declare const root: RootFunction;
|
|
22
23
|
export type { RootProps };
|
|
@@ -3,10 +3,10 @@ import { Platform } from "react-native";
|
|
|
3
3
|
import { Routing } from "./routing/Routing";
|
|
4
4
|
const root = ({ Messaging, I18n, Notifications, authToken, development }) =>
|
|
5
5
|
// eslint-disable-next-line react/display-name, react/prop-types
|
|
6
|
-
({ basePath, locale = "en", customerId, onNotAccessible }) => {
|
|
6
|
+
({ basePath, locale = "en", customerId, onNotAccessible, useRedirect }) => {
|
|
7
7
|
const handleOnI18nError = useCallback(() => void 0, []);
|
|
8
8
|
return (React.createElement(Messaging, { includeReactQueryDevTools: Platform.OS === "web" },
|
|
9
9
|
React.createElement(Notifications, { includeReactQueryDevTools: Platform.OS === "web" },
|
|
10
|
-
React.createElement(Routing, { I18n: I18n, authToken: authToken, basePath: basePath, customerId: customerId, locale: locale, onI18nError: development ? undefined : handleOnI18nError, onNotAccessible: onNotAccessible }))));
|
|
10
|
+
React.createElement(Routing, { I18n: I18n, authToken: authToken, basePath: basePath, customerId: customerId, locale: locale, useRedirect: useRedirect, onI18nError: development ? undefined : handleOnI18nError, onNotAccessible: onNotAccessible }))));
|
|
11
11
|
};
|
|
12
12
|
export { root };
|
|
@@ -8,6 +8,7 @@ interface RoutingProps {
|
|
|
8
8
|
readonly authToken: string;
|
|
9
9
|
readonly onNotAccessible: () => void;
|
|
10
10
|
readonly onI18nError?: (err: Error) => void;
|
|
11
|
+
readonly useRedirect: () => Record<string, string>;
|
|
11
12
|
}
|
|
12
13
|
declare const Routing: FC<RoutingProps>;
|
|
13
14
|
export { Routing };
|
|
@@ -10,7 +10,7 @@ const Intro = lazy(() => import("../views/intro/Intro").then((module) => ({ defa
|
|
|
10
10
|
const Item = lazy(() => import("../views/item/Item").then((module) => ({ default: module.Item })));
|
|
11
11
|
const Summary = lazy(() => import("../views/summary/Summary").then((module) => ({ default: module.Summary })));
|
|
12
12
|
const Checkout = lazy(() => import("../views/checkout/Checkout").then((module) => ({ default: module.Checkout })));
|
|
13
|
-
const Routing = ({ basePath = "", customerId, locale, I18n, authToken, onI18nError, onNotAccessible, }) => {
|
|
13
|
+
const Routing = ({ basePath = "", customerId, locale, I18n, authToken, onI18nError, onNotAccessible, useRedirect, }) => {
|
|
14
14
|
const routes = useRoutes([
|
|
15
15
|
{
|
|
16
16
|
path: "",
|
|
@@ -44,7 +44,7 @@ const Routing = ({ basePath = "", customerId, locale, I18n, authToken, onI18nErr
|
|
|
44
44
|
{
|
|
45
45
|
path: Routes.CHECKOUT,
|
|
46
46
|
element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
|
|
47
|
-
React.createElement(Checkout, { authToken: authToken, customerId: customerId }))),
|
|
47
|
+
React.createElement(Checkout, { authToken: authToken, customerId: customerId, useRedirect: useRedirect }))),
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
path: "*",
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
|
|
2
1
|
import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
|
|
3
2
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
4
3
|
import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
|
|
5
|
-
import { CheckoutStatus, PaymentFlow } from "@lookiero/payments-front";
|
|
4
|
+
import { CheckoutStatus, PaymentFlow, PaymentInstrumentSelect, PaymentMethod, Section, } from "@lookiero/payments-front";
|
|
6
5
|
import React, { useCallback, useMemo, useRef, useState } from "react";
|
|
7
6
|
import { View } from "react-native";
|
|
8
7
|
import { useNavigate } from "react-router-native";
|
|
@@ -13,19 +12,22 @@ import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner"
|
|
|
13
12
|
import { useMarkCheckoutAsPaid } from "../../../domain/checkout/react/useMarkCheckoutAsPaid";
|
|
14
13
|
import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
15
14
|
import { useViewPaymentFlowPayloadByCheckoutId } from "../../../projection/payment/react/useViewPaymentFlowPayloadByCheckoutId";
|
|
15
|
+
import { useViewPricingByCheckoutId } from "../../../projection/pricing/react/useViewPricingByCheckoutId";
|
|
16
16
|
import { Body } from "../../components/layouts/body/Body";
|
|
17
17
|
import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
|
|
18
18
|
import { I18nMessages } from "../../i18n/i18n";
|
|
19
19
|
import { Routes } from "../../routing/routes";
|
|
20
20
|
import { useBasePath } from "../../routing/useBasePath";
|
|
21
21
|
import { ProductVariant } from "../item/components/productVariant/ProductVariant";
|
|
22
|
+
import { Pricing } from "../summary/components/pricing/Pricing";
|
|
22
23
|
import { style } from "./Checkout.style";
|
|
23
24
|
import { CheckoutSuccessModal } from "./components/CheckoutSuccessModal";
|
|
24
|
-
const Checkout = ({ customerId, authToken }) => {
|
|
25
|
+
const Checkout = ({ customerId, authToken, useRedirect }) => {
|
|
25
26
|
const titleText = useI18nMessage({ id: I18nMessages.CHECKOUT_TITLE });
|
|
26
|
-
const
|
|
27
|
+
const paymentInstrumentSelectRef = useRef(null);
|
|
27
28
|
const paymentFlowRef = useRef(null);
|
|
28
29
|
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
30
|
+
const [pricing, pricingStatus] = useViewPricingByCheckoutId({ checkoutId: checkout?.id });
|
|
29
31
|
const [paymentFlowPayload] = useViewPaymentFlowPayloadByCheckoutId({
|
|
30
32
|
checkoutId: checkout?.id,
|
|
31
33
|
});
|
|
@@ -34,7 +36,9 @@ const Checkout = ({ customerId, authToken }) => {
|
|
|
34
36
|
const [processingCheckout, setProcessingCheckout] = useState(false);
|
|
35
37
|
const navigate = useNavigate();
|
|
36
38
|
const basePath = useBasePath();
|
|
37
|
-
const
|
|
39
|
+
const { returnUrl } = useRedirect();
|
|
40
|
+
const handleOnSubmitCheckout = useCallback(() => {
|
|
41
|
+
console.log("onSubmit checkout");
|
|
38
42
|
if (!paymentFlowRef.current) {
|
|
39
43
|
return;
|
|
40
44
|
}
|
|
@@ -64,17 +68,19 @@ const Checkout = ({ customerId, authToken }) => {
|
|
|
64
68
|
const handleOnSuccessModalDismiss = useCallback(() => navigate(`${basePath}/${Routes.FEEDBACK}`), [basePath, navigate]);
|
|
65
69
|
const checkoutItemsKept = useMemo(() => checkout?.items.filter((checkoutItem) => checkoutItem.status === CheckoutItemStatus.KEPT || checkoutItem.status === CheckoutItemStatus.REPLACED), [checkout?.items]);
|
|
66
70
|
const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
|
|
67
|
-
const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus);
|
|
71
|
+
const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus) && dependenciesLoadedStatuses.includes(pricingStatus);
|
|
68
72
|
if (!dependenciesLoaded)
|
|
69
73
|
return React.createElement(Spinner, null);
|
|
70
74
|
return (React.createElement(React.Fragment, null,
|
|
71
75
|
React.createElement(CheckoutSuccessModal, { visible: markAsPaidStatus === CommandStatus.SUCCESS, onDismiss: handleOnSuccessModalDismiss }),
|
|
72
76
|
React.createElement(SafeAreaScrollView, null,
|
|
73
77
|
React.createElement(Body, { style: { column: style.bodyColumn } },
|
|
78
|
+
React.createElement(PaymentInstrumentSelect, { ref: paymentInstrumentSelectRef, beforeRedirect: returnUrl ? () => Promise.resolve(returnUrl) : undefined, hasError: false, hidePaymentMethods: [PaymentMethod.GOOGLE_PAY], section: Section.BOX_CHECKOUT }),
|
|
74
79
|
React.createElement(Text, { level: 3, style: style.title, heading: true }, titleText),
|
|
75
80
|
checkoutItemsKept?.map((checkoutItem) => (React.createElement(View, { key: checkoutItem.id, style: style.checkoutItemKept, testID: "checkout-items-kept" },
|
|
76
81
|
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, status: checkoutItem.status })))),
|
|
77
|
-
React.createElement(
|
|
82
|
+
pricing && (React.createElement(View, { style: style.pricingContainer },
|
|
83
|
+
React.createElement(Pricing, { balanceDiscount: pricing.balanceDiscount, busy: processingCheckout || markAsPaidStatus === CommandStatus.LOADING, collapsible: false, discount: pricing.discount, discountPercentage: pricing.discountPercentage, orderTotal: pricing.orderTotal, service: pricing.service, subtotal: pricing.subtotal, totalCheckoutItemsKept: checkoutItemsKept?.length || 0, onSubmit: handleOnSubmitCheckout }))))),
|
|
78
84
|
React.createElement(PaymentFlow, { ref: paymentFlowRef, token: authToken })));
|
|
79
85
|
};
|
|
80
86
|
export { Checkout };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StyleSheet } from "react-native";
|
|
2
2
|
import { theme } from "../../theme/theme";
|
|
3
|
-
const { spaceM, spaceXL } = theme();
|
|
3
|
+
const { spaceM, spaceXL, spaceXXL } = theme();
|
|
4
4
|
const style = StyleSheet.create({
|
|
5
5
|
bodyColumn: {
|
|
6
6
|
paddingHorizontal: spaceXL,
|
|
@@ -8,8 +8,12 @@ const style = StyleSheet.create({
|
|
|
8
8
|
checkoutItemKept: {
|
|
9
9
|
paddingVertical: spaceM,
|
|
10
10
|
},
|
|
11
|
+
pricingContainer: {
|
|
12
|
+
marginTop: spaceXL,
|
|
13
|
+
},
|
|
11
14
|
title: {
|
|
12
15
|
marginBottom: spaceM,
|
|
16
|
+
marginTop: spaceXXL,
|
|
13
17
|
textAlign: "center",
|
|
14
18
|
},
|
|
15
19
|
});
|
|
@@ -13,7 +13,7 @@ const PS_SERVICE_FREE_INDICATOR = 100;
|
|
|
13
13
|
const Row = ({ text, level = 3, children }) => (React.createElement(View, { style: style.row },
|
|
14
14
|
React.createElement(Text, { level: level, style: style.uppercase, action: true }, text),
|
|
15
15
|
children));
|
|
16
|
-
const Pricing = ({ orderTotal, subtotal, balanceDiscount, discount, discountPercentage = 0, totalCheckoutItemsKept, service, collapsible = true, collapsed = false, onPress = () => void 0, onSubmit, }) => {
|
|
16
|
+
const Pricing = ({ orderTotal, subtotal, balanceDiscount, discount, discountPercentage = 0, totalCheckoutItemsKept, service, collapsible = true, collapsed = false, busy = false, onPress = () => void 0, onSubmit, }) => {
|
|
17
17
|
const totalText = useI18nMessage({ id: I18nMessages.SUMMARY_TOTAL }) || "";
|
|
18
18
|
const totalCheckoutItemsKeptText = useI18nMessage({
|
|
19
19
|
id: I18nMessages.SUMMARY_TOTAL_ITEMS_KEPT,
|
|
@@ -31,7 +31,7 @@ const Pricing = ({ orderTotal, subtotal, balanceDiscount, discount, discountPerc
|
|
|
31
31
|
const isPSServiceFree = service.discount.amount === PS_SERVICE_FREE_INDICATOR;
|
|
32
32
|
const collapsedStyle = useSpring({ opacitiy: collapsed ? 1 : 0 });
|
|
33
33
|
const notCollapsedStyle = useSpring({ opacitiy: collapsed ? 0 : 1 });
|
|
34
|
-
return (React.createElement(Pressable, {
|
|
34
|
+
return (React.createElement(Pressable, { testID: "pricing", onPress: collapsible ? onPress : null },
|
|
35
35
|
collapsible && (React.createElement(View, { style: style.iconContainer }, collapsed ? (React.createElement(ArrowUp, { style: style.icon, testID: "arrow-up" })) : (React.createElement(ArrowDown, { style: style.icon, testID: "arrow-down" })))),
|
|
36
36
|
collapsed && collapsible ? (React.createElement(animated.View, { style: [style.collapsed, { opacity: collapsedStyle.opacitiy }] },
|
|
37
37
|
React.createElement(View, null,
|
|
@@ -41,7 +41,7 @@ const Pricing = ({ orderTotal, subtotal, balanceDiscount, discount, discountPerc
|
|
|
41
41
|
totalCheckoutItemsKeptText),
|
|
42
42
|
React.createElement(Price, { price: orderTotal, variant: "detail" })),
|
|
43
43
|
React.createElement(View, null,
|
|
44
|
-
React.createElement(Button, { small: true, onPress: onSubmit }, submitButtonText)))) : (React.createElement(animated.View, { style: { opacity: notCollapsedStyle.opacitiy } },
|
|
44
|
+
React.createElement(Button, { busy: busy, small: true, onPress: onSubmit }, submitButtonText)))) : (React.createElement(animated.View, { style: { opacity: notCollapsedStyle.opacitiy } },
|
|
45
45
|
React.createElement(Row, { text: `${subtotalText} ${totalCheckoutItemsKeptText}` },
|
|
46
46
|
React.createElement(Price, { price: subtotal, variant: "subtotal" })),
|
|
47
47
|
discount && (React.createElement(Row, { text: discountText },
|
|
@@ -52,6 +52,6 @@ const Pricing = ({ orderTotal, subtotal, balanceDiscount, discount, discountPerc
|
|
|
52
52
|
React.createElement(View, { style: style.divider }),
|
|
53
53
|
React.createElement(Row, { level: 2, text: totalText },
|
|
54
54
|
React.createElement(Price, { price: orderTotal, variant: "total" })),
|
|
55
|
-
React.createElement(Button, { onPress: onSubmit }, submitButtonText)))));
|
|
55
|
+
React.createElement(Button, { busy: busy, onPress: onSubmit }, submitButtonText)))));
|
|
56
56
|
};
|
|
57
57
|
export { Pricing };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lookiero/checkout",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@lookiero/data-sources": "^0.3",
|
|
47
47
|
"@lookiero/event": "^0.3",
|
|
48
48
|
"@lookiero/locale": "^0.3",
|
|
49
|
-
"@lookiero/payments-front": "^0.16.
|
|
49
|
+
"@lookiero/payments-front": "^0.16.5",
|
|
50
50
|
"apollo-boost": "0.4.4",
|
|
51
51
|
"graphql": "14.5.8",
|
|
52
52
|
"graphql-tag": "2.12.6",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@lookiero/data-sources": "^0.3",
|
|
67
67
|
"@lookiero/event": "^0.3",
|
|
68
68
|
"@lookiero/locale": "^0.3",
|
|
69
|
-
"@lookiero/payments-front": "^0.16.
|
|
69
|
+
"@lookiero/payments-front": "^0.16.5",
|
|
70
70
|
"@pact-foundation/pact": "^10.1.4",
|
|
71
71
|
"@pact-foundation/pact-node": "^10.17.6",
|
|
72
72
|
"@testing-library/react": "^13.4.0",
|