@lookiero/checkout 0.2.30 → 0.2.32-LK-25049
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/infrastructure/delivery/baseBootstrap.d.ts +2 -0
- package/dist/infrastructure/delivery/baseBootstrap.js +5 -1
- package/dist/infrastructure/delivery/bootstrap.js +2 -0
- package/dist/infrastructure/delivery/bootstrap.mock.js +3 -0
- package/dist/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.d.ts +12 -0
- package/dist/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.js +12 -0
- package/dist/infrastructure/projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId.d.ts +10 -0
- package/dist/infrastructure/projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId.js +9 -0
- package/dist/infrastructure/projection/returnQuestion/returnQuestion.d.ts +14 -0
- package/dist/infrastructure/projection/returnQuestion/returnQuestion.js +9 -0
- package/dist/infrastructure/ui/components/layouts/body/Body.d.ts +3 -0
- package/dist/infrastructure/ui/components/layouts/body/Body.js +2 -2
- package/dist/infrastructure/ui/components/layouts/body/Body.style.d.ts +0 -3
- package/dist/infrastructure/ui/components/layouts/body/Body.style.js +0 -5
- package/dist/infrastructure/ui/shared/hooks/useScreenSize.js +1 -1
- package/dist/infrastructure/ui/views/item/Item.js +16 -10
- package/dist/infrastructure/ui/views/item/Item.style.d.ts +3 -0
- package/dist/infrastructure/ui/views/item/Item.style.js +3 -0
- package/dist/infrastructure/ui/views/item/components/{productVariantActions/ProductVariantActions.d.ts → itemActions/ItemActions.d.ts} +5 -3
- package/dist/infrastructure/ui/views/item/components/itemActions/ItemActions.js +25 -0
- package/dist/infrastructure/ui/views/item/components/{productVariantActions/ProductVariantActions.style.d.ts → itemActions/ItemActions.style.d.ts} +1 -1
- package/dist/infrastructure/ui/views/item/components/{productVariantActions/ProductVariantActions.style.js → itemActions/ItemActions.style.js} +2 -2
- package/dist/projection/returnQuestion/listReturnQuestionsByCheckoutItemId.d.ts +25 -0
- package/dist/projection/returnQuestion/listReturnQuestionsByCheckoutItemId.js +8 -0
- package/dist/projection/returnQuestion/returnQuestion.d.ts +5 -5
- package/package.json +3 -3
- package/dist/infrastructure/ui/views/item/components/productVariantActions/ProductVariantActions.js +0 -22
|
@@ -11,6 +11,7 @@ import { FirstAvailableCheckoutByCustomerIdView } from "../../projection/checkou
|
|
|
11
11
|
import { FiveItemsDiscountByCustomerIdView } from "../../projection/checkout/viewFiveItemsDiscountByCustomerId";
|
|
12
12
|
import { IsCheckoutEnabledByCustomerIdView } from "../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
|
|
13
13
|
import { CheckoutItemByIdView } from "../../projection/checkoutItem/viewCheckoutItemById";
|
|
14
|
+
import { ReturnQuestionsByCheckoutItemIdView } from "../../projection/returnQuestion/listReturnQuestionsByCheckoutItemId";
|
|
14
15
|
import { UiSettingByKeyView } from "../../projection/uiSetting/viewUiSettingByKey";
|
|
15
16
|
declare const MESSAGING_CONTEXT_ID = "Checkout";
|
|
16
17
|
declare type NeverWhenEmptyRecord<K extends [Record<string, unknown>]> = K extends [Record<string, never>] ? [never?] : K;
|
|
@@ -22,6 +23,7 @@ interface BaseBootstrapFunctionArgs<UiSettingGetFunctionArgs extends RepositoryG
|
|
|
22
23
|
readonly fiveItemsDiscountByCustomerIdView: FiveItemsDiscountByCustomerIdView;
|
|
23
24
|
readonly uiSettingByKeyView: UiSettingByKeyView;
|
|
24
25
|
readonly checkoutItemByIdView: CheckoutItemByIdView;
|
|
26
|
+
readonly returnQuestionsByCheckoutItemIdView: ReturnQuestionsByCheckoutItemIdView;
|
|
25
27
|
readonly getUiSetting: UiSettingGetFunction<UiSettingGetFunctionArgs>;
|
|
26
28
|
readonly saveUiSetting: UiSettingSaveFunction<UiSettingSaveFunctionArgs>;
|
|
27
29
|
readonly uiSettingsDependencies: NeverWhenEmptyRecord<[
|
|
@@ -11,9 +11,10 @@ import { viewFiveItemsDiscountByCustomerIdHandler, VIEW_FIVE_ITEMS_DISCOUNT_BY_C
|
|
|
11
11
|
import { viewIsCheckoutAccessibleByCustomerIdHandler, VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, } from "../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
12
12
|
import { viewIsCheckoutEnabledByCustomerIdHandler, VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, } from "../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
|
|
13
13
|
import { viewCheckoutItemByIdHandler, VIEW_CHECKOUT_ITEM_BY_ID, } from "../../projection/checkoutItem/viewCheckoutItemById";
|
|
14
|
+
import { listReturnQuestionsByCheckoutItemIdHandler, LIST_RETURN_QUESTIONS_BY_CHECKOUT_ITEM_ID, } from "../../projection/returnQuestion/listReturnQuestionsByCheckoutItemId";
|
|
14
15
|
import { viewUiSettingByKeyHandler, VIEW_UI_SETTING_BY_KEY, } from "../../projection/uiSetting/viewUiSettingByKey";
|
|
15
16
|
const MESSAGING_CONTEXT_ID = "Checkout";
|
|
16
|
-
const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdView, isCheckoutEnabledByCustomerIdView, fiveItemsDiscountByCustomerIdView, uiSettingByKeyView, checkoutItemByIdView, getUiSetting, saveUiSetting, uiSettingsDependencies, getCheckout, saveCheckout, checkoutsDependencies, getCheckoutItem, saveCheckoutItem, checkoutItemsDependencies, }) => messagingBootstrap({ id: MESSAGING_CONTEXT_ID })
|
|
17
|
+
const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdView, isCheckoutEnabledByCustomerIdView, fiveItemsDiscountByCustomerIdView, uiSettingByKeyView, checkoutItemByIdView, returnQuestionsByCheckoutItemIdView, getUiSetting, saveUiSetting, uiSettingsDependencies, getCheckout, saveCheckout, checkoutsDependencies, getCheckoutItem, saveCheckoutItem, checkoutItemsDependencies, }) => messagingBootstrap({ id: MESSAGING_CONTEXT_ID })
|
|
17
18
|
.query(VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, viewFiveItemsDiscountByCustomerIdHandler, {
|
|
18
19
|
view: fiveItemsDiscountByCustomerIdView,
|
|
19
20
|
})
|
|
@@ -30,6 +31,9 @@ const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdVie
|
|
|
30
31
|
.command(START_CHECKOUT, startCheckoutHandler)(getCheckout, saveCheckout, ...checkoutsDependencies)
|
|
31
32
|
.query(VIEW_CHECKOUT_ITEM_BY_ID, viewCheckoutItemByIdHandler, {
|
|
32
33
|
view: checkoutItemByIdView,
|
|
34
|
+
})
|
|
35
|
+
.query(LIST_RETURN_QUESTIONS_BY_CHECKOUT_ITEM_ID, listReturnQuestionsByCheckoutItemIdHandler, {
|
|
36
|
+
view: returnQuestionsByCheckoutItemIdView,
|
|
33
37
|
})
|
|
34
38
|
.command(KEEP_CHECKOUT_ITEM, keepCheckoutItemHandler)(getCheckoutItem, saveCheckoutItem, ...checkoutItemsDependencies)
|
|
35
39
|
.query(VIEW_UI_SETTING_BY_KEY, viewUiSettingByKeyHandler, {
|
|
@@ -7,6 +7,7 @@ import { httpFirstAvailableCheckoutByCustomerIdView } from "../projection/checko
|
|
|
7
7
|
import { httpFiveItemsDiscountByCustomerIdView } from "../projection/checkout/httpFiveItemsDiscountByCustomerIdView";
|
|
8
8
|
import { httpIsCheckoutEnabledByCustomerIdView } from "../projection/checkout/httpIsCheckoutEnabledByCustomerIdView";
|
|
9
9
|
import { httpCheckoutItemByIdView } from "../projection/checkoutItem/httpCheckoutItemByIdView";
|
|
10
|
+
import { httpReturnQuestionsByCheckoutItemIdView } from "../projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView";
|
|
10
11
|
import { storageUiSettingByKeyView } from "../projection/uiSetting/storageUiSettingByKeyView";
|
|
11
12
|
import { baseBootstrap } from "./baseBootstrap";
|
|
12
13
|
import { fetchHttpGet, fetchHttpPost } from "./http/fetchHttpClient";
|
|
@@ -20,6 +21,7 @@ const bootstrap = ({ apiUrl, getAuthToken }) => {
|
|
|
20
21
|
fiveItemsDiscountByCustomerIdView: httpFiveItemsDiscountByCustomerIdView({ httpGet }),
|
|
21
22
|
uiSettingByKeyView: storageUiSettingByKeyView({ read }),
|
|
22
23
|
checkoutItemByIdView: httpCheckoutItemByIdView({ httpPost }),
|
|
24
|
+
returnQuestionsByCheckoutItemIdView: httpReturnQuestionsByCheckoutItemIdView({ httpPost }),
|
|
23
25
|
getUiSetting,
|
|
24
26
|
saveUiSetting,
|
|
25
27
|
uiSettingsDependencies: [{ read, write }],
|
|
@@ -2,6 +2,7 @@ import { CheckoutItemStatus } from "../../domain/checkoutItem/model/checkoutItem
|
|
|
2
2
|
import { getUiSetting, saveUiSetting } from "../domain/uiSetting/model/storageUiSettings";
|
|
3
3
|
import { read, write } from "../persistence/asyncStorageStorage";
|
|
4
4
|
import { startedCheckoutWithStatusProjection } from "../projection/checkout/checkout.mock";
|
|
5
|
+
import { returnQuestions as returnQuestionsMock } from "../projection/returnQuestion/returnQuestions.mock";
|
|
5
6
|
import { storageUiSettingByKeyView } from "../projection/uiSetting/storageUiSettingByKeyView";
|
|
6
7
|
import { baseBootstrap } from "./baseBootstrap";
|
|
7
8
|
import { checkoutDataSource } from "./mock/checkoutDataSource";
|
|
@@ -25,6 +26,7 @@ const firstAvailableCheckoutByCustomerIdView = async () => dataSource.getCheckou
|
|
|
25
26
|
const isCheckoutEnabledByCustomerIdView = async () => IS_CHECKOUT_ENABLED;
|
|
26
27
|
const fiveItemsDiscountByCustomerIdView = async () => FIVE_ITEMS_DISCOUNT;
|
|
27
28
|
const checkoutItemByIdView = async ({ checkoutItemId }) => dataSource.getCheckoutItem(checkoutItemId);
|
|
29
|
+
const returnQuestionsByCheckoutItemIdView = async () => returnQuestionsMock;
|
|
28
30
|
const bootstrap = () => baseBootstrap({
|
|
29
31
|
checkoutByIdView,
|
|
30
32
|
firstAvailableCheckoutByCustomerIdView,
|
|
@@ -32,6 +34,7 @@ const bootstrap = () => baseBootstrap({
|
|
|
32
34
|
fiveItemsDiscountByCustomerIdView,
|
|
33
35
|
uiSettingByKeyView: storageUiSettingByKeyView({ read }),
|
|
34
36
|
checkoutItemByIdView,
|
|
37
|
+
returnQuestionsByCheckoutItemIdView,
|
|
35
38
|
getUiSetting,
|
|
36
39
|
saveUiSetting,
|
|
37
40
|
uiSettingsDependencies: [{ read, write }],
|
package/dist/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReturnQuestionsByCheckoutItemIdView } from "../../../projection/returnQuestion/listReturnQuestionsByCheckoutItemId";
|
|
2
|
+
import { HttpPostFunction } from "../../delivery/http/httpClient";
|
|
3
|
+
interface HttpReturnQuestionsByCheckoutItemIdView extends ReturnQuestionsByCheckoutItemIdView {
|
|
4
|
+
}
|
|
5
|
+
interface HttpReturnQuestionsByCheckoutItemIdViewFunctionArgs {
|
|
6
|
+
readonly httpPost: HttpPostFunction;
|
|
7
|
+
}
|
|
8
|
+
interface HttpReturnQuestionsByCheckoutItemIdViewFunction {
|
|
9
|
+
(args: HttpReturnQuestionsByCheckoutItemIdViewFunctionArgs): HttpReturnQuestionsByCheckoutItemIdView;
|
|
10
|
+
}
|
|
11
|
+
declare const httpReturnQuestionsByCheckoutItemIdView: HttpReturnQuestionsByCheckoutItemIdViewFunction;
|
|
12
|
+
export { httpReturnQuestionsByCheckoutItemIdView };
|
package/dist/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { toReturnQuestionsProjection } from "./returnQuestion";
|
|
2
|
+
const httpReturnQuestionsByCheckoutItemIdView = ({ httpPost }) => async ({ checkoutItemId, signal }) => {
|
|
3
|
+
const response = await httpPost({
|
|
4
|
+
endpoint: "/list-return-questions-by-checkout-item-id",
|
|
5
|
+
body: { checkout_item_id: checkoutItemId },
|
|
6
|
+
signal,
|
|
7
|
+
});
|
|
8
|
+
return !response.ok || response.status === 404
|
|
9
|
+
? undefined
|
|
10
|
+
: toReturnQuestionsProjection((await response.json()).result);
|
|
11
|
+
};
|
|
12
|
+
export { httpReturnQuestionsByCheckoutItemIdView };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UseQueryFunctionResult } from "@lookiero/messaging-react";
|
|
2
|
+
import { ReturnQuestionProjection } from "../../../../projection/returnQuestion/returnQuestion";
|
|
3
|
+
interface UseListReturnQuestionsByCheckoutItemIdFunctionArgs {
|
|
4
|
+
readonly checkoutItemId: string;
|
|
5
|
+
}
|
|
6
|
+
interface UseListReturnQuestionsByCheckoutItemIdFunction {
|
|
7
|
+
(args: UseListReturnQuestionsByCheckoutItemIdFunctionArgs): UseQueryFunctionResult<ReturnQuestionProjection[]>;
|
|
8
|
+
}
|
|
9
|
+
declare const useListReturnQuestionsByCheckoutItemId: UseListReturnQuestionsByCheckoutItemIdFunction;
|
|
10
|
+
export { useListReturnQuestionsByCheckoutItemId };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useQuery } from "@lookiero/messaging-react";
|
|
2
|
+
import { listReturnQuestionsByCheckoutItemId } from "../../../../projection/returnQuestion/listReturnQuestionsByCheckoutItemId";
|
|
3
|
+
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
4
|
+
const useListReturnQuestionsByCheckoutItemId = ({ checkoutItemId }) => useQuery({
|
|
5
|
+
query: listReturnQuestionsByCheckoutItemId({ checkoutItemId }),
|
|
6
|
+
contextId: MESSAGING_CONTEXT_ID,
|
|
7
|
+
options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
|
|
8
|
+
});
|
|
9
|
+
export { useListReturnQuestionsByCheckoutItemId };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ReturnQuestionProjection, ReturnQuestionType } from "../../../projection/returnQuestion/returnQuestion";
|
|
2
|
+
interface ReturnQuestionDto {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly placeholder?: string;
|
|
6
|
+
readonly type: ReturnQuestionType;
|
|
7
|
+
readonly children?: ReturnQuestionDto[];
|
|
8
|
+
}
|
|
9
|
+
interface ToReturnQuestionsProjectionFunction {
|
|
10
|
+
(returnQuestionsDto: ReturnQuestionDto[]): ReturnQuestionProjection[];
|
|
11
|
+
}
|
|
12
|
+
declare const toReturnQuestionsProjection: ToReturnQuestionsProjectionFunction;
|
|
13
|
+
export type { ReturnQuestionDto };
|
|
14
|
+
export { toReturnQuestionsProjection };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const toReturnQuestionProjection = (returnQuestionDto) => ({
|
|
2
|
+
id: returnQuestionDto.id,
|
|
3
|
+
name: returnQuestionDto.name,
|
|
4
|
+
placeholder: returnQuestionDto.placeholder,
|
|
5
|
+
type: returnQuestionDto.type,
|
|
6
|
+
children: returnQuestionDto.children ? toReturnQuestionsProjection(returnQuestionDto.children) : undefined,
|
|
7
|
+
});
|
|
8
|
+
const toReturnQuestionsProjection = (returnQuestionsDto) => returnQuestionsDto.map(toReturnQuestionProjection);
|
|
9
|
+
export { toReturnQuestionsProjection };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { FC, ReactNode } from "react";
|
|
2
|
+
import { StyleProp, ViewStyle } from "react-native";
|
|
3
|
+
declare type BodyStyle = "row" | "column";
|
|
2
4
|
interface BodyProps {
|
|
3
5
|
readonly children: ReactNode;
|
|
6
|
+
readonly style?: Partial<Record<BodyStyle, StyleProp<ViewStyle>>>;
|
|
4
7
|
}
|
|
5
8
|
declare const Body: FC<BodyProps>;
|
|
6
9
|
export { Body };
|
|
@@ -2,6 +2,6 @@ import React from "react";
|
|
|
2
2
|
import { Column } from "../../../shared/components/layouts/column/Column";
|
|
3
3
|
import { Row } from "../../../shared/components/layouts/row/Row";
|
|
4
4
|
import { style } from "./Body.style";
|
|
5
|
-
const Body = ({ children }) => (React.createElement(Row, { style: style.row },
|
|
6
|
-
React.createElement(Column, { style:
|
|
5
|
+
const Body = ({ children, style: customStyle }) => (React.createElement(Row, { style: [style.row, customStyle?.row] },
|
|
6
|
+
React.createElement(Column, { style: customStyle?.column }, children)));
|
|
7
7
|
export { Body };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useDevice } from "@lookiero/aurora-next/build/
|
|
1
|
+
import { useDevice } from "@lookiero/aurora-next/build/hooks/useDevice/useDevice";
|
|
2
2
|
const useScreenSize = () => {
|
|
3
3
|
const { screen } = useDevice();
|
|
4
4
|
const screenSize = Object.entries(screen)
|
|
@@ -2,25 +2,29 @@ import { QueryStatus } from "@lookiero/messaging-react";
|
|
|
2
2
|
import React, { useCallback, useState } from "react";
|
|
3
3
|
import { Text, TouchableHighlight, View } from "react-native";
|
|
4
4
|
import { useParams } from "react-router-native";
|
|
5
|
+
import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
|
|
5
6
|
import "../../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
6
7
|
import { bookedSizeReplaceableProductVariants as bookedSizeReplaceableProductVariantsMock } from "../../../projection/bookedSizeReplaceableProductVariants/bookedSizeReplaceableProductVariants.mock";
|
|
7
8
|
import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
8
9
|
import { feedback as feedbackMock } from "../../../projection/feedback/feedback.mock";
|
|
9
|
-
import {
|
|
10
|
+
import { useListReturnQuestionsByCheckoutItemId } from "../../../projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId";
|
|
10
11
|
import { Body } from "../../components/layouts/body/Body";
|
|
11
12
|
import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
|
|
12
13
|
import { Spinner } from "../../shared/components/atoms/spinner/Spinner";
|
|
13
|
-
import { Sticky } from "../../shared/components/layouts/sticky/Sticky";
|
|
14
14
|
import { style } from "./Item.style";
|
|
15
|
-
import {
|
|
15
|
+
import { CustomerDecissionBanner } from "./components/banner/CustomerDecissionBanner";
|
|
16
|
+
import { ItemActions } from "./components/itemActions/ItemActions";
|
|
16
17
|
import { ProductVariantDescription } from "./components/productVariantDescription/ProductVariantDescription";
|
|
17
18
|
import { ProductVariantSlider } from "./components/productVariantSlider/ProductVariantSlider";
|
|
18
19
|
import { ReturnQuestionsFeedback } from "./components/returnQuestionsFeedback/ReturnQuestionsFeedback";
|
|
19
20
|
import { ReturnQuestionsForm } from "./components/returnQuestionsForm/ReturnQuestionsForm";
|
|
20
21
|
const Item = ({ customerId }) => {
|
|
21
22
|
const { id } = useParams();
|
|
22
|
-
const [checkout,
|
|
23
|
+
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
23
24
|
const checkoutItem = checkout?.items.find((checkoutItem) => checkoutItem.id === id);
|
|
25
|
+
const [returnQuestions = [], returnQuestionsStatus] = useListReturnQuestionsByCheckoutItemId({
|
|
26
|
+
checkoutItemId: checkoutItem.id,
|
|
27
|
+
});
|
|
24
28
|
const [stickyHeight, setStickyHeight] = useState(0);
|
|
25
29
|
const handleOnStickyLayout = useCallback(({ height }) => setStickyHeight(height), []);
|
|
26
30
|
const [returnQuestionsVisible, setReturnQuestionsVisible] = useState(false);
|
|
@@ -31,11 +35,14 @@ const Item = ({ customerId }) => {
|
|
|
31
35
|
const handleOnKeep = useCallback(() => void 0, []);
|
|
32
36
|
const handleOnReplace = useCallback(() => void 0, []);
|
|
33
37
|
const handleOnReturn = useCallback(() => void 0, []);
|
|
34
|
-
|
|
38
|
+
const handleOnBannerPress = useCallback(() => void 0, []);
|
|
39
|
+
const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
|
|
40
|
+
const dependenciesLoaded = dependenciesLoadedStatuses.includes(returnQuestionsStatus) && dependenciesLoadedStatuses.includes(checkoutStatus);
|
|
41
|
+
if (!dependenciesLoaded)
|
|
35
42
|
return React.createElement(Spinner, null);
|
|
36
43
|
const { price } = checkoutItem;
|
|
37
44
|
const { media, brand, name, size, color } = checkoutItem.productVariant;
|
|
38
|
-
const
|
|
45
|
+
const customerDecissionMade = checkoutItem.status === CheckoutItemStatus.INITIAL || checkoutItem.status === CheckoutItemStatus.EXPIRED;
|
|
39
46
|
const feedback = feedbackMock;
|
|
40
47
|
const sizes = bookedSizeReplaceableProductVariantsMock.productVariants
|
|
41
48
|
.map((productVariant) => productVariant.size)
|
|
@@ -43,7 +50,8 @@ const Item = ({ customerId }) => {
|
|
|
43
50
|
return (React.createElement(React.Fragment, null,
|
|
44
51
|
React.createElement(SafeAreaScrollView, null,
|
|
45
52
|
React.createElement(Body, null,
|
|
46
|
-
React.createElement(
|
|
53
|
+
!customerDecissionMade && (React.createElement(CustomerDecissionBanner, { checkoutItemStatus: checkoutItem.status, onPress: handleOnBannerPress })),
|
|
54
|
+
React.createElement(View, { style: [style.container, { paddingBottom: stickyHeight }] },
|
|
47
55
|
React.createElement(View, { style: style.sliderContainer },
|
|
48
56
|
React.createElement(ProductVariantSlider, { producVariantMedia: media })),
|
|
49
57
|
React.createElement(ProductVariantDescription, { brand: brand, color: color, name: name, price: price, size: size }),
|
|
@@ -52,9 +60,7 @@ const Item = ({ customerId }) => {
|
|
|
52
60
|
React.createElement(View, { style: { flexDirection: "row", justifyContent: "center" } },
|
|
53
61
|
React.createElement(TouchableHighlight, { onPress: handleOnShowReturnQuestions },
|
|
54
62
|
React.createElement(Text, { style: { padding: 16 } }, "show return questions")))))),
|
|
55
|
-
React.createElement(
|
|
56
|
-
React.createElement(Body, null,
|
|
57
|
-
React.createElement(ProductVariantActions, { size: checkoutItem.productVariant.size, sizes: sizes, onKeep: handleOnKeep, onReplace: handleOnReplace, onReturn: handleOnReturn }))),
|
|
63
|
+
customerDecissionMade && (React.createElement(ItemActions, { size: checkoutItem.productVariant.size, sizes: sizes, onKeep: handleOnKeep, onLayout: handleOnStickyLayout, onReplace: handleOnReplace, onReturn: handleOnReturn })),
|
|
58
64
|
React.createElement(ReturnQuestionsForm, { checkoutItemPrice: checkoutItem.price, feedback: feedback, productVariant: checkoutItem.productVariant, returnQuestions: returnQuestions, visible: returnQuestionsVisible, onClose: handleOnHideReturnQuestions, onSubmit: handleOnSubmit })));
|
|
59
65
|
};
|
|
60
66
|
export { Item };
|
|
@@ -2,6 +2,9 @@ import { StyleSheet } from "react-native";
|
|
|
2
2
|
import { theme } from "../../theme/theme";
|
|
3
3
|
const { borderSize, colorGrayscaleM, spaceXL } = theme();
|
|
4
4
|
const style = StyleSheet.create({
|
|
5
|
+
container: {
|
|
6
|
+
paddingHorizontal: spaceXL,
|
|
7
|
+
},
|
|
5
8
|
feedbackContainer: {
|
|
6
9
|
borderTopColor: colorGrayscaleM,
|
|
7
10
|
borderTopWidth: borderSize,
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
2
|
import { SizeProjection } from "../../../../../../projection/shared/size";
|
|
3
|
-
|
|
3
|
+
import { Layout } from "../../../../shared/components/layouts/sticky/Sticky";
|
|
4
|
+
interface ItemActionsProps {
|
|
4
5
|
readonly sizes: SizeProjection[];
|
|
5
6
|
readonly size: SizeProjection;
|
|
6
7
|
readonly onKeep: (value: string) => void;
|
|
7
8
|
readonly onReturn: () => void;
|
|
8
9
|
readonly onReplace: () => void;
|
|
10
|
+
readonly onLayout?: ({ width, height }: Layout) => void;
|
|
9
11
|
}
|
|
10
|
-
declare const
|
|
11
|
-
export {
|
|
12
|
+
declare const ItemActions: FC<ItemActionsProps>;
|
|
13
|
+
export { ItemActions };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
|
|
2
|
+
import { BUTTON_VARIANT } from "@lookiero/aurora-next/build/components/atoms/Button/Button.definition";
|
|
3
|
+
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
4
|
+
import React, { useMemo } from "react";
|
|
5
|
+
import { View } from "react-native";
|
|
6
|
+
import { Body } from "../../../../components/layouts/body/Body";
|
|
7
|
+
import { I18nMessages } from "../../../../i18n/i18n";
|
|
8
|
+
import { Sticky } from "../../../../shared/components/layouts/sticky/Sticky";
|
|
9
|
+
import { SelectField } from "../../../../shared/components/molecules/selectField/SelectField";
|
|
10
|
+
import { style } from "./ItemActions.style";
|
|
11
|
+
const ItemActions = ({ sizes, size, onKeep, onReplace, onReturn, onLayout }) => {
|
|
12
|
+
const sizeSelectorLabelText = useI18nMessage({ id: I18nMessages.ITEM_SIZES_LABEL });
|
|
13
|
+
const keepButtonText = useI18nMessage({ id: I18nMessages.ITEM_KEEP_BUTTON });
|
|
14
|
+
const returnButtonText = useI18nMessage({ id: I18nMessages.ITEM_RETURN_BUTTON });
|
|
15
|
+
const sizeSelectorOptions = useMemo(() => sizes.map((size) => ({ label: size.lookiero, value: size.id })), [sizes]);
|
|
16
|
+
const disabledSizeSelector = useMemo(() => sizeSelectorOptions.length === 1 && sizeSelectorOptions[0]?.value === size.id, [sizeSelectorOptions, size.id]);
|
|
17
|
+
return (React.createElement(Sticky, { onLayout: onLayout },
|
|
18
|
+
React.createElement(Body, { style: { column: style.container } },
|
|
19
|
+
React.createElement(Button, { onPress: onKeep }, keepButtonText),
|
|
20
|
+
React.createElement(View, { style: style.row },
|
|
21
|
+
!size.unique && (React.createElement(SelectField, { disabled: disabledSizeSelector, options: sizeSelectorOptions, placeholder: sizeSelectorLabelText || "", style: { selectField: style.sizeSelector }, testID: "size-selector", value: size.id, onChange: onReplace })),
|
|
22
|
+
React.createElement(View, { style: style.returnButtonContainer },
|
|
23
|
+
React.createElement(Button, { variant: BUTTON_VARIANT.SECONDARY, onPress: onReturn }, returnButtonText))))));
|
|
24
|
+
};
|
|
25
|
+
export { ItemActions };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { StyleSheet } from "react-native";
|
|
2
2
|
import { theme } from "../../../../theme/theme";
|
|
3
|
-
const { spaceL } = theme();
|
|
3
|
+
const { spaceL, spaceXL } = theme();
|
|
4
4
|
const style = StyleSheet.create({
|
|
5
5
|
container: {
|
|
6
|
-
|
|
6
|
+
paddingHorizontal: spaceXL,
|
|
7
7
|
},
|
|
8
8
|
returnButtonContainer: {
|
|
9
9
|
flex: 1,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CancelableQueryViewArgs, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
|
|
2
|
+
import { ReturnQuestionProjection } from "./returnQuestion";
|
|
3
|
+
declare const LIST_RETURN_QUESTIONS_BY_CHECKOUT_ITEM_ID = "list_return_questions_by_checkout_item_id";
|
|
4
|
+
interface ListReturnQuestionsByCheckoutItemIdPayload {
|
|
5
|
+
readonly checkoutItemId: string;
|
|
6
|
+
}
|
|
7
|
+
interface ListReturnQuestionsByCheckoutItemId extends Query<typeof LIST_RETURN_QUESTIONS_BY_CHECKOUT_ITEM_ID>, ListReturnQuestionsByCheckoutItemIdPayload {
|
|
8
|
+
}
|
|
9
|
+
interface ListReturnQuestionsByCheckoutItemIdFunction {
|
|
10
|
+
(payload: ListReturnQuestionsByCheckoutItemIdPayload): ListReturnQuestionsByCheckoutItemId;
|
|
11
|
+
}
|
|
12
|
+
declare const listReturnQuestionsByCheckoutItemId: ListReturnQuestionsByCheckoutItemIdFunction;
|
|
13
|
+
declare type ListReturnQuestionsByCheckoutItemIdResult = ReturnQuestionProjection[] | undefined;
|
|
14
|
+
interface ReturnQuestionsByCheckoutItemIdViewArgs extends CancelableQueryViewArgs {
|
|
15
|
+
readonly checkoutItemId: string;
|
|
16
|
+
}
|
|
17
|
+
interface ReturnQuestionsByCheckoutItemIdView {
|
|
18
|
+
(args: ReturnQuestionsByCheckoutItemIdViewArgs): Promise<ListReturnQuestionsByCheckoutItemIdResult>;
|
|
19
|
+
}
|
|
20
|
+
interface ListReturnQuestionsByCheckoutItemIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
|
|
21
|
+
readonly view: ReturnQuestionsByCheckoutItemIdView;
|
|
22
|
+
}
|
|
23
|
+
declare const listReturnQuestionsByCheckoutItemIdHandler: QueryHandlerFunction<ListReturnQuestionsByCheckoutItemId, ListReturnQuestionsByCheckoutItemIdResult, ListReturnQuestionsByCheckoutItemIdHandlerFunctionArgs>;
|
|
24
|
+
export type { ListReturnQuestionsByCheckoutItemId, ReturnQuestionsByCheckoutItemIdView, ListReturnQuestionsByCheckoutItemIdResult, };
|
|
25
|
+
export { LIST_RETURN_QUESTIONS_BY_CHECKOUT_ITEM_ID, listReturnQuestionsByCheckoutItemId, listReturnQuestionsByCheckoutItemIdHandler, };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { query, } from "@lookiero/messaging";
|
|
2
|
+
const LIST_RETURN_QUESTIONS_BY_CHECKOUT_ITEM_ID = "list_return_questions_by_checkout_item_id";
|
|
3
|
+
const listReturnQuestionsByCheckoutItemId = (payload) => ({
|
|
4
|
+
...query({ name: LIST_RETURN_QUESTIONS_BY_CHECKOUT_ITEM_ID }),
|
|
5
|
+
...payload,
|
|
6
|
+
});
|
|
7
|
+
const listReturnQuestionsByCheckoutItemIdHandler = ({ view, signal }) => async ({ checkoutItemId }) => view({ checkoutItemId, signal });
|
|
8
|
+
export { LIST_RETURN_QUESTIONS_BY_CHECKOUT_ITEM_ID, listReturnQuestionsByCheckoutItemId, listReturnQuestionsByCheckoutItemIdHandler, };
|
|
@@ -7,11 +7,11 @@ declare enum ReturnQuestionType {
|
|
|
7
7
|
OPTION = "OPTION"
|
|
8
8
|
}
|
|
9
9
|
interface ReturnQuestionProjection {
|
|
10
|
-
id: string;
|
|
11
|
-
name: string;
|
|
12
|
-
placeholder?: string;
|
|
13
|
-
type: ReturnQuestionType;
|
|
14
|
-
children?: ReturnQuestionProjection[];
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly placeholder?: string;
|
|
13
|
+
readonly type: ReturnQuestionType;
|
|
14
|
+
readonly children?: ReturnQuestionProjection[];
|
|
15
15
|
}
|
|
16
16
|
export { ReturnQuestionType };
|
|
17
17
|
export type { ReturnQuestionProjection };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lookiero/checkout",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.32-LK-25049",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"uuid": "^9.0.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@lookiero/aurora-next": "
|
|
40
|
+
"@lookiero/aurora-next": "3.0.184-LK-25049-2022.10.24.094214",
|
|
41
41
|
"react": "^18.0.0",
|
|
42
42
|
"react-dom": "^18.0.0",
|
|
43
43
|
"react-native": "^0.70.1",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@expo/webpack-config": "^0.17.2",
|
|
49
49
|
"@lookiero/aurora-fonts": "^1.0.6",
|
|
50
50
|
"@lookiero/aurora-iconfont": "^2.0.37",
|
|
51
|
-
"@lookiero/aurora-next": "
|
|
51
|
+
"@lookiero/aurora-next": "3.0.184-LK-25049-2022.10.24.094214",
|
|
52
52
|
"@testing-library/react": "^13.4.0",
|
|
53
53
|
"@testing-library/react-hooks": "^8.0.1",
|
|
54
54
|
"@testing-library/react-native": "^11.0.0",
|
package/dist/infrastructure/ui/views/item/components/productVariantActions/ProductVariantActions.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
|
|
2
|
-
import { BUTTON_VARIANT } from "@lookiero/aurora-next/build/components/atoms/Button/Button.definition";
|
|
3
|
-
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
4
|
-
import React, { useMemo } from "react";
|
|
5
|
-
import { View } from "react-native";
|
|
6
|
-
import { I18nMessages } from "../../../../i18n/i18n";
|
|
7
|
-
import { SelectField } from "../../../../shared/components/molecules/selectField/SelectField";
|
|
8
|
-
import { style } from "./ProductVariantActions.style";
|
|
9
|
-
const ProductVariantActions = ({ sizes, size, onKeep, onReplace, onReturn }) => {
|
|
10
|
-
const sizeSelectorLabelText = useI18nMessage({ id: I18nMessages.ITEM_SIZES_LABEL });
|
|
11
|
-
const keepButtonText = useI18nMessage({ id: I18nMessages.ITEM_KEEP_BUTTON });
|
|
12
|
-
const returnButtonText = useI18nMessage({ id: I18nMessages.ITEM_RETURN_BUTTON });
|
|
13
|
-
const sizeSelectorOptions = useMemo(() => sizes.map((size) => ({ label: size.lookiero, value: size.id })), [sizes]);
|
|
14
|
-
const disabledSizeSelector = useMemo(() => sizeSelectorOptions.length === 1 && sizeSelectorOptions[0]?.value === size.id, [sizeSelectorOptions, size.id]);
|
|
15
|
-
return (React.createElement(View, { style: style.container },
|
|
16
|
-
React.createElement(Button, { onPress: onKeep }, keepButtonText),
|
|
17
|
-
React.createElement(View, { style: style.row },
|
|
18
|
-
!size.unique && (React.createElement(SelectField, { disabled: disabledSizeSelector, options: sizeSelectorOptions, placeholder: sizeSelectorLabelText || "", style: { selectField: style.sizeSelector }, testID: "size-selector", value: size.id, onChange: onReplace })),
|
|
19
|
-
React.createElement(View, { style: style.returnButtonContainer },
|
|
20
|
-
React.createElement(Button, { variant: BUTTON_VARIANT.SECONDARY, onPress: onReturn }, returnButtonText)))));
|
|
21
|
-
};
|
|
22
|
-
export { ProductVariantActions };
|