@lookiero/checkout 7.0.0-beta.0 → 7.0.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.
Files changed (84) hide show
  1. package/dist/src/ExpoRoot.js +1 -8
  2. package/dist/src/infrastructure/ab-testing/kameleoonEnvironment.d.ts +2 -6
  3. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.js +1 -10
  4. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.style.d.ts +1 -7
  5. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.style.js +1 -7
  6. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.js +2 -7
  7. package/dist/src/infrastructure/ui/routing/Routing.js +2 -4
  8. package/dist/src/infrastructure/ui/views/checkout/Checkout.js +4 -4
  9. package/dist/src/infrastructure/ui/views/feedback/Feedback.d.ts +2 -2
  10. package/dist/src/infrastructure/ui/views/item/Item.js +4 -33
  11. package/dist/src/infrastructure/ui/views/return/Return.js +8 -127
  12. package/dist/src/infrastructure/ui/views/return/components/productVariantPreview/ProductVariantPreview.js +5 -7
  13. package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.d.ts +15 -0
  14. package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.js +112 -0
  15. package/dist/src/infrastructure/ui/views/summary/Summary.js +4 -4
  16. package/dist/src/version.d.ts +1 -1
  17. package/dist/src/version.js +1 -1
  18. package/package.json +1 -1
  19. package/src/ExpoRoot.tsx +1 -8
  20. package/src/infrastructure/ab-testing/kameleoonEnvironment.ts +3 -7
  21. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.style.ts +1 -7
  22. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.test.tsx +0 -5
  23. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.tsx +2 -17
  24. package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.test.tsx +0 -5
  25. package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.tsx +11 -20
  26. package/src/infrastructure/ui/routing/Routing.tsx +3 -6
  27. package/src/infrastructure/ui/views/checkout/Checkout.tsx +6 -6
  28. package/src/infrastructure/ui/views/feedback/Feedback.tsx +2 -2
  29. package/src/infrastructure/ui/views/item/Item.test.tsx +6 -62
  30. package/src/infrastructure/ui/views/item/Item.tsx +5 -48
  31. package/src/infrastructure/ui/views/return/Return.test.tsx +54 -0
  32. package/src/infrastructure/ui/views/return/Return.tsx +12 -200
  33. package/src/infrastructure/ui/views/return/components/productVariantPreview/ProductVariantPreview.test.tsx +32 -0
  34. package/src/infrastructure/ui/views/return/components/productVariantPreview/ProductVariantPreview.tsx +12 -7
  35. package/src/infrastructure/ui/views/return/components/productVariantPreview/__snapshots__/ProductVariantPreview.test.tsx.snap +221 -0
  36. package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.test.tsx +95 -0
  37. package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.tsx +184 -0
  38. package/src/infrastructure/ui/views/summary/Summary.tsx +6 -6
  39. package/dist/public/public/assets/adaptive-icon.png +0 -0
  40. package/dist/public/public/assets/favicon.png +0 -0
  41. package/dist/public/public/assets/icon.png +0 -0
  42. package/dist/public/public/assets/splash.png +0 -0
  43. package/dist/public/public/images/not-found.png +0 -0
  44. package/dist/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.d.ts +0 -10
  45. package/dist/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.js +0 -17
  46. package/dist/src/infrastructure/ui/components/layouts/layout/Layout.d.ts +0 -21
  47. package/dist/src/infrastructure/ui/components/layouts/layout/Layout.js +0 -1
  48. package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.d.ts +0 -6
  49. package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.js +0 -4
  50. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.d.ts +0 -6
  51. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.js +0 -5
  52. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.d.ts +0 -4
  53. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.js +0 -19
  54. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.d.ts +0 -3
  55. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.js +0 -18
  56. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.d.ts +0 -12
  57. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.js +0 -13
  58. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.d.ts +0 -6
  59. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.js +0 -11
  60. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.d.ts +0 -8
  61. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.js +0 -11
  62. package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.d.ts +0 -11
  63. package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.js +0 -49
  64. package/dist/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.d.ts +0 -9
  65. package/dist/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +0 -21
  66. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.d.ts +0 -7
  67. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.js +0 -10
  68. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.d.ts +0 -11
  69. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.js +0 -40
  70. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts +0 -12
  71. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.js +0 -15
  72. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.d.ts +0 -13
  73. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.js +0 -9
  74. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.d.ts +0 -7
  75. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.js +0 -10
  76. package/dist/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.d.ts +0 -17
  77. package/dist/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.js +0 -13
  78. package/src/infrastructure/ui/hooks/useNewFeedbackExperiment.test.tsx +0 -84
  79. package/src/infrastructure/ui/hooks/useNewFeedbackExperiment.tsx +0 -82
  80. package/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.ts +0 -18
  81. package/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.tsx +0 -79
  82. /package/dist/src/infrastructure/ui/views/return/{Return.style.d.ts → components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts} +0 -0
  83. /package/dist/src/infrastructure/ui/views/return/{Return.style.js → components/returnQuestionsForm/ReturnQuestionsForm.style.js} +0 -0
  84. /package/src/infrastructure/ui/views/return/{Return.style.ts → components/returnQuestionsForm/ReturnQuestionsForm.style.ts} +0 -0
