@lookiero/checkout 0.2.17 → 0.2.18
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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AggregateRoot, CommandHandlerFunction } from "@lookiero/messaging";
|
|
2
2
|
import { KeepCheckoutItem } from "../command/keepCheckoutItem";
|
|
3
|
+
import { Price } from "./price";
|
|
3
4
|
declare enum CheckoutItemStatus {
|
|
4
5
|
INITIAL = "INITIAL",
|
|
5
6
|
KEPT = "KEPT",
|
|
@@ -9,6 +10,7 @@ declare enum CheckoutItemStatus {
|
|
|
9
10
|
}
|
|
10
11
|
interface CheckoutItem extends AggregateRoot {
|
|
11
12
|
readonly status: CheckoutItemStatus;
|
|
13
|
+
readonly price: Price;
|
|
12
14
|
}
|
|
13
15
|
declare const keepCheckoutItemHandler: CommandHandlerFunction<KeepCheckoutItem, CheckoutItem>;
|
|
14
16
|
export type { CheckoutItem };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,6 +4,8 @@ const toCheckoutItemProjection = (checkoutItem) => ({
|
|
|
4
4
|
id: checkoutItem.aggregateId,
|
|
5
5
|
status: checkoutItem.status,
|
|
6
6
|
productVariant: {},
|
|
7
|
+
feedback: {},
|
|
8
|
+
price: checkoutItem.price,
|
|
7
9
|
});
|
|
8
10
|
const toCheckoutItemDomain = (checkoutItem) => {
|
|
9
11
|
invariant(checkoutItem, "No checkoutItem found!");
|
|
@@ -11,6 +13,7 @@ const toCheckoutItemDomain = (checkoutItem) => {
|
|
|
11
13
|
id: checkoutItem.id,
|
|
12
14
|
status: checkoutItem.status,
|
|
13
15
|
aggregateId: checkoutItem.id,
|
|
16
|
+
price: checkoutItem.price,
|
|
14
17
|
domainEvents: [],
|
|
15
18
|
};
|
|
16
19
|
};
|
|
@@ -8,7 +8,18 @@ const toCheckoutProjection = (checkoutDto) => ({
|
|
|
8
8
|
items: checkoutDto.items.map((item) => ({
|
|
9
9
|
id: item.id,
|
|
10
10
|
status: item.status,
|
|
11
|
+
price: {
|
|
12
|
+
amount: item.price.amount,
|
|
13
|
+
currency: item.price.currency,
|
|
14
|
+
discountedPrice: item.price.discounted_price
|
|
15
|
+
? {
|
|
16
|
+
amount: item.price.discounted_price.amount,
|
|
17
|
+
percentage: item.price.discounted_price.percentage,
|
|
18
|
+
}
|
|
19
|
+
: undefined,
|
|
20
|
+
},
|
|
11
21
|
replacedFor: item.replaced_for,
|
|
22
|
+
feedback: {},
|
|
12
23
|
productVariant: {
|
|
13
24
|
id: item.product_variant.id,
|
|
14
25
|
media: item.product_variant.media.map((media) => ({
|
|
@@ -18,16 +29,6 @@ const toCheckoutProjection = (checkoutDto) => ({
|
|
|
18
29
|
})),
|
|
19
30
|
brand: item.product_variant.brand,
|
|
20
31
|
name: item.product_variant.name,
|
|
21
|
-
price: {
|
|
22
|
-
amount: item.product_variant.price.amount,
|
|
23
|
-
currency: item.product_variant.price.currency,
|
|
24
|
-
discountedPrice: item.product_variant.price.discounted_price
|
|
25
|
-
? {
|
|
26
|
-
amount: item.product_variant.price.discounted_price.amount,
|
|
27
|
-
percentage: item.product_variant.price.discounted_price.percentage,
|
|
28
|
-
}
|
|
29
|
-
: undefined,
|
|
30
|
-
},
|
|
31
32
|
size: {
|
|
32
33
|
id: item.product_variant.size.id,
|
|
33
34
|
lookiero: item.product_variant.size.lookiero,
|
|
@@ -3,6 +3,16 @@ import { CheckoutItemProjection, Currency, MediaPerspective } from "../../../pro
|
|
|
3
3
|
interface CheckoutItemDto {
|
|
4
4
|
readonly id: string;
|
|
5
5
|
readonly status: CheckoutItemStatus;
|
|
6
|
+
readonly price: {
|
|
7
|
+
readonly amount: number;
|
|
8
|
+
readonly currency: Currency;
|
|
9
|
+
readonly discounted_price?: {
|
|
10
|
+
readonly amount: number;
|
|
11
|
+
readonly percentage: number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
readonly replaced_for?: string;
|
|
15
|
+
readonly feedback: Record<string, string>;
|
|
6
16
|
readonly product_variant: {
|
|
7
17
|
readonly id: string;
|
|
8
18
|
readonly media: {
|
|
@@ -12,14 +22,6 @@ interface CheckoutItemDto {
|
|
|
12
22
|
}[];
|
|
13
23
|
readonly brand: string;
|
|
14
24
|
readonly name: string;
|
|
15
|
-
readonly price: {
|
|
16
|
-
readonly amount: number;
|
|
17
|
-
readonly currency: Currency;
|
|
18
|
-
readonly discounted_price?: {
|
|
19
|
-
readonly amount: number;
|
|
20
|
-
readonly percentage: number;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
25
|
readonly size: {
|
|
24
26
|
readonly id: string;
|
|
25
27
|
readonly lookiero: string;
|
|
@@ -34,7 +36,6 @@ interface CheckoutItemDto {
|
|
|
34
36
|
readonly label: string;
|
|
35
37
|
};
|
|
36
38
|
};
|
|
37
|
-
readonly replaced_for?: string;
|
|
38
39
|
}
|
|
39
40
|
interface ToCheckoutItemProjectionFunction {
|
|
40
41
|
(checkoutItemDto: CheckoutItemDto): CheckoutItemProjection;
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
const toCheckoutItemProjection = (checkoutItemDto) => ({
|
|
2
2
|
id: checkoutItemDto.id,
|
|
3
3
|
status: checkoutItemDto.status,
|
|
4
|
+
price: {
|
|
5
|
+
amount: checkoutItemDto.price.amount,
|
|
6
|
+
currency: checkoutItemDto.price.currency,
|
|
7
|
+
discountedPrice: checkoutItemDto.price.discounted_price
|
|
8
|
+
? {
|
|
9
|
+
amount: checkoutItemDto.price.discounted_price.amount,
|
|
10
|
+
percentage: checkoutItemDto.price.discounted_price.percentage,
|
|
11
|
+
}
|
|
12
|
+
: undefined,
|
|
13
|
+
},
|
|
4
14
|
replacedFor: checkoutItemDto.replaced_for,
|
|
15
|
+
feedback: checkoutItemDto.feedback,
|
|
5
16
|
productVariant: {
|
|
6
17
|
id: checkoutItemDto.product_variant.id,
|
|
7
18
|
media: checkoutItemDto.product_variant.media.map((media) => ({
|
|
@@ -11,16 +22,6 @@ const toCheckoutItemProjection = (checkoutItemDto) => ({
|
|
|
11
22
|
})),
|
|
12
23
|
brand: checkoutItemDto.product_variant.brand,
|
|
13
24
|
name: checkoutItemDto.product_variant.name,
|
|
14
|
-
price: {
|
|
15
|
-
amount: checkoutItemDto.product_variant.price.amount,
|
|
16
|
-
currency: checkoutItemDto.product_variant.price.currency,
|
|
17
|
-
discountedPrice: checkoutItemDto.product_variant.price.discounted_price
|
|
18
|
-
? {
|
|
19
|
-
amount: checkoutItemDto.product_variant.price.discounted_price.amount,
|
|
20
|
-
percentage: checkoutItemDto.product_variant.price.discounted_price.percentage,
|
|
21
|
-
}
|
|
22
|
-
: undefined,
|
|
23
|
-
},
|
|
24
25
|
size: {
|
|
25
26
|
id: checkoutItemDto.product_variant.size.id,
|
|
26
27
|
lookiero: checkoutItemDto.product_variant.size.lookiero,
|
|
@@ -4,6 +4,11 @@ import { toCheckoutItemProjection } from "./checkoutItem";
|
|
|
4
4
|
const checkoutItemDto = ({ status }) => ({
|
|
5
5
|
id: uuid(),
|
|
6
6
|
status,
|
|
7
|
+
price: {
|
|
8
|
+
amount: 3999,
|
|
9
|
+
currency: Currency.EUR,
|
|
10
|
+
},
|
|
11
|
+
feedback: {},
|
|
7
12
|
product_variant: {
|
|
8
13
|
id: uuid(),
|
|
9
14
|
media: [
|
|
@@ -20,10 +25,6 @@ const checkoutItemDto = ({ status }) => ({
|
|
|
20
25
|
],
|
|
21
26
|
brand: "CKS",
|
|
22
27
|
name: "Sari Tshirt lines",
|
|
23
|
-
price: {
|
|
24
|
-
amount: 3999,
|
|
25
|
-
currency: Currency.EUR,
|
|
26
|
-
},
|
|
27
28
|
size: {
|
|
28
29
|
id: uuid(),
|
|
29
30
|
lookiero: "M",
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { ReturnQuestionType } from "../../../projection/returnQuestion/returnQuestion";
|
|
2
|
+
const returnQuestions = [
|
|
3
|
+
{
|
|
4
|
+
id: "efe07b97-f6fb-4b6a-ba92-b68519320b2c",
|
|
5
|
+
name: "main_title",
|
|
6
|
+
type: ReturnQuestionType.HOST_DEFAULT,
|
|
7
|
+
children: [
|
|
8
|
+
{
|
|
9
|
+
id: "ed396b68-1436-48ab-842f-fbfea996fad4",
|
|
10
|
+
name: "size",
|
|
11
|
+
placeholder: "size_placeholder",
|
|
12
|
+
type: ReturnQuestionType.HOST_SELECT,
|
|
13
|
+
children: [
|
|
14
|
+
{
|
|
15
|
+
id: "0ad1dba8-b02c-4121-a1e3-981f1c30800d",
|
|
16
|
+
name: "size_title",
|
|
17
|
+
type: ReturnQuestionType.HOST_STACK,
|
|
18
|
+
children: [
|
|
19
|
+
{
|
|
20
|
+
id: "9251dc2c-d76a-484d-9299-346929af932f",
|
|
21
|
+
name: "size_large",
|
|
22
|
+
type: ReturnQuestionType.OPTION,
|
|
23
|
+
children: [
|
|
24
|
+
{
|
|
25
|
+
id: "542c4d24-e1da-484f-8c3a-7d89ee135adc",
|
|
26
|
+
name: "",
|
|
27
|
+
type: ReturnQuestionType.HOST_STACK,
|
|
28
|
+
children: [
|
|
29
|
+
{
|
|
30
|
+
id: "68c0bb98-b00a-4b86-af43-528fe903cb69",
|
|
31
|
+
name: "size_overall",
|
|
32
|
+
type: ReturnQuestionType.OPTION,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: "85e84a77-461c-41e6-8544-95b5294d0b80",
|
|
36
|
+
name: "size_trousers_too_long",
|
|
37
|
+
type: ReturnQuestionType.OPTION,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: "29441d25-8d9f-471e-a13e-a03f61c88091",
|
|
41
|
+
name: "size_fit_cut_does_not_fit",
|
|
42
|
+
type: ReturnQuestionType.OPTION,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: "a081c3e9-1904-4a60-8899-b72c1a3a0291",
|
|
50
|
+
name: "size_correct",
|
|
51
|
+
type: ReturnQuestionType.OPTION,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: "624cce3d-bd86-463a-b16b-c862ad73d5f3",
|
|
55
|
+
name: "size_small",
|
|
56
|
+
type: ReturnQuestionType.OPTION,
|
|
57
|
+
children: [
|
|
58
|
+
{
|
|
59
|
+
id: "58e5ae9a-bc0d-4d27-b267-854a51c2a79a",
|
|
60
|
+
name: "",
|
|
61
|
+
type: ReturnQuestionType.HOST_STACK,
|
|
62
|
+
children: [
|
|
63
|
+
{
|
|
64
|
+
id: "6a3d11fc-570c-4085-a850-1967228cdd4c",
|
|
65
|
+
name: "size_overall",
|
|
66
|
+
type: ReturnQuestionType.OPTION,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: "c27e1936-deea-4dbe-a8f1-fe4fb8564deb",
|
|
70
|
+
name: "size_trousers_too_short",
|
|
71
|
+
type: ReturnQuestionType.OPTION,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: "e77232ae-eeec-4722-b2d3-f5c0d34fd0ca",
|
|
75
|
+
name: "size_fit_cut_does_not_fit",
|
|
76
|
+
type: ReturnQuestionType.OPTION,
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: "6a6d3878-5561-412c-96f3-7ed79ee587bb",
|
|
88
|
+
name: "style",
|
|
89
|
+
placeholder: "style_placeholder",
|
|
90
|
+
type: ReturnQuestionType.HOST_SELECT,
|
|
91
|
+
children: [
|
|
92
|
+
{
|
|
93
|
+
id: "fd7ff4a0-78ed-4c0d-aa4d-64962739c322",
|
|
94
|
+
name: "style_title",
|
|
95
|
+
type: ReturnQuestionType.HOST_STACK,
|
|
96
|
+
children: [
|
|
97
|
+
{
|
|
98
|
+
id: "56631448-d33d-49fb-b3f8-4486b68b60c3",
|
|
99
|
+
name: "style_i_love_it_but",
|
|
100
|
+
type: ReturnQuestionType.OPTION,
|
|
101
|
+
children: [
|
|
102
|
+
{
|
|
103
|
+
id: "90329d91-bd5d-4439-bb0a-b338caaeff2b",
|
|
104
|
+
name: "",
|
|
105
|
+
type: ReturnQuestionType.HOST_STACK,
|
|
106
|
+
children: [
|
|
107
|
+
{
|
|
108
|
+
id: "a3d937b6-7499-4a3c-86bf-5c0af9ab2e23",
|
|
109
|
+
name: "style_i_already_have_something_similar",
|
|
110
|
+
type: ReturnQuestionType.OPTION,
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
id: "7970edd3-fb5c-42d3-afe3-ce31bcbb856c",
|
|
114
|
+
name: "style_very_basic_simple",
|
|
115
|
+
type: ReturnQuestionType.OPTION,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
id: "bab3d4f9-0227-4550-a53f-3c125d68429c",
|
|
119
|
+
name: "style_i_dont_need_it_at_the_moment",
|
|
120
|
+
type: ReturnQuestionType.OPTION,
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
id: "5287d1df-a28a-42cd-9138-01f82aeea4c2",
|
|
128
|
+
name: "style_i_like_it_but",
|
|
129
|
+
type: ReturnQuestionType.OPTION,
|
|
130
|
+
children: [
|
|
131
|
+
{
|
|
132
|
+
id: "35b86395-6b6b-4a39-ab16-05511f58acdd",
|
|
133
|
+
name: "",
|
|
134
|
+
type: ReturnQuestionType.HOST_STACK,
|
|
135
|
+
children: [
|
|
136
|
+
{
|
|
137
|
+
id: "e1f6ac53-f203-4b32-9ff0-782c028d9e95",
|
|
138
|
+
name: "style_i_already_have_something_similar",
|
|
139
|
+
type: ReturnQuestionType.OPTION,
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
id: "12875926-b67a-4ad3-852c-1608c7dcc558",
|
|
143
|
+
name: "style_very_basic_simple",
|
|
144
|
+
type: ReturnQuestionType.OPTION,
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
id: "a5eb96bf-73d4-4df5-8ad8-097410b24526",
|
|
148
|
+
name: "style_i_dont_need_it_at_the_moment",
|
|
149
|
+
type: ReturnQuestionType.OPTION,
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
id: "757107a9-8e2d-4194-a7fe-0d55cde49c11",
|
|
157
|
+
name: "style_not_bad_but",
|
|
158
|
+
type: ReturnQuestionType.OPTION,
|
|
159
|
+
children: [
|
|
160
|
+
{
|
|
161
|
+
id: "c6f75ee3-a445-4103-a682-f0c3a742108d",
|
|
162
|
+
name: "",
|
|
163
|
+
type: ReturnQuestionType.HOST_STACK,
|
|
164
|
+
children: [
|
|
165
|
+
{
|
|
166
|
+
id: "4f46d4b1-b103-43b2-b669-be721ab46e03",
|
|
167
|
+
name: "style_i_dont_like_the_color",
|
|
168
|
+
type: ReturnQuestionType.OPTION,
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
id: "48412165-5e05-4806-8e21-ea59c41d0479",
|
|
172
|
+
name: "style_very_basic_simple",
|
|
173
|
+
type: ReturnQuestionType.OPTION,
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
id: "51262c01-eaa3-4d3a-aeb9-95dc8b0dd687",
|
|
177
|
+
name: "style_i_dont_like_the_fabric",
|
|
178
|
+
type: ReturnQuestionType.OPTION,
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
id: "9dea1c2b-4f8c-4192-a547-999df55e77e4",
|
|
182
|
+
name: "style_i_dont_like_the_print",
|
|
183
|
+
type: ReturnQuestionType.OPTION,
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
id: "b1277bf3-4bbb-487a-8e58-88efecc61c3f",
|
|
187
|
+
name: "style_not_my_style_in_general",
|
|
188
|
+
type: ReturnQuestionType.OPTION,
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
},
|
|
192
|
+
],
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
id: "8a9cd6f8-db4b-4904-8a48-3d9bbd6f7a69",
|
|
196
|
+
name: "style_i_dont_like",
|
|
197
|
+
type: ReturnQuestionType.OPTION,
|
|
198
|
+
children: [
|
|
199
|
+
{
|
|
200
|
+
id: "f604240d-c093-4a9e-ab85-4adc0744066a",
|
|
201
|
+
name: "",
|
|
202
|
+
type: ReturnQuestionType.HOST_STACK,
|
|
203
|
+
children: [
|
|
204
|
+
{
|
|
205
|
+
id: "42dbbb93-7808-4ac3-8431-582f812cb314",
|
|
206
|
+
name: "style_i_dont_like_the_color",
|
|
207
|
+
type: ReturnQuestionType.OPTION,
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
id: "af1ade81-7b22-4f7e-a505-2ae275a6440f",
|
|
211
|
+
name: "style_very_basic_simple",
|
|
212
|
+
type: ReturnQuestionType.OPTION,
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
id: "26d073b4-2588-4391-9b4c-e8e4a8eba2a8",
|
|
216
|
+
name: "style_i_dont_like_the_fabric",
|
|
217
|
+
type: ReturnQuestionType.OPTION,
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
id: "ee50ab07-b7a6-415e-a04a-c9f350396185",
|
|
221
|
+
name: "style_i_dont_like_the_print",
|
|
222
|
+
type: ReturnQuestionType.OPTION,
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
id: "ce3227e4-851e-47b7-98c1-c63a402e8477",
|
|
226
|
+
name: "style_not_my_style_in_general",
|
|
227
|
+
type: ReturnQuestionType.OPTION,
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
},
|
|
231
|
+
],
|
|
232
|
+
},
|
|
233
|
+
],
|
|
234
|
+
},
|
|
235
|
+
],
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
id: "a1acdb2d-62c8-467f-b7cc-dc24d967290c",
|
|
239
|
+
name: "quality",
|
|
240
|
+
placeholder: "quality_placeholder",
|
|
241
|
+
type: ReturnQuestionType.HOST_SELECT,
|
|
242
|
+
children: [
|
|
243
|
+
{
|
|
244
|
+
id: "405de847-188f-46c1-b66d-941c22a6b7a9",
|
|
245
|
+
name: "quality_title",
|
|
246
|
+
type: ReturnQuestionType.HOST_STACK,
|
|
247
|
+
children: [
|
|
248
|
+
{
|
|
249
|
+
id: "cce7851c-92c7-461b-8dcb-903c5de59ed1",
|
|
250
|
+
name: "quality_good",
|
|
251
|
+
type: ReturnQuestionType.OPTION,
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
id: "4bf8f27d-669b-4d36-8d39-b5599c671816",
|
|
255
|
+
name: "quality_regular",
|
|
256
|
+
type: ReturnQuestionType.OPTION,
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
id: "48bfe766-92c0-4ff5-a793-e107b60786ff",
|
|
260
|
+
name: "quality_bad",
|
|
261
|
+
type: ReturnQuestionType.OPTION,
|
|
262
|
+
},
|
|
263
|
+
],
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
id: "f25ccdcf-b648-479e-b4a1-86129e3e8c0b",
|
|
269
|
+
name: "price",
|
|
270
|
+
placeholder: "price_placeholder",
|
|
271
|
+
type: ReturnQuestionType.HOST_SELECT,
|
|
272
|
+
children: [
|
|
273
|
+
{
|
|
274
|
+
id: "b0e0463c-787f-4d6c-adf3-5151ab6fc959",
|
|
275
|
+
name: "price_title",
|
|
276
|
+
type: ReturnQuestionType.HOST_STACK,
|
|
277
|
+
children: [
|
|
278
|
+
{
|
|
279
|
+
id: "9c59e396-4135-4255-9437-22555837d686",
|
|
280
|
+
name: "price_expensive",
|
|
281
|
+
type: ReturnQuestionType.OPTION,
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
id: "10db17f8-0982-49ee-9aeb-f752d953654c",
|
|
285
|
+
name: "price_cheap",
|
|
286
|
+
type: ReturnQuestionType.OPTION,
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
id: "acf64bb3-b91b-48e7-bba1-0541620ed1c5",
|
|
290
|
+
name: "price_fair",
|
|
291
|
+
type: ReturnQuestionType.OPTION,
|
|
292
|
+
},
|
|
293
|
+
],
|
|
294
|
+
},
|
|
295
|
+
],
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
id: "b7ad1665-5e54-4ee4-b455-e7189f33083c",
|
|
299
|
+
name: "others",
|
|
300
|
+
placeholder: "others_placeholder",
|
|
301
|
+
type: ReturnQuestionType.HOST_SELECT,
|
|
302
|
+
children: [
|
|
303
|
+
{
|
|
304
|
+
id: "32cd0ef9-78d7-4605-a279-556749b36d4a",
|
|
305
|
+
name: "others_title",
|
|
306
|
+
type: ReturnQuestionType.HOST_STACK,
|
|
307
|
+
children: [
|
|
308
|
+
{
|
|
309
|
+
id: "95c4fd13-9ca3-45a6-8795-23415bbd0a5e",
|
|
310
|
+
name: "others_i_dont_like_the_brand",
|
|
311
|
+
type: ReturnQuestionType.OPTION,
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
id: "f25c63bd-42d3-4242-9b81-927025aa9d67",
|
|
315
|
+
name: "others_different_from_preview",
|
|
316
|
+
type: ReturnQuestionType.OPTION,
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
id: "0e0b16c1-a721-4a14-aea6-e0cf5c262222",
|
|
320
|
+
name: "others_delivery_delay",
|
|
321
|
+
type: ReturnQuestionType.OPTION,
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
id: "11699ae8-325d-429c-9c05-ff2d6cc45d54",
|
|
325
|
+
name: "others_item_is_defective",
|
|
326
|
+
type: ReturnQuestionType.OPTION,
|
|
327
|
+
},
|
|
328
|
+
],
|
|
329
|
+
},
|
|
330
|
+
],
|
|
331
|
+
},
|
|
332
|
+
],
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
id: "ce3e8d57-5eea-4dd3-bef4-2e811a143612",
|
|
336
|
+
name: "comment_title",
|
|
337
|
+
type: ReturnQuestionType.HOST_DEFAULT,
|
|
338
|
+
children: [
|
|
339
|
+
{
|
|
340
|
+
id: "1123a37d-bc00-43a4-9d28-cee1dfaf356c",
|
|
341
|
+
name: "comment_textarea",
|
|
342
|
+
placeholder: "comment_textarea_placeholder",
|
|
343
|
+
type: ReturnQuestionType.TEXTAREA,
|
|
344
|
+
},
|
|
345
|
+
],
|
|
346
|
+
},
|
|
347
|
+
];
|
|
348
|
+
export { returnQuestions };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ReturnQuestionProjection } from "../../../../../projection/returnQuestion/returnQuestion";
|
|
3
|
+
interface ReturnQuestionProps {
|
|
4
|
+
readonly returnQuestionParentId: string;
|
|
5
|
+
readonly returnQuestion: ReturnQuestionProjection;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: React.NamedExoticComponent<ReturnQuestionProps>;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { memo, useCallback } from "react";
|
|
2
|
+
import { useReturnQuestionFeedbackForId } from "./behaviors/useReturnQuestionFeedback";
|
|
3
|
+
import { useReturnQuestionItem } from "./behaviors/useReturnQuestionItem";
|
|
4
|
+
const ReturnQuestion = ({ returnQuestion, returnQuestionParentId }) => {
|
|
5
|
+
const Item = useReturnQuestionItem({ type: returnQuestion.type });
|
|
6
|
+
const { onChange } = useReturnQuestionFeedbackForId({ id: returnQuestion.id });
|
|
7
|
+
const handleOnChange = useCallback(({ feedback }) => onChange({ returnQuestionId: returnQuestionParentId, returnQuestionFeedback: feedback }), [onChange, returnQuestionParentId]);
|
|
8
|
+
return (React.createElement(Item, { returnQuestion: returnQuestion, onChange: handleOnChange },
|
|
9
|
+
React.createElement(React.Fragment, null, returnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, returnQuestion: childReturnQuestion, returnQuestionParentId: returnQuestion.id }))))));
|
|
10
|
+
};
|
|
11
|
+
export default memo(ReturnQuestion);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { ReturnQuestionProjection } from "../../../../../projection/returnQuestion/returnQuestion";
|
|
3
|
+
interface ReturnQuestionsProps {
|
|
4
|
+
readonly returnQuestions: ReturnQuestionProjection[];
|
|
5
|
+
}
|
|
6
|
+
declare const ReturnQuestions: FC<ReturnQuestionsProps>;
|
|
7
|
+
export { ReturnQuestions };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import ReturnQuestion from "./ReturnQuestion";
|
|
3
|
+
const ReturnQuestions = ({ returnQuestions }) => (React.createElement(React.Fragment, null, returnQuestions.map((returnQuestion) => (React.createElement(ReturnQuestion, { key: returnQuestion.id, returnQuestion: returnQuestion, returnQuestionParentId: "" })))));
|
|
4
|
+
export { ReturnQuestions };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FC, ReactNode } from "react";
|
|
2
|
+
import { FeedbackProjection } from "../../../../../../projection/feedback/feedback";
|
|
3
|
+
interface OnChangeReturnQuestionFeedbackFunctionArgs {
|
|
4
|
+
readonly returnQuestionId: string;
|
|
5
|
+
readonly returnQuestionFeedback: string | undefined;
|
|
6
|
+
}
|
|
7
|
+
interface OnChangeReturnQuestionFeedbackFunction {
|
|
8
|
+
(args: OnChangeReturnQuestionFeedbackFunctionArgs): void;
|
|
9
|
+
}
|
|
10
|
+
interface ReturnQuestionFeedbackContextProviderProps {
|
|
11
|
+
readonly feedback: FeedbackProjection | undefined;
|
|
12
|
+
readonly children: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
declare const ReturnQuestionFeedbackProvider: FC<ReturnQuestionFeedbackContextProviderProps>;
|
|
15
|
+
interface UseReturnQuestionFeedbackForIdFunctionArgs {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
}
|
|
18
|
+
interface UseReturnQuestionFeedbackForIdFunction {
|
|
19
|
+
(args: UseReturnQuestionFeedbackForIdFunctionArgs): {
|
|
20
|
+
readonly feedback: string | undefined;
|
|
21
|
+
readonly onChange: OnChangeReturnQuestionFeedbackFunction;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
declare const useReturnQuestionFeedbackForId: UseReturnQuestionFeedbackForIdFunction;
|
|
25
|
+
interface UseReturnQuestionFeedbackFunction {
|
|
26
|
+
(): FeedbackProjection;
|
|
27
|
+
}
|
|
28
|
+
declare const useReturnQuestionFeedback: UseReturnQuestionFeedbackFunction;
|
|
29
|
+
export { useReturnQuestionFeedbackForId, useReturnQuestionFeedback, ReturnQuestionFeedbackProvider };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { createContext, useCallback, useContext, useMemo, useState } from "react";
|
|
2
|
+
import invariant from "tiny-invariant";
|
|
3
|
+
const ReturnQuestionFeedbackContext = createContext(null);
|
|
4
|
+
const ReturnQuestionFeedbackProvider = ({ feedback = {}, children, }) => {
|
|
5
|
+
const [contextFeedback, setContextFeedback] = useState(feedback);
|
|
6
|
+
const onChange = useCallback(({ returnQuestionId, returnQuestionFeedback }) => setContextFeedback((feedback) => returnQuestionFeedback
|
|
7
|
+
? { ...feedback, [returnQuestionId]: returnQuestionFeedback }
|
|
8
|
+
: Object.entries(feedback).reduce((acc, [id, feedback]) => (id !== returnQuestionId ? { ...acc, [id]: feedback } : acc), {})), []);
|
|
9
|
+
const value = useMemo(() => ({
|
|
10
|
+
feedback: contextFeedback,
|
|
11
|
+
onChange,
|
|
12
|
+
}), [contextFeedback, onChange]);
|
|
13
|
+
return React.createElement(ReturnQuestionFeedbackContext.Provider, { value: value }, children);
|
|
14
|
+
};
|
|
15
|
+
const useReturnQuestionFeedbackForId = ({ id }) => {
|
|
16
|
+
const returnQuestionFeedbackContext = useContext(ReturnQuestionFeedbackContext);
|
|
17
|
+
invariant(returnQuestionFeedbackContext, "Your are trying to use the useReturnQuestionFeedbackForId hook without wrapping your app with the <ReturnQuestionFeedbackProvider>.");
|
|
18
|
+
const { feedback, onChange } = returnQuestionFeedbackContext;
|
|
19
|
+
return { feedback: feedback[id], onChange };
|
|
20
|
+
};
|
|
21
|
+
const useReturnQuestionFeedback = () => {
|
|
22
|
+
const returnQuestionFeedbackContext = useContext(ReturnQuestionFeedbackContext);
|
|
23
|
+
invariant(returnQuestionFeedbackContext, "Your are trying to use the useReturnQuestionFeedback hook without wrapping your app with the <ReturnQuestionFeedbackProvider>.");
|
|
24
|
+
const { feedback } = returnQuestionFeedbackContext;
|
|
25
|
+
return feedback;
|
|
26
|
+
};
|
|
27
|
+
export { useReturnQuestionFeedbackForId, useReturnQuestionFeedback, ReturnQuestionFeedbackProvider };
|