@lookiero/checkout 12.3.0 → 12.5.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/integration/checkout.spec.ts +14 -9
- package/cypress/support/interceptViewCheckoutFeedbackDefinitionByCheckoutId.ts +6 -0
- package/dist/public/public/assets/adaptive-icon.png +0 -0
- package/dist/public/public/assets/favicon.png +0 -0
- package/dist/public/public/assets/icon.png +0 -0
- package/dist/public/public/assets/splash.png +0 -0
- package/dist/public/public/images/not-found.png +0 -0
- package/dist/src/ExpoRoot.js +2 -2
- package/dist/src/domain/checkoutItem/model/currency.d.ts +6 -0
- package/dist/src/domain/checkoutItem/model/currency.js +7 -0
- package/dist/src/domain/uiSetting/command/updateUiSetting.d.ts +15 -0
- package/dist/src/domain/uiSetting/command/updateUiSetting.js +10 -0
- package/dist/src/domain/uiSetting/model/uiSetting.d.ts +9 -0
- package/dist/src/domain/uiSetting/model/uiSetting.js +11 -0
- package/dist/src/domain/uiSetting/model/uiSettingUpdated.d.ts +15 -0
- package/dist/src/domain/uiSetting/model/uiSettingUpdated.js +8 -0
- package/dist/src/domain/uiSetting/model/uiSettings.d.ts +7 -0
- package/dist/src/domain/uiSetting/model/uiSettings.js +1 -0
- package/dist/src/infrastructure/delivery/baseBootstrap.d.ts +2 -2
- package/dist/src/infrastructure/delivery/baseBootstrap.js +4 -4
- package/dist/src/infrastructure/delivery/bootstrap.js +2 -2
- package/dist/src/infrastructure/delivery/bootstrap.mock.js +3 -3
- package/dist/src/infrastructure/domain/uiSetting/model/storageUiSettings.d.ts +17 -0
- package/dist/src/infrastructure/domain/uiSetting/model/storageUiSettings.js +20 -0
- package/dist/src/infrastructure/domain/uiSetting/react/useUpdateUiSetting.d.ts +18 -0
- package/dist/src/infrastructure/domain/uiSetting/react/useUpdateUiSetting.js +22 -0
- package/dist/src/infrastructure/integration/useRedirect.d.ts +7 -0
- package/dist/src/infrastructure/integration/useRedirect.js +1 -0
- package/dist/src/infrastructure/persistence/asyncStorageStorage.d.ts +5 -0
- package/dist/src/infrastructure/persistence/asyncStorageStorage.js +7 -0
- package/dist/src/infrastructure/persistence/uiSettingData.d.ts +6 -0
- package/dist/src/infrastructure/persistence/uiSettingData.js +1 -0
- package/dist/src/infrastructure/projection/checkoutFeedback/checkoutFeedbackDefinition.mock.d.ts +3 -0
- package/dist/src/infrastructure/projection/checkoutFeedback/checkoutFeedbackDefinition.mock.js +107 -0
- package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.d.ts +12 -0
- package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.js +10 -0
- package/dist/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.d.ts +10 -0
- package/dist/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.js +9 -0
- package/dist/src/infrastructure/projection/returnQuestion/returnQuestions.mock.js +47 -58
- package/dist/src/infrastructure/projection/uiSetting/react/useViewUiSettingByKey.d.ts +10 -0
- package/dist/src/infrastructure/projection/uiSetting/react/useViewUiSettingByKey.js +11 -0
- package/dist/src/infrastructure/projection/uiSetting/storageUiSettingByKeyView.d.ts +13 -0
- package/dist/src/infrastructure/projection/uiSetting/storageUiSettingByKeyView.js +15 -0
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.d.ts +2 -2
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.js +4 -2
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.d.ts +2 -2
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.d.ts +5 -5
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.js +1 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/CheckoutQuestionItem.d.ts +5 -4
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.d.ts +2 -3
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.js +5 -7
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.js +1 -2
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.d.ts +4 -0
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.js +17 -0
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.style.d.ts +11 -0
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.style.js +16 -0
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.d.ts +1 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.js +3 -5
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.js +2 -3
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.js +2 -4
- package/dist/src/infrastructure/ui/hooks/useSubmitCheckout.d.ts +27 -0
- package/dist/src/infrastructure/ui/hooks/useSubmitCheckout.js +97 -0
- package/dist/src/infrastructure/ui/routing/useBasePath.d.ts +8 -0
- package/dist/src/infrastructure/ui/routing/useBasePath.js +9 -0
- package/dist/src/infrastructure/ui/settings/UISettings.d.ts +3 -0
- package/dist/src/infrastructure/ui/settings/UISettings.js +4 -0
- package/dist/src/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.d.ts +12 -0
- package/dist/src/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.js +90 -0
- package/dist/src/infrastructure/ui/views/feedback/Feedback.js +10 -9
- package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.d.ts +2 -3
- package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.js +17 -9
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.js +1 -0
- package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.js +3 -1
- package/dist/src/projection/checkoutFeedback/checkoutFeedback.constants.d.ts +11 -0
- package/dist/src/projection/checkoutFeedback/checkoutFeedback.constants.js +10 -0
- package/dist/src/projection/checkoutFeedback/checkoutFeedback.d.ts +22 -2
- package/dist/src/projection/checkoutFeedback/checkoutFeedback.metadata.d.ts +21 -0
- package/dist/src/projection/checkoutFeedback/checkoutFeedback.metadata.js +1 -0
- package/dist/src/projection/checkoutFeedback/checkoutFeedback.typeguards.d.ts +3 -0
- package/dist/src/projection/checkoutFeedback/checkoutFeedback.typeguards.js +7 -0
- package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.d.ts +25 -0
- package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.js +8 -0
- package/dist/src/projection/returnQuestion/returnQuestion.constants.d.ts +1 -0
- package/dist/src/projection/returnQuestion/returnQuestion.constants.js +1 -0
- package/dist/src/projection/returnQuestion/returnQuestion.d.ts +2 -2
- package/dist/src/projection/returnQuestion/returnQuestion.typeguard.d.ts +2 -4
- package/dist/src/projection/returnQuestion/returnQuestion.typeguard.js +2 -2
- package/dist/src/projection/uiSetting/viewUiSettingByKey.d.ts +29 -0
- package/dist/src/projection/uiSetting/viewUiSettingByKey.js +8 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
- package/src/ExpoRoot.tsx +2 -2
- package/src/infrastructure/delivery/baseBootstrap.ts +9 -9
- package/src/infrastructure/delivery/bootstrap.mock.ts +5 -4
- package/src/infrastructure/delivery/bootstrap.ts +2 -2
- package/src/infrastructure/projection/checkoutFeedback/checkoutFeedbackDefinition.mock.ts +110 -0
- package/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.test.ts +52 -0
- package/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.ts +30 -0
- package/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.test.ts +58 -0
- package/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.ts +25 -0
- package/src/infrastructure/projection/returnQuestion/returnQuestions.mock.ts +47 -58
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.test.tsx +25 -30
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.tsx +12 -13
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.test.tsx +19 -26
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.tsx +3 -3
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.test.tsx +26 -26
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.tsx +6 -6
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/CheckoutQuestionItem.ts +5 -4
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.test.tsx +7 -11
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.tsx +6 -4
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.tsx +6 -4
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultReturnQuestionItem.test.tsx +16 -10
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.test.tsx +16 -22
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.tsx +6 -4
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.test.tsx +16 -14
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.tsx +13 -14
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.test.tsx +9 -19
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.tsx +7 -5
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.tsx +1 -2
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.style.ts +19 -0
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.tsx +36 -0
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.test.tsx +46 -0
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.tsx +7 -12
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.tsx +6 -5
- package/src/infrastructure/ui/components/organisms/returnQuestions/util/__snapshots__/returnQuestionFeedback.test.ts.snap +22 -2
- package/src/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.ts +2 -7
- package/src/infrastructure/ui/views/feedback/Feedback.test.tsx +11 -5
- package/src/infrastructure/ui/views/feedback/Feedback.tsx +10 -9
- package/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.test.tsx +2 -2
- package/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.tsx +20 -13
- package/src/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.tsx +1 -0
- package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.tsx +3 -1
- package/src/projection/checkoutFeedback/checkoutFeedback.constants.ts +16 -0
- package/src/projection/checkoutFeedback/checkoutFeedback.metadata.ts +28 -0
- package/src/projection/checkoutFeedback/checkoutFeedback.ts +38 -2
- package/src/projection/checkoutFeedback/checkoutFeedback.typeguards.ts +13 -0
- package/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.test.ts +52 -0
- package/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.ts +61 -0
- package/src/projection/returnQuestion/returnQuestion.constants.ts +1 -0
- package/src/projection/returnQuestion/returnQuestion.ts +6 -2
- package/src/projection/returnQuestion/returnQuestion.typeguard.ts +3 -11
- package/cypress/support/interceptListCheckoutQuestionsByCheckoutId.ts +0 -9
- package/src/infrastructure/projection/checkoutQuestion/checkoutQuestions.mock.ts +0 -108
- package/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.test.ts +0 -55
- package/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.ts +0 -34
- package/src/infrastructure/projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId.test.ts +0 -38
- package/src/infrastructure/projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId.ts +0 -21
- package/src/projection/checkoutQuestion/checkoutQuestion.ts +0 -20
- package/src/projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId.test.ts +0 -31
- package/src/projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId.ts +0 -61
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { useCallback, useMemo, useState } from "react";
|
|
2
|
+
import { CommandStatus } from "@lookiero/messaging-react";
|
|
3
|
+
import { NotificationLevel, useCreateToastNotification } from "@lookiero/sty-psp-notifications";
|
|
4
|
+
import { viewCheckoutBookingById, } from "../../../projection/checkoutBooking/viewCheckoutBookingById";
|
|
5
|
+
import { MESSAGING_CONTEXT_ID } from "../../delivery/baseBootstrap";
|
|
6
|
+
import { useSubmitCheckout as useSubmitCheckoutCommand } from "../../domain/checkout/react/useSubmitCheckout";
|
|
7
|
+
import { useBlockCheckoutBooking } from "../../domain/checkoutBooking/react/useBlockCheckoutBooking";
|
|
8
|
+
import { I18nMessages } from "../i18n/i18n";
|
|
9
|
+
import { useQueryBus } from "./useQueryBus";
|
|
10
|
+
var ChargeStatus;
|
|
11
|
+
(function (ChargeStatus) {
|
|
12
|
+
ChargeStatus["EXECUTED"] = "EXECUTED";
|
|
13
|
+
ChargeStatus["REQUIRES_ACTION"] = "REQUIRES_ACTION";
|
|
14
|
+
ChargeStatus["REQUIRED_ACTION_CANCELLED"] = "REQUIRED_ACTION_CANCELLED";
|
|
15
|
+
ChargeStatus["REJECTED"] = "REJECTED";
|
|
16
|
+
ChargeStatus["CANCELLED"] = "CANCELLED";
|
|
17
|
+
ChargeStatus["TO_CONFIRM"] = "TO_CONFIRM";
|
|
18
|
+
ChargeStatus["ERROR"] = "ERROR";
|
|
19
|
+
ChargeStatus["UNKNOWN"] = "UNKNOWN";
|
|
20
|
+
})(ChargeStatus || (ChargeStatus = {}));
|
|
21
|
+
const useSubmitCheckout = ({ checkoutId, checkoutBookingId, paymentFlowRef, onError, onSuccess, logger, }) => {
|
|
22
|
+
const queryBus = useQueryBus();
|
|
23
|
+
const [submitCheckoutCommand, submitCheckoutCommandStatus] = useSubmitCheckoutCommand({ checkoutId, logger });
|
|
24
|
+
const [blockCheckoutBooking, blockCheckoutBookingStatus] = useBlockCheckoutBooking({ checkoutBookingId, logger });
|
|
25
|
+
const [createNotification] = useCreateToastNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
|
|
26
|
+
const [checkoutBookingExpired, setCheckoutBookingExpired] = useState(false);
|
|
27
|
+
const [startLegacyBoxCheckoutStatus, setStartLegacyBoxCheckoutStatus] = useState("idle");
|
|
28
|
+
const submitCheckout = useCallback(async ({ paymentFlowPayload, sizeChangeEnabled }) => {
|
|
29
|
+
try {
|
|
30
|
+
sizeChangeEnabled && (await blockCheckoutBooking());
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const checkoutBooking = await queryBus(viewCheckoutBookingById({ checkoutBookingId }));
|
|
36
|
+
if (checkoutBooking?.isExpired) {
|
|
37
|
+
setCheckoutBookingExpired(true);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
paymentFlowRef.current?.startLegacyBoxCheckout(
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
paymentFlowPayload, async ({ status, toaster, final }) => {
|
|
44
|
+
setStartLegacyBoxCheckoutStatus("loading");
|
|
45
|
+
if (final) {
|
|
46
|
+
if (status === ChargeStatus.EXECUTED) {
|
|
47
|
+
setStartLegacyBoxCheckoutStatus("success");
|
|
48
|
+
await submitCheckoutCommand();
|
|
49
|
+
onSuccess?.();
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
createNotification({
|
|
53
|
+
level: NotificationLevel.ERROR,
|
|
54
|
+
bodyI18nKey: toaster?.id || I18nMessages.CHECKOUT_TOAST_PAYMENT_ERROR,
|
|
55
|
+
});
|
|
56
|
+
setStartLegacyBoxCheckoutStatus("error");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}, [
|
|
61
|
+
queryBus,
|
|
62
|
+
checkoutBookingId,
|
|
63
|
+
paymentFlowRef,
|
|
64
|
+
blockCheckoutBooking,
|
|
65
|
+
submitCheckoutCommand,
|
|
66
|
+
onSuccess,
|
|
67
|
+
createNotification,
|
|
68
|
+
]);
|
|
69
|
+
const status = useMemo(() => {
|
|
70
|
+
if (blockCheckoutBookingStatus === CommandStatus.LOADING ||
|
|
71
|
+
startLegacyBoxCheckoutStatus === "loading" ||
|
|
72
|
+
submitCheckoutCommandStatus === CommandStatus.LOADING) {
|
|
73
|
+
return "loading";
|
|
74
|
+
}
|
|
75
|
+
if (blockCheckoutBookingStatus === CommandStatus.SUCCESS &&
|
|
76
|
+
startLegacyBoxCheckoutStatus === "success" &&
|
|
77
|
+
submitCheckoutCommandStatus === CommandStatus.SUCCESS) {
|
|
78
|
+
return "success";
|
|
79
|
+
}
|
|
80
|
+
if (blockCheckoutBookingStatus === CommandStatus.ERROR ||
|
|
81
|
+
startLegacyBoxCheckoutStatus === "error" ||
|
|
82
|
+
submitCheckoutCommandStatus === CommandStatus.ERROR ||
|
|
83
|
+
checkoutBookingExpired) {
|
|
84
|
+
onError();
|
|
85
|
+
return "error";
|
|
86
|
+
}
|
|
87
|
+
return "idle";
|
|
88
|
+
}, [
|
|
89
|
+
blockCheckoutBookingStatus,
|
|
90
|
+
startLegacyBoxCheckoutStatus,
|
|
91
|
+
submitCheckoutCommandStatus,
|
|
92
|
+
checkoutBookingExpired,
|
|
93
|
+
onError,
|
|
94
|
+
]);
|
|
95
|
+
return [submitCheckout, status];
|
|
96
|
+
};
|
|
97
|
+
export { useSubmitCheckout };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React, { createContext, useContext } from "react";
|
|
2
|
+
import invariant from "tiny-invariant";
|
|
3
|
+
const BasePathContext = createContext(null);
|
|
4
|
+
export const BasePathProvider = ({ basePath, children }) => (React.createElement(BasePathContext.Provider, { value: basePath }, children));
|
|
5
|
+
export const useBasePath = () => {
|
|
6
|
+
const basePath = useContext(BasePathContext);
|
|
7
|
+
invariant(basePath !== null, "Your are trying to use the useBasePath hook without wrapping your app with the <BasePathProvider>.");
|
|
8
|
+
return basePath;
|
|
9
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { Subscription } from "../../../../../../projection/subscription/subscription";
|
|
3
|
+
interface CheckoutPaymentModalProps {
|
|
4
|
+
readonly coupon: string | null;
|
|
5
|
+
readonly orderNumber: number;
|
|
6
|
+
readonly isFirstOrder: boolean;
|
|
7
|
+
readonly subscription: Subscription;
|
|
8
|
+
readonly getAuthToken: () => Promise<string>;
|
|
9
|
+
readonly onCheckoutSubmitted?: () => void;
|
|
10
|
+
}
|
|
11
|
+
declare const CheckoutPaymentModal: FC<CheckoutPaymentModalProps>;
|
|
12
|
+
export { CheckoutPaymentModal };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { useNavigate } from "react-router-native";
|
|
3
|
+
import { QueryStatus } from "@lookiero/messaging-react";
|
|
4
|
+
import { PaymentFlow } from "@lookiero/payments-front";
|
|
5
|
+
import { useLogger } from "@lookiero/sty-psp-logging";
|
|
6
|
+
import { CheckoutItemStatus } from "../../../../../../domain/checkoutItem/model/checkoutItem";
|
|
7
|
+
import { useViewFirstAvailableCheckoutByCustomerId } from "../../../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
8
|
+
import { useViewIsSizeChangeEnabledByCheckoutId } from "../../../../../projection/checkout/react/useViewIsSizeChangeEnabledByCheckoutId";
|
|
9
|
+
import { useViewPaymentFlowPayloadByCheckoutId } from "../../../../../projection/payment/react/useViewPaymentFlowPayloadByCheckoutId";
|
|
10
|
+
import { useViewPricingByCheckoutId } from "../../../../../projection/pricing/react/useViewPricingByCheckoutId";
|
|
11
|
+
import { TrackingPage } from "../../../../../tracking/tracking";
|
|
12
|
+
import { useTrackCheckout } from "../../../../../tracking/useTrackCheckout";
|
|
13
|
+
import { useStaticInfo } from "../../../../hooks/useStaticInfo";
|
|
14
|
+
import { useSubmitCheckout } from "../../../../hooks/useSubmitCheckout";
|
|
15
|
+
import { Routes } from "../../../../routing/routes";
|
|
16
|
+
import { useBasePath } from "../../../../routing/useBasePath";
|
|
17
|
+
const CheckoutPaymentModal = ({ coupon, isFirstOrder, subscription, orderNumber, getAuthToken, onCheckoutSubmitted, }) => {
|
|
18
|
+
const paymentFlowRef = useRef(null);
|
|
19
|
+
const logger = useLogger();
|
|
20
|
+
const { customer: { customerId, country, segment }, } = useStaticInfo();
|
|
21
|
+
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
22
|
+
const [paymentFlowPayload] = useViewPaymentFlowPayloadByCheckoutId({
|
|
23
|
+
checkoutId: checkout?.id,
|
|
24
|
+
});
|
|
25
|
+
const [sizeChangeEnabled] = useViewIsSizeChangeEnabledByCheckoutId({ checkoutId: checkout?.id });
|
|
26
|
+
const [pricing] = useViewPricingByCheckoutId({
|
|
27
|
+
checkoutId: checkout?.id,
|
|
28
|
+
queryOptions: { refetchOnMount: true },
|
|
29
|
+
});
|
|
30
|
+
const [authToken, setAuthToken] = useState();
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const loadAuthToken = async () => setAuthToken(await getAuthToken());
|
|
33
|
+
loadAuthToken();
|
|
34
|
+
}, [getAuthToken]);
|
|
35
|
+
const basePath = useBasePath();
|
|
36
|
+
const navigate = useNavigate();
|
|
37
|
+
const trackCheckout = useTrackCheckout({
|
|
38
|
+
page: TrackingPage.CHECKOUT,
|
|
39
|
+
checkoutId: checkout?.id,
|
|
40
|
+
country,
|
|
41
|
+
segment,
|
|
42
|
+
});
|
|
43
|
+
const handleOnSubmitCheckoutError = useCallback(() => navigate(`${basePath}/${Routes.CHECKOUT}`, { replace: true }), [basePath, navigate]);
|
|
44
|
+
const handleOnSubmitCheckoutSuccess = useCallback(() => {
|
|
45
|
+
const checkoutItemsKept = checkout?.items.filter((checkoutItem) => checkoutItem.status === CheckoutItemStatus.KEPT || checkoutItem.status === CheckoutItemStatus.REPLACED);
|
|
46
|
+
const totalReplacedFor = checkoutItemsKept?.filter(({ replacedFor }) => Boolean(replacedFor)).length || 0;
|
|
47
|
+
trackCheckout({
|
|
48
|
+
totalCheckoutItemsKept: checkoutItemsKept?.length || 0,
|
|
49
|
+
pendingToPay: pricing?.pendingToPay.amount / 100,
|
|
50
|
+
coupon,
|
|
51
|
+
currencyCode: pricing?.pendingToPay.currency,
|
|
52
|
+
isFirstOrder,
|
|
53
|
+
orderNumber,
|
|
54
|
+
totalReplacedFor,
|
|
55
|
+
subscription,
|
|
56
|
+
userId: customerId,
|
|
57
|
+
});
|
|
58
|
+
onCheckoutSubmitted?.();
|
|
59
|
+
}, [
|
|
60
|
+
checkout?.items,
|
|
61
|
+
coupon,
|
|
62
|
+
customerId,
|
|
63
|
+
isFirstOrder,
|
|
64
|
+
onCheckoutSubmitted,
|
|
65
|
+
orderNumber,
|
|
66
|
+
pricing?.pendingToPay.amount,
|
|
67
|
+
pricing?.pendingToPay.currency,
|
|
68
|
+
subscription,
|
|
69
|
+
trackCheckout,
|
|
70
|
+
]);
|
|
71
|
+
const [submitCheckout] = useSubmitCheckout({
|
|
72
|
+
checkoutId: checkout?.id,
|
|
73
|
+
checkoutBookingId: checkout?.checkoutBookingId,
|
|
74
|
+
paymentFlowRef,
|
|
75
|
+
onError: handleOnSubmitCheckoutError,
|
|
76
|
+
onSuccess: handleOnSubmitCheckoutSuccess,
|
|
77
|
+
logger,
|
|
78
|
+
});
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (paymentFlowPayload && sizeChangeEnabled !== undefined && pricing !== undefined) {
|
|
81
|
+
submitCheckout({ paymentFlowPayload, sizeChangeEnabled });
|
|
82
|
+
}
|
|
83
|
+
}, [paymentFlowPayload, pricing, sizeChangeEnabled, submitCheckout]);
|
|
84
|
+
const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
|
|
85
|
+
const dependenciesLoaded = (dependenciesLoadedStatuses.includes(checkoutStatus) || checkout) && authToken;
|
|
86
|
+
if (!dependenciesLoaded)
|
|
87
|
+
return null;
|
|
88
|
+
return React.createElement(PaymentFlow, { ref: paymentFlowRef, token: authToken });
|
|
89
|
+
};
|
|
90
|
+
export { CheckoutPaymentModal };
|
|
@@ -3,10 +3,10 @@ import { Spinner } from "@lookiero/aurora";
|
|
|
3
3
|
import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
|
|
4
4
|
import { useLogger } from "@lookiero/sty-psp-logging";
|
|
5
5
|
import { useScreenSize } from "@lookiero/sty-psp-ui";
|
|
6
|
-
import {
|
|
6
|
+
import { CheckoutFeedbackQuestionType } from "../../../../projection/checkoutFeedback/checkoutFeedback.constants";
|
|
7
7
|
import { useGiveCheckoutFeedback } from "../../../domain/checkoutFeedback/react/useGiveCheckoutFeedback";
|
|
8
8
|
import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
9
|
-
import {
|
|
9
|
+
import { useViewCheckoutFeedbackDefinitionByCheckoutId } from "../../../projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId";
|
|
10
10
|
import { TrackingPage } from "../../../tracking/tracking";
|
|
11
11
|
import { useTrackChangeFeedback } from "../../../tracking/useTrackChangeFeedback";
|
|
12
12
|
import { useTrackPageView } from "../../../tracking/useTrackPageView";
|
|
@@ -23,7 +23,7 @@ const Feedback = ({ layout: Layout }) => {
|
|
|
23
23
|
const { customer: { customerId, country, segment }, tradename, } = useStaticInfo();
|
|
24
24
|
const style = useMemo(() => feedbackStyle(), []);
|
|
25
25
|
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
26
|
-
const [
|
|
26
|
+
const [checkoutFeedbackDefinition, checkoutFeedbackDefinitionStatus] = useViewCheckoutFeedbackDefinitionByCheckoutId({
|
|
27
27
|
checkoutId: checkout?.id,
|
|
28
28
|
});
|
|
29
29
|
useTrackPageView({
|
|
@@ -41,16 +41,16 @@ const Feedback = ({ layout: Layout }) => {
|
|
|
41
41
|
tradename,
|
|
42
42
|
});
|
|
43
43
|
const handleOnChangedFeedback = useCallback(({ checkoutQuestionId, checkoutQuestionFeedback, hasFeedback }) => {
|
|
44
|
-
const question =
|
|
45
|
-
if (question?.type ===
|
|
44
|
+
const question = checkoutFeedbackDefinition?.find((question) => question.id === checkoutQuestionId);
|
|
45
|
+
if (question?.type === CheckoutFeedbackQuestionType.HOST_TEXTAREA && hasFeedback) {
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
trackChangeFeedback({
|
|
49
49
|
questionId: checkoutQuestionId,
|
|
50
|
-
questionName: question?.
|
|
50
|
+
questionName: question?.translationKey || "",
|
|
51
51
|
feedback: checkoutQuestionFeedback,
|
|
52
52
|
});
|
|
53
|
-
}, [
|
|
53
|
+
}, [checkoutFeedbackDefinition, trackChangeFeedback]);
|
|
54
54
|
const [giveCheckoutFeedback, giveCheckoutFeedbackStatus] = useGiveCheckoutFeedback({
|
|
55
55
|
checkoutId: checkout?.id,
|
|
56
56
|
logger,
|
|
@@ -81,12 +81,13 @@ const Feedback = ({ layout: Layout }) => {
|
|
|
81
81
|
}
|
|
82
82
|
}, [giveCheckoutFeedback]);
|
|
83
83
|
const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
|
|
84
|
-
const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus) &&
|
|
84
|
+
const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus) &&
|
|
85
|
+
dependenciesLoadedStatuses.includes(checkoutFeedbackDefinitionStatus);
|
|
85
86
|
if (!dependenciesLoaded)
|
|
86
87
|
return React.createElement(Spinner, null);
|
|
87
88
|
return (React.createElement(CheckoutQuestionFeedbackProvider, { onChanged: handleOnChangedFeedback },
|
|
88
89
|
React.createElement(Layout, null,
|
|
89
90
|
React.createElement(Body, { style: { row: [style.container, isDesktop && style.containerDesktop] } },
|
|
90
|
-
React.createElement(CheckoutQuestionsForm, { checkoutQuestions:
|
|
91
|
+
React.createElement(CheckoutQuestionsForm, { checkoutQuestions: checkoutFeedbackDefinition || [], submitButtonDisabled: giveCheckoutFeedbackStatus === CommandStatus.LOADING, onSubmit: handleOnSubmit })))));
|
|
91
92
|
};
|
|
92
93
|
export { Feedback };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
-
import { CheckoutFeedbackProjection } from "../../../../../../projection/checkoutFeedback/checkoutFeedback";
|
|
3
|
-
import { CheckoutQuestionProjection } from "../../../../../../projection/checkoutQuestion/checkoutQuestion";
|
|
2
|
+
import { CheckoutFeedbackProjection, CheckoutFeedbackQuestionProjection } from "../../../../../../projection/checkoutFeedback/checkoutFeedback";
|
|
4
3
|
interface CheckoutQuestionsFormProps {
|
|
5
|
-
readonly checkoutQuestions:
|
|
4
|
+
readonly checkoutQuestions: CheckoutFeedbackQuestionProjection[];
|
|
6
5
|
readonly submitButtonDisabled: boolean;
|
|
7
6
|
readonly onSubmit: (feedback: CheckoutFeedbackProjection) => void;
|
|
8
7
|
}
|
|
@@ -2,7 +2,7 @@ import React, { useCallback, useMemo } from "react";
|
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import { Button } from "@lookiero/aurora";
|
|
4
4
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
5
|
-
import {
|
|
5
|
+
import { CheckoutFeedbackQuestionType } from "../../../../../../projection/checkoutFeedback/checkoutFeedback.constants";
|
|
6
6
|
import { CheckoutQuestions } from "../../../../components/organisms/checkoutQuestions/CheckoutQuestions";
|
|
7
7
|
import { useCheckoutQuestionFeedback } from "../../../../components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionFeedback";
|
|
8
8
|
import { CheckoutQuestionItemProvider, } from "../../../../components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem";
|
|
@@ -13,12 +13,12 @@ import { IconCheckoutQuestionItem } from "../../../../components/organisms/check
|
|
|
13
13
|
import { TextareaCheckoutQuestionItem } from "../../../../components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem";
|
|
14
14
|
import { DOMAIN, I18nMessages } from "../../../../i18n/i18n";
|
|
15
15
|
const checkoutQuestionItems = {
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
19
|
-
[
|
|
20
|
-
[
|
|
21
|
-
[
|
|
16
|
+
[CheckoutFeedbackQuestionType.HOST_DEFAULT]: HostDefaultCheckoutQuestionItem,
|
|
17
|
+
[CheckoutFeedbackQuestionType.HOST_TEXTAREA]: HostDefaultCheckoutQuestionItem,
|
|
18
|
+
[CheckoutFeedbackQuestionType.HOST_SELECT]: HostSelectCheckoutQuestionItem,
|
|
19
|
+
[CheckoutFeedbackQuestionType.TEXTAREA]: TextareaCheckoutQuestionItem,
|
|
20
|
+
[CheckoutFeedbackQuestionType.ICON]: IconCheckoutQuestionItem,
|
|
21
|
+
[CheckoutFeedbackQuestionType.BUTTON]: ButtonCheckoutQuestionItem,
|
|
22
22
|
};
|
|
23
23
|
const CheckoutQuestionsForm = ({ checkoutQuestions, submitButtonDisabled, onSubmit, }) => {
|
|
24
24
|
const buttonText = useI18nMessage({ domain: DOMAIN, id: I18nMessages.FEEDBACK_BUTTON });
|
|
@@ -26,8 +26,16 @@ const CheckoutQuestionsForm = ({ checkoutQuestions, submitButtonDisabled, onSubm
|
|
|
26
26
|
const handlePress = useCallback(() => onSubmit(feedback), [feedback, onSubmit]);
|
|
27
27
|
const filteredCheckoutQuestions = useMemo(() => {
|
|
28
28
|
const responses = Object.values(feedback);
|
|
29
|
-
return checkoutQuestions.filter((checkoutQuestion) =>
|
|
30
|
-
|
|
29
|
+
return checkoutQuestions.filter((checkoutQuestion) =>
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
!checkoutQuestion?.metadata?.showCondition ||
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
checkoutQuestion?.metadata?.showCondition.length === 0 ||
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
checkoutQuestion?.metadata?.showCondition.some((condition) => responses.includes(condition)));
|
|
31
39
|
}, [checkoutQuestions, feedback]);
|
|
32
40
|
return (React.createElement(View, { testID: "checkout-questions-form" },
|
|
33
41
|
React.createElement(CheckoutQuestionItemProvider, { checkoutQuestionItems: checkoutQuestionItems },
|
|
@@ -17,6 +17,7 @@ const returnQuestionItems = {
|
|
|
17
17
|
[ReturnQuestionType.HOST_STACK]: ReturnQuestionFeedbackItem,
|
|
18
18
|
[ReturnQuestionType.TEXTAREA]: ReturnQuestionFeedbackItem,
|
|
19
19
|
[ReturnQuestionType.OPTION]: ReturnQuestionFeedbackItem,
|
|
20
|
+
[ReturnQuestionType.HOST_RADIO_GROUP]: ReturnQuestionFeedbackItem,
|
|
20
21
|
};
|
|
21
22
|
const ReturnQuestionsFeedback = ({ returnQuestions, onEditFeedback }) => {
|
|
22
23
|
const titleText = useI18nMessage({ domain: DOMAIN, id: I18nMessages.FEEDBACK_TITLE });
|
|
@@ -20,6 +20,7 @@ import { ReturnQuestions } from "../../../../components/organisms/returnQuestion
|
|
|
20
20
|
import { useReturnQuestionFeedback } from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
|
|
21
21
|
import { ReturnQuestionItemProvider, } from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionItem";
|
|
22
22
|
import { HostDefaultReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem";
|
|
23
|
+
import { HostLegacyRadioGroupReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem";
|
|
23
24
|
import { HostRadioGroupReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem";
|
|
24
25
|
import { HostStackReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostStackReturnQuestionItem/form/HostStackReturnQuestionItem";
|
|
25
26
|
import { RadioReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem";
|
|
@@ -34,7 +35,8 @@ const RETURN_QUESTION_FORM_PORTAL_HOST_NAME = "return-question-form-portal";
|
|
|
34
35
|
const returnQuestionItems = {
|
|
35
36
|
[ReturnQuestionType.HOST_DEFAULT]: HostDefaultReturnQuestionItem,
|
|
36
37
|
[ReturnQuestionType.HOST_TEXTAREA]: HostDefaultReturnQuestionItem,
|
|
37
|
-
[ReturnQuestionType.HOST_SELECT]:
|
|
38
|
+
[ReturnQuestionType.HOST_SELECT]: HostLegacyRadioGroupReturnQuestionItem,
|
|
39
|
+
[ReturnQuestionType.HOST_RADIO_GROUP]: HostRadioGroupReturnQuestionItem,
|
|
38
40
|
[ReturnQuestionType.HOST_STACK]: HostStackReturnQuestionItem,
|
|
39
41
|
[ReturnQuestionType.TEXTAREA]: TextareaReturnQuestionItem,
|
|
40
42
|
[ReturnQuestionType.OPTION]: RadioReturnQuestionItem,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare enum CheckoutFeedbackQuestionType {
|
|
2
|
+
HOST_DEFAULT = "HOST_DEFAULT",
|
|
3
|
+
HOST_TEXTAREA = "HOST_TEXTAREA",
|
|
4
|
+
HOST_SELECT = "HOST_SELECT",
|
|
5
|
+
TEXTAREA = "TEXTAREA",
|
|
6
|
+
ICON = "ICON",
|
|
7
|
+
BUTTON = "BUTTON"
|
|
8
|
+
}
|
|
9
|
+
type CheckoutFeedbackQuestionIcon = "checkout_feedback.icon.bad" | "checkout_feedback.icon.regular" | "checkout_feedback.icon.good";
|
|
10
|
+
export type { CheckoutFeedbackQuestionIcon };
|
|
11
|
+
export { CheckoutFeedbackQuestionType };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var CheckoutFeedbackQuestionType;
|
|
2
|
+
(function (CheckoutFeedbackQuestionType) {
|
|
3
|
+
CheckoutFeedbackQuestionType["HOST_DEFAULT"] = "HOST_DEFAULT";
|
|
4
|
+
CheckoutFeedbackQuestionType["HOST_TEXTAREA"] = "HOST_TEXTAREA";
|
|
5
|
+
CheckoutFeedbackQuestionType["HOST_SELECT"] = "HOST_SELECT";
|
|
6
|
+
CheckoutFeedbackQuestionType["TEXTAREA"] = "TEXTAREA";
|
|
7
|
+
CheckoutFeedbackQuestionType["ICON"] = "ICON";
|
|
8
|
+
CheckoutFeedbackQuestionType["BUTTON"] = "BUTTON";
|
|
9
|
+
})(CheckoutFeedbackQuestionType || (CheckoutFeedbackQuestionType = {}));
|
|
10
|
+
export { CheckoutFeedbackQuestionType };
|
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
import { EmptyObject, ExcludePropertyIfOptional, NonEmptyArray } from "@lookiero/sty-psp-typescript";
|
|
1
2
|
import { FeedbackProjection } from "../feedback/feedback";
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
import { CheckoutFeedbackQuestionType } from "./checkoutFeedback.constants";
|
|
4
|
+
import { Metadata } from "./checkoutFeedback.metadata";
|
|
5
|
+
type CheckoutFeedback = FeedbackProjection;
|
|
6
|
+
type CheckoutFeedbackQuestionTypesWithChildren = CheckoutFeedbackQuestionType.HOST_DEFAULT | CheckoutFeedbackQuestionType.HOST_TEXTAREA | CheckoutFeedbackQuestionType.HOST_SELECT;
|
|
7
|
+
type CheckoutFeedbackQuestionTypesWithOptionalTranslationKeys = CheckoutFeedbackQuestionType.ICON;
|
|
8
|
+
type CheckoutFeedbackQuestionMetadata<CFDT extends CheckoutFeedbackQuestionType> = ExcludePropertyIfOptional<"metadata", {
|
|
9
|
+
readonly metadata: Metadata<CFDT>;
|
|
10
|
+
}>;
|
|
11
|
+
type CheckoutFeedbackQuestionTypeChildren<QT extends CheckoutFeedbackQuestionType> = QT extends CheckoutFeedbackQuestionTypesWithChildren ? {
|
|
12
|
+
readonly children: NonEmptyArray<CheckoutFeedbackQuestion>;
|
|
13
|
+
} : EmptyObject;
|
|
14
|
+
type CheckoutFeedbackQuestionTypeTranslationKey<QT extends CheckoutFeedbackQuestionType> = QT extends CheckoutFeedbackQuestionTypesWithOptionalTranslationKeys ? {
|
|
15
|
+
readonly translationKey?: string;
|
|
16
|
+
} : {
|
|
17
|
+
readonly translationKey: string;
|
|
18
|
+
};
|
|
19
|
+
type CheckoutFeedbackQuestion<CFDT extends CheckoutFeedbackQuestionType = CheckoutFeedbackQuestionType> = CFDT extends infer K extends CheckoutFeedbackQuestionType ? {
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly type: K;
|
|
22
|
+
} & CheckoutFeedbackQuestionTypeTranslationKey<K> & CheckoutFeedbackQuestionTypeChildren<K> & CheckoutFeedbackQuestionMetadata<K> : never;
|
|
23
|
+
export type { CheckoutFeedback as CheckoutFeedbackProjection, CheckoutFeedbackQuestion as CheckoutFeedbackQuestionProjection, CheckoutFeedbackQuestionTypesWithChildren, };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { EmptyObject } from "@lookiero/sty-psp-typescript";
|
|
2
|
+
import { CheckoutFeedbackQuestionIcon, CheckoutFeedbackQuestionType } from "./checkoutFeedback.constants";
|
|
3
|
+
type MetadataDictionary = Record<CheckoutFeedbackQuestionType, EmptyObject>;
|
|
4
|
+
interface ComponentWithPlaceholder {
|
|
5
|
+
readonly placeholder: string;
|
|
6
|
+
}
|
|
7
|
+
interface ComponentCondition {
|
|
8
|
+
readonly showCondition: string[];
|
|
9
|
+
}
|
|
10
|
+
interface ComponentIcon {
|
|
11
|
+
readonly icon: CheckoutFeedbackQuestionIcon;
|
|
12
|
+
}
|
|
13
|
+
type ComponentMetadata = MetadataDictionary & {
|
|
14
|
+
[CheckoutFeedbackQuestionType.HOST_DEFAULT]: ComponentCondition;
|
|
15
|
+
[CheckoutFeedbackQuestionType.HOST_TEXTAREA]: ComponentCondition;
|
|
16
|
+
[CheckoutFeedbackQuestionType.HOST_SELECT]: ComponentCondition & ComponentWithPlaceholder;
|
|
17
|
+
[CheckoutFeedbackQuestionType.TEXTAREA]: ComponentWithPlaceholder;
|
|
18
|
+
[CheckoutFeedbackQuestionType.ICON]: ComponentIcon;
|
|
19
|
+
};
|
|
20
|
+
type Metadata<CFDT extends CheckoutFeedbackQuestionType> = ComponentMetadata[CFDT];
|
|
21
|
+
export type { Metadata, ComponentCondition };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { CheckoutFeedbackQuestionType } from "./checkoutFeedback.constants";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { CheckoutFeedbackQuestionProjection, CheckoutFeedbackQuestionTypesWithChildren } from "./checkoutFeedback";
|
|
2
|
+
declare const checkoutFeedbackQuestionHasChildren: (question: CheckoutFeedbackQuestionProjection) => question is CheckoutFeedbackQuestionProjection<CheckoutFeedbackQuestionTypesWithChildren>;
|
|
3
|
+
export { checkoutFeedbackQuestionHasChildren };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CheckoutFeedbackQuestionType } from "./checkoutFeedback.constants";
|
|
2
|
+
const checkoutFeedbackQuestionHasChildren = (question) => [
|
|
3
|
+
CheckoutFeedbackQuestionType.HOST_DEFAULT,
|
|
4
|
+
CheckoutFeedbackQuestionType.HOST_SELECT,
|
|
5
|
+
CheckoutFeedbackQuestionType.HOST_TEXTAREA,
|
|
6
|
+
].includes(question.type);
|
|
7
|
+
export { checkoutFeedbackQuestionHasChildren };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CancelableQueryViewArgs, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
|
|
2
|
+
import { CheckoutFeedbackQuestionProjection } from "./checkoutFeedback";
|
|
3
|
+
declare const VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID = "view_checkout_feedback_definition_by_checkout_id";
|
|
4
|
+
interface ViewCheckoutFeedbackDefinitionByCheckoutIdPayload {
|
|
5
|
+
readonly checkoutId: string;
|
|
6
|
+
}
|
|
7
|
+
interface ViewCheckoutFeedbackDefinitionByCheckoutId extends Query<typeof VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID>, ViewCheckoutFeedbackDefinitionByCheckoutIdPayload {
|
|
8
|
+
}
|
|
9
|
+
interface ViewCheckoutFeedbackDefinitionByCheckoutIdFunction {
|
|
10
|
+
(payload: ViewCheckoutFeedbackDefinitionByCheckoutIdPayload): ViewCheckoutFeedbackDefinitionByCheckoutId;
|
|
11
|
+
}
|
|
12
|
+
declare const viewCheckoutFeedbackDefinitionByCheckoutId: ViewCheckoutFeedbackDefinitionByCheckoutIdFunction;
|
|
13
|
+
type ViewCheckoutFeedbackDefinitionByCheckoutIdResult = CheckoutFeedbackQuestionProjection[] | null;
|
|
14
|
+
interface CheckoutFeedbackDefinitionByCheckoutIdViewArgs extends CancelableQueryViewArgs {
|
|
15
|
+
readonly checkoutId: string;
|
|
16
|
+
}
|
|
17
|
+
interface CheckoutFeedbackDefinitionByCheckoutIdView {
|
|
18
|
+
(args: CheckoutFeedbackDefinitionByCheckoutIdViewArgs): Promise<ViewCheckoutFeedbackDefinitionByCheckoutIdResult>;
|
|
19
|
+
}
|
|
20
|
+
interface ViewCheckoutFeedbackDefinitionByCheckoutIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
|
|
21
|
+
readonly view: CheckoutFeedbackDefinitionByCheckoutIdView;
|
|
22
|
+
}
|
|
23
|
+
declare const viewCheckoutFeedbackDefinitionByCheckoutIdHandler: QueryHandlerFunction<ViewCheckoutFeedbackDefinitionByCheckoutId, ViewCheckoutFeedbackDefinitionByCheckoutIdResult, ViewCheckoutFeedbackDefinitionByCheckoutIdHandlerFunctionArgs>;
|
|
24
|
+
export type { ViewCheckoutFeedbackDefinitionByCheckoutId, CheckoutFeedbackDefinitionByCheckoutIdView, ViewCheckoutFeedbackDefinitionByCheckoutIdResult, };
|
|
25
|
+
export { VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID, viewCheckoutFeedbackDefinitionByCheckoutId, viewCheckoutFeedbackDefinitionByCheckoutIdHandler, };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { query, } from "@lookiero/messaging";
|
|
2
|
+
const VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID = "view_checkout_feedback_definition_by_checkout_id";
|
|
3
|
+
const viewCheckoutFeedbackDefinitionByCheckoutId = (payload) => ({
|
|
4
|
+
...query({ name: VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID }),
|
|
5
|
+
...payload,
|
|
6
|
+
});
|
|
7
|
+
const viewCheckoutFeedbackDefinitionByCheckoutIdHandler = ({ view, signal }) => async ({ checkoutId }) => view({ checkoutId, signal });
|
|
8
|
+
export { VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID, viewCheckoutFeedbackDefinitionByCheckoutId, viewCheckoutFeedbackDefinitionByCheckoutIdHandler, };
|
|
@@ -4,6 +4,7 @@ var ReturnQuestionType;
|
|
|
4
4
|
ReturnQuestionType["HOST_TEXTAREA"] = "HOST_TEXTAREA";
|
|
5
5
|
ReturnQuestionType["HOST_SELECT"] = "HOST_SELECT";
|
|
6
6
|
ReturnQuestionType["HOST_STACK"] = "HOST_STACK";
|
|
7
|
+
ReturnQuestionType["HOST_RADIO_GROUP"] = "HOST_RADIO_GROUP";
|
|
7
8
|
ReturnQuestionType["TEXTAREA"] = "TEXTAREA";
|
|
8
9
|
ReturnQuestionType["OPTION"] = "OPTION";
|
|
9
10
|
})(ReturnQuestionType || (ReturnQuestionType = {}));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { EmptyObject, ExcludePropertyIfOptional, NonEmptyArray } from "@lookiero/sty-psp-typescript";
|
|
2
2
|
import { ReturnQuestionType } from "./returnQuestion.constants";
|
|
3
3
|
import { Metadata } from "./returnQuestion.metadata";
|
|
4
|
-
type ReturnQuestionTypesWithChildren = ReturnQuestionType.HOST_DEFAULT | ReturnQuestionType.HOST_SELECT | ReturnQuestionType.HOST_STACK | ReturnQuestionType.HOST_TEXTAREA;
|
|
4
|
+
type ReturnQuestionTypesWithChildren = ReturnQuestionType.HOST_DEFAULT | ReturnQuestionType.HOST_SELECT | ReturnQuestionType.HOST_STACK | ReturnQuestionType.HOST_TEXTAREA | ReturnQuestionType.HOST_RADIO_GROUP;
|
|
5
5
|
type ReturnQuestionTypesWithOptionalChildren = ReturnQuestionType.OPTION;
|
|
6
|
-
type ReturnQuestionTypesWithOptionalTranslationKeys = ReturnQuestionType.HOST_STACK;
|
|
6
|
+
type ReturnQuestionTypesWithOptionalTranslationKeys = ReturnQuestionType.HOST_DEFAULT | ReturnQuestionType.HOST_STACK | ReturnQuestionType.HOST_RADIO_GROUP;
|
|
7
7
|
type ReturnQuestionMetadata<RQT extends ReturnQuestionType> = ExcludePropertyIfOptional<"metadata", {
|
|
8
8
|
readonly metadata: Metadata<RQT>;
|
|
9
9
|
}>;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ReturnQuestionProjection, ReturnQuestionTypesWithChildren
|
|
2
|
-
import { ReturnQuestionType } from "./returnQuestion.constants";
|
|
3
|
-
declare const returnQuestionWithTranslationKey: (question: ReturnQuestionProjection) => question is ReturnQuestionProjection<Exclude<ReturnQuestionType, ReturnQuestionTypesWithOptionalTranslationKeys>>;
|
|
1
|
+
import { ReturnQuestionProjection, ReturnQuestionTypesWithChildren } from "./returnQuestion";
|
|
4
2
|
declare const returnQuestionHasChildren: (question: ReturnQuestionProjection) => question is ReturnQuestionProjection<ReturnQuestionTypesWithChildren>;
|
|
5
|
-
export {
|
|
3
|
+
export { returnQuestionHasChildren };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ReturnQuestionType } from "./returnQuestion.constants";
|
|
2
|
-
const returnQuestionWithTranslationKey = (question) => Boolean(question.translationKey);
|
|
3
2
|
const returnQuestionHasChildren = (question) => [
|
|
4
3
|
ReturnQuestionType.HOST_DEFAULT,
|
|
5
4
|
ReturnQuestionType.HOST_SELECT,
|
|
6
5
|
ReturnQuestionType.HOST_STACK,
|
|
7
6
|
ReturnQuestionType.HOST_TEXTAREA,
|
|
7
|
+
ReturnQuestionType.HOST_RADIO_GROUP,
|
|
8
8
|
ReturnQuestionType.OPTION,
|
|
9
9
|
].includes(question.type);
|
|
10
|
-
export {
|
|
10
|
+
export { returnQuestionHasChildren };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
|
|
2
|
+
interface UiSettingProjection {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly key: string;
|
|
5
|
+
readonly value: unknown;
|
|
6
|
+
}
|
|
7
|
+
declare const VIEW_UI_SETTING_BY_KEY = "view_ui_setting_by_key";
|
|
8
|
+
interface ViewUiSettingByKeyPayload {
|
|
9
|
+
readonly key: string;
|
|
10
|
+
}
|
|
11
|
+
interface ViewUiSettingByKey extends Query<typeof VIEW_UI_SETTING_BY_KEY>, ViewUiSettingByKeyPayload {
|
|
12
|
+
}
|
|
13
|
+
interface ViewUiSettingByKeyFunction {
|
|
14
|
+
(payload: ViewUiSettingByKeyPayload): ViewUiSettingByKey;
|
|
15
|
+
}
|
|
16
|
+
declare const viewUiSettingByKey: ViewUiSettingByKeyFunction;
|
|
17
|
+
type ViewUiSettingByKeyResult = UiSettingProjection | null;
|
|
18
|
+
interface UiSettingByKeyViewArgs {
|
|
19
|
+
readonly key: string;
|
|
20
|
+
}
|
|
21
|
+
interface UiSettingByKeyView {
|
|
22
|
+
(args: UiSettingByKeyViewArgs): Promise<ViewUiSettingByKeyResult>;
|
|
23
|
+
}
|
|
24
|
+
interface ViewUiSettingByKeyHandlerFunctionArgs extends QueryHandlerFunctionArgs {
|
|
25
|
+
readonly view: UiSettingByKeyView;
|
|
26
|
+
}
|
|
27
|
+
declare const viewUiSettingByKeyHandler: QueryHandlerFunction<ViewUiSettingByKey, ViewUiSettingByKeyResult, ViewUiSettingByKeyHandlerFunctionArgs>;
|
|
28
|
+
export type { UiSettingProjection, UiSettingByKeyView };
|
|
29
|
+
export { VIEW_UI_SETTING_BY_KEY, viewUiSettingByKey, viewUiSettingByKeyHandler };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { query } from "@lookiero/messaging";
|
|
2
|
+
const VIEW_UI_SETTING_BY_KEY = "view_ui_setting_by_key";
|
|
3
|
+
const viewUiSettingByKey = (payload) => ({
|
|
4
|
+
...query({ name: VIEW_UI_SETTING_BY_KEY }),
|
|
5
|
+
...payload,
|
|
6
|
+
});
|
|
7
|
+
const viewUiSettingByKeyHandler = ({ view }) => async ({ key }) => view({ key });
|
|
8
|
+
export { VIEW_UI_SETTING_BY_KEY, viewUiSettingByKey, viewUiSettingByKeyHandler };
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "12.
|
|
1
|
+
export declare const VERSION = "12.5.0";
|
package/dist/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "12.
|
|
1
|
+
export const VERSION = "12.5.0";
|