@@ -1,15 +0,0 @@
1
- import { StyleSheet } from "react-native";
2
- import { theme } from "@lookiero/sty-psp-ui";
3
- const { space6, space8 } = theme();
4
- const style = StyleSheet.create({
5
- modalContent: {
6
- paddingHorizontal: space6,
7
- },
8
- submit: {
9
- marginTop: space8,
10
- },
11
- title: {
12
- marginBottom: space6,
13
- },
14
- });
15
- export { style };
@@ -1,13 +0,0 @@
1
- import { FC } from "react";
2
- import { LayoutRectangle } from "react-native";
3
- import { PricingProjection } from "../../../../../../projection/pricing/pricing";
4
- interface StickyPricingProps {
5
- readonly pricing: PricingProjection;
6
- readonly totalCheckoutItemsKept: number;
7
- readonly collapsed: boolean;
8
- readonly onPress: () => void;
9
- readonly onSubmit: () => void;
10
- readonly onLayout?: ({ width, height }: LayoutRectangle) => void;
11
- }
12
- declare const StickyPricing: FC<StickyPricingProps>;
13
- export { StickyPricing };
@@ -1,9 +0,0 @@
1
- import React from "react";
2
- import { Sticky } from "@lookiero/sty-psp-ui";
3
- import { Body } from "../../../../components/layouts/body/Body";
4
- import { Pricing } from "../pricing/Pricing";
5
- import { style } from "./StickyPricing.style";
6
- const StickyPricing = ({ pricing, totalCheckoutItemsKept, collapsed, onPress, onSubmit, onLayout, }) => (React.createElement(Sticky, { style: style.sticky, onLayout: onLayout },
7
- React.createElement(Body, null,
8
- React.createElement(Pricing, { balanceDiscount: pricing.balanceDiscount, collapsed: collapsed, discount: pricing.discount, discountPercentage: pricing.discountPercentage, pendingToPay: pricing.pendingToPay, service: pricing.service, subtotal: pricing.subtotal, totalCheckoutItemsKept: totalCheckoutItemsKept, onPress: onPress, onSubmit: onSubmit }))));
9
- export { StickyPricing };
@@ -1,7 +0,0 @@
1
- declare const style: {
2
- sticky: {
3
- paddingBottom: number;
4
- paddingTop: number;
5
- };
6
- };
7
- export { style };
@@ -1,10 +0,0 @@
1
- import { StyleSheet } from "react-native";
2
- import { theme } from "@lookiero/sty-psp-ui";
3
- const { space3, space4 } = theme();
4
- const style = StyleSheet.create({
5
- sticky: {
6
- paddingBottom: space4,
7
- paddingTop: space3,
8
- },
9
- });
10
- export { style };
@@ -1,17 +0,0 @@
1
- import { Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
- type IsCheckoutAccessibleByCustomerIdProjection = boolean;
3
- declare const VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID = "view_is_checkout_accessible_by_customer_id";
4
- interface ViewIsCheckoutAccessibleByCustomerIdPayload {
5
- readonly customerId: string | undefined;
6
- }
7
- interface ViewIsCheckoutAccessibleByCustomerId extends Query<typeof VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID>, ViewIsCheckoutAccessibleByCustomerIdPayload {
8
- }
9
- interface ViewIsCheckoutAccessibleByCustomerIdFunction {
10
- (payload: ViewIsCheckoutAccessibleByCustomerIdPayload): ViewIsCheckoutAccessibleByCustomerId;
11
- }
12
- declare const viewIsCheckoutAccessibleByCustomerId: ViewIsCheckoutAccessibleByCustomerIdFunction;
13
- interface ViewIsCheckoutAccessibleByCustomerIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
14
- }
15
- declare const viewIsCheckoutAccessibleByCustomerIdHandler: QueryHandlerFunction<ViewIsCheckoutAccessibleByCustomerId, IsCheckoutAccessibleByCustomerIdProjection, ViewIsCheckoutAccessibleByCustomerIdHandlerFunctionArgs>;
16
- export type { IsCheckoutAccessibleByCustomerIdProjection };
17
- export { VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerId, viewIsCheckoutAccessibleByCustomerIdHandler, };
@@ -1,13 +0,0 @@
1
- import { query } from "@lookiero/messaging";
2
- import { viewFirstAvailableCheckoutByCustomerId } from "./viewFirstAvailableCheckoutByCustomerId";
3
- import { viewIsCheckoutEnabledByCustomerId } from "./viewIsCheckoutEnabledByCustomerId";
4
- const VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID = "view_is_checkout_accessible_by_customer_id";
5
- const viewIsCheckoutAccessibleByCustomerId = (payload) => ({
6
- ...query({ name: VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID }),
7
- ...payload,
8
- });
9
- const isNonEmptyCustomerId = (customerId) => Boolean(customerId);
10
- const viewIsCheckoutAccessibleByCustomerIdHandler = ({ queryBus }) => async ({ customerId }) => isNonEmptyCustomerId(customerId) &&
11
- Boolean(await queryBus(viewFirstAvailableCheckoutByCustomerId({ customerId }))) &&
12
- Boolean(await queryBus(viewIsCheckoutEnabledByCustomerId({ customerId })));
13
- export { VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerId, viewIsCheckoutAccessibleByCustomerIdHandler, };
@@ -1,84 +0,0 @@
1
- import { renderHook, waitFor } from "@testing-library/react-native";
2
- import React, { FC } from "react";
3
- import { Variation, useAssignedVariationByExperimentId } from "@lookiero/sty-psp-ab-testing";
4
- import { Segment } from "@lookiero/sty-psp-segment";
5
- import { CheckoutProjection } from "../../../projection/checkout/checkout";
6
- import { Country } from "../../../projection/shared/country";
7
- import { KameleoonEnvironment } from "../../ab-testing/kameleoonEnvironment";
8
- import {
9
- NewFeedbackExperimentProvider,
10
- NewFeedbackExperimentVariation,
11
- useNewFeedbackExperiment as sut,
12
- } from "./useNewFeedbackExperiment";
13
-
14
- const mockKameleoon: KameleoonEnvironment = {
15
- siteCode: "aplm4v3ckn",
16
- experiments: {
17
- newFeedback: {
18
- id: "245000",
19
- variations: {
20
- v1: "964072",
21
- },
22
- },
23
- },
24
- };
25
-
26
- const country = Country.ES;
27
- const segment = Segment.WOMEN;
28
- const customerId = "1f410890-b3e1-49d2-9950-2ff89182cb79";
29
- const mockTrackAssignedVariation = jest.fn();
30
- // useStaticInfo
31
-
32
- jest.mock("../../tracking/useTrackAssignedVariationByExperiment", () => ({
33
- useTrackAssignedVariationByExperiment: () => mockTrackAssignedVariation,
34
- }));
35
-
36
- jest.mock("@lookiero/sty-psp-ab-testing");
37
-
38
- jest.mock("./useStaticInfo", () => ({
39
- useStaticInfo: () => ({ kameleoon: mockKameleoon, customer: { customerId, country, segment } }),
40
- }));
41
-
42
- jest.mock("../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId", () => ({
43
- useViewFirstAvailableCheckoutByCustomerId: () => [
44
- { id: "3db6984e-c8d2-4242-a795-ab5babb25e8c" } as CheckoutProjection,
45
- ],
46
- }));
47
-
48
- interface WrapperProps {
49
- readonly children: JSX.Element;
50
- }
51
-
52
- const Wrapper: FC<WrapperProps> = ({ children }) => (
53
- <NewFeedbackExperimentProvider>{children}</NewFeedbackExperimentProvider>
54
- );
55
-
56
- beforeEach(() => {
57
- mockTrackAssignedVariation.mockClear();
58
- });
59
-
60
- describe("useNewFeedbackExperiment hook", () => {
61
- it("returns 'control' as variation", async () => {
62
- const assignedVariation: Variation = { id: 0, name: "Control" };
63
- (useAssignedVariationByExperimentId as jest.Mock).mockReturnValue({ assignedVariation });
64
-
65
- const { result } = renderHook(() => sut(), { wrapper: Wrapper });
66
-
67
- await waitFor(() => expect(result.current).toBe(NewFeedbackExperimentVariation.CONTROL));
68
- await waitFor(() => {
69
- expect(mockTrackAssignedVariation).toHaveBeenCalledWith({ assignedVariation });
70
- });
71
- });
72
-
73
- it("returns 'return_page' as variation", async () => {
74
- const assignedVariation: Variation = { id: 964072, name: "Variation 1" };
75
- (useAssignedVariationByExperimentId as jest.Mock).mockReturnValue({ assignedVariation });
76
-
77
- const { result } = renderHook(() => sut(), { wrapper: Wrapper });
78
-
79
- await waitFor(() => expect(result.current).toBe(NewFeedbackExperimentVariation.RETURN_PAGE));
80
- await waitFor(() => {
81
- expect(mockTrackAssignedVariation).toHaveBeenCalledWith({ assignedVariation });
82
- });
83
- });
84
- });
@@ -1,82 +0,0 @@
1
- import React, { createContext, FC, ReactNode, useContext, useEffect, useMemo, useRef } from "react";
2
- import invariant from "tiny-invariant";
3
- import { Spinner } from "@lookiero/aurora";
4
- import { useAssignedVariationByExperimentId } from "@lookiero/sty-psp-ab-testing";
5
- import { useViewFirstAvailableCheckoutByCustomerId } from "../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
6
- import { useTrackAssignedVariationByExperiment } from "../../tracking/useTrackAssignedVariationByExperiment";
7
- import { useStaticInfo } from "./useStaticInfo";
8
-
9
- enum NewFeedbackExperimentVariation {
10
- CONTROL = "control",
11
- RETURN_PAGE = "return_page",
12
- }
13
-
14
- interface NewFeedbackExperiment {
15
- readonly variation: NewFeedbackExperimentVariation;
16
- }
17
-
18
- const NewFeedbackExperimentContext = createContext<NewFeedbackExperiment>(null as unknown as NewFeedbackExperiment);
19
-
20
- interface NewFeedbackExperimentProviderProps {
21
- readonly children: ReactNode;
22
- }
23
-
24
- const NewFeedbackExperimentProvider: FC<NewFeedbackExperimentProviderProps> = ({ children }) => {
25
- const {
26
- kameleoon: {
27
- experiments: {
28
- newFeedback: { id: newFeedbackId, variations },
29
- },
30
- },
31
- customer: { customerId, country, segment },
32
- } = useStaticInfo();
33
- const [checkout] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
34
- const { assignedVariation: newFeedbackVariation } = useAssignedVariationByExperimentId({
35
- experimentId: newFeedbackId,
36
- });
37
- const trackAssignedVariation = useTrackAssignedVariationByExperiment({
38
- checkoutId: checkout?.id,
39
- country,
40
- segment,
41
- experimentId: newFeedbackId,
42
- });
43
-
44
- const value = useMemo(
45
- () => ({
46
- variation:
47
- newFeedbackVariation?.id === Number(variations.v1)
48
- ? NewFeedbackExperimentVariation.RETURN_PAGE
49
- : NewFeedbackExperimentVariation.CONTROL,
50
- }),
51
- [newFeedbackVariation?.id, variations.v1],
52
- );
53
-
54
- const assignedVariantTracked = useRef(false);
55
- useEffect(() => {
56
- if (assignedVariantTracked.current || !newFeedbackVariation || !checkout?.id) {
57
- return;
58
- }
59
-
60
- trackAssignedVariation({ assignedVariation: newFeedbackVariation });
61
- assignedVariantTracked.current = true;
62
- }, [checkout?.id, newFeedbackVariation, trackAssignedVariation]);
63
-
64
- if (!checkout) {
65
- return <Spinner />;
66
- }
67
-
68
- return <NewFeedbackExperimentContext.Provider value={value}>{children}</NewFeedbackExperimentContext.Provider>;
69
- };
70
-
71
- const useNewFeedbackExperiment = () => {
72
- const newFeedbackExperiment = useContext(NewFeedbackExperimentContext);
73
-
74
- invariant(
75
- newFeedbackExperiment,
76
- "Your are trying to use the useNewFeedbackExperiment hook without wrapping your app with the <NewFeedbackExperimentProvider>.",
77
- );
78
-
79
- return newFeedbackExperiment.variation;
80
- };
81
-
82
- export { useNewFeedbackExperiment, NewFeedbackExperimentProvider, NewFeedbackExperimentVariation };
@@ -1,18 +0,0 @@
1
- import { StyleSheet } from "react-native";
2
- import { theme } from "@lookiero/sty-psp-ui";
3
-
4
- const { space6, space8 } = theme();
5
-
6
- const style = StyleSheet.create({
7
- modalContent: {
8
- paddingHorizontal: space6,
9
- },
10
- submit: {
11
- marginTop: space8,
12
- },
13
- title: {
14
- marginBottom: space6,
15
- },
16
- });
17
-
18
- export { style };
@@ -1,79 +0,0 @@
1
- import { PortalHost } from "@gorhom/portal";
2
- import React, { FC, useCallback } from "react";
3
- import { View } from "react-native";
4
- import { Button, Text } from "@lookiero/aurora";
5
- import { useI18nMessage } from "@lookiero/i18n-react";
6
- import { Modal } from "@lookiero/sty-psp-ui";
7
- import { FeedbackProjection } from "../../../../../../projection/feedback/feedback";
8
- import {
9
- ReturnQuestionProjection,
10
- ReturnQuestionType,
11
- } from "../../../../../../projection/returnQuestion/returnQuestion";
12
- import { ReturnQuestions } from "../../../../components/organisms/returnQuestions/ReturnQuestions";
13
- import { useReturnQuestionFeedback } from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
14
- import {
15
- ReturnQuestionItemProvider,
16
- ReturnQuestionItems,
17
- } from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionItem";
18
- import { HostDefaultReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem";
19
- import { HostSelectReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem";
20
- import { HostStackReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem";
21
- import { OptionReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem";
22
- import { TextareaReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem";
23
- import { I18nMessages } from "../../../../i18n/i18n";
24
- import { style } from "./ReturnQuestionsForm.style";
25
-
26
- const RETURN_QUESTION_FORM_PORTAL_HOST_NAME = "return-question-form-portal";
27
-
28
- const returnQuestionItems: ReturnQuestionItems = {
29
- [ReturnQuestionType.HOST_DEFAULT]: HostDefaultReturnQuestionItem,
30
- [ReturnQuestionType.HOST_TEXTAREA]: HostDefaultReturnQuestionItem,
31
- [ReturnQuestionType.HOST_SELECT]: HostSelectReturnQuestionItem,
32
- [ReturnQuestionType.HOST_STACK]: HostStackReturnQuestionItem,
33
- [ReturnQuestionType.TEXTAREA]: TextareaReturnQuestionItem,
34
- [ReturnQuestionType.OPTION]: OptionReturnQuestionItem,
35
- };
36
-
37
- interface ReturnQuestionsFormProps {
38
- readonly visible: boolean;
39
- readonly returnQuestions: ReturnQuestionProjection[];
40
- readonly onSubmit: (feedback: FeedbackProjection) => void;
41
- readonly onClose: () => void;
42
- }
43
-
44
- const ReturnQuestionsForm: FC<ReturnQuestionsFormProps> = ({ returnQuestions, visible, onSubmit, onClose }) => {
45
- const titleText = useI18nMessage({ id: I18nMessages.RETURN_QUESTIONS_TITLE });
46
- const submitButtonText = useI18nMessage({ id: I18nMessages.RETURN_QUESTIONS_SUBMIT_BUTTON });
47
-
48
- const feedback = useReturnQuestionFeedback();
49
-
50
- const handleOnSubmit = useCallback(() => onSubmit(feedback), [feedback, onSubmit]);
51
-
52
- return (
53
- <ReturnQuestionItemProvider returnQuestionItems={returnQuestionItems}>
54
- <PortalHost name={RETURN_QUESTION_FORM_PORTAL_HOST_NAME} />
55
- <Modal
56
- portalHostName={RETURN_QUESTION_FORM_PORTAL_HOST_NAME}
57
- testID="return-questions-form-modal"
58
- visible={visible}
59
- scroll
60
- showCloseButton
61
- onClose={onClose}
62
- >
63
- <View style={style.modalContent}>
64
- <Text level={3} style={style.title} heading>
65
- {titleText}
66
- </Text>
67
-
68
- <ReturnQuestions portalHostName={RETURN_QUESTION_FORM_PORTAL_HOST_NAME} returnQuestions={returnQuestions} />
69
-
70
- <Button style={style.submit} testID="return-questions-button" onPress={handleOnSubmit}>
71
- {submitButtonText}
72
- </Button>
73
- </View>
74
- </Modal>
75
- </ReturnQuestionItemProvider>
76
- );
77
- };
78
-
79
- export { ReturnQuestionsForm };