@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
|
@@ -1,30 +1,22 @@
|
|
|
1
1
|
import { mock } from "jest-mock-extended";
|
|
2
2
|
import { QueryBus } from "@lookiero/messaging";
|
|
3
|
+
import { returnQuestions } from "../../infrastructure/projection/returnQuestion/returnQuestions.mock";
|
|
3
4
|
import {
|
|
4
5
|
listReturnQuestionsByCheckoutItemId,
|
|
5
6
|
listReturnQuestionsByCheckoutItemIdHandler as sut,
|
|
6
7
|
} from "./listReturnQuestionsByCheckoutItemId";
|
|
7
|
-
import { ReturnQuestionProjection, ReturnQuestionType } from "./returnQuestion";
|
|
8
8
|
|
|
9
9
|
const checkoutItemId = "29790d24-b139-4ab8-b618-d796d101e974";
|
|
10
|
-
const returnQuestionsProjection: ReturnQuestionProjection[] = [
|
|
11
|
-
{
|
|
12
|
-
id: "efe07b97-f6fb-4b6a-ba92-b68519320b2c",
|
|
13
|
-
name: "main_title",
|
|
14
|
-
placeholder: "",
|
|
15
|
-
type: ReturnQuestionType.HOST_DEFAULT,
|
|
16
|
-
},
|
|
17
|
-
];
|
|
18
10
|
const queryBus = mock<QueryBus>();
|
|
19
11
|
const signal = mock<AbortSignal>();
|
|
20
12
|
|
|
21
13
|
describe("listReturnQuestionsByCheckoutItemId", () => {
|
|
22
14
|
it("returns return questions by checkout item id", async () => {
|
|
23
15
|
const query = listReturnQuestionsByCheckoutItemId({ checkoutItemId });
|
|
24
|
-
const view = jest.fn(() => Promise.resolve(
|
|
16
|
+
const view = jest.fn(() => Promise.resolve(returnQuestions));
|
|
25
17
|
|
|
26
|
-
const
|
|
18
|
+
const returnQuestionsResult = await sut({ view, queryBus, signal })(query);
|
|
27
19
|
|
|
28
|
-
expect(
|
|
20
|
+
expect(returnQuestionsResult).toBe(returnQuestions);
|
|
29
21
|
});
|
|
30
22
|
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EmptyObject } from "@lookiero/sty-psp-typescript";
|
|
2
|
+
import { ReturnQuestionType } from "./returnQuestion.constants";
|
|
3
|
+
|
|
4
|
+
interface ComponentPlaceholder {
|
|
5
|
+
readonly placeholder: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type MetadataDictionary = Record<ReturnQuestionType, EmptyObject>;
|
|
9
|
+
|
|
10
|
+
type ComponentMetadata = MetadataDictionary & {
|
|
11
|
+
[ReturnQuestionType.HOST_SELECT]: ComponentPlaceholder;
|
|
12
|
+
[ReturnQuestionType.TEXTAREA]: ComponentPlaceholder;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type Metadata<RQT extends ReturnQuestionType> = ComponentMetadata[RQT];
|
|
16
|
+
|
|
17
|
+
export type { Metadata };
|
|
@@ -1,20 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { EmptyObject, ExcludePropertyIfOptional, NonEmptyArray } from "@lookiero/sty-psp-typescript";
|
|
2
|
+
import { ReturnQuestionType } from "./returnQuestion.constants";
|
|
3
|
+
import { Metadata } from "./returnQuestion.metadata";
|
|
4
|
+
|
|
5
|
+
type ReturnQuestionTypesWithChildren =
|
|
6
|
+
| ReturnQuestionType.HOST_DEFAULT
|
|
7
|
+
| ReturnQuestionType.HOST_SELECT
|
|
8
|
+
| ReturnQuestionType.HOST_STACK
|
|
9
|
+
| ReturnQuestionType.HOST_TEXTAREA;
|
|
10
|
+
|
|
11
|
+
type ReturnQuestionTypesWithOptionalChildren = ReturnQuestionType.OPTION;
|
|
12
|
+
|
|
13
|
+
type ReturnQuestionTypesWithOptionalTranslationKeys = ReturnQuestionType.HOST_STACK;
|
|
14
|
+
|
|
15
|
+
type ReturnQuestionMetadata<RQT extends ReturnQuestionType> = ExcludePropertyIfOptional<
|
|
16
|
+
"metadata",
|
|
17
|
+
{ readonly metadata: Metadata<RQT> }
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
type ReturnQuestionChildren<RQT extends ReturnQuestionType> = RQT extends ReturnQuestionTypesWithChildren
|
|
21
|
+
? { readonly children: NonEmptyArray<ReturnQuestion> }
|
|
22
|
+
: RQT extends ReturnQuestionTypesWithOptionalChildren
|
|
23
|
+
? { readonly children?: NonEmptyArray<ReturnQuestion> }
|
|
24
|
+
: EmptyObject;
|
|
25
|
+
|
|
26
|
+
type ReturnQuestionTranslationKey<RQT extends ReturnQuestionType> =
|
|
27
|
+
RQT extends ReturnQuestionTypesWithOptionalTranslationKeys
|
|
28
|
+
? { readonly translationKey?: string }
|
|
29
|
+
: { readonly translationKey: string };
|
|
30
|
+
|
|
31
|
+
type ReturnQuestion<RQT extends ReturnQuestionType = ReturnQuestionType> = RQT extends infer K extends
|
|
32
|
+
ReturnQuestionType
|
|
33
|
+
? { readonly id: string; readonly type: K } & ReturnQuestionTranslationKey<K> &
|
|
34
|
+
ReturnQuestionChildren<K> &
|
|
35
|
+
ReturnQuestionMetadata<K>
|
|
36
|
+
: never;
|
|
37
|
+
|
|
38
|
+
export type {
|
|
39
|
+
ReturnQuestion as ReturnQuestionProjection,
|
|
40
|
+
ReturnQuestionTypesWithOptionalTranslationKeys,
|
|
41
|
+
ReturnQuestionTypesWithChildren,
|
|
42
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ReturnQuestionProjection,
|
|
3
|
+
ReturnQuestionTypesWithChildren,
|
|
4
|
+
ReturnQuestionTypesWithOptionalTranslationKeys,
|
|
5
|
+
} from "./returnQuestion";
|
|
6
|
+
import { ReturnQuestionType } from "./returnQuestion.constants";
|
|
7
|
+
|
|
8
|
+
const returnQuestionWithTranslationKey = (
|
|
9
|
+
question: ReturnQuestionProjection,
|
|
10
|
+
): question is ReturnQuestionProjection<Exclude<ReturnQuestionType, ReturnQuestionTypesWithOptionalTranslationKeys>> =>
|
|
11
|
+
Boolean(question.translationKey);
|
|
12
|
+
|
|
13
|
+
const returnQuestionHasChildren = (
|
|
14
|
+
question: ReturnQuestionProjection,
|
|
15
|
+
): question is ReturnQuestionProjection<ReturnQuestionTypesWithChildren> =>
|
|
16
|
+
[
|
|
17
|
+
ReturnQuestionType.HOST_DEFAULT,
|
|
18
|
+
ReturnQuestionType.HOST_SELECT,
|
|
19
|
+
ReturnQuestionType.HOST_STACK,
|
|
20
|
+
ReturnQuestionType.HOST_TEXTAREA,
|
|
21
|
+
ReturnQuestionType.OPTION,
|
|
22
|
+
].includes(question.type);
|
|
23
|
+
|
|
24
|
+
export { returnQuestionWithTranslationKey, returnQuestionHasChildren };
|