@lookiero/checkout 0.2.17 → 0.2.19
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/domain/checkoutItem/model/checkoutItem.d.ts +2 -0
- package/dist/domain/checkoutItem/model/currency.d.ts +5 -0
- package/dist/domain/checkoutItem/model/currency.js +6 -0
- package/dist/domain/checkoutItem/model/price.d.ts +10 -0
- package/dist/domain/checkoutItem/model/price.js +1 -0
- package/dist/infrastructure/delivery/mock/dataSourceCheckoutItems.js +3 -0
- package/dist/infrastructure/domain/checkoutItem/model/httpCheckoutItems.js +1 -0
- package/dist/infrastructure/projection/checkout/checkout.js +11 -10
- package/dist/infrastructure/projection/checkoutItem/checkoutItem.d.ts +10 -9
- package/dist/infrastructure/projection/checkoutItem/checkoutItem.js +11 -10
- package/dist/infrastructure/projection/checkoutItem/checkoutItem.mock.js +5 -4
- package/dist/infrastructure/projection/returnQuestion/returnQuestions.mock.d.ts +3 -0
- package/dist/infrastructure/projection/returnQuestion/returnQuestions.mock.js +348 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestion.d.ts +8 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestion.js +11 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestions.d.ts +7 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestions.js +4 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback.d.ts +29 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback.js +27 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/behaviors/useReturnQuestionItem.d.ts +18 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/behaviors/useReturnQuestionItem.js +12 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/ReturnQuestionItem.d.ts +15 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/ReturnQuestionItem.js +1 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.d.ts +3 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.js +12 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.style.d.ts +8 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.style.js +11 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.d.ts +3 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.js +30 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.style.d.ts +20 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.style.js +23 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/HostStackReturnQuestionItem.d.ts +3 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/HostStackReturnQuestionItem.js +33 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/HostStackReturnQuestionItem.style.d.ts +17 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/HostStackReturnQuestionItem.style.js +20 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.d.ts +3 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.js +13 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.style.d.ts +9 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.style.js +12 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.d.ts +3 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.js +12 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.d.ts +13 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.js +31 -0
- package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.d.ts +6 -0
- package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.js +6 -0
- package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.style.d.ts +10 -0
- package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.style.js +11 -0
- package/dist/infrastructure/ui/i18n/i18n.d.ts +2 -1
- package/dist/infrastructure/ui/i18n/i18n.js +2 -1
- package/dist/infrastructure/ui/views/intro/Intro.js +3 -2
- package/dist/infrastructure/ui/views/intro/Intro.style.d.ts +0 -3
- package/dist/infrastructure/ui/views/intro/Intro.style.js +0 -3
- package/dist/infrastructure/ui/views/item/Item.js +22 -7
- package/dist/infrastructure/ui/views/item/Item.style.d.ts +0 -7
- package/dist/infrastructure/ui/views/item/Item.style.js +0 -7
- package/dist/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.d.ts +11 -0
- package/dist/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.js +29 -0
- package/dist/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts +19 -0
- package/dist/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.js +22 -0
- package/dist/infrastructure/ui/views/summary/Summary.js +4 -2
- package/dist/projection/checkoutItem/checkoutItem.d.ts +4 -5
- package/dist/projection/checkoutItem/checkoutItem.js +1 -5
- package/dist/projection/feedback/feedback.d.ts +3 -0
- package/dist/projection/feedback/feedback.js +1 -0
- package/dist/projection/returnQuestion/returnQuestion.d.ts +16 -0
- package/dist/projection/returnQuestion/returnQuestion.js +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FC, ReactNode } from "react";
|
|
2
|
+
import { ReturnQuestionType } from "../../../../../../projection/returnQuestion/returnQuestion";
|
|
3
|
+
import { ReturnQuestionItem } from "../components/ReturnQuestionItem";
|
|
4
|
+
declare type ReturnQuestionItems = Record<ReturnQuestionType, ReturnQuestionItem>;
|
|
5
|
+
interface ReturnQuestionItemContextProviderProps {
|
|
6
|
+
readonly returnQuestionItems: ReturnQuestionItems;
|
|
7
|
+
readonly children: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
declare const ReturnQuestionItemProvider: FC<ReturnQuestionItemContextProviderProps>;
|
|
10
|
+
interface UseReturnQuestionItemFunctionArgs {
|
|
11
|
+
readonly type: ReturnQuestionType;
|
|
12
|
+
}
|
|
13
|
+
interface UseReturnQuestionItemFunction {
|
|
14
|
+
(args: UseReturnQuestionItemFunctionArgs): ReturnQuestionItem;
|
|
15
|
+
}
|
|
16
|
+
declare const useReturnQuestionItem: UseReturnQuestionItemFunction;
|
|
17
|
+
export type { ReturnQuestionItems };
|
|
18
|
+
export { useReturnQuestionItem, ReturnQuestionItemProvider };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { createContext, useContext, useMemo } from "react";
|
|
2
|
+
import invariant from "tiny-invariant";
|
|
3
|
+
const ReturnQuestionItemContext = createContext({});
|
|
4
|
+
const ReturnQuestionItemProvider = ({ returnQuestionItems, children }) => (React.createElement(ReturnQuestionItemContext.Provider, { value: returnQuestionItems }, children));
|
|
5
|
+
const useReturnQuestionItem = ({ type }) => {
|
|
6
|
+
const items = useContext(ReturnQuestionItemContext);
|
|
7
|
+
const item = useMemo(() => items[type], [items, type]);
|
|
8
|
+
invariant(items, "Your are trying to use the useReturnQuestionItem hook without wrapping your app with the <ReturnQuestionItemProvider>.");
|
|
9
|
+
invariant(item, `The provided ReturnQuestionType (${type}) is NOT SUPPORTED`);
|
|
10
|
+
return item;
|
|
11
|
+
};
|
|
12
|
+
export { useReturnQuestionItem, ReturnQuestionItemProvider };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { ReturnQuestionProjection } from "../../../../../../projection/returnQuestion/returnQuestion";
|
|
3
|
+
interface OnChangeReturnQuestionItemFunctionArgs {
|
|
4
|
+
readonly feedback: string | undefined;
|
|
5
|
+
}
|
|
6
|
+
interface OnChangeReturnQuestionItemFunction {
|
|
7
|
+
(args: OnChangeReturnQuestionItemFunctionArgs): void;
|
|
8
|
+
}
|
|
9
|
+
interface ReturnQuestionItemProps {
|
|
10
|
+
readonly returnQuestion: ReturnQuestionProjection;
|
|
11
|
+
readonly onChange: OnChangeReturnQuestionItemFunction;
|
|
12
|
+
readonly children?: JSX.Element;
|
|
13
|
+
}
|
|
14
|
+
declare type ReturnQuestionItem = FC<ReturnQuestionItemProps>;
|
|
15
|
+
export type { ReturnQuestionItem, ReturnQuestionItemProps, OnChangeReturnQuestionItemFunction };
|
package/dist/infrastructure/ui/components/organisms/returnQuestions/components/ReturnQuestionItem.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
|
|
2
|
+
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { RETURN_QUESTIONS_PREFIX } from "../../../../../i18n/i18n";
|
|
5
|
+
import { style } from "./HostDefaultReturnQuestionItem.style";
|
|
6
|
+
const HostDefaultReturnQuestionItem = ({ returnQuestion, children }) => {
|
|
7
|
+
const titleText = useI18nMessage({ id: returnQuestion.name, prefix: RETURN_QUESTIONS_PREFIX });
|
|
8
|
+
return (React.createElement(React.Fragment, null,
|
|
9
|
+
React.createElement(Text, { level: 2, style: style.title }, titleText),
|
|
10
|
+
children));
|
|
11
|
+
};
|
|
12
|
+
export { HostDefaultReturnQuestionItem };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { theme } from "../../../../../theme/theme";
|
|
3
|
+
const { spaceL, spaceXXXL } = theme();
|
|
4
|
+
const style = StyleSheet.create({
|
|
5
|
+
title: {
|
|
6
|
+
marginTop: spaceXXXL,
|
|
7
|
+
marginBottom: spaceL,
|
|
8
|
+
textAlign: "center",
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
export { style };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ButtonIcon } from "@lookiero/aurora-next/build/components/atoms/ButtonIcon/ButtonIcon";
|
|
2
|
+
import { InputField } from "@lookiero/aurora-next/build/components/atoms/InputField/InputField";
|
|
3
|
+
import { Modal } from "@lookiero/aurora-next/build/components/molecules/Modal/Modal";
|
|
4
|
+
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
5
|
+
import React, { useCallback, useState } from "react";
|
|
6
|
+
import { useIntl } from "react-intl";
|
|
7
|
+
import { TouchableHighlight, View } from "react-native";
|
|
8
|
+
import { RETURN_QUESTIONS_PREFIX } from "../../../../../i18n/i18n";
|
|
9
|
+
import { useReturnQuestionFeedback } from "../../behaviors/useReturnQuestionFeedback";
|
|
10
|
+
import { feedbackForReturnQuestion } from "../../util/returnQuestionFeedback";
|
|
11
|
+
import { style, containerUnderlayColor } from "./HostSelectReturnQuestionItem.style";
|
|
12
|
+
const HostSelectReturnQuestionItem = ({ returnQuestion, children }) => {
|
|
13
|
+
const placeholderText = useI18nMessage({ id: returnQuestion.placeholder, prefix: RETURN_QUESTIONS_PREFIX });
|
|
14
|
+
const [modalVisible, setModalVisible] = useState(false);
|
|
15
|
+
const handleOnPress = useCallback(() => setModalVisible(true), []);
|
|
16
|
+
const handleOnModalClose = useCallback(() => setModalVisible(false), []);
|
|
17
|
+
const feedback = useReturnQuestionFeedback();
|
|
18
|
+
const intl = useIntl();
|
|
19
|
+
const translate = useCallback((returnQuestionName) => intl.formatMessage({ id: `${RETURN_QUESTIONS_PREFIX}${returnQuestionName}`, defaultMessage: returnQuestionName }), [intl]);
|
|
20
|
+
const inputValue = feedbackForReturnQuestion({ feedback, returnQuestion, translate }).join(" / ");
|
|
21
|
+
return (React.createElement(React.Fragment, null,
|
|
22
|
+
React.createElement(TouchableHighlight, { style: style.container, onPress: handleOnPress, underlayColor: containerUnderlayColor },
|
|
23
|
+
React.createElement(View, { pointerEvents: "none" },
|
|
24
|
+
React.createElement(InputField, { label: placeholderText, value: inputValue, name: returnQuestion.name, icon: "arrow-down", type: "text", testID: returnQuestion.name }))),
|
|
25
|
+
React.createElement(Modal, { style: style.modal, size: "1/2", isVisible: modalVisible },
|
|
26
|
+
React.createElement(View, { style: style.modalContent },
|
|
27
|
+
React.createElement(ButtonIcon, { name: "close", style: style.backButton, onPress: handleOnModalClose }),
|
|
28
|
+
children))));
|
|
29
|
+
};
|
|
30
|
+
export { HostSelectReturnQuestionItem };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const containerUnderlayColor: string;
|
|
2
|
+
declare const style: {
|
|
3
|
+
container: {
|
|
4
|
+
marginVertical: number;
|
|
5
|
+
};
|
|
6
|
+
modal: {
|
|
7
|
+
zIndex: number;
|
|
8
|
+
};
|
|
9
|
+
modalContent: {
|
|
10
|
+
marginTop: number;
|
|
11
|
+
paddingBottom: number;
|
|
12
|
+
};
|
|
13
|
+
backButton: {
|
|
14
|
+
top: number;
|
|
15
|
+
right: number;
|
|
16
|
+
alignSelf: "flex-end";
|
|
17
|
+
zIndex: number;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export { style, containerUnderlayColor };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { theme } from "../../../../../theme/theme";
|
|
3
|
+
const { spaceM, spaceXL, colorGrayscaleS } = theme();
|
|
4
|
+
const containerUnderlayColor = colorGrayscaleS;
|
|
5
|
+
const style = StyleSheet.create({
|
|
6
|
+
container: {
|
|
7
|
+
marginVertical: spaceM,
|
|
8
|
+
},
|
|
9
|
+
modal: {
|
|
10
|
+
zIndex: 10,
|
|
11
|
+
},
|
|
12
|
+
modalContent: {
|
|
13
|
+
marginTop: -spaceXL,
|
|
14
|
+
paddingBottom: spaceXL,
|
|
15
|
+
},
|
|
16
|
+
backButton: {
|
|
17
|
+
top: 0,
|
|
18
|
+
right: -spaceM,
|
|
19
|
+
alignSelf: "flex-end",
|
|
20
|
+
zIndex: 20,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
export { style, containerUnderlayColor };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ButtonIcon } from "@lookiero/aurora-next/build/components/atoms/ButtonIcon/ButtonIcon";
|
|
2
|
+
import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
|
|
3
|
+
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
4
|
+
import React, { useCallback } from "react";
|
|
5
|
+
import { RETURN_QUESTIONS_PREFIX } from "../../../../../i18n/i18n";
|
|
6
|
+
import ReturnQuestion from "../../ReturnQuestion";
|
|
7
|
+
import { useReturnQuestionFeedbackForId } from "../../behaviors/useReturnQuestionFeedback";
|
|
8
|
+
import { style } from "./HostStackReturnQuestionItem.style";
|
|
9
|
+
const HostStackReturnQuestionItem = ({ returnQuestion, children }) => {
|
|
10
|
+
const titleText = useI18nMessage({ id: returnQuestion.name, prefix: RETURN_QUESTIONS_PREFIX });
|
|
11
|
+
const { feedback, onChange } = useReturnQuestionFeedbackForId({ id: returnQuestion.id });
|
|
12
|
+
const feedbackReturnQuestion = feedback
|
|
13
|
+
? returnQuestion.children?.find((returnQuestion) => returnQuestion.id === feedback)
|
|
14
|
+
: undefined;
|
|
15
|
+
const feedbackText = useI18nMessage({ id: feedbackReturnQuestion?.name, prefix: RETURN_QUESTIONS_PREFIX });
|
|
16
|
+
const handleOnBackButtonPress = useCallback(() => {
|
|
17
|
+
onChange({ returnQuestionId: returnQuestion.id, returnQuestionFeedback: undefined });
|
|
18
|
+
}, [onChange, returnQuestion.id]);
|
|
19
|
+
const questionTitle = titleText && (React.createElement(Text, { level: 2, style: style.title }, titleText));
|
|
20
|
+
if (feedbackReturnQuestion) {
|
|
21
|
+
return (React.createElement(React.Fragment, null,
|
|
22
|
+
React.createElement(ButtonIcon, { name: "arrow-left", style: style.backButton, onPress: handleOnBackButtonPress }),
|
|
23
|
+
questionTitle,
|
|
24
|
+
React.createElement(Text, { level: 3, style: style.feedback }, feedbackText),
|
|
25
|
+
feedbackReturnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, returnQuestion: childReturnQuestion, returnQuestionParentId: feedbackReturnQuestion.id })))));
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return (React.createElement(React.Fragment, null,
|
|
29
|
+
questionTitle,
|
|
30
|
+
children));
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export { HostStackReturnQuestionItem };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare const style: {
|
|
2
|
+
backButton: {
|
|
3
|
+
position: "absolute";
|
|
4
|
+
top: number;
|
|
5
|
+
left: number;
|
|
6
|
+
zIndex: number;
|
|
7
|
+
};
|
|
8
|
+
title: {
|
|
9
|
+
marginVertical: number;
|
|
10
|
+
textAlign: "center";
|
|
11
|
+
};
|
|
12
|
+
feedback: {
|
|
13
|
+
color: string;
|
|
14
|
+
marginVertical: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export { style };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { theme } from "../../../../../theme/theme";
|
|
3
|
+
const { colorGrayscaleL, spaceM, spaceL } = theme();
|
|
4
|
+
const style = StyleSheet.create({
|
|
5
|
+
backButton: {
|
|
6
|
+
position: "absolute",
|
|
7
|
+
top: 0,
|
|
8
|
+
left: -spaceM,
|
|
9
|
+
zIndex: 20,
|
|
10
|
+
},
|
|
11
|
+
title: {
|
|
12
|
+
marginVertical: spaceL,
|
|
13
|
+
textAlign: "center",
|
|
14
|
+
},
|
|
15
|
+
feedback: {
|
|
16
|
+
color: colorGrayscaleL,
|
|
17
|
+
marginVertical: spaceM,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
export { style };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
|
|
2
|
+
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
3
|
+
import React, { useCallback } from "react";
|
|
4
|
+
import { TouchableHighlight } from "react-native";
|
|
5
|
+
import { RETURN_QUESTIONS_PREFIX } from "../../../../../i18n/i18n";
|
|
6
|
+
import { containerUnderlayColor, style } from "./OptionReturnQuestionItem.style";
|
|
7
|
+
const OptionReturnQuestionItem = ({ returnQuestion, onChange }) => {
|
|
8
|
+
const optionText = useI18nMessage({ id: returnQuestion.name, prefix: RETURN_QUESTIONS_PREFIX });
|
|
9
|
+
const handleOnPress = useCallback(() => onChange({ feedback: returnQuestion.id }), [onChange, returnQuestion.id]);
|
|
10
|
+
return (React.createElement(TouchableHighlight, { style: style.container, onPress: handleOnPress, underlayColor: containerUnderlayColor },
|
|
11
|
+
React.createElement(Text, { level: 3 }, optionText)));
|
|
12
|
+
};
|
|
13
|
+
export { OptionReturnQuestionItem };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { theme } from "../../../../../theme/theme";
|
|
3
|
+
const { spaceM, colorGrayscaleS } = theme();
|
|
4
|
+
const containerUnderlayColor = colorGrayscaleS;
|
|
5
|
+
const style = StyleSheet.create({
|
|
6
|
+
container: {
|
|
7
|
+
paddingVertical: spaceM,
|
|
8
|
+
borderBottomWidth: 1,
|
|
9
|
+
borderBottomColor: colorGrayscaleS,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
export { style, containerUnderlayColor };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { InputField } from "@lookiero/aurora-next/build/components/atoms/InputField/InputField";
|
|
2
|
+
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
3
|
+
import React, { useCallback } from "react";
|
|
4
|
+
import { RETURN_QUESTIONS_PREFIX } from "../../../../../i18n/i18n";
|
|
5
|
+
import { useReturnQuestionFeedbackForId } from "../../behaviors/useReturnQuestionFeedback";
|
|
6
|
+
const TextareaReturnQuestionItem = ({ returnQuestion, onChange }) => {
|
|
7
|
+
const placeholderText = useI18nMessage({ id: returnQuestion.placeholder, prefix: RETURN_QUESTIONS_PREFIX });
|
|
8
|
+
const { feedback } = useReturnQuestionFeedbackForId({ id: returnQuestion.id });
|
|
9
|
+
const handleOnChange = useCallback((value) => onChange({ feedback: value }), [onChange]);
|
|
10
|
+
return (React.createElement(InputField, { name: returnQuestion.name, type: "text", multiLine: true, label: placeholderText, placeholder: placeholderText, value: feedback, onChange: handleOnChange }));
|
|
11
|
+
};
|
|
12
|
+
export { TextareaReturnQuestionItem };
|
package/dist/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FeedbackProjection } from "../../../../../../projection/feedback/feedback";
|
|
2
|
+
import { ReturnQuestionProjection } from "../../../../../../projection/returnQuestion/returnQuestion";
|
|
3
|
+
interface RecursiveFeedbackForReturnQuestionFunctionArgs {
|
|
4
|
+
readonly feedback: FeedbackProjection | undefined;
|
|
5
|
+
readonly returnQuestion: ReturnQuestionProjection;
|
|
6
|
+
readonly translate: (i18nString: string) => string;
|
|
7
|
+
readonly acc?: string[];
|
|
8
|
+
}
|
|
9
|
+
interface RecursiveFeedbackForReturnQuestionFunction {
|
|
10
|
+
(args: RecursiveFeedbackForReturnQuestionFunctionArgs): string[];
|
|
11
|
+
}
|
|
12
|
+
declare const feedbackForReturnQuestion: RecursiveFeedbackForReturnQuestionFunction;
|
|
13
|
+
export { feedbackForReturnQuestion };
|
package/dist/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { validate } from "uuid";
|
|
2
|
+
const isUuid = (value) => validate(value);
|
|
3
|
+
const feedbackForReturnQuestion = ({ feedback, returnQuestion, translate, acc = [], }) => {
|
|
4
|
+
if (!feedback) {
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
const returnQuestionId = Object.keys(feedback).find((id) => id === returnQuestion.id);
|
|
8
|
+
if (returnQuestionId) {
|
|
9
|
+
const returnQuestionFeedback = feedback[returnQuestionId];
|
|
10
|
+
if (returnQuestionFeedback !== undefined) {
|
|
11
|
+
if (isUuid(returnQuestionFeedback)) {
|
|
12
|
+
const feebackReturnQuestionChild = returnQuestion.children?.find((childReturnQuestion) => childReturnQuestion.id === returnQuestionFeedback);
|
|
13
|
+
if (feebackReturnQuestionChild) {
|
|
14
|
+
return [
|
|
15
|
+
...acc,
|
|
16
|
+
translate(feebackReturnQuestionChild?.name),
|
|
17
|
+
...feedbackForReturnQuestion({ feedback, returnQuestion: feebackReturnQuestionChild, translate, acc }),
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
return acc;
|
|
21
|
+
}
|
|
22
|
+
return [...acc, returnQuestionFeedback];
|
|
23
|
+
}
|
|
24
|
+
return acc;
|
|
25
|
+
}
|
|
26
|
+
return (returnQuestion.children?.reduce((acc, childReturnQuestion) => [
|
|
27
|
+
...acc,
|
|
28
|
+
...feedbackForReturnQuestion({ feedback, returnQuestion: childReturnQuestion, translate, acc }),
|
|
29
|
+
], []) || []);
|
|
30
|
+
};
|
|
31
|
+
export { feedbackForReturnQuestion };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SafeAreaView, ScrollView } from "react-native";
|
|
3
|
+
import { style } from "./SafeAreaScrollView.style";
|
|
4
|
+
const SafeAreaScrollView = ({ children }) => (React.createElement(SafeAreaView, { style: style.container },
|
|
5
|
+
React.createElement(ScrollView, { contentContainerStyle: style.scrollContainer, showsVerticalScrollIndicator: false }, children)));
|
|
6
|
+
export { SafeAreaScrollView };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
declare const COLOR_I18N_PREFIX = "color.";
|
|
2
|
+
declare const RETURN_QUESTIONS_PREFIX = "return_questions.";
|
|
2
3
|
declare enum I18nMessages {
|
|
3
4
|
INTRO_TITLE = "intro.title",
|
|
4
5
|
INTRO_SUBTITLE = "intro.subtitle",
|
|
@@ -28,4 +29,4 @@ declare enum I18nMessages {
|
|
|
28
29
|
GET_OUT_OF_CHECKOUT_MODAL_DISMISS_BUTTON = "get_out_of_checkout_modal.dismiss_button",
|
|
29
30
|
GET_OUT_OF_CHECKOUT_MODAL_CONFIRM_BUTTON = "get_out_of_checkout_modal.confirm_button"
|
|
30
31
|
}
|
|
31
|
-
export { I18nMessages, COLOR_I18N_PREFIX };
|
|
32
|
+
export { I18nMessages, COLOR_I18N_PREFIX, RETURN_QUESTIONS_PREFIX };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const COLOR_I18N_PREFIX = "color.";
|
|
2
|
+
const RETURN_QUESTIONS_PREFIX = "return_questions.";
|
|
2
3
|
var I18nMessages;
|
|
3
4
|
(function (I18nMessages) {
|
|
4
5
|
I18nMessages["INTRO_TITLE"] = "intro.title";
|
|
@@ -29,4 +30,4 @@ var I18nMessages;
|
|
|
29
30
|
I18nMessages["GET_OUT_OF_CHECKOUT_MODAL_DISMISS_BUTTON"] = "get_out_of_checkout_modal.dismiss_button";
|
|
30
31
|
I18nMessages["GET_OUT_OF_CHECKOUT_MODAL_CONFIRM_BUTTON"] = "get_out_of_checkout_modal.confirm_button";
|
|
31
32
|
})(I18nMessages || (I18nMessages = {}));
|
|
32
|
-
export { I18nMessages, COLOR_I18N_PREFIX };
|
|
33
|
+
export { I18nMessages, COLOR_I18N_PREFIX, RETURN_QUESTIONS_PREFIX };
|
|
@@ -4,11 +4,12 @@ import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Tex
|
|
|
4
4
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
5
5
|
import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
|
|
6
6
|
import React, { useCallback } from "react";
|
|
7
|
-
import {
|
|
7
|
+
import { View } from "react-native";
|
|
8
8
|
import { useSetCheckoutIntroShown } from "../../../domain/uiSetting/react/useSetCheckoutIntroShown";
|
|
9
9
|
import { useViewFiveItemsDiscountByCustomerId } from "../../../projection/checkout/react/useViewFiveItemsDiscountByCustomerId";
|
|
10
10
|
import { Spinner } from "../../components/atoms/spinner/Spinner";
|
|
11
11
|
import { Body } from "../../components/layouts/body/Body";
|
|
12
|
+
import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
|
|
12
13
|
import { I18nMessages } from "../../i18n/i18n";
|
|
13
14
|
import { style } from "./Intro.style";
|
|
14
15
|
const Bullet = ({ text }) => (React.createElement(View, { style: style.bullet },
|
|
@@ -29,7 +30,7 @@ const Intro = ({ customerId }) => {
|
|
|
29
30
|
const handleOnPress = useCallback(() => setCheckoutIntroShown(), [setCheckoutIntroShown]);
|
|
30
31
|
if (fiveItemsDiscountState === QueryStatus.LOADING)
|
|
31
32
|
return React.createElement(Spinner, null);
|
|
32
|
-
return (React.createElement(
|
|
33
|
+
return (React.createElement(SafeAreaScrollView, null,
|
|
33
34
|
React.createElement(Body, null,
|
|
34
35
|
React.createElement(View, { style: style.container },
|
|
35
36
|
React.createElement(View, { style: style.content },
|
|
@@ -2,9 +2,6 @@ import { StyleSheet } from "react-native";
|
|
|
2
2
|
import { theme } from "../../theme/theme";
|
|
3
3
|
const { borderSize, colorAccent, spaceXS, spaceS, spaceM, spaceL, spaceXL } = theme();
|
|
4
4
|
const style = StyleSheet.create({
|
|
5
|
-
safeAreaContainer: {
|
|
6
|
-
flex: 1,
|
|
7
|
-
},
|
|
8
5
|
container: {
|
|
9
6
|
flex: 1,
|
|
10
7
|
justifyContent: "space-between",
|
|
@@ -1,26 +1,41 @@
|
|
|
1
|
+
import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
|
|
1
2
|
import { QueryStatus } from "@lookiero/messaging-react";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import {
|
|
3
|
+
import React, { useCallback, useState } from "react";
|
|
4
|
+
import { View } from "react-native";
|
|
4
5
|
import { useParams } from "react-router-native";
|
|
5
6
|
import "../../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
6
7
|
import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
8
|
+
import { returnQuestions as returnQuestionsMock } from "../../../projection/returnQuestion/returnQuestions.mock";
|
|
7
9
|
import { Spinner } from "../../components/atoms/spinner/Spinner";
|
|
8
10
|
import { Body } from "../../components/layouts/body/Body";
|
|
11
|
+
import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
|
|
9
12
|
import { style } from "./Item.style";
|
|
10
13
|
import { ProductVariantDescription } from "./components/productVariantDescription/ProductVariantDescription";
|
|
11
14
|
import { ProductVariantSlider } from "./components/productVariantSlider/ProductVariantSlider";
|
|
15
|
+
import { ReturnQuestionsForm } from "./components/returnQuestionsForm/ReturnQuestionsForm";
|
|
16
|
+
// const feedback: FeedbackProjection = {
|
|
17
|
+
// ["bb02cedd-09a7-43ed-8e78-ee5b3ad56914"]: "7f336540-4453-4280-9b5f-3bfd4e03ff25",
|
|
18
|
+
// };
|
|
19
|
+
const feedback = {};
|
|
12
20
|
const Item = ({ customerId }) => {
|
|
13
21
|
const { id } = useParams();
|
|
14
22
|
const [checkout, status] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
23
|
+
const checkoutItem = checkout?.items.find((checkoutItem) => checkoutItem.id === id);
|
|
24
|
+
const [returnQuestionsVisible, setReturnQuestionsVisible] = useState(true);
|
|
25
|
+
const handleOnShowReturnQuestions = useCallback(() => setReturnQuestionsVisible(true), []);
|
|
26
|
+
const handleOnHideReturnQuestions = useCallback(() => setReturnQuestionsVisible(false), []);
|
|
15
27
|
if (status === QueryStatus.LOADING)
|
|
16
28
|
return React.createElement(Spinner, null);
|
|
17
|
-
const
|
|
18
|
-
const { media, brand, name,
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
const { price } = checkoutItem;
|
|
30
|
+
const { media, brand, name, size, color } = checkoutItem.productVariant;
|
|
31
|
+
const returnQuestions = returnQuestionsMock;
|
|
32
|
+
return (React.createElement(React.Fragment, null,
|
|
33
|
+
React.createElement(SafeAreaScrollView, null,
|
|
21
34
|
React.createElement(Body, null,
|
|
22
35
|
React.createElement(View, { style: style.sliderContainer },
|
|
23
36
|
React.createElement(ProductVariantSlider, { producVariantMedia: media })),
|
|
24
|
-
React.createElement(ProductVariantDescription, { brand: brand, name: name, price: price, size: size, color: color })
|
|
37
|
+
React.createElement(ProductVariantDescription, { brand: brand, name: name, price: price, size: size, color: color }),
|
|
38
|
+
React.createElement(Button, { onPress: handleOnShowReturnQuestions }, "show return questions"))),
|
|
39
|
+
React.createElement(ReturnQuestionsForm, { feedback: feedback, returnQuestions: returnQuestions, visible: returnQuestionsVisible, onClose: handleOnHideReturnQuestions })));
|
|
25
40
|
};
|
|
26
41
|
export { Item };
|
|
@@ -2,13 +2,6 @@ import { StyleSheet } from "react-native";
|
|
|
2
2
|
import { theme } from "../../theme/theme";
|
|
3
3
|
const { spaceXL } = theme();
|
|
4
4
|
const style = StyleSheet.create({
|
|
5
|
-
container: {
|
|
6
|
-
flex: 1,
|
|
7
|
-
},
|
|
8
|
-
scrollContainer: {
|
|
9
|
-
flex: 1,
|
|
10
|
-
flexGrow: 1,
|
|
11
|
-
},
|
|
12
5
|
sliderContainer: {
|
|
13
6
|
flex: 1,
|
|
14
7
|
marginBottom: spaceXL,
|
package/dist/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { FeedbackProjection } from "../../../../../../projection/feedback/feedback";
|
|
3
|
+
import { ReturnQuestionProjection } from "../../../../../../projection/returnQuestion/returnQuestion";
|
|
4
|
+
interface ReturnQuestionsFormProps {
|
|
5
|
+
readonly visible: boolean;
|
|
6
|
+
readonly feedback: FeedbackProjection;
|
|
7
|
+
readonly returnQuestions: ReturnQuestionProjection[];
|
|
8
|
+
readonly onClose: () => void;
|
|
9
|
+
}
|
|
10
|
+
declare const ReturnQuestionsForm: FC<ReturnQuestionsFormProps>;
|
|
11
|
+
export { ReturnQuestionsForm };
|
package/dist/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ButtonIcon } from "@lookiero/aurora-next/build/components/atoms/ButtonIcon/ButtonIcon";
|
|
2
|
+
import { Modal } from "@lookiero/aurora-next/build/components/molecules/Modal/Modal";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { ScrollView, View } from "react-native";
|
|
5
|
+
import { ReturnQuestionType, } from "../../../../../../projection/returnQuestion/returnQuestion";
|
|
6
|
+
import { ReturnQuestions } from "../../../../components/organisms/returnQuestions/ReturnQuestions";
|
|
7
|
+
import { ReturnQuestionFeedbackProvider } from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
|
|
8
|
+
import { ReturnQuestionItemProvider, } from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionItem";
|
|
9
|
+
import { HostDefaultReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem";
|
|
10
|
+
import { HostSelectReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem";
|
|
11
|
+
import { HostStackReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostStackReturnQuestionItem/HostStackReturnQuestionItem";
|
|
12
|
+
import { OptionReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem";
|
|
13
|
+
import { TextareaReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem";
|
|
14
|
+
import { style } from "./ReturnQuestionsForm.style";
|
|
15
|
+
const returnQuestionItems = {
|
|
16
|
+
[ReturnQuestionType.HOST_DEFAULT]: HostDefaultReturnQuestionItem,
|
|
17
|
+
[ReturnQuestionType.HOST_SELECT]: HostSelectReturnQuestionItem,
|
|
18
|
+
[ReturnQuestionType.HOST_STACK]: HostStackReturnQuestionItem,
|
|
19
|
+
[ReturnQuestionType.TEXTAREA]: TextareaReturnQuestionItem,
|
|
20
|
+
[ReturnQuestionType.OPTION]: OptionReturnQuestionItem,
|
|
21
|
+
};
|
|
22
|
+
const ReturnQuestionsForm = ({ feedback, returnQuestions, onClose, visible }) => (React.createElement(ReturnQuestionFeedbackProvider, { feedback: feedback },
|
|
23
|
+
React.createElement(ReturnQuestionItemProvider, { returnQuestionItems: returnQuestionItems },
|
|
24
|
+
React.createElement(Modal, { style: style.modal, fullHeight: true, size: "1/2", isVisible: visible },
|
|
25
|
+
React.createElement(ButtonIcon, { name: "close", style: style.backButton, onPress: onClose }),
|
|
26
|
+
React.createElement(ScrollView, { contentContainerStyle: style.scrollContainer, showsVerticalScrollIndicator: false },
|
|
27
|
+
React.createElement(View, { style: style.returnQuestionsContainer },
|
|
28
|
+
React.createElement(ReturnQuestions, { returnQuestions: returnQuestions })))))));
|
|
29
|
+
export { ReturnQuestionsForm };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare const style: {
|
|
2
|
+
scrollContainer: {
|
|
3
|
+
flex: number;
|
|
4
|
+
flexGrow: number;
|
|
5
|
+
};
|
|
6
|
+
modal: {
|
|
7
|
+
zIndex: number;
|
|
8
|
+
};
|
|
9
|
+
backButton: {
|
|
10
|
+
top: number;
|
|
11
|
+
right: number;
|
|
12
|
+
alignSelf: "flex-end";
|
|
13
|
+
zIndex: number;
|
|
14
|
+
};
|
|
15
|
+
returnQuestionsContainer: {
|
|
16
|
+
paddingBottom: number;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export { style };
|