@lookiero/checkout 0.3.21 → 0.3.23
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 +13 -13
- package/dist/src/domain/checkout/model/checkout.d.ts +1 -1
- package/dist/src/infrastructure/delivery/baseBootstrap.d.ts +2 -0
- package/dist/src/infrastructure/delivery/baseBootstrap.js +5 -1
- package/dist/src/infrastructure/delivery/bootstrap.js +2 -0
- package/dist/src/infrastructure/delivery/mock/dataSourceCheckouts.js +2 -2
- package/dist/src/infrastructure/domain/checkout/model/httpCheckouts.js +1 -1
- package/dist/src/infrastructure/projection/checkout/checkout.d.ts +1 -1
- package/dist/src/infrastructure/projection/pricing/react/useViewPricingByCheckoutId.js +9 -1
- package/dist/src/infrastructure/ui/routing/CheckoutMiddleware.js +1 -2
- package/dist/src/infrastructure/ui/views/item/Item.js +43 -13
- package/dist/src/infrastructure/ui/views/summary/components/pricing/Pricing.js +2 -2
- package/dist/src/projection/checkout/checkout.d.ts +1 -1
- package/dist/src/projection/pricing/pricing.d.ts +3 -3
- package/package.json +13 -13
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lookiero/checkout",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.23",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -48,14 +48,14 @@
|
|
|
48
48
|
"@lookiero/locale": "^0.3",
|
|
49
49
|
"@lookiero/payments-front": "^0.16.5",
|
|
50
50
|
"apollo-boost": "0.4.4",
|
|
51
|
-
"graphql": "
|
|
51
|
+
"graphql": "16.6.0",
|
|
52
52
|
"graphql-tag": "2.12.6",
|
|
53
53
|
"react": "^18.0.0",
|
|
54
54
|
"react-dom": "^18.0.0",
|
|
55
|
-
"react-native": "^0.70.
|
|
55
|
+
"react-native": "^0.70.6",
|
|
56
56
|
"react-native-web": "^0.18.9",
|
|
57
|
-
"react-router-dom": "^6.4.
|
|
58
|
-
"react-router-native": "^6.4.
|
|
57
|
+
"react-router-dom": "^6.4.5",
|
|
58
|
+
"react-router-native": "^6.4.5"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@babel/core": "^7.19.1",
|
|
@@ -73,11 +73,11 @@
|
|
|
73
73
|
"@testing-library/react-hooks": "^8.0.1",
|
|
74
74
|
"@testing-library/react-native": "^11.0.0",
|
|
75
75
|
"@trivago/prettier-plugin-sort-imports": "^3.3.0",
|
|
76
|
-
"@types/jest": "^29.2.
|
|
76
|
+
"@types/jest": "^29.2.4",
|
|
77
77
|
"@types/react": "~18.0.0",
|
|
78
78
|
"@types/react-dom": "~18.0.0",
|
|
79
79
|
"@types/react-native": "~0.69.1",
|
|
80
|
-
"@types/uuid": "^
|
|
80
|
+
"@types/uuid": "^9.0.0",
|
|
81
81
|
"apollo-boost": "0.4.4",
|
|
82
82
|
"eslint": "^8.24.0",
|
|
83
83
|
"eslint-config-prettier": "^8.5.0",
|
|
@@ -92,9 +92,9 @@
|
|
|
92
92
|
"expo": "~46.0.8",
|
|
93
93
|
"expo-modules-core": "^1.0.3",
|
|
94
94
|
"expo-status-bar": "~1.4.0",
|
|
95
|
-
"graphql": "
|
|
95
|
+
"graphql": "16.6.0",
|
|
96
96
|
"graphql-tag": "2.12.6",
|
|
97
|
-
"husky": "^8.0.
|
|
97
|
+
"husky": "^8.0.2",
|
|
98
98
|
"jest": "^29.3.1",
|
|
99
99
|
"jest-expo": "^46.0.1",
|
|
100
100
|
"jest-fetch-mock": "^3.0.3",
|
|
@@ -104,14 +104,14 @@
|
|
|
104
104
|
"prettier": "^2.7.1",
|
|
105
105
|
"react": "^18.0.0",
|
|
106
106
|
"react-dom": "^18.0.0",
|
|
107
|
-
"react-native": "^0.70.
|
|
107
|
+
"react-native": "^0.70.6",
|
|
108
108
|
"react-native-get-random-values": "^1.8.0",
|
|
109
109
|
"react-native-unimodules": "^0.14.10",
|
|
110
110
|
"react-native-web": "^0.18.9",
|
|
111
|
-
"react-router-dom": "^6.4.
|
|
112
|
-
"react-router-native": "^6.4.
|
|
111
|
+
"react-router-dom": "^6.4.5",
|
|
112
|
+
"react-router-native": "^6.4.5",
|
|
113
113
|
"react-test-renderer": "^18.0.0",
|
|
114
114
|
"typescript": "^4.9.3",
|
|
115
|
-
"webpack-bundle-analyzer": "^4.
|
|
115
|
+
"webpack-bundle-analyzer": "^4.7.0"
|
|
116
116
|
}
|
|
117
117
|
}
|
|
@@ -12,7 +12,7 @@ interface Checkout extends AggregateRoot {
|
|
|
12
12
|
readonly status: CheckoutStatus;
|
|
13
13
|
readonly customerId: string;
|
|
14
14
|
readonly boxId: string;
|
|
15
|
-
readonly
|
|
15
|
+
readonly checkoutBookingId: string;
|
|
16
16
|
readonly expiresOn: Date;
|
|
17
17
|
}
|
|
18
18
|
declare const startCheckoutHandler: CommandHandlerFunction<StartCheckout, Checkout>;
|
|
@@ -15,6 +15,7 @@ import { CheckoutByIdView } from "../../projection/checkout/viewCheckoutById";
|
|
|
15
15
|
import { FirstAvailableCheckoutByCustomerIdView } from "../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
16
16
|
import { FiveItemsDiscountByCustomerIdView } from "../../projection/checkout/viewFiveItemsDiscountByCustomerId";
|
|
17
17
|
import { IsCheckoutEnabledByCustomerIdView } from "../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
|
|
18
|
+
import { CheckoutBookingByIdView } from "../../projection/checkoutBooking/viewCheckoutBookingById";
|
|
18
19
|
import { CheckoutItemByIdView } from "../../projection/checkoutItem/viewCheckoutItemById";
|
|
19
20
|
import { CheckoutQuestionsByCheckoutIdView } from "../../projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId";
|
|
20
21
|
import { PaymentFlowPayloadByCheckoutIdView } from "../../projection/payment/viewPaymentFlowPayloadByCheckoutId";
|
|
@@ -31,6 +32,7 @@ interface BaseBootstrapFunctionArgs<UiSettingGetFunctionArgs extends RepositoryG
|
|
|
31
32
|
readonly fiveItemsDiscountByCustomerIdView: FiveItemsDiscountByCustomerIdView;
|
|
32
33
|
readonly uiSettingByKeyView: UiSettingByKeyView;
|
|
33
34
|
readonly checkoutItemByIdView: CheckoutItemByIdView;
|
|
35
|
+
readonly checkoutBookingByIdView: CheckoutBookingByIdView;
|
|
34
36
|
readonly returnQuestionsByCheckoutItemIdView: ReturnQuestionsByCheckoutItemIdView;
|
|
35
37
|
readonly bookedSizeChangeProductsVariantsForCheckoutItemView: BookedSizeChangeProductsVariantsForCheckoutItemView;
|
|
36
38
|
readonly pricingByCheckoutIdView: PricingByCheckoutIdView;
|
|
@@ -18,6 +18,7 @@ import { viewFirstAvailableCheckoutByCustomerIdHandler, VIEW_FIRST_AVAILABLE_CHE
|
|
|
18
18
|
import { viewFiveItemsDiscountByCustomerIdHandler, VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, } from "../../projection/checkout/viewFiveItemsDiscountByCustomerId";
|
|
19
19
|
import { viewIsCheckoutAccessibleByCustomerIdHandler, VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, } from "../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
20
20
|
import { viewIsCheckoutEnabledByCustomerIdHandler, VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, } from "../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
|
|
21
|
+
import { viewCheckoutBookingByIdHandler, VIEW_CHECKOUT_BOOKING_BY_ID, } from "../../projection/checkoutBooking/viewCheckoutBookingById";
|
|
21
22
|
import { viewCheckoutItemByIdHandler, VIEW_CHECKOUT_ITEM_BY_ID, } from "../../projection/checkoutItem/viewCheckoutItemById";
|
|
22
23
|
import { listCheckoutQuestionsByCheckoutIdHandler, LIST_CHECKOUT_QUESTIONS_BY_CHECKOUT_ID, } from "../../projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId";
|
|
23
24
|
import { viewPaymentFlowPayloadByCheckoutIdHandler, VIEW_PAYMENT_FLOW_PAYLOAD_BY_CHECKOUT_ID, } from "../../projection/payment/viewPaymentFlowPayloadByCheckoutId";
|
|
@@ -25,7 +26,7 @@ import { viewPricingByCheckoutIdHandler, VIEW_PRICING_BY_CHECKOUT_ID, } from "..
|
|
|
25
26
|
import { listReturnQuestionsByCheckoutItemIdHandler, LIST_RETURN_QUESTIONS_BY_CHECKOUT_ITEM_ID, } from "../../projection/returnQuestion/listReturnQuestionsByCheckoutItemId";
|
|
26
27
|
import { viewUiSettingByKeyHandler, VIEW_UI_SETTING_BY_KEY, } from "../../projection/uiSetting/viewUiSettingByKey";
|
|
27
28
|
const MESSAGING_CONTEXT_ID = "Checkout";
|
|
28
|
-
const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdView, isCheckoutEnabledByCustomerIdView, fiveItemsDiscountByCustomerIdView, uiSettingByKeyView, checkoutItemByIdView, returnQuestionsByCheckoutItemIdView, bookedSizeChangeProductsVariantsForCheckoutItemView, pricingByCheckoutIdView, paymentFlowPayloadByCheckoutIdView, checkoutQuestionsByCheckoutIdView, getUiSetting, saveUiSetting, uiSettingsDependencies, getCheckout, saveCheckout, checkoutsDependencies, getCheckoutItem, saveCheckoutItem, checkoutItemsDependencies, getCheckoutBooking, saveCheckoutBooking, checkoutBookingsDependencies, getCheckoutFeedback, saveCheckoutFeedback, checkoutFeedbacksDependencies, }) => messagingBootstrap({ id: MESSAGING_CONTEXT_ID })
|
|
29
|
+
const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdView, isCheckoutEnabledByCustomerIdView, fiveItemsDiscountByCustomerIdView, uiSettingByKeyView, checkoutItemByIdView, returnQuestionsByCheckoutItemIdView, bookedSizeChangeProductsVariantsForCheckoutItemView, checkoutBookingByIdView, pricingByCheckoutIdView, paymentFlowPayloadByCheckoutIdView, checkoutQuestionsByCheckoutIdView, getUiSetting, saveUiSetting, uiSettingsDependencies, getCheckout, saveCheckout, checkoutsDependencies, getCheckoutItem, saveCheckoutItem, checkoutItemsDependencies, getCheckoutBooking, saveCheckoutBooking, checkoutBookingsDependencies, getCheckoutFeedback, saveCheckoutFeedback, checkoutFeedbacksDependencies, }) => messagingBootstrap({ id: MESSAGING_CONTEXT_ID })
|
|
29
30
|
.query(VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, viewFiveItemsDiscountByCustomerIdHandler, {
|
|
30
31
|
view: fiveItemsDiscountByCustomerIdView,
|
|
31
32
|
})
|
|
@@ -58,6 +59,9 @@ const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdVie
|
|
|
58
59
|
})
|
|
59
60
|
.query(LIST_CHECKOUT_QUESTIONS_BY_CHECKOUT_ID, listCheckoutQuestionsByCheckoutIdHandler, {
|
|
60
61
|
view: checkoutQuestionsByCheckoutIdView,
|
|
62
|
+
})
|
|
63
|
+
.query(VIEW_CHECKOUT_BOOKING_BY_ID, viewCheckoutBookingByIdHandler, {
|
|
64
|
+
view: checkoutBookingByIdView,
|
|
61
65
|
})
|
|
62
66
|
.query(VIEW_BOOKED_SIZE_CHANGE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, viewBookedSizeChangeProductsVariantsForCheckoutItemHandler, {
|
|
63
67
|
view: bookedSizeChangeProductsVariantsForCheckoutItemView,
|
|
@@ -9,6 +9,7 @@ import { httpCheckoutByIdView } from "../projection/checkout/httpCheckoutByIdVie
|
|
|
9
9
|
import { httpFirstAvailableCheckoutByCustomerIdView } from "../projection/checkout/httpFirstAvailableCheckoutByCustomerIdView";
|
|
10
10
|
import { httpFiveItemsDiscountByCustomerIdView } from "../projection/checkout/httpFiveItemsDiscountByCustomerIdView";
|
|
11
11
|
import { httpIsCheckoutEnabledByCustomerIdView } from "../projection/checkout/httpIsCheckoutEnabledByCustomerIdView";
|
|
12
|
+
import { httpCheckoutBookingByIdView } from "../projection/checkoutBooking/httpCheckoutBookingByIdView";
|
|
12
13
|
import { httpCheckoutItemByIdView } from "../projection/checkoutItem/httpCheckoutItemByIdView";
|
|
13
14
|
import { httpCheckoutQuestionsByCheckoutIdView } from "../projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView";
|
|
14
15
|
import { httpPaymentFlowPayloadByCheckoutIdView } from "../projection/payment/httpPaymentFlowPayloadByCheckoutIdView";
|
|
@@ -28,6 +29,7 @@ const bootstrap = ({ apiUrl, authToken }) => {
|
|
|
28
29
|
uiSettingByKeyView: storageUiSettingByKeyView({ read }),
|
|
29
30
|
checkoutItemByIdView: httpCheckoutItemByIdView({ httpPost }),
|
|
30
31
|
returnQuestionsByCheckoutItemIdView: httpReturnQuestionsByCheckoutItemIdView({ httpPost }),
|
|
32
|
+
checkoutBookingByIdView: httpCheckoutBookingByIdView({ httpPost }),
|
|
31
33
|
bookedSizeChangeProductsVariantsForCheckoutItemView: httpBookedSizeChangeProductsVariantsForCheckoutItemView({
|
|
32
34
|
httpPost,
|
|
33
35
|
}),
|
|
@@ -7,7 +7,7 @@ const toCheckoutDomain = (checkout) => {
|
|
|
7
7
|
status: checkout.status,
|
|
8
8
|
customerId: checkout.customerId,
|
|
9
9
|
boxId: checkout.boxId,
|
|
10
|
-
|
|
10
|
+
checkoutBookingId: checkout.checkoutBookingId,
|
|
11
11
|
expiresOn: checkout.expiresOn,
|
|
12
12
|
aggregateId: checkout.id,
|
|
13
13
|
domainEvents: [],
|
|
@@ -18,7 +18,7 @@ const toCheckoutProjection = (checkout) => ({
|
|
|
18
18
|
status: checkout.status,
|
|
19
19
|
customerId: checkout.customerId,
|
|
20
20
|
boxId: checkout.boxId,
|
|
21
|
-
|
|
21
|
+
checkoutBookingId: checkout.checkoutBookingId,
|
|
22
22
|
expiresOn: checkout.expiresOn,
|
|
23
23
|
items: [],
|
|
24
24
|
});
|
|
@@ -9,7 +9,7 @@ const toDomain = (checkout) => {
|
|
|
9
9
|
status: checkout.status,
|
|
10
10
|
customerId: checkout.customerId,
|
|
11
11
|
boxId: checkout.boxId,
|
|
12
|
-
|
|
12
|
+
checkoutBookingId: checkout.checkoutBookingId,
|
|
13
13
|
expiresOn: checkout.expiresOn,
|
|
14
14
|
aggregateId: checkout.id,
|
|
15
15
|
domainEvents: [],
|
|
@@ -5,7 +5,7 @@ interface CheckoutDto {
|
|
|
5
5
|
readonly id: string;
|
|
6
6
|
readonly customerId: string;
|
|
7
7
|
readonly boxId: string;
|
|
8
|
-
readonly
|
|
8
|
+
readonly checkoutBookingId: string;
|
|
9
9
|
readonly status: CheckoutStatus;
|
|
10
10
|
readonly expiresOn: string;
|
|
11
11
|
readonly items: CheckoutItemProjection[];
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { useQuery } from "@lookiero/messaging-react";
|
|
2
|
+
import { CHECKOUT_ITEM_KEPT } from "../../../../domain/checkoutItem/model/checkoutItemKept";
|
|
3
|
+
import { CHECKOUT_ITEM_REPLACED, } from "../../../../domain/checkoutItem/model/checkoutItemReplaced";
|
|
4
|
+
import { CHECKOUT_ITEM_RETURNED, } from "../../../../domain/checkoutItem/model/checkoutItemReturned";
|
|
2
5
|
import { viewPricingByCheckoutId } from "../../../../projection/pricing/viewPricingByCheckoutId";
|
|
3
6
|
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
7
|
+
const isCheckoutItemKept = (event) => event.name === CHECKOUT_ITEM_KEPT;
|
|
8
|
+
const isCheckoutItemReturned = (event) => event.name === CHECKOUT_ITEM_RETURNED;
|
|
9
|
+
const isCheckoutItemReplaced = (event) => event.name === CHECKOUT_ITEM_REPLACED;
|
|
10
|
+
const shouldInvalidate = (event) => isCheckoutItemKept(event) || isCheckoutItemReplaced(event) || isCheckoutItemReturned(event);
|
|
4
11
|
const useViewPricingByCheckoutId = ({ checkoutId }) => useQuery({
|
|
5
12
|
query: viewPricingByCheckoutId({ checkoutId }),
|
|
6
13
|
contextId: MESSAGING_CONTEXT_ID,
|
|
7
|
-
|
|
14
|
+
invalidation: shouldInvalidate,
|
|
15
|
+
options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false, refetchOnMount: "always" },
|
|
8
16
|
});
|
|
9
17
|
export { useViewPricingByCheckoutId };
|
|
@@ -23,7 +23,7 @@ const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner,
|
|
|
23
23
|
const notFoundRouteMatch = useMatch(`${basePath}/${Routes.NOT_FOUND}`);
|
|
24
24
|
const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
|
|
25
25
|
const dependenciesLoaded = dependenciesLoadedStatuses.includes(shouldIntroBeShownStatus) &&
|
|
26
|
-
dependenciesLoadedStatuses.includes(checkoutStatus);
|
|
26
|
+
(dependenciesLoadedStatuses.includes(checkoutStatus) || checkout);
|
|
27
27
|
if (!dependenciesLoaded) {
|
|
28
28
|
return loader;
|
|
29
29
|
}
|
|
@@ -54,7 +54,6 @@ const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner,
|
|
|
54
54
|
}
|
|
55
55
|
/* Navigate to the first item without customer's decission */
|
|
56
56
|
if (firstItemWithoutCustomerDecision && !itemRouteMatch) {
|
|
57
|
-
console.log("navigate to first item...", firstItemWithoutCustomerDecision.id);
|
|
58
57
|
return (React.createElement(Navigate, { to: generatePath(`${basePath}/${Routes.ITEM}`, { id: firstItemWithoutCustomerDecision.id }), replace: true }));
|
|
59
58
|
}
|
|
60
59
|
/* Navigate to the summary if required */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
|
|
2
2
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
3
3
|
import { View } from "react-native";
|
|
4
|
-
import { useParams } from "react-router-native";
|
|
4
|
+
import { generatePath, useMatch, useNavigate, useParams } from "react-router-native";
|
|
5
5
|
import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
|
|
6
6
|
import "../../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
7
7
|
import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
|
|
@@ -15,6 +15,8 @@ import { useListReturnQuestionsByCheckoutItemId } from "../../../projection/retu
|
|
|
15
15
|
import { Body } from "../../components/layouts/body/Body";
|
|
16
16
|
import { ReturnQuestionFeedbackProvider } from "../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
|
|
17
17
|
import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
|
|
18
|
+
import { Routes } from "../../routing/routes";
|
|
19
|
+
import { useBasePath } from "../../routing/useBasePath";
|
|
18
20
|
import { style } from "./Item.style";
|
|
19
21
|
import { CustomerDecissionBanner } from "./components/banner/CustomerDecissionBanner";
|
|
20
22
|
import { ItemActions } from "./components/itemActions/ItemActions";
|
|
@@ -28,14 +30,48 @@ const Item = ({ customerId }) => {
|
|
|
28
30
|
const { id } = useParams();
|
|
29
31
|
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
30
32
|
const checkoutItem = checkout?.items.find((checkoutItem) => checkoutItem.id === id);
|
|
31
|
-
const
|
|
33
|
+
const basePath = useBasePath();
|
|
34
|
+
const itemRouteMatch = useMatch(`${basePath}/${Routes.ITEM}`);
|
|
35
|
+
const firstItemWithoutCustomerDecision = checkout?.items.find((item) => [CheckoutItemStatus.EXPIRED, CheckoutItemStatus.INITIAL].includes(item.status));
|
|
36
|
+
const navigate = useNavigate();
|
|
37
|
+
const navigateToNextItem = useCallback(() => {
|
|
38
|
+
if (itemRouteMatch && firstItemWithoutCustomerDecision) {
|
|
39
|
+
navigate(generatePath(`${basePath}/${Routes.ITEM}`, { id: firstItemWithoutCustomerDecision.id }));
|
|
40
|
+
}
|
|
41
|
+
}, [basePath, firstItemWithoutCustomerDecision, itemRouteMatch, navigate]);
|
|
42
|
+
const [customerDecissionMade, setCustomerDecissionMade] = useState(false);
|
|
32
43
|
const handleOnBannerPress = useCallback(() => setCustomerDecissionMade(!customerDecissionMade), [customerDecissionMade]);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
setCustomerDecissionMade(checkoutItem.status === CheckoutItemStatus.INITIAL || checkoutItem.status === CheckoutItemStatus.EXPIRED);
|
|
46
|
+
}, [checkoutItem]);
|
|
47
|
+
const [keepCheckoutItem, keepCheckoutItemStatus] = useKeepCheckoutItem({ checkoutItemId: checkoutItem.id });
|
|
48
|
+
const [returnCheckoutItem, returnCheckoutItemStatus] = useReturnCheckoutItem({
|
|
49
|
+
checkoutItemId: checkoutItem.id,
|
|
50
|
+
});
|
|
51
|
+
const [replaceCheckoutItem, replaceCheckoutItemStatus] = useReplaceCheckoutItem({
|
|
52
|
+
checkoutItemId: checkoutItem.id,
|
|
53
|
+
});
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (keepCheckoutItemStatus === CommandStatus.SUCCESS) {
|
|
56
|
+
navigateToNextItem();
|
|
57
|
+
}
|
|
58
|
+
}, [keepCheckoutItemStatus, navigateToNextItem]);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (returnCheckoutItemStatus === CommandStatus.SUCCESS) {
|
|
61
|
+
navigateToNextItem();
|
|
62
|
+
}
|
|
63
|
+
}, [returnCheckoutItemStatus, navigateToNextItem]);
|
|
33
64
|
const [sizeWithoutStockModalVisible, setSizeWithoutStockModalVisible] = useState(false);
|
|
34
65
|
const handleOnShowSizeWithoutStockModal = useCallback(() => setSizeWithoutStockModalVisible(true), []);
|
|
35
66
|
const handleOnHideSizeWithoutStockModal = useCallback(() => setSizeWithoutStockModalVisible(false), []);
|
|
36
67
|
const [sizeChangeModalVisible, setSizeChangeModalVisible] = useState(false);
|
|
37
68
|
const handleOnShowSizeChangeModal = useCallback(() => setSizeChangeModalVisible(true), []);
|
|
38
|
-
const handleOnHideSizeChangeModal = useCallback(() =>
|
|
69
|
+
const handleOnHideSizeChangeModal = useCallback(() => {
|
|
70
|
+
setSizeChangeModalVisible(false);
|
|
71
|
+
if (replaceCheckoutItemStatus === CommandStatus.SUCCESS) {
|
|
72
|
+
navigateToNextItem();
|
|
73
|
+
}
|
|
74
|
+
}, [navigateToNextItem, replaceCheckoutItemStatus]);
|
|
39
75
|
const [bookedSizeChangeProductsVariants, bookedSizeChangeProductsVariantsStatus] = useViewBookedSizeChangeProductsVariantsForCheckoutItem({
|
|
40
76
|
checkoutItemId: checkoutItem.id,
|
|
41
77
|
});
|
|
@@ -44,17 +80,10 @@ const Item = ({ customerId }) => {
|
|
|
44
80
|
});
|
|
45
81
|
useEffect(() => {
|
|
46
82
|
bookedSizeChangeProductsVariants === null && bookCheckouBooking();
|
|
47
|
-
}, [bookCheckouBooking, bookedSizeChangeProductsVariants
|
|
83
|
+
}, [bookCheckouBooking, bookedSizeChangeProductsVariants]);
|
|
48
84
|
const [returnQuestions, returnQuestionsStatus] = useListReturnQuestionsByCheckoutItemId({
|
|
49
85
|
checkoutItemId: checkoutItem.id,
|
|
50
86
|
});
|
|
51
|
-
const [keepCheckoutItem, keepCheckoutItemStatus] = useKeepCheckoutItem({ checkoutItemId: checkoutItem.id });
|
|
52
|
-
const [returnCheckoutItem, returnCheckoutItemStatus] = useReturnCheckoutItem({
|
|
53
|
-
checkoutItemId: checkoutItem.id,
|
|
54
|
-
});
|
|
55
|
-
const [replaceCheckoutItem, replaceCheckoutItemStatus] = useReplaceCheckoutItem({
|
|
56
|
-
checkoutItemId: checkoutItem.id,
|
|
57
|
-
});
|
|
58
87
|
const [stickyHeight, setStickyHeight] = useState(0);
|
|
59
88
|
const handleOnStickyLayout = useCallback(({ height }) => setStickyHeight(height), []);
|
|
60
89
|
const [returnQuestionsVisible, setReturnQuestionsVisible] = useState(false);
|
|
@@ -70,17 +99,18 @@ const Item = ({ customerId }) => {
|
|
|
70
99
|
replaceCheckoutItem({ replacedFor });
|
|
71
100
|
}, [handleOnShowSizeChangeModal, replaceCheckoutItem]);
|
|
72
101
|
const handleOnReturn = useCallback(() => handleOnShowReturnQuestions(), [handleOnShowReturnQuestions]);
|
|
73
|
-
const productVariantSelected = useMemo(() => checkoutItem.replacedFor
|
|
102
|
+
const productVariantSelected = useMemo(() => checkoutItem.status === CheckoutItemStatus.REPLACED && checkoutItem.replacedFor
|
|
74
103
|
? bookedSizeChangeProductsVariants?.productVariants.find((productVariant) => productVariant.id === checkoutItem.replacedFor)
|
|
75
104
|
: { id: checkoutItem.productVariant.id, size: checkoutItem.productVariant.size }, [
|
|
76
105
|
bookedSizeChangeProductsVariants?.productVariants,
|
|
77
106
|
checkoutItem.productVariant.id,
|
|
78
107
|
checkoutItem.productVariant.size,
|
|
79
108
|
checkoutItem.replacedFor,
|
|
109
|
+
checkoutItem.status,
|
|
80
110
|
]);
|
|
81
111
|
const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
|
|
82
112
|
const dependenciesLoaded = dependenciesLoadedStatuses.includes(returnQuestionsStatus) &&
|
|
83
|
-
dependenciesLoadedStatuses.includes(checkoutStatus) &&
|
|
113
|
+
(dependenciesLoadedStatuses.includes(checkoutStatus) || checkout) &&
|
|
84
114
|
dependenciesLoadedStatuses.includes(bookedSizeChangeProductsVariantsStatus);
|
|
85
115
|
if (!dependenciesLoaded)
|
|
86
116
|
return React.createElement(Spinner, null);
|
|
@@ -44,9 +44,9 @@ const Pricing = ({ orderTotal, subtotal, balanceDiscount, discount, discountPerc
|
|
|
44
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
|
-
discount && (React.createElement(Row, { text: discountText },
|
|
47
|
+
discount && discount.amount !== 0 && (React.createElement(Row, { text: discountText },
|
|
48
48
|
React.createElement(Price, { price: discount, variant: "subtotal" }))),
|
|
49
|
-
balanceDiscount && (React.createElement(Row, { text: creditText },
|
|
49
|
+
balanceDiscount && balanceDiscount.amount !== 0 && (React.createElement(Row, { text: creditText },
|
|
50
50
|
React.createElement(Price, { price: balanceDiscount, variant: "subtotal" }))),
|
|
51
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
52
|
React.createElement(View, { style: style.divider }),
|
|
@@ -4,7 +4,7 @@ interface CheckoutProjection {
|
|
|
4
4
|
readonly id: string;
|
|
5
5
|
readonly customerId: string;
|
|
6
6
|
readonly boxId: string;
|
|
7
|
-
readonly
|
|
7
|
+
readonly checkoutBookingId: string;
|
|
8
8
|
readonly status: CheckoutStatus;
|
|
9
9
|
readonly expiresOn: Date;
|
|
10
10
|
readonly items: CheckoutItemProjection[];
|
|
@@ -9,9 +9,9 @@ interface ServiceProjection {
|
|
|
9
9
|
interface PricingProjection {
|
|
10
10
|
readonly orderTotal: PriceProjection;
|
|
11
11
|
readonly subtotal: PriceProjection;
|
|
12
|
-
readonly balanceDiscount
|
|
13
|
-
readonly discount
|
|
14
|
-
readonly discountPercentage
|
|
12
|
+
readonly balanceDiscount: PriceProjection;
|
|
13
|
+
readonly discount: PriceProjection;
|
|
14
|
+
readonly discountPercentage: number;
|
|
15
15
|
readonly service: ServiceProjection;
|
|
16
16
|
}
|
|
17
17
|
export type { PricingProjection, ServiceProjection };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lookiero/checkout",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.23",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -48,14 +48,14 @@
|
|
|
48
48
|
"@lookiero/locale": "^0.3",
|
|
49
49
|
"@lookiero/payments-front": "^0.16.5",
|
|
50
50
|
"apollo-boost": "0.4.4",
|
|
51
|
-
"graphql": "
|
|
51
|
+
"graphql": "16.6.0",
|
|
52
52
|
"graphql-tag": "2.12.6",
|
|
53
53
|
"react": "^18.0.0",
|
|
54
54
|
"react-dom": "^18.0.0",
|
|
55
|
-
"react-native": "^0.70.
|
|
55
|
+
"react-native": "^0.70.6",
|
|
56
56
|
"react-native-web": "^0.18.9",
|
|
57
|
-
"react-router-dom": "^6.4.
|
|
58
|
-
"react-router-native": "^6.4.
|
|
57
|
+
"react-router-dom": "^6.4.5",
|
|
58
|
+
"react-router-native": "^6.4.5"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@babel/core": "^7.19.1",
|
|
@@ -73,11 +73,11 @@
|
|
|
73
73
|
"@testing-library/react-hooks": "^8.0.1",
|
|
74
74
|
"@testing-library/react-native": "^11.0.0",
|
|
75
75
|
"@trivago/prettier-plugin-sort-imports": "^3.3.0",
|
|
76
|
-
"@types/jest": "^29.2.
|
|
76
|
+
"@types/jest": "^29.2.4",
|
|
77
77
|
"@types/react": "~18.0.0",
|
|
78
78
|
"@types/react-dom": "~18.0.0",
|
|
79
79
|
"@types/react-native": "~0.69.1",
|
|
80
|
-
"@types/uuid": "^
|
|
80
|
+
"@types/uuid": "^9.0.0",
|
|
81
81
|
"apollo-boost": "0.4.4",
|
|
82
82
|
"eslint": "^8.24.0",
|
|
83
83
|
"eslint-config-prettier": "^8.5.0",
|
|
@@ -92,9 +92,9 @@
|
|
|
92
92
|
"expo": "~46.0.8",
|
|
93
93
|
"expo-modules-core": "^1.0.3",
|
|
94
94
|
"expo-status-bar": "~1.4.0",
|
|
95
|
-
"graphql": "
|
|
95
|
+
"graphql": "16.6.0",
|
|
96
96
|
"graphql-tag": "2.12.6",
|
|
97
|
-
"husky": "^8.0.
|
|
97
|
+
"husky": "^8.0.2",
|
|
98
98
|
"jest": "^29.3.1",
|
|
99
99
|
"jest-expo": "^46.0.1",
|
|
100
100
|
"jest-fetch-mock": "^3.0.3",
|
|
@@ -104,14 +104,14 @@
|
|
|
104
104
|
"prettier": "^2.7.1",
|
|
105
105
|
"react": "^18.0.0",
|
|
106
106
|
"react-dom": "^18.0.0",
|
|
107
|
-
"react-native": "^0.70.
|
|
107
|
+
"react-native": "^0.70.6",
|
|
108
108
|
"react-native-get-random-values": "^1.8.0",
|
|
109
109
|
"react-native-unimodules": "^0.14.10",
|
|
110
110
|
"react-native-web": "^0.18.9",
|
|
111
|
-
"react-router-dom": "^6.4.
|
|
112
|
-
"react-router-native": "^6.4.
|
|
111
|
+
"react-router-dom": "^6.4.5",
|
|
112
|
+
"react-router-native": "^6.4.5",
|
|
113
113
|
"react-test-renderer": "^18.0.0",
|
|
114
114
|
"typescript": "^4.9.3",
|
|
115
|
-
"webpack-bundle-analyzer": "^4.
|
|
115
|
+
"webpack-bundle-analyzer": "^4.7.0"
|
|
116
116
|
}
|
|
117
117
|
}
|