@lookiero/checkout 5.0.3 → 5.0.4

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.
@@ -3,6 +3,7 @@ declare enum TrackingPage {
3
3
  ITEM = "item",
4
4
  CHECKOUT = "checkout",
5
5
  SUMMARY = "summary",
6
- FEEDBACK = "feedback"
6
+ FEEDBACK = "feedback",
7
+ RETURN = "return"
7
8
  }
8
9
  export { PROJECT, TrackingPage };
@@ -5,5 +5,6 @@ var TrackingPage;
5
5
  TrackingPage["CHECKOUT"] = "checkout";
6
6
  TrackingPage["SUMMARY"] = "summary";
7
7
  TrackingPage["FEEDBACK"] = "feedback";
8
+ TrackingPage["RETURN"] = "return";
8
9
  })(TrackingPage || (TrackingPage = {}));
9
10
  export { PROJECT, TrackingPage };
@@ -23,6 +23,7 @@ declare enum I18nMessages {
23
23
  FEEDBACK_TITLE = "return_questions_feedback.feedback.title",
24
24
  FEEDBACK_UNANSWERED = "return_questions_feedback.feedback.unanswered",
25
25
  RETURN_QUESTIONS_TITLE = "return_questions.title",
26
+ RETURN_QUESTIONS_DESCRIPTION = "return_questions.description",
26
27
  RETURN_QUESTIONS_SUBMIT_BUTTON = "return_questions.submit_button",
27
28
  RETURN_QUESTION_MAIN_ALL_OPINION = "return_question.main.all.opinion",
28
29
  SUMMARY_TITLE = "summary.title",
@@ -25,6 +25,7 @@ var I18nMessages;
25
25
  I18nMessages["FEEDBACK_TITLE"] = "return_questions_feedback.feedback.title";
26
26
  I18nMessages["FEEDBACK_UNANSWERED"] = "return_questions_feedback.feedback.unanswered";
27
27
  I18nMessages["RETURN_QUESTIONS_TITLE"] = "return_questions.title";
28
+ I18nMessages["RETURN_QUESTIONS_DESCRIPTION"] = "return_questions.description";
28
29
  I18nMessages["RETURN_QUESTIONS_SUBMIT_BUTTON"] = "return_questions.submit_button";
29
30
  I18nMessages["RETURN_QUESTION_MAIN_ALL_OPINION"] = "return_question.main.all.opinion";
30
31
  I18nMessages["SUMMARY_TITLE"] = "summary.title";
@@ -71,7 +71,7 @@ const Routing = ({ basePath = "", customer, order, subscription, locale, I18n, k
71
71
  {
72
72
  path: Routes.RETURN,
73
73
  element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
74
- React.createElement(Return, null))),
74
+ React.createElement(Return, { country: customer?.country, customerId: customer?.customerId, layout: layout }))),
75
75
  },
76
76
  {
77
77
  path: "*",
@@ -1,3 +1,10 @@
1
1
  import { FC } from "react";
2
- declare const Return: FC;
2
+ import { Country } from "../../../../projection/shared/country";
3
+ import { Layout as LocalLayout } from "../../components/layouts/layout/Layout";
4
+ interface ReturnProps {
5
+ readonly customerId: string;
6
+ readonly country: Country;
7
+ readonly layout: LocalLayout;
8
+ }
9
+ declare const Return: FC<ReturnProps>;
3
10
  export { Return };
@@ -1,11 +1,95 @@
1
- import { Text, View } from "@lookiero/aurora";
2
- import React from "react";
1
+ import { PortalHost } from "@gorhom/portal";
2
+ import { Button, Text, View, useDevice } from "@lookiero/aurora";
3
+ import { useI18nMessage } from "@lookiero/i18n-react";
4
+ import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
5
+ import React, { useCallback } from "react";
6
+ import { useParams } from "react-router-native";
7
+ import { ReturnQuestionType } from "../../../../projection/returnQuestion/returnQuestion";
8
+ import { useLogger } from "../../../../shared/logging/useLogger";
9
+ import { useTrackReturnItem } from "../../../../shared/tracking/infrastructure/useTrackReturnItem";
3
10
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
4
- const Return = () => {
5
- const dependenciesLoaded = true;
6
- if (!dependenciesLoaded)
11
+ import { Column } from "../../../../shared/ui/components/layouts/column/Column";
12
+ import { Row } from "../../../../shared/ui/components/layouts/row/Row";
13
+ import { useReturnCheckoutItem } from "../../../domain/checkoutItem/react/useReturnCheckoutItem";
14
+ import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
15
+ import { useListReturnQuestionsByCheckoutItemId } from "../../../projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId";
16
+ import { TrackingPage } from "../../../tracking/tracking";
17
+ import { ReturnQuestions } from "../../components/organisms/returnQuestions/ReturnQuestions";
18
+ import { ReturnQuestionFeedbackProvider, useReturnQuestionFeedback, } from "../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
19
+ import { ReturnQuestionItemProvider, } from "../../components/organisms/returnQuestions/behaviors/useReturnQuestionItem";
20
+ import { HostDefaultReturnQuestionItem } from "../../components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem";
21
+ import { HostSelectReturnQuestionItem } from "../../components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem";
22
+ import { HostStackReturnQuestionItem } from "../../components/organisms/returnQuestions/components/hostStackReturnQuestionItem/HostStackReturnQuestionItem";
23
+ import { OptionReturnQuestionItem } from "../../components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem";
24
+ import { TextareaReturnQuestionItem } from "../../components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem";
25
+ import { I18nMessages } from "../../i18n/i18n";
26
+ import { style } from "./Return.style";
27
+ const returnQuestionItems = {
28
+ [ReturnQuestionType.HOST_DEFAULT]: HostDefaultReturnQuestionItem,
29
+ [ReturnQuestionType.HOST_TEXTAREA]: HostDefaultReturnQuestionItem,
30
+ [ReturnQuestionType.HOST_SELECT]: HostSelectReturnQuestionItem,
31
+ [ReturnQuestionType.HOST_STACK]: HostStackReturnQuestionItem,
32
+ [ReturnQuestionType.TEXTAREA]: TextareaReturnQuestionItem,
33
+ [ReturnQuestionType.OPTION]: OptionReturnQuestionItem,
34
+ };
35
+ const ReturnForm = ({ checkoutItem, checkoutId, country, layout: LocalLayout }) => {
36
+ const { screen } = useDevice();
37
+ const logger = useLogger();
38
+ const titleText = useI18nMessage({ id: I18nMessages.RETURN_QUESTIONS_TITLE });
39
+ const descriptionText = useI18nMessage({ id: I18nMessages.RETURN_QUESTIONS_DESCRIPTION });
40
+ const submitButtonText = useI18nMessage({ id: I18nMessages.RETURN_QUESTIONS_SUBMIT_BUTTON });
41
+ const isSmallScreen = screen.S;
42
+ /* ReturnCheckoutItem */
43
+ const [returnQuestions] = useListReturnQuestionsByCheckoutItemId({
44
+ checkoutItemId: checkoutItem.id,
45
+ });
46
+ const hideReturnQuestions = useCallback(() => void 0, []);
47
+ const [returnCheckoutItem, returnCheckoutItemStatus] = useReturnCheckoutItem({
48
+ checkoutItemId: checkoutItem.id,
49
+ logger,
50
+ });
51
+ const trackReturnItem = useTrackReturnItem({
52
+ page: TrackingPage.RETURN,
53
+ country,
54
+ checkoutId: checkoutId,
55
+ checkoutItemId: checkoutItem.id,
56
+ });
57
+ const returnItem = useCallback(async (feedbacks) => {
58
+ hideReturnQuestions();
59
+ returnCheckoutItem({ feedbacks });
60
+ trackReturnItem();
61
+ }, [hideReturnQuestions, returnCheckoutItem, trackReturnItem]);
62
+ const feedback = useReturnQuestionFeedback();
63
+ const handleOnSubmit = useCallback(() => returnItem(feedback), [feedback, returnItem]);
64
+ /* ReturnCheckoutItem */
65
+ const dependenciesLoaded = checkoutItem && returnQuestions && returnCheckoutItemStatus !== CommandStatus.LOADING;
66
+ if (!dependenciesLoaded) {
67
+ return React.createElement(Spinner, null);
68
+ }
69
+ return (React.createElement(ReturnQuestionItemProvider, { returnQuestionItems: returnQuestionItems },
70
+ React.createElement(PortalHost, { name: "return-question-form-portal" }),
71
+ React.createElement(LocalLayout, { scrollEnabled: true, style: {
72
+ header: style.header,
73
+ scrollView: style.scrollView,
74
+ } },
75
+ React.createElement(Row, { style: [style.row, isSmallScreen ? undefined : style.desktopRow] },
76
+ React.createElement(Column, { size: { M: "2/3", L: "2/3" } },
77
+ React.createElement(View, { style: [style.container, isSmallScreen ? undefined : style.desktopContainer] },
78
+ React.createElement(Text, { level: 3, style: style.title, heading: true }, titleText),
79
+ React.createElement(Text, { level: 1, style: style.description, detail: true }, descriptionText),
80
+ React.createElement(ReturnQuestions, { portalHostName: "return-question-form-portal", returnQuestions: returnQuestions }),
81
+ React.createElement(View, { style: style.submit },
82
+ React.createElement(Button, { testID: "return-questions-button", onPress: handleOnSubmit }, submitButtonText))))))));
83
+ };
84
+ const Return = ({ customerId, country, layout: LocalLayout }) => {
85
+ const { id } = useParams();
86
+ const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
87
+ const checkoutItem = checkout?.items.find((checkoutItem) => checkoutItem.id === id);
88
+ const dependenciesLoaded = checkoutStatus !== QueryStatus.LOADING && checkout && checkoutItem;
89
+ if (!dependenciesLoaded) {
7
90
  return React.createElement(Spinner, null);
8
- return (React.createElement(View, null,
9
- React.createElement(Text, null, "RETURN VIEW")));
91
+ }
92
+ return (React.createElement(ReturnQuestionFeedbackProvider, { key: checkoutItem.id, feedback: checkoutItem.feedbacks || {} },
93
+ React.createElement(ReturnForm, { checkoutId: checkout.id, checkoutItem: checkoutItem, country: country, layout: LocalLayout })));
10
94
  };
11
95
  export { Return };
@@ -0,0 +1,33 @@
1
+ declare const style: {
2
+ container: {
3
+ backgroundColor: string;
4
+ paddingHorizontal: number;
5
+ paddingTop: number;
6
+ };
7
+ description: {
8
+ color: string;
9
+ marginBottom: number;
10
+ };
11
+ desktopContainer: {
12
+ borderRadius: number;
13
+ };
14
+ desktopRow: {
15
+ marginTop: number;
16
+ };
17
+ header: {
18
+ height: number;
19
+ };
20
+ row: {
21
+ flex: number;
22
+ justifyContent: "center";
23
+ };
24
+ scrollView: {
25
+ backgroundColor: string;
26
+ flex: number;
27
+ };
28
+ submit: {
29
+ paddingVertical: number;
30
+ };
31
+ title: {};
32
+ };
33
+ export { style };
@@ -0,0 +1,37 @@
1
+ import { Theme } from "@lookiero/aurora";
2
+ import { StyleSheet } from "react-native";
3
+ import { HEADER_HEIGHT } from "../../components/templates/header/Header.style";
4
+ const { borderRadius5, colorBgPrimaryLight, colorBgBase, colorTextMedium, space4, space6, space8 } = Theme.get();
5
+ const style = StyleSheet.create({
6
+ container: {
7
+ backgroundColor: colorBgBase,
8
+ paddingHorizontal: space6,
9
+ paddingTop: space8,
10
+ },
11
+ description: {
12
+ color: colorTextMedium,
13
+ marginBottom: space4,
14
+ },
15
+ desktopContainer: {
16
+ borderRadius: borderRadius5,
17
+ },
18
+ desktopRow: {
19
+ marginTop: space8,
20
+ },
21
+ header: {
22
+ height: HEADER_HEIGHT,
23
+ },
24
+ row: {
25
+ flex: 1,
26
+ justifyContent: "center",
27
+ },
28
+ scrollView: {
29
+ backgroundColor: colorBgPrimaryLight,
30
+ flex: 1,
31
+ },
32
+ submit: {
33
+ paddingVertical: space6,
34
+ },
35
+ title: {},
36
+ });
37
+ export { style };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "5.0.3",
3
+ "version": "5.0.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [