@lookiero/checkout 8.18.0 → 8.20.0
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/cypress/support/interceptListReturnQuestionsByCheckoutItemId.ts +1 -1
- package/dist/src/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.js +1 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestion.js +3 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/behaviors/isChildReturnQuestion.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/behaviors/useReturnQuestionItem.d.ts +3 -3
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/ReturnQuestionItem.d.ts +4 -3
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionFeedbackItem/HostDefaultReturnQuestionFeedbackItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionFeedbackItem/HostDefaultReturnQuestionFeedbackItem.js +1 -0
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.js +8 -6
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/form/HostStackReturnQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/form/HostStackReturnQuestionItem.js +1 -0
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem.js +5 -3
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems.js +4 -2
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.js +18 -9
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.js +1 -1
- package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.js +1 -1
- package/dist/src/projection/returnQuestion/returnQuestion.constants.d.ts +9 -0
- package/dist/src/projection/returnQuestion/returnQuestion.constants.js +10 -0
- package/dist/src/projection/returnQuestion/returnQuestion.d.ts +23 -16
- package/dist/src/projection/returnQuestion/returnQuestion.js +1 -11
- package/dist/src/projection/returnQuestion/returnQuestion.metadata.d.ts +12 -0
- package/dist/src/projection/returnQuestion/returnQuestion.metadata.js +1 -0
- package/dist/src/projection/returnQuestion/returnQuestion.typeguard.d.ts +5 -0
- package/dist/src/projection/returnQuestion/returnQuestion.typeguard.js +10 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
- package/src/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.ts +1 -1
- package/src/infrastructure/projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId.test.ts +4 -9
- package/src/infrastructure/projection/returnQuestion/returnQuestions.mock.ts +72 -117
- package/src/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestion.test.tsx +10 -12
- package/src/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestion.tsx +10 -8
- package/src/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestions.test.tsx +10 -9
- package/src/infrastructure/ui/components/organisms/returnQuestions/behaviors/isChildReturnQuestion.ts +2 -1
- package/src/infrastructure/ui/components/organisms/returnQuestions/behaviors/useReturnQuestionItem.test.tsx +7 -9
- package/src/infrastructure/ui/components/organisms/returnQuestions/behaviors/useReturnQuestionItem.tsx +3 -3
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/ReturnQuestionItem.ts +4 -3
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionFeedbackItem/HostDefaultReturnQuestionFeedbackItem.test.tsx +7 -13
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionFeedbackItem/HostDefaultReturnQuestionFeedbackItem.tsx +4 -2
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.test.tsx +8 -14
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.tsx +13 -7
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.tsx +7 -5
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.test.tsx +10 -14
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.tsx +7 -5
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/form/HostStackReturnQuestionItem.tsx +5 -3
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem.test.tsx +43 -36
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem.tsx +10 -7
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems.tsx +11 -9
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.test.tsx +8 -14
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.tsx +6 -4
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem.tsx +6 -4
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.test.tsx +23 -25
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.tsx +5 -3
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.test.tsx +9 -29
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.tsx +7 -5
- package/src/infrastructure/ui/components/organisms/returnQuestions/util/__snapshots__/returnQuestionFeedback.test.ts.snap +5 -4
- package/src/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.ts +32 -18
- package/src/infrastructure/ui/views/item/components/productVariantSlider/__snapshots__/ProductVariantSlider.test.tsx.snap +212 -254
- package/src/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.tsx +2 -4
- package/src/infrastructure/ui/views/item/views/productVariant/__snapshots__/ProductVariant.test.tsx.snap +636 -762
- package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.tsx +1 -1
- package/src/infrastructure/ui/views/summaryTabs/components/checkoutItemsTabs/__snapshots__/CheckoutItemsTabs.test.tsx.snap +1169 -1211
- package/src/projection/returnQuestion/listReturnQuestionsByCheckoutItemId.test.ts +4 -12
- package/src/projection/returnQuestion/returnQuestion.constants.ts +10 -0
- package/src/projection/returnQuestion/returnQuestion.metadata.ts +17 -0
- package/src/projection/returnQuestion/returnQuestion.ts +42 -20
- package/src/projection/returnQuestion/returnQuestion.typeguard.ts +24 -0
|
@@ -2,7 +2,7 @@ import { ReturnQuestionProjection } from "../../src/projection/returnQuestion/re
|
|
|
2
2
|
|
|
3
3
|
const interceptListReturnQuestionsByCheckoutItemId = (response: ReturnQuestionProjection[]) =>
|
|
4
4
|
cy.intercept(
|
|
5
|
-
{ method: "POST", url: "/local-to-dev/list-return-
|
|
5
|
+
{ method: "POST", url: "/local-to-dev/list-return-reasons-by-checkout-item-id" },
|
|
6
6
|
{ body: { result: response } },
|
|
7
7
|
);
|
|
8
8
|
|
package/dist/src/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const httpReturnQuestionsByCheckoutItemIdView = ({ httpPost }) => async ({ checkoutItemId, signal }) => await httpPost({
|
|
2
|
-
endpoint: "/list-return-
|
|
2
|
+
endpoint: "/list-return-reasons-by-checkout-item-id",
|
|
3
3
|
body: { checkoutItemId },
|
|
4
4
|
signal,
|
|
5
5
|
result: {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React, { memo } from "react";
|
|
2
|
+
import { returnQuestionHasChildren } from "../../../../../projection/returnQuestion/returnQuestion.typeguard";
|
|
2
3
|
import { useReturnQuestionItem } from "./behaviors/useReturnQuestionItem";
|
|
3
4
|
const ReturnQuestion = ({ returnQuestionParent, returnQuestion, portalHostName }) => {
|
|
4
5
|
const Item = useReturnQuestionItem({ type: returnQuestion.type });
|
|
5
6
|
return (React.createElement(Item, { portalHostName: portalHostName, returnQuestion: returnQuestion, returnQuestionParent: returnQuestionParent, testID: returnQuestion.id },
|
|
6
|
-
React.createElement(React.Fragment, null, returnQuestion
|
|
7
|
+
React.createElement(React.Fragment, null, returnQuestionHasChildren(returnQuestion) &&
|
|
8
|
+
returnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, portalHostName: portalHostName, returnQuestion: childReturnQuestion, returnQuestionParent: returnQuestion }))))));
|
|
7
9
|
};
|
|
8
10
|
export default memo(ReturnQuestion);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { returnQuestionHasChildren } from "../../../../../../projection/returnQuestion/returnQuestion.typeguard";
|
|
1
2
|
const isChildReturnQuestion = ({ returnQuestionId, returnQuestion }) => {
|
|
2
3
|
if (returnQuestionId === returnQuestion.id) {
|
|
3
4
|
return true;
|
|
4
5
|
}
|
|
5
|
-
const children = returnQuestion.children || [];
|
|
6
|
+
const children = (returnQuestionHasChildren(returnQuestion) && returnQuestion.children) || [];
|
|
6
7
|
for (let index = 0; index < children.length; index++) {
|
|
7
8
|
const isChild = isChildReturnQuestion({
|
|
8
9
|
returnQuestionId,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FC, ReactNode } from "react";
|
|
2
|
-
import { ReturnQuestionType } from "../../../../../../projection/returnQuestion/returnQuestion";
|
|
2
|
+
import { ReturnQuestionType } from "../../../../../../projection/returnQuestion/returnQuestion.constants";
|
|
3
3
|
import { ReturnQuestionItem } from "../components/ReturnQuestionItem";
|
|
4
|
-
type ReturnQuestionItems = Record<ReturnQuestionType, ReturnQuestionItem
|
|
4
|
+
type ReturnQuestionItems = Record<ReturnQuestionType, ReturnQuestionItem<ReturnQuestionType>>;
|
|
5
5
|
interface ReturnQuestionItemContextProviderProps {
|
|
6
6
|
readonly returnQuestionItems: ReturnQuestionItems;
|
|
7
7
|
readonly children: ReactNode;
|
|
@@ -11,7 +11,7 @@ interface UseReturnQuestionItemFunctionArgs {
|
|
|
11
11
|
readonly type: ReturnQuestionType;
|
|
12
12
|
}
|
|
13
13
|
interface UseReturnQuestionItemFunction {
|
|
14
|
-
(args: UseReturnQuestionItemFunctionArgs): ReturnQuestionItem
|
|
14
|
+
(args: UseReturnQuestionItemFunctionArgs): ReturnQuestionItem<ReturnQuestionType>;
|
|
15
15
|
}
|
|
16
16
|
declare const useReturnQuestionItem: UseReturnQuestionItemFunction;
|
|
17
17
|
export type { ReturnQuestionItems };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { FC, ReactNode } from "react";
|
|
2
2
|
import { ReturnQuestionProjection } from "../../../../../../projection/returnQuestion/returnQuestion";
|
|
3
|
-
|
|
3
|
+
import { ReturnQuestionType } from "../../../../../../projection/returnQuestion/returnQuestion.constants";
|
|
4
|
+
interface ReturnQuestionItemProps<RQT extends ReturnQuestionType> {
|
|
4
5
|
readonly returnQuestionParent: ReturnQuestionProjection;
|
|
5
|
-
readonly returnQuestion: ReturnQuestionProjection
|
|
6
|
+
readonly returnQuestion: ReturnQuestionProjection<RQT>;
|
|
6
7
|
readonly children?: ReactNode;
|
|
7
8
|
readonly portalHostName?: string;
|
|
8
9
|
readonly testID?: string;
|
|
9
10
|
}
|
|
10
|
-
type ReturnQuestionItem = FC<ReturnQuestionItemProps
|
|
11
|
+
type ReturnQuestionItem<QT extends ReturnQuestionType> = FC<ReturnQuestionItemProps<QT>>;
|
|
11
12
|
export type { ReturnQuestionItem, ReturnQuestionItemProps };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
|
|
1
2
|
import { ReturnQuestionItem } from "../ReturnQuestionItem";
|
|
2
|
-
declare const HostDefaultReturnQuestionFeedbackItem: ReturnQuestionItem
|
|
3
|
+
declare const HostDefaultReturnQuestionFeedbackItem: ReturnQuestionItem<ReturnQuestionType.HOST_DEFAULT>;
|
|
3
4
|
export { HostDefaultReturnQuestionFeedbackItem };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
|
|
1
2
|
import { ReturnQuestionItem } from "../ReturnQuestionItem";
|
|
2
|
-
declare const HostDefaultReturnQuestionItem: ReturnQuestionItem
|
|
3
|
+
declare const HostDefaultReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.HOST_DEFAULT>;
|
|
3
4
|
export { HostDefaultReturnQuestionItem };
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
1
2
|
import React from "react";
|
|
2
3
|
import { Text, View } from "@lookiero/aurora";
|
|
3
|
-
import {
|
|
4
|
+
import { useIntl } from "@lookiero/i18n-react";
|
|
5
|
+
import { returnQuestionWithTranslationKey } from "../../../../../../../projection/returnQuestion/returnQuestion.typeguard";
|
|
4
6
|
import { I18nMessages } from "../../../../../i18n/i18n";
|
|
5
7
|
import { style } from "./HostDefaultReturnQuestionItem.style";
|
|
6
|
-
const HostDefaultReturnQuestionItem = ({ returnQuestion, children }) => {
|
|
7
|
-
const
|
|
8
|
-
const isAllOptions = returnQuestion.
|
|
8
|
+
const HostDefaultReturnQuestionItem = ({ returnQuestion, children, }) => {
|
|
9
|
+
const { formatMessage } = useIntl();
|
|
10
|
+
const isAllOptions = returnQuestion.translationKey === I18nMessages.RETURN_QUESTION_MAIN_ALL_OPINION;
|
|
9
11
|
return (React.createElement(React.Fragment, null,
|
|
10
|
-
|
|
11
|
-
React.createElement(Text, { level: 3, action: true },
|
|
12
|
+
returnQuestionWithTranslationKey(returnQuestion) && returnQuestion.translationKey !== " " && !isAllOptions ? (React.createElement(View, { style: style.title },
|
|
13
|
+
React.createElement(Text, { level: 3, action: true }, formatMessage({ id: returnQuestion.translationKey })))) : null,
|
|
12
14
|
children));
|
|
13
15
|
};
|
|
14
16
|
export { HostDefaultReturnQuestionItem };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
|
|
1
2
|
import { ReturnQuestionItem } from "../ReturnQuestionItem";
|
|
2
3
|
import { style } from "./HostRadioGroupReturnQuestionItem.style";
|
|
3
|
-
declare const HostRadioGroupReturnQuestionItem: ReturnQuestionItem
|
|
4
|
+
declare const HostRadioGroupReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.HOST_SELECT>;
|
|
4
5
|
export { HostRadioGroupReturnQuestionItem, style };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
1
2
|
import React, { useMemo } from "react";
|
|
2
3
|
import { View } from "react-native";
|
|
3
4
|
import { Text } from "@lookiero/aurora";
|
|
@@ -5,7 +6,7 @@ import { useIntl } from "@lookiero/i18n-react";
|
|
|
5
6
|
import { style } from "./HostRadioGroupReturnQuestionItem.style";
|
|
6
7
|
const HostRadioGroupReturnQuestionItem = ({ returnQuestion, children, testID, }) => {
|
|
7
8
|
const { formatMessage } = useIntl();
|
|
8
|
-
const placeholderText = useMemo(() => (returnQuestion.placeholder ? formatMessage({ id: returnQuestion.placeholder }) : ""), [formatMessage, returnQuestion.placeholder]);
|
|
9
|
+
const placeholderText = useMemo(() => (returnQuestion.metadata.placeholder ? formatMessage({ id: returnQuestion.metadata.placeholder }) : ""), [formatMessage, returnQuestion.metadata.placeholder]);
|
|
9
10
|
return (React.createElement(React.Fragment, null,
|
|
10
11
|
React.createElement(View, { style: style.wrapper, testID: testID },
|
|
11
12
|
React.createElement(Text, { level: 3, style: style.title, action: true }, placeholderText),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
|
|
1
2
|
import { ReturnQuestionItem } from "../ReturnQuestionItem";
|
|
2
|
-
declare const HostSelectReturnQuestionItem: ReturnQuestionItem
|
|
3
|
+
declare const HostSelectReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.HOST_SELECT>;
|
|
3
4
|
export { HostSelectReturnQuestionItem };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
1
2
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
3
|
import { TouchableHighlight, View } from "react-native";
|
|
3
4
|
import { ButtonIcon } from "@lookiero/aurora";
|
|
@@ -9,7 +10,7 @@ import { deepestReturnQuestionWithFeedbackForReturnQuestion, feedbackForReturnQu
|
|
|
9
10
|
import { style, containerUnderlayColor } from "./HostSelectReturnQuestionItem.style";
|
|
10
11
|
const HostSelectReturnQuestionItem = ({ returnQuestion, children, portalHostName, testID, }) => {
|
|
11
12
|
const { formatMessage } = useIntl();
|
|
12
|
-
const placeholderText = useMemo(() => (returnQuestion.placeholder ? formatMessage({ id: returnQuestion.placeholder }) : ""), [formatMessage, returnQuestion.placeholder]);
|
|
13
|
+
const placeholderText = useMemo(() => (returnQuestion.metadata.placeholder ? formatMessage({ id: returnQuestion.metadata.placeholder }) : ""), [formatMessage, returnQuestion.metadata.placeholder]);
|
|
13
14
|
const [modalVisible, setModalVisible] = useState(false);
|
|
14
15
|
const handleOnPress = useCallback(() => setModalVisible(true), []);
|
|
15
16
|
const handleOnModalClose = useCallback(() => setModalVisible(false), []);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReturnQuestionType } from "../../../../../../../../projection/returnQuestion/returnQuestion.constants";
|
|
1
2
|
import { ReturnQuestionItem } from "../../ReturnQuestionItem";
|
|
2
|
-
declare const HostStackReturnQuestionItem: ReturnQuestionItem
|
|
3
|
+
declare const HostStackReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.HOST_STACK>;
|
|
3
4
|
export { HostStackReturnQuestionItem };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
1
2
|
import React from "react";
|
|
2
3
|
import ReturnQuestion from "../../../ReturnQuestion";
|
|
3
4
|
const HostStackReturnQuestionItem = ({ returnQuestion, portalHostName, }) => (React.createElement(React.Fragment, null, returnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, portalHostName: portalHostName, returnQuestion: childReturnQuestion, returnQuestionParent: returnQuestion })))));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReturnQuestionType } from "../../../../../../../../projection/returnQuestion/returnQuestion.constants";
|
|
1
2
|
import { ReturnQuestionItem } from "../../ReturnQuestionItem";
|
|
2
|
-
declare const HostStackReturnQuestionItem: ReturnQuestionItem
|
|
3
|
+
declare const HostStackReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.HOST_STACK>;
|
|
3
4
|
export { HostStackReturnQuestionItem };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
1
2
|
import { animated, useSpring } from "@react-spring/native";
|
|
2
3
|
import React, { useCallback, useMemo, useState } from "react";
|
|
3
4
|
import { View } from "react-native";
|
|
4
5
|
import { COLOR, Text } from "@lookiero/aurora";
|
|
5
6
|
import { useIntl } from "@lookiero/i18n-react";
|
|
7
|
+
import { returnQuestionHasChildren } from "../../../../../../../../projection/returnQuestion/returnQuestion.typeguard";
|
|
6
8
|
import ReturnQuestion from "../../../ReturnQuestion";
|
|
7
9
|
import { useReturnQuestionFeedbackForReturnQuestion } from "../../../behaviors/useReturnQuestionFeedback";
|
|
8
10
|
import { style } from "./HostStackReturnQuestionItem.style";
|
|
@@ -12,15 +14,15 @@ const HostStackReturnQuestionItem = ({ returnQuestion, children, portalHostName,
|
|
|
12
14
|
const feedbackReturnQuestion = feedback
|
|
13
15
|
? returnQuestion.children?.find((returnQuestion) => returnQuestion.id === feedback)
|
|
14
16
|
: undefined;
|
|
15
|
-
const titleText = useMemo(() => (returnQuestion.
|
|
16
|
-
const feedbackText = useMemo(() => (feedbackReturnQuestion ? formatMessage({ id: feedbackReturnQuestion.
|
|
17
|
+
const titleText = useMemo(() => (returnQuestion.translationKey ? formatMessage({ id: returnQuestion.translationKey }) : undefined), [formatMessage, returnQuestion.translationKey]);
|
|
18
|
+
const feedbackText = useMemo(() => (feedbackReturnQuestion ? formatMessage({ id: feedbackReturnQuestion.translationKey }) : undefined), [feedbackReturnQuestion, formatMessage]);
|
|
17
19
|
const [stackHeight, setStackHeight] = useState();
|
|
18
20
|
const handleOnLayout = useCallback(({ nativeEvent: { layout: { height }, }, }) => setStackHeight(height), []);
|
|
19
21
|
const stackSyle = useSpring({ height: stackHeight });
|
|
20
22
|
return (React.createElement(animated.View, { style: stackSyle },
|
|
21
23
|
React.createElement(View, { onLayout: handleOnLayout },
|
|
22
24
|
titleText && (React.createElement(Text, { level: 3, style: style.title, heading: true }, titleText)),
|
|
23
|
-
feedbackReturnQuestion ? (React.createElement(React.Fragment, null,
|
|
25
|
+
feedbackReturnQuestion && returnQuestionHasChildren(feedbackReturnQuestion) ? (React.createElement(React.Fragment, null,
|
|
24
26
|
React.createElement(Text, { color: COLOR.TEXT_MEDIUM, level: 3 }, feedbackText),
|
|
25
27
|
feedbackReturnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, portalHostName: portalHostName, returnQuestion: childReturnQuestion, returnQuestionParent: feedbackReturnQuestion }))))) : (children))));
|
|
26
28
|
};
|
|
@@ -3,14 +3,16 @@ import { View } from "react-native";
|
|
|
3
3
|
import { COLOR, Text } from "@lookiero/aurora";
|
|
4
4
|
import { useIntl } from "@lookiero/i18n-react";
|
|
5
5
|
import { Modal } from "@lookiero/sty-psp-ui";
|
|
6
|
+
import { returnQuestionHasChildren } from "../../../../../../../projection/returnQuestion/returnQuestion.typeguard";
|
|
6
7
|
import ReturnQuestion from "../../ReturnQuestion";
|
|
7
8
|
import { style } from "./ModalOptionReturnQuestionItems.style";
|
|
8
9
|
const ModalOptionReturnQuestionItems = ({ portalHostName, returnQuestion, visible, onClose, }) => {
|
|
9
10
|
const { formatMessage } = useIntl();
|
|
10
|
-
const title = formatMessage({ id: returnQuestion.
|
|
11
|
+
const title = formatMessage({ id: returnQuestion.translationKey });
|
|
11
12
|
return (React.createElement(Modal, { portalHostName: portalHostName, visible: visible, scroll: true, showCloseButton: true, onClose: onClose },
|
|
12
13
|
React.createElement(View, { style: style.modalContent },
|
|
13
14
|
React.createElement(Text, { color: COLOR.TEXT_MEDIUM, level: 2, style: style.optionText }, title),
|
|
14
|
-
React.createElement(React.Fragment, null, returnQuestion
|
|
15
|
+
React.createElement(React.Fragment, null, returnQuestionHasChildren(returnQuestion) &&
|
|
16
|
+
returnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, portalHostName: "", returnQuestion: childReturnQuestion, returnQuestionParent: returnQuestion })))))));
|
|
15
17
|
};
|
|
16
18
|
export { ModalOptionReturnQuestionItems };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
|
|
1
2
|
import { ReturnQuestionItem } from "../ReturnQuestionItem";
|
|
2
|
-
declare const OptionReturnQuestionItem: ReturnQuestionItem
|
|
3
|
+
declare const OptionReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.OPTION>;
|
|
3
4
|
export { OptionReturnQuestionItem };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
1
2
|
import React, { useCallback } from "react";
|
|
2
3
|
import { TouchableHighlight } from "react-native";
|
|
3
4
|
import { Text } from "@lookiero/aurora";
|
|
@@ -6,7 +7,7 @@ import { useReturnQuestionFeedbackForReturnQuestion } from "../../behaviors/useR
|
|
|
6
7
|
import { containerUnderlayColor, style } from "./OptionReturnQuestionItem.style";
|
|
7
8
|
const OptionReturnQuestionItem = ({ returnQuestion, returnQuestionParent, testID, }) => {
|
|
8
9
|
const { onChange } = useReturnQuestionFeedbackForReturnQuestion({ returnQuestion: returnQuestionParent });
|
|
9
|
-
const optionText = useI18nMessage({ id: returnQuestion.
|
|
10
|
+
const optionText = useI18nMessage({ id: returnQuestion.translationKey });
|
|
10
11
|
const handleOnPress = useCallback(() => onChange({ returnQuestionId: returnQuestionParent.id, returnQuestionFeedback: returnQuestion.id }), [onChange, returnQuestion.id, returnQuestionParent.id]);
|
|
11
12
|
return (React.createElement(TouchableHighlight, { accessibilityLabel: testID, style: style.container, testID: testID, underlayColor: containerUnderlayColor, onPress: handleOnPress },
|
|
12
13
|
React.createElement(Text, { level: 3, style: style.text }, optionText)));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
|
|
1
2
|
import { ReturnQuestionItem } from "../ReturnQuestionItem";
|
|
2
|
-
declare const RadioReturnQuestionItem: ReturnQuestionItem
|
|
3
|
+
declare const RadioReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.OPTION>;
|
|
3
4
|
export { RadioReturnQuestionItem };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
1
2
|
import React, { useCallback, useEffect, useState } from "react";
|
|
2
3
|
import { View, Option, OPTION_VARIANT, SIZE } from "@lookiero/aurora";
|
|
3
4
|
import { useIntl } from "@lookiero/i18n-react";
|
|
@@ -12,7 +13,7 @@ const RadioReturnQuestionItem = ({ returnQuestion, returnQuestionParent, testID,
|
|
|
12
13
|
const feedback = useReturnQuestionFeedback();
|
|
13
14
|
const translate = useCallback((returnQuestionName) => intl.formatMessage({ id: returnQuestionName, defaultMessage: returnQuestionName }), [intl]);
|
|
14
15
|
const inputValue = feedbackForReturnQuestion({ feedback, returnQuestion, translate }).join(" / ");
|
|
15
|
-
const optionText = intl.formatMessage({ id: returnQuestion.
|
|
16
|
+
const optionText = intl.formatMessage({ id: returnQuestion.translationKey });
|
|
16
17
|
const hasChildren = Boolean(returnQuestion.children && returnQuestion.children.length > 0);
|
|
17
18
|
const handleOnModalClose = useCallback(() => {
|
|
18
19
|
// Uncomment if we want to clear current selection (and update callback's dependencies)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
|
|
1
2
|
import { ReturnQuestionItem } from "../ReturnQuestionItem";
|
|
2
|
-
declare const ReturnQuestionFeedbackItem: ReturnQuestionItem
|
|
3
|
+
declare const ReturnQuestionFeedbackItem: ReturnQuestionItem<ReturnQuestionType.HOST_DEFAULT>;
|
|
3
4
|
export { ReturnQuestionFeedbackItem };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
1
2
|
import React, { useCallback } from "react";
|
|
2
3
|
import { View } from "react-native";
|
|
3
4
|
import { Text } from "@lookiero/aurora";
|
|
@@ -7,7 +8,7 @@ import { useReturnQuestionFeedback } from "../../behaviors/useReturnQuestionFeed
|
|
|
7
8
|
import { feedbackForReturnQuestion } from "../../util/returnQuestionFeedback";
|
|
8
9
|
import { style } from "./ReturnQuestionFeedbackItem.style";
|
|
9
10
|
const ReturnQuestionFeedbackItem = ({ returnQuestion }) => {
|
|
10
|
-
const titleText = useI18nMessage({ id: returnQuestion.
|
|
11
|
+
const titleText = useI18nMessage({ id: returnQuestion.translationKey });
|
|
11
12
|
const unansweredText = useI18nMessage({ id: I18nMessages.FEEDBACK_UNANSWERED });
|
|
12
13
|
const returnQuestionFeedback = useReturnQuestionFeedback();
|
|
13
14
|
const intl = useIntl();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
|
|
1
2
|
import { ReturnQuestionItem } from "../ReturnQuestionItem";
|
|
2
|
-
declare const TextareaReturnQuestionItem: ReturnQuestionItem
|
|
3
|
+
declare const TextareaReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.TEXTAREA>;
|
|
3
4
|
export { TextareaReturnQuestionItem };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
1
2
|
import React, { useCallback, useMemo } from "react";
|
|
2
3
|
import { View } from "@lookiero/aurora";
|
|
3
4
|
import { useIntl } from "@lookiero/i18n-react";
|
|
@@ -6,7 +7,7 @@ import { useReturnQuestionFeedbackForReturnQuestion } from "../../behaviors/useR
|
|
|
6
7
|
import { style } from "./TextareaReturnQuestionItem.style";
|
|
7
8
|
const TextareaReturnQuestionItem = ({ returnQuestion, returnQuestionParent, testID, }) => {
|
|
8
9
|
const { formatMessage } = useIntl();
|
|
9
|
-
const placeholderText = useMemo(() => (returnQuestion.placeholder ? formatMessage({ id: returnQuestion.placeholder }) : ""), [formatMessage, returnQuestion.placeholder]);
|
|
10
|
+
const placeholderText = useMemo(() => (returnQuestion.metadata.placeholder ? formatMessage({ id: returnQuestion.metadata.placeholder }) : ""), [formatMessage, returnQuestion.metadata.placeholder]);
|
|
10
11
|
const { feedback, onChange } = useReturnQuestionFeedbackForReturnQuestion({ returnQuestion: returnQuestionParent });
|
|
11
12
|
const handleOnChange = useCallback((value) => onChange({ returnQuestionId: returnQuestionParent.id, returnQuestionFeedback: value }), [onChange, returnQuestionParent.id]);
|
|
12
13
|
return (React.createElement(View, { style: style.wrapper },
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { isUuid } from "@lookiero/sty-psp-uuid";
|
|
2
|
+
import { returnQuestionHasChildren, returnQuestionWithTranslationKey, } from "../../../../../../projection/returnQuestion/returnQuestion.typeguard";
|
|
2
3
|
const feedbackForReturnQuestion = ({ feedback, returnQuestion, translate, acc = [], }) => {
|
|
3
4
|
const returnQuestionId = Object.keys(feedback).find((id) => id === returnQuestion.id);
|
|
4
5
|
if (returnQuestionId) {
|
|
5
6
|
const returnQuestionFeedback = feedback[returnQuestionId];
|
|
6
7
|
if (isUuid(returnQuestionFeedback)) {
|
|
7
|
-
const feebackReturnQuestionChild = returnQuestion
|
|
8
|
+
const feebackReturnQuestionChild = returnQuestionHasChildren(returnQuestion) &&
|
|
9
|
+
returnQuestion.children?.find((childReturnQuestion) => childReturnQuestion.id === returnQuestionFeedback);
|
|
8
10
|
if (feebackReturnQuestionChild) {
|
|
9
11
|
return [
|
|
10
12
|
...acc,
|
|
11
|
-
|
|
13
|
+
...(returnQuestionWithTranslationKey(feebackReturnQuestionChild)
|
|
14
|
+
? [translate(feebackReturnQuestionChild.translationKey)]
|
|
15
|
+
: []),
|
|
12
16
|
...feedbackForReturnQuestion({ feedback, returnQuestion: feebackReturnQuestionChild, translate, acc }),
|
|
13
17
|
];
|
|
14
18
|
}
|
|
@@ -16,17 +20,20 @@ const feedbackForReturnQuestion = ({ feedback, returnQuestion, translate, acc =
|
|
|
16
20
|
}
|
|
17
21
|
return [...acc, returnQuestionFeedback];
|
|
18
22
|
}
|
|
19
|
-
return (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
return ((returnQuestionHasChildren(returnQuestion) &&
|
|
24
|
+
returnQuestion.children?.reduce((acc, childReturnQuestion) => [
|
|
25
|
+
...acc,
|
|
26
|
+
...feedbackForReturnQuestion({ feedback, returnQuestion: childReturnQuestion, translate, acc }),
|
|
27
|
+
], [])) ||
|
|
28
|
+
[]);
|
|
23
29
|
};
|
|
24
30
|
const deepestReturnQuestionWithFeedbackForReturnQuestion = ({ feedback, returnQuestion, deepestReturnQuestion, }) => {
|
|
25
31
|
const returnQuestionId = Object.keys(feedback).find((id) => id === returnQuestion.id);
|
|
26
32
|
if (returnQuestionId) {
|
|
27
33
|
const returnQuestionFeedback = feedback[returnQuestionId];
|
|
28
34
|
if (isUuid(returnQuestionFeedback)) {
|
|
29
|
-
const feebackReturnQuestionChild = returnQuestion
|
|
35
|
+
const feebackReturnQuestionChild = returnQuestionHasChildren(returnQuestion) &&
|
|
36
|
+
returnQuestion.children?.find((childReturnQuestion) => childReturnQuestion.id === returnQuestionFeedback);
|
|
30
37
|
if (feebackReturnQuestionChild) {
|
|
31
38
|
return deepestReturnQuestionWithFeedbackForReturnQuestion({
|
|
32
39
|
feedback,
|
|
@@ -38,7 +45,8 @@ const deepestReturnQuestionWithFeedbackForReturnQuestion = ({ feedback, returnQu
|
|
|
38
45
|
}
|
|
39
46
|
return [returnQuestion, false];
|
|
40
47
|
}
|
|
41
|
-
const feebackReturnQuestionChild = returnQuestion
|
|
48
|
+
const feebackReturnQuestionChild = returnQuestionHasChildren(returnQuestion) &&
|
|
49
|
+
returnQuestion.children?.find((childReturnQuestion) => Object.keys(feedback).find((id) => id === childReturnQuestion.id));
|
|
42
50
|
if (feebackReturnQuestionChild) {
|
|
43
51
|
return deepestReturnQuestionWithFeedbackForReturnQuestion({
|
|
44
52
|
feedback,
|
|
@@ -46,6 +54,7 @@ const deepestReturnQuestionWithFeedbackForReturnQuestion = ({ feedback, returnQu
|
|
|
46
54
|
deepestReturnQuestion: feebackReturnQuestionChild,
|
|
47
55
|
});
|
|
48
56
|
}
|
|
49
|
-
|
|
57
|
+
const hasChildren = Boolean(returnQuestionHasChildren(returnQuestion) && returnQuestion.children && returnQuestion.children.length > 0);
|
|
58
|
+
return [deepestReturnQuestion, !hasChildren];
|
|
50
59
|
};
|
|
51
60
|
export { feedbackForReturnQuestion, deepestReturnQuestionWithFeedbackForReturnQuestion };
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import { ButtonIcon, Text } from "@lookiero/aurora";
|
|
4
4
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
5
|
-
import { ReturnQuestionType
|
|
5
|
+
import { ReturnQuestionType } from "../../../../../../projection/returnQuestion/returnQuestion.constants";
|
|
6
6
|
import { ReturnQuestions } from "../../../../components/organisms/returnQuestions/ReturnQuestions";
|
|
7
7
|
import { ReturnQuestionItemProvider, } from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionItem";
|
|
8
8
|
import { HostDefaultReturnQuestionFeedbackItem } from "../../../../components/organisms/returnQuestions/components/hostDefaultReturnQuestionFeedbackItem/HostDefaultReturnQuestionFeedbackItem";
|
|
@@ -7,7 +7,7 @@ import { Box, Button, Layout as AuroraLayout, Spinner, Text, View, useDevice } f
|
|
|
7
7
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
8
8
|
import { CommandStatus } from "@lookiero/messaging-react";
|
|
9
9
|
import { useLogger } from "@lookiero/sty-psp-logging";
|
|
10
|
-
import { ReturnQuestionType } from "../../../../../../projection/returnQuestion/returnQuestion";
|
|
10
|
+
import { ReturnQuestionType } from "../../../../../../projection/returnQuestion/returnQuestion.constants";
|
|
11
11
|
import { useReturnCheckoutItem } from "../../../../../domain/checkoutItem/react/useReturnCheckoutItem";
|
|
12
12
|
import { useListReturnQuestionsByCheckoutItemId } from "../../../../../projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId";
|
|
13
13
|
import { TrackingPage } from "../../../../../tracking/tracking";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var ReturnQuestionType;
|
|
2
|
+
(function (ReturnQuestionType) {
|
|
3
|
+
ReturnQuestionType["HOST_DEFAULT"] = "HOST_DEFAULT";
|
|
4
|
+
ReturnQuestionType["HOST_TEXTAREA"] = "HOST_TEXTAREA";
|
|
5
|
+
ReturnQuestionType["HOST_SELECT"] = "HOST_SELECT";
|
|
6
|
+
ReturnQuestionType["HOST_STACK"] = "HOST_STACK";
|
|
7
|
+
ReturnQuestionType["TEXTAREA"] = "TEXTAREA";
|
|
8
|
+
ReturnQuestionType["OPTION"] = "OPTION";
|
|
9
|
+
})(ReturnQuestionType || (ReturnQuestionType = {}));
|
|
10
|
+
export { ReturnQuestionType };
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { EmptyObject, ExcludePropertyIfOptional, NonEmptyArray } from "@lookiero/sty-psp-typescript";
|
|
2
|
+
import { ReturnQuestionType } from "./returnQuestion.constants";
|
|
3
|
+
import { Metadata } from "./returnQuestion.metadata";
|
|
4
|
+
type ReturnQuestionTypesWithChildren = ReturnQuestionType.HOST_DEFAULT | ReturnQuestionType.HOST_SELECT | ReturnQuestionType.HOST_STACK | ReturnQuestionType.HOST_TEXTAREA;
|
|
5
|
+
type ReturnQuestionTypesWithOptionalChildren = ReturnQuestionType.OPTION;
|
|
6
|
+
type ReturnQuestionTypesWithOptionalTranslationKeys = ReturnQuestionType.HOST_STACK;
|
|
7
|
+
type ReturnQuestionMetadata<RQT extends ReturnQuestionType> = ExcludePropertyIfOptional<"metadata", {
|
|
8
|
+
readonly metadata: Metadata<RQT>;
|
|
9
|
+
}>;
|
|
10
|
+
type ReturnQuestionChildren<RQT extends ReturnQuestionType> = RQT extends ReturnQuestionTypesWithChildren ? {
|
|
11
|
+
readonly children: NonEmptyArray<ReturnQuestion>;
|
|
12
|
+
} : RQT extends ReturnQuestionTypesWithOptionalChildren ? {
|
|
13
|
+
readonly children?: NonEmptyArray<ReturnQuestion>;
|
|
14
|
+
} : EmptyObject;
|
|
15
|
+
type ReturnQuestionTranslationKey<RQT extends ReturnQuestionType> = RQT extends ReturnQuestionTypesWithOptionalTranslationKeys ? {
|
|
16
|
+
readonly translationKey?: string;
|
|
17
|
+
} : {
|
|
18
|
+
readonly translationKey: string;
|
|
19
|
+
};
|
|
20
|
+
type ReturnQuestion<RQT extends ReturnQuestionType = ReturnQuestionType> = RQT extends infer K extends ReturnQuestionType ? {
|
|
10
21
|
readonly id: string;
|
|
11
|
-
readonly
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
readonly children?: ReturnQuestionProjection[];
|
|
15
|
-
}
|
|
16
|
-
export { ReturnQuestionType };
|
|
17
|
-
export type { ReturnQuestionProjection };
|
|
22
|
+
readonly type: K;
|
|
23
|
+
} & ReturnQuestionTranslationKey<K> & ReturnQuestionChildren<K> & ReturnQuestionMetadata<K> : never;
|
|
24
|
+
export type { ReturnQuestion as ReturnQuestionProjection, ReturnQuestionTypesWithOptionalTranslationKeys, ReturnQuestionTypesWithChildren, };
|
|
@@ -1,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
(function (ReturnQuestionType) {
|
|
3
|
-
ReturnQuestionType["HOST_DEFAULT"] = "HOST_DEFAULT";
|
|
4
|
-
ReturnQuestionType["HOST_TEXTAREA"] = "HOST_TEXTAREA";
|
|
5
|
-
ReturnQuestionType["HOST_SELECT"] = "HOST_SELECT";
|
|
6
|
-
ReturnQuestionType["HOST_STACK"] = "HOST_STACK";
|
|
7
|
-
ReturnQuestionType["TEXTAREA"] = "TEXTAREA";
|
|
8
|
-
ReturnQuestionType["OPTION"] = "OPTION";
|
|
9
|
-
// ICON = "ICON",
|
|
10
|
-
})(ReturnQuestionType || (ReturnQuestionType = {}));
|
|
11
|
-
export { ReturnQuestionType };
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EmptyObject } from "@lookiero/sty-psp-typescript";
|
|
2
|
+
import { ReturnQuestionType } from "./returnQuestion.constants";
|
|
3
|
+
interface ComponentPlaceholder {
|
|
4
|
+
readonly placeholder: string;
|
|
5
|
+
}
|
|
6
|
+
type MetadataDictionary = Record<ReturnQuestionType, EmptyObject>;
|
|
7
|
+
type ComponentMetadata = MetadataDictionary & {
|
|
8
|
+
[ReturnQuestionType.HOST_SELECT]: ComponentPlaceholder;
|
|
9
|
+
[ReturnQuestionType.TEXTAREA]: ComponentPlaceholder;
|
|
10
|
+
};
|
|
11
|
+
type Metadata<RQT extends ReturnQuestionType> = ComponentMetadata[RQT];
|
|
12
|
+
export type { Metadata };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { ReturnQuestionType } from "./returnQuestion.constants";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ReturnQuestionProjection, ReturnQuestionTypesWithChildren } from "./returnQuestion";
|
|
2
|
+
import { ReturnQuestionType } from "./returnQuestion.constants";
|
|
3
|
+
declare const returnQuestionWithTranslationKey: (question: ReturnQuestionProjection) => question is ReturnQuestionProjection<ReturnQuestionType.HOST_DEFAULT | ReturnQuestionType.HOST_TEXTAREA | ReturnQuestionType.HOST_SELECT | ReturnQuestionType.TEXTAREA | ReturnQuestionType.OPTION>;
|
|
4
|
+
declare const returnQuestionHasChildren: (question: ReturnQuestionProjection) => question is ReturnQuestionProjection<ReturnQuestionTypesWithChildren>;
|
|
5
|
+
export { returnQuestionWithTranslationKey, returnQuestionHasChildren };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReturnQuestionType } from "./returnQuestion.constants";
|
|
2
|
+
const returnQuestionWithTranslationKey = (question) => Boolean(question.translationKey);
|
|
3
|
+
const returnQuestionHasChildren = (question) => [
|
|
4
|
+
ReturnQuestionType.HOST_DEFAULT,
|
|
5
|
+
ReturnQuestionType.HOST_SELECT,
|
|
6
|
+
ReturnQuestionType.HOST_STACK,
|
|
7
|
+
ReturnQuestionType.HOST_TEXTAREA,
|
|
8
|
+
ReturnQuestionType.OPTION,
|
|
9
|
+
].includes(question.type);
|
|
10
|
+
export { returnQuestionWithTranslationKey, returnQuestionHasChildren };
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "8.
|
|
1
|
+
export declare const VERSION = "8.20.0";
|
package/dist/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "8.
|
|
1
|
+
export const VERSION = "8.20.0";
|
package/package.json
CHANGED
package/src/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.ts
CHANGED
|
@@ -22,7 +22,7 @@ const httpReturnQuestionsByCheckoutItemIdView: HttpReturnQuestionsByCheckoutItem
|
|
|
22
22
|
({ httpPost }) =>
|
|
23
23
|
async ({ checkoutItemId, signal }) =>
|
|
24
24
|
await httpPost<ListReturnQuestionsByCheckoutItemIdResponse, ListReturnQuestionsByCheckoutItemIdResult>({
|
|
25
|
-
endpoint: "/list-return-
|
|
25
|
+
endpoint: "/list-return-reasons-by-checkout-item-id",
|
|
26
26
|
body: { checkoutItemId },
|
|
27
27
|
signal,
|
|
28
28
|
result: {
|
|
@@ -4,18 +4,13 @@ import {
|
|
|
4
4
|
listReturnQuestionsByCheckoutItemIdHandler,
|
|
5
5
|
LIST_RETURN_QUESTIONS_BY_CHECKOUT_ITEM_ID,
|
|
6
6
|
} from "../../../../projection/returnQuestion/listReturnQuestionsByCheckoutItemId";
|
|
7
|
-
import { ReturnQuestionProjection, ReturnQuestionType } from "../../../../projection/returnQuestion/returnQuestion";
|
|
8
7
|
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
8
|
+
import { returnQuestions } from "../returnQuestions.mock";
|
|
9
9
|
import { useListReturnQuestionsByCheckoutItemId as sut } from "./useListReturnQuestionsByCheckoutItemId";
|
|
10
10
|
|
|
11
11
|
const checkoutItemId = "29790d24-b139-4ab8-b618-d796d101e974";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
name: "main_title",
|
|
15
|
-
placeholder: "",
|
|
16
|
-
type: ReturnQuestionType.HOST_DEFAULT,
|
|
17
|
-
};
|
|
18
|
-
const view = jest.fn().mockReturnValue(returnQuestionProjection);
|
|
12
|
+
|
|
13
|
+
const view = jest.fn().mockReturnValue(returnQuestions);
|
|
19
14
|
const { Component: Messaging } = bootstrap({ id: MESSAGING_CONTEXT_ID })
|
|
20
15
|
.query(LIST_RETURN_QUESTIONS_BY_CHECKOUT_ITEM_ID, listReturnQuestionsByCheckoutItemIdHandler, { view })
|
|
21
16
|
.build();
|
|
@@ -27,7 +22,7 @@ describe("useListReturnQuestionsByCheckoutItemId integration hook", () => {
|
|
|
27
22
|
await waitFor(() => {
|
|
28
23
|
const [projection, status] = result.current;
|
|
29
24
|
|
|
30
|
-
expect(projection).toStrictEqual(
|
|
25
|
+
expect(projection).toStrictEqual(returnQuestions);
|
|
31
26
|
expect(status).toBe(QueryStatus.SUCCESS);
|
|
32
27
|
});
|
|
33
28
|
});
|