@lookiero/checkout 0.2.22 → 0.2.24

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 (37) hide show
  1. package/dist/infrastructure/projection/feedback/feedback.mock.d.ts +3 -0
  2. package/dist/infrastructure/projection/feedback/feedback.mock.js +6 -0
  3. package/dist/infrastructure/ui/components/layouts/body/Body.style.d.ts +1 -5
  4. package/dist/infrastructure/ui/components/layouts/body/Body.style.js +2 -6
  5. package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionFeedbackItem/HostDefaultReturnQuestionFeedbackItem.d.ts +3 -0
  6. package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionFeedbackItem/HostDefaultReturnQuestionFeedbackItem.js +3 -0
  7. package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.js +12 -8
  8. package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/HostStackReturnQuestionItem.js +13 -19
  9. package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/HostStackReturnQuestionItem.style.d.ts +0 -6
  10. package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/HostStackReturnQuestionItem.style.js +1 -10
  11. package/dist/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.d.ts +3 -0
  12. package/dist/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.js +27 -0
  13. package/dist/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.style.d.ts +10 -0
  14. package/dist/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.style.js +13 -0
  15. package/dist/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.d.ts +10 -1
  16. package/dist/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.js +41 -14
  17. package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.d.ts +2 -0
  18. package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.js +13 -5
  19. package/dist/infrastructure/ui/i18n/i18n.d.ts +5 -2
  20. package/dist/infrastructure/ui/i18n/i18n.js +4 -1
  21. package/dist/infrastructure/ui/shared/components/layouts/modal/Modal.d.ts +1 -0
  22. package/dist/infrastructure/ui/shared/components/layouts/modal/Modal.js +7 -5
  23. package/dist/infrastructure/ui/shared/components/layouts/modal/Modal.style.d.ts +0 -3
  24. package/dist/infrastructure/ui/shared/components/layouts/modal/Modal.style.js +0 -3
  25. package/dist/infrastructure/ui/shared/components/molecules/buttonIcon/ButtonIcon.d.ts +5 -3
  26. package/dist/infrastructure/ui/shared/components/molecules/buttonIcon/ButtonIcon.js +1 -1
  27. package/dist/infrastructure/ui/views/item/Item.js +9 -6
  28. package/dist/infrastructure/ui/views/item/Item.style.d.ts +6 -1
  29. package/dist/infrastructure/ui/views/item/Item.style.js +7 -2
  30. package/dist/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.d.ts +10 -0
  31. package/dist/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.js +32 -0
  32. package/dist/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.style.d.ts +12 -0
  33. package/dist/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.style.js +15 -0
  34. package/dist/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.js +7 -14
  35. package/package.json +1 -1
  36. package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.style.d.ts +0 -10
  37. package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.style.js +0 -11
@@ -0,0 +1,3 @@
1
+ import { FeedbackProjection } from "../../../projection/feedback/feedback";
2
+ declare const feedback: FeedbackProjection;
3
+ export { feedback };
@@ -0,0 +1,6 @@
1
+ const feedback = {
2
+ ["0ad1dba8-b02c-4121-a1e3-981f1c30800d"]: "9251dc2c-d76a-484d-9299-346929af932f",
3
+ ["542c4d24-e1da-484f-8c3a-7d89ee135adc"]: "68c0bb98-b00a-4b86-af43-528fe903cb69",
4
+ ["1123a37d-bc00-43a4-9d28-cee1dfaf356c"]: "Free text comment",
5
+ };
6
+ export { feedback };
@@ -1,14 +1,10 @@
1
1
  declare const style: {
2
- container: {
3
- flex: number;
4
- };
5
2
  row: {
6
3
  flex: number;
7
4
  justifyContent: "center";
8
- paddingVertical: number;
9
5
  };
10
6
  column: {
11
- height: string;
7
+ paddingHorizontal: number;
12
8
  };
13
9
  };
14
10
  export { style };
@@ -1,17 +1,13 @@
1
- import { Platform, StyleSheet } from "react-native";
1
+ import { StyleSheet } from "react-native";
2
2
  import { theme } from "../../../theme/theme";
3
3
  const { spaceXL } = theme();
4
4
  const style = StyleSheet.create({
5
- container: {
6
- flex: 1,
7
- },
8
5
  row: {
9
6
  flex: 1,
10
7
  justifyContent: "center",
11
- paddingVertical: Platform.OS === "web" ? spaceXL : 0,
12
8
  },
13
9
  column: {
14
- height: "100%",
10
+ paddingHorizontal: spaceXL,
15
11
  },
16
12
  });
17
13
  export { style };
@@ -0,0 +1,3 @@
1
+ import { ReturnQuestionItem } from "../ReturnQuestionItem";
2
+ declare const HostDefaultReturnQuestionFeedbackItem: ReturnQuestionItem;
3
+ export { HostDefaultReturnQuestionFeedbackItem };
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ const HostDefaultReturnQuestionFeedbackItem = ({ children }) => (React.createElement(React.Fragment, null, children));
3
+ export { HostDefaultReturnQuestionFeedbackItem };
@@ -2,30 +2,34 @@ import { useI18nMessage } from "@lookiero/i18n-react";
2
2
  import React, { useCallback, useState } from "react";
3
3
  import { useIntl } from "react-intl";
4
4
  import { TouchableHighlight, View } from "react-native";
5
- import { useSafeAreaInsets } from "react-native-safe-area-context";
6
5
  import { RETURN_QUESTIONS_PREFIX } from "../../../../../i18n/i18n";
7
6
  import { Modal } from "../../../../../shared/components/layouts/modal/Modal";
7
+ import { ButtonIcon } from "../../../../../shared/components/molecules/buttonIcon/ButtonIcon";
8
8
  import { InputField } from "../../../../../shared/components/molecules/inputField/InputField";
9
- import { theme } from "../../../../../theme/theme";
10
- import { useReturnQuestionFeedback } from "../../behaviors/useReturnQuestionFeedback";
11
- import { feedbackForReturnQuestion } from "../../util/returnQuestionFeedback";
9
+ import { useReturnQuestionFeedback, useReturnQuestionFeedbackForId } from "../../behaviors/useReturnQuestionFeedback";
10
+ import { deepestReturnQuestionWithFeedbackForReturnQuestion, feedbackForReturnQuestion, } from "../../util/returnQuestionFeedback";
12
11
  import { style, containerUnderlayColor } from "./HostSelectReturnQuestionItem.style";
13
- const { spaceXL } = theme();
14
12
  const HostSelectReturnQuestionItem = ({ returnQuestion, children, portalHostName, }) => {
15
- const { bottom: safeAreaInsetBottom } = useSafeAreaInsets();
16
13
  const placeholderText = useI18nMessage({ id: returnQuestion.placeholder, prefix: RETURN_QUESTIONS_PREFIX });
17
14
  const [modalVisible, setModalVisible] = useState(false);
18
15
  const handleOnPress = useCallback(() => setModalVisible(true), []);
19
16
  const handleOnModalClose = useCallback(() => setModalVisible(false), []);
20
17
  const feedback = useReturnQuestionFeedback();
18
+ const { onChange } = useReturnQuestionFeedbackForId({ id: returnQuestion.id });
21
19
  const intl = useIntl();
22
20
  const translate = useCallback((returnQuestionName) => intl.formatMessage({ id: `${RETURN_QUESTIONS_PREFIX}${returnQuestionName}`, defaultMessage: returnQuestionName }), [intl]);
23
21
  const inputValue = feedbackForReturnQuestion({ feedback, returnQuestion, translate }).join(" / ");
22
+ const deepestReturnQuestionWithFeedback = deepestReturnQuestionWithFeedbackForReturnQuestion({
23
+ feedback,
24
+ returnQuestion,
25
+ });
26
+ const handleOnBackButtonPress = useCallback(() => deepestReturnQuestionWithFeedback &&
27
+ onChange({ returnQuestionId: deepestReturnQuestionWithFeedback.id, returnQuestionFeedback: undefined }), [deepestReturnQuestionWithFeedback, onChange]);
24
28
  return (React.createElement(React.Fragment, null,
25
29
  React.createElement(TouchableHighlight, { style: style.container, onPress: handleOnPress, underlayColor: containerUnderlayColor },
26
30
  React.createElement(View, { pointerEvents: "none" },
27
31
  React.createElement(InputField, { label: placeholderText || "", value: inputValue, icon: "arrow-down", editable: false }))),
28
- React.createElement(Modal, { visible: modalVisible, onClose: handleOnModalClose, portalHostName: portalHostName },
29
- React.createElement(View, { style: [style.modalContent, { paddingBottom: spaceXL + safeAreaInsetBottom }] }, children))));
32
+ React.createElement(Modal, { visible: modalVisible, onClose: handleOnModalClose, portalHostName: portalHostName, header: deepestReturnQuestionWithFeedback && (React.createElement(ButtonIcon, { name: "arrow-left", onPress: handleOnBackButtonPress, testID: "modal-back-button" })), scroll: true },
33
+ React.createElement(View, { style: style.modalContent }, children))));
30
34
  };
31
35
  export { HostSelectReturnQuestionItem };
@@ -1,33 +1,27 @@
1
1
  import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
2
2
  import { useI18nMessage } from "@lookiero/i18n-react";
3
- import React, { useCallback } from "react";
3
+ import { animated, useSpring } from "@react-spring/native";
4
+ import React, { useCallback, useState } from "react";
5
+ import { View } from "react-native";
4
6
  import { RETURN_QUESTIONS_PREFIX } from "../../../../../i18n/i18n";
5
- import { ButtonIcon } from "../../../../../shared/components/molecules/buttonIcon/ButtonIcon";
6
7
  import ReturnQuestion from "../../ReturnQuestion";
7
8
  import { useReturnQuestionFeedbackForId } from "../../behaviors/useReturnQuestionFeedback";
8
9
  import { style } from "./HostStackReturnQuestionItem.style";
9
10
  const HostStackReturnQuestionItem = ({ returnQuestion, children, portalHostName, }) => {
10
11
  const titleText = useI18nMessage({ id: returnQuestion.name, prefix: RETURN_QUESTIONS_PREFIX });
11
- const { feedback, onChange } = useReturnQuestionFeedbackForId({ id: returnQuestion.id });
12
+ const { feedback } = useReturnQuestionFeedbackForId({ id: returnQuestion.id });
12
13
  const feedbackReturnQuestion = feedback
13
14
  ? returnQuestion.children?.find((returnQuestion) => returnQuestion.id === feedback)
14
15
  : undefined;
15
16
  const feedbackText = useI18nMessage({ id: feedbackReturnQuestion?.name, prefix: RETURN_QUESTIONS_PREFIX });
16
- const handleOnBackButtonPress = useCallback(() => {
17
- onChange({ returnQuestionId: returnQuestion.id, returnQuestionFeedback: undefined });
18
- }, [onChange, returnQuestion.id]);
19
- const questionTitle = titleText && (React.createElement(Text, { level: 2, style: style.title }, titleText));
20
- if (feedbackReturnQuestion) {
21
- return (React.createElement(React.Fragment, null,
22
- React.createElement(ButtonIcon, { name: "arrow-left", style: { icon: style.backButton }, onPress: handleOnBackButtonPress }),
23
- questionTitle,
24
- React.createElement(Text, { level: 3, style: style.feedback }, feedbackText),
25
- feedbackReturnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, returnQuestion: childReturnQuestion, returnQuestionParentId: feedbackReturnQuestion.id, portalHostName: portalHostName })))));
26
- }
27
- else {
28
- return (React.createElement(React.Fragment, null,
29
- questionTitle,
30
- children));
31
- }
17
+ const [stackHeight, setStackHeight] = useState();
18
+ const handleOnLayout = useCallback(({ nativeEvent: { layout: { height }, }, }) => setStackHeight(height), []);
19
+ const stackSyle = useSpring({ height: stackHeight });
20
+ return (React.createElement(animated.View, { style: stackSyle },
21
+ React.createElement(View, { onLayout: handleOnLayout },
22
+ titleText && (React.createElement(Text, { level: 2, style: style.title }, titleText)),
23
+ feedbackReturnQuestion ? (React.createElement(React.Fragment, null,
24
+ React.createElement(Text, { level: 3, style: style.feedback }, feedbackText),
25
+ feedbackReturnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, returnQuestion: childReturnQuestion, returnQuestionParentId: feedbackReturnQuestion.id, portalHostName: portalHostName }))))) : (children))));
32
26
  };
33
27
  export { HostStackReturnQuestionItem };
@@ -1,10 +1,4 @@
1
1
  declare const style: {
2
- backButton: {
3
- position: "absolute";
4
- top: number;
5
- left: number;
6
- zIndex: number;
7
- };
8
2
  title: {
9
3
  marginVertical: number;
10
4
  textAlign: "center";
@@ -1,16 +1,7 @@
1
1
  import { StyleSheet } from "react-native";
2
2
  import { theme } from "../../../../../theme/theme";
3
- const { colorGrayscaleL, spaceS, spaceM, spaceL, iconSize } = theme();
4
- const headerPadding = spaceM;
5
- const buttonIconPadding = spaceS;
6
- const backButtonTop = (iconSize + headerPadding + buttonIconPadding * 2) * -1;
3
+ const { colorGrayscaleL, spaceM, spaceL } = theme();
7
4
  const style = StyleSheet.create({
8
- backButton: {
9
- position: "absolute",
10
- top: backButtonTop,
11
- left: spaceM,
12
- zIndex: 20,
13
- },
14
5
  title: {
15
6
  marginVertical: spaceL,
16
7
  textAlign: "center",
@@ -0,0 +1,3 @@
1
+ import { ReturnQuestionItem } from "../ReturnQuestionItem";
2
+ declare const ReturnQuestionFeedbackItem: ReturnQuestionItem;
3
+ export { ReturnQuestionFeedbackItem };
@@ -0,0 +1,27 @@
1
+ import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
2
+ import { useI18nMessage } from "@lookiero/i18n-react";
3
+ import React, { useCallback } from "react";
4
+ import { useIntl } from "react-intl";
5
+ import { View } from "react-native";
6
+ import { I18nMessages, RETURN_QUESTIONS_FEEDBACK_PREFIX, RETURN_QUESTIONS_PREFIX } from "../../../../../i18n/i18n";
7
+ import { useReturnQuestionFeedback } from "../../behaviors/useReturnQuestionFeedback";
8
+ import { feedbackForReturnQuestion } from "../../util/returnQuestionFeedback";
9
+ import { style } from "./ReturnQuestionFeedbackItem.style";
10
+ const ReturnQuestionFeedbackItem = ({ returnQuestion }) => {
11
+ const titleText = useI18nMessage({ id: returnQuestion.name, prefix: RETURN_QUESTIONS_FEEDBACK_PREFIX });
12
+ const unansweredText = useI18nMessage({
13
+ id: I18nMessages.FEEDBACK_UNANSWERED,
14
+ prefix: RETURN_QUESTIONS_FEEDBACK_PREFIX,
15
+ });
16
+ const returnQuestionFeedback = useReturnQuestionFeedback();
17
+ const intl = useIntl();
18
+ const translate = useCallback((returnQuestionName) => intl.formatMessage({
19
+ id: `${RETURN_QUESTIONS_PREFIX}${returnQuestionName}`,
20
+ defaultMessage: returnQuestionName,
21
+ }), [intl]);
22
+ const feedback = feedbackForReturnQuestion({ feedback: returnQuestionFeedback, returnQuestion, translate }).join(" / ");
23
+ return (React.createElement(View, { style: style.container },
24
+ React.createElement(Text, { detail: true, level: 2, style: style.title }, titleText),
25
+ React.createElement(Text, { level: 3 }, feedback || unansweredText)));
26
+ };
27
+ export { ReturnQuestionFeedbackItem };
@@ -0,0 +1,10 @@
1
+ declare const style: {
2
+ container: {
3
+ marginBottom: number;
4
+ };
5
+ title: {
6
+ color: string;
7
+ marginBottom: number;
8
+ };
9
+ };
10
+ export { style };
@@ -0,0 +1,13 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "../../../../../theme/theme";
3
+ const { colorGrayscaleL, spaceM, spaceXL } = theme();
4
+ const style = StyleSheet.create({
5
+ container: {
6
+ marginBottom: spaceXL,
7
+ },
8
+ title: {
9
+ color: colorGrayscaleL,
10
+ marginBottom: spaceM,
11
+ },
12
+ });
13
+ export { style };
@@ -10,4 +10,13 @@ interface RecursiveFeedbackForReturnQuestionFunction {
10
10
  (args: RecursiveFeedbackForReturnQuestionFunctionArgs): string[];
11
11
  }
12
12
  declare const feedbackForReturnQuestion: RecursiveFeedbackForReturnQuestionFunction;
13
- export { feedbackForReturnQuestion };
13
+ interface RecursiveDeepestReturnQuestionWithFeedbackFunctionArgs {
14
+ readonly feedback: FeedbackProjection | undefined;
15
+ readonly returnQuestion: ReturnQuestionProjection;
16
+ readonly deepestReturnQuestion?: ReturnQuestionProjection;
17
+ }
18
+ interface RecursiveDeepestReturnQuestionWithFeedbackFunction {
19
+ (args: RecursiveDeepestReturnQuestionWithFeedbackFunctionArgs): ReturnQuestionProjection | undefined;
20
+ }
21
+ declare const deepestReturnQuestionWithFeedbackForReturnQuestion: RecursiveDeepestReturnQuestionWithFeedbackFunction;
22
+ export { feedbackForReturnQuestion, deepestReturnQuestionWithFeedbackForReturnQuestion };
@@ -7,25 +7,52 @@ const feedbackForReturnQuestion = ({ feedback, returnQuestion, translate, acc =
7
7
  const returnQuestionId = Object.keys(feedback).find((id) => id === returnQuestion.id);
8
8
  if (returnQuestionId) {
9
9
  const returnQuestionFeedback = feedback[returnQuestionId];
10
- if (returnQuestionFeedback !== undefined) {
11
- if (isUuid(returnQuestionFeedback)) {
12
- const feebackReturnQuestionChild = returnQuestion.children?.find((childReturnQuestion) => childReturnQuestion.id === returnQuestionFeedback);
13
- if (feebackReturnQuestionChild) {
14
- return [
15
- ...acc,
16
- translate(feebackReturnQuestionChild?.name),
17
- ...feedbackForReturnQuestion({ feedback, returnQuestion: feebackReturnQuestionChild, translate, acc }),
18
- ];
19
- }
20
- return acc;
10
+ if (isUuid(returnQuestionFeedback)) {
11
+ const feebackReturnQuestionChild = returnQuestion.children?.find((childReturnQuestion) => childReturnQuestion.id === returnQuestionFeedback);
12
+ if (feebackReturnQuestionChild) {
13
+ return [
14
+ ...acc,
15
+ translate(feebackReturnQuestionChild?.name),
16
+ ...feedbackForReturnQuestion({ feedback, returnQuestion: feebackReturnQuestionChild, translate, acc }),
17
+ ];
21
18
  }
22
- return [...acc, returnQuestionFeedback];
19
+ return acc;
23
20
  }
24
- return acc;
21
+ return [...acc, returnQuestionFeedback];
25
22
  }
26
23
  return (returnQuestion.children?.reduce((acc, childReturnQuestion) => [
27
24
  ...acc,
28
25
  ...feedbackForReturnQuestion({ feedback, returnQuestion: childReturnQuestion, translate, acc }),
29
26
  ], []) || []);
30
27
  };
31
- export { feedbackForReturnQuestion };
28
+ const deepestReturnQuestionWithFeedbackForReturnQuestion = ({ feedback, returnQuestion, deepestReturnQuestion, }) => {
29
+ if (!feedback) {
30
+ return;
31
+ }
32
+ const returnQuestionId = Object.keys(feedback).find((id) => id === returnQuestion.id);
33
+ if (returnQuestionId) {
34
+ const returnQuestionFeedback = feedback[returnQuestionId];
35
+ if (isUuid(returnQuestionFeedback)) {
36
+ const feebackReturnQuestionChild = returnQuestion.children?.find((childReturnQuestion) => childReturnQuestion.id === returnQuestionFeedback);
37
+ if (feebackReturnQuestionChild) {
38
+ return deepestReturnQuestionWithFeedbackForReturnQuestion({
39
+ feedback,
40
+ returnQuestion: feebackReturnQuestionChild,
41
+ deepestReturnQuestion: returnQuestion,
42
+ });
43
+ }
44
+ return returnQuestion;
45
+ }
46
+ return returnQuestion;
47
+ }
48
+ const feebackReturnQuestionChild = returnQuestion.children?.find((childReturnQuestion) => Object.keys(feedback).find((id) => id === childReturnQuestion.id));
49
+ if (feebackReturnQuestionChild) {
50
+ return deepestReturnQuestionWithFeedbackForReturnQuestion({
51
+ feedback,
52
+ returnQuestion: feebackReturnQuestionChild,
53
+ deepestReturnQuestion: feebackReturnQuestionChild,
54
+ });
55
+ }
56
+ return deepestReturnQuestion;
57
+ };
58
+ export { feedbackForReturnQuestion, deepestReturnQuestionWithFeedbackForReturnQuestion };
@@ -1,6 +1,8 @@
1
1
  import { FC, ReactNode } from "react";
2
+ import { Edge } from "react-native-safe-area-context";
2
3
  interface SafeAreaScrollViewProps {
3
4
  readonly children: ReactNode;
5
+ readonly edges?: Edge[];
4
6
  }
5
7
  declare const SafeAreaScrollView: FC<SafeAreaScrollViewProps>;
6
8
  export { SafeAreaScrollView };
@@ -1,7 +1,15 @@
1
1
  import React from "react";
2
- import { ScrollView } from "react-native";
3
- import { SafeAreaView } from "react-native-safe-area-context";
4
- import { style } from "./SafeAreaScrollView.style";
5
- const SafeAreaScrollView = ({ children }) => (React.createElement(SafeAreaView, { style: style.container },
6
- React.createElement(ScrollView, { contentContainerStyle: style.scrollContainer, showsVerticalScrollIndicator: false }, children)));
2
+ import { ScrollView, View } from "react-native";
3
+ import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
4
+ import { theme } from "../../theme/theme";
5
+ const { spaceXL } = theme();
6
+ const SafeAreaScrollView = ({ children, edges = ["top", "bottom", "left", "right"] }) => {
7
+ const { top: safeAreaInsetTop, bottom: safeAreaInsetBottom } = useSafeAreaInsets();
8
+ return (React.createElement(SafeAreaView, { edges: edges },
9
+ React.createElement(ScrollView, { showsVerticalScrollIndicator: false },
10
+ React.createElement(View, { style: {
11
+ paddingTop: !safeAreaInsetTop ? spaceXL : 0,
12
+ paddingBottom: !safeAreaInsetBottom ? spaceXL : 0,
13
+ } }, children))));
14
+ };
7
15
  export { SafeAreaScrollView };
@@ -1,5 +1,6 @@
1
1
  declare const COLOR_I18N_PREFIX = "color.";
2
2
  declare const RETURN_QUESTIONS_PREFIX = "return_questions.";
3
+ declare const RETURN_QUESTIONS_FEEDBACK_PREFIX = "return_questions_feedback.";
3
4
  declare enum I18nMessages {
4
5
  INTRO_TITLE = "intro.title",
5
6
  INTRO_SUBTITLE = "intro.subtitle",
@@ -27,6 +28,8 @@ declare enum I18nMessages {
27
28
  GET_OUT_OF_CHECKOUT_MODAL_TITLE = "get_out_of_checkout_modal.title",
28
29
  GET_OUT_OF_CHECKOUT_MODAL_DESCRIPTION = "get_out_of_checkout_modal.description",
29
30
  GET_OUT_OF_CHECKOUT_MODAL_DISMISS_BUTTON = "get_out_of_checkout_modal.dismiss_button",
30
- GET_OUT_OF_CHECKOUT_MODAL_CONFIRM_BUTTON = "get_out_of_checkout_modal.confirm_button"
31
+ GET_OUT_OF_CHECKOUT_MODAL_CONFIRM_BUTTON = "get_out_of_checkout_modal.confirm_button",
32
+ FEEDBACK_TITLE = "feedback.title",
33
+ FEEDBACK_UNANSWERED = "feedback.unanswered"
31
34
  }
32
- export { I18nMessages, COLOR_I18N_PREFIX, RETURN_QUESTIONS_PREFIX };
35
+ export { I18nMessages, COLOR_I18N_PREFIX, RETURN_QUESTIONS_PREFIX, RETURN_QUESTIONS_FEEDBACK_PREFIX };
@@ -1,5 +1,6 @@
1
1
  const COLOR_I18N_PREFIX = "color.";
2
2
  const RETURN_QUESTIONS_PREFIX = "return_questions.";
3
+ const RETURN_QUESTIONS_FEEDBACK_PREFIX = "return_questions_feedback.";
3
4
  var I18nMessages;
4
5
  (function (I18nMessages) {
5
6
  I18nMessages["INTRO_TITLE"] = "intro.title";
@@ -29,5 +30,7 @@ var I18nMessages;
29
30
  I18nMessages["GET_OUT_OF_CHECKOUT_MODAL_DESCRIPTION"] = "get_out_of_checkout_modal.description";
30
31
  I18nMessages["GET_OUT_OF_CHECKOUT_MODAL_DISMISS_BUTTON"] = "get_out_of_checkout_modal.dismiss_button";
31
32
  I18nMessages["GET_OUT_OF_CHECKOUT_MODAL_CONFIRM_BUTTON"] = "get_out_of_checkout_modal.confirm_button";
33
+ I18nMessages["FEEDBACK_TITLE"] = "feedback.title";
34
+ I18nMessages["FEEDBACK_UNANSWERED"] = "feedback.unanswered";
32
35
  })(I18nMessages || (I18nMessages = {}));
33
- export { I18nMessages, COLOR_I18N_PREFIX, RETURN_QUESTIONS_PREFIX };
36
+ export { I18nMessages, COLOR_I18N_PREFIX, RETURN_QUESTIONS_PREFIX, RETURN_QUESTIONS_FEEDBACK_PREFIX };
@@ -9,6 +9,7 @@ interface ModalProps {
9
9
  readonly onClose?: () => void;
10
10
  readonly header?: ReactNode;
11
11
  readonly portalHostName?: string;
12
+ readonly scroll?: boolean;
12
13
  readonly size?: Partial<Record<ScreenSize, ColumnSize>>;
13
14
  readonly style?: Partial<Record<ModalStyle, ViewProps>>;
14
15
  }
@@ -1,14 +1,14 @@
1
1
  import { Portal } from "@gorhom/portal";
2
2
  import { animated, useTransition } from "@react-spring/native";
3
- import React, { useCallback, useState } from "react";
4
- import { Dimensions, Platform, TouchableWithoutFeedback, View } from "react-native";
3
+ import React, { useCallback, useMemo, useState } from "react";
4
+ import { Dimensions, Platform, ScrollView, TouchableWithoutFeedback, View, } from "react-native";
5
5
  import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
6
6
  import { useScreenSize } from "../../../hooks/useScreenSize";
7
7
  import { ButtonIcon } from "../../molecules/buttonIcon/ButtonIcon";
8
8
  import { Row } from "../row/Row";
9
9
  import { style } from "./Modal.style";
10
10
  const TRANSITION_MODAL_SCALE = 0.9;
11
- const Modal = ({ children, visible, header, portalHostName, onClose, size = { M: "2/3", L: "1/3" }, style: customStyle, }) => {
11
+ const Modal = ({ children, visible, header, portalHostName, onClose, size = { M: "2/3", L: "1/3" }, style: customStyle, scroll = false, }) => {
12
12
  const { height: screenHeight } = Dimensions.get("screen");
13
13
  const { top: safeAreaInsetTop, bottom: safeAreaInsetBottom } = useSafeAreaInsets();
14
14
  const screenSizeWithoutInsets = screenHeight - safeAreaInsetTop;
@@ -37,6 +37,7 @@ const Modal = ({ children, visible, header, portalHostName, onClose, size = { M:
37
37
  : { modalOpacity: 0, overlayOpacity: 0, modalTranslateY: 0, modalScale: TRANSITION_MODAL_SCALE },
38
38
  unique: true,
39
39
  });
40
+ const ModalContentView = useMemo(() => (scroll ? ScrollView : View), [scroll]);
40
41
  return (React.createElement(Portal, { hostName: portalHostName }, transitions(({ modalOpacity, overlayOpacity, modalTranslateY, modalScale }, item) => item && (React.createElement(View, { style: style.container, pointerEvents: visible ? "auto" : "none", testID: "modal" },
41
42
  React.createElement(TouchableWithoutFeedback, { onPress: visible ? onClose : undefined },
42
43
  React.createElement(animated.View, { style: [style.overlay, { opacity: overlayOpacity }, customStyle?.overlay] })),
@@ -54,7 +55,8 @@ const Modal = ({ children, visible, header, portalHostName, onClose, size = { M:
54
55
  ], onLayout: handleOnModalLayout, pointerEvents: visible ? "auto" : "none" },
55
56
  (header || onClose) && (React.createElement(View, { style: [style.header, customStyle?.header] },
56
57
  React.createElement(View, null, header),
57
- onClose && (React.createElement(ButtonIcon, { style: { button: [style.closeButton, customStyle?.closeButton] }, name: "close", onPress: onClose })))),
58
- children))))))));
58
+ onClose && (React.createElement(ButtonIcon, { style: { button: customStyle?.closeButton }, name: "close", onPress: onClose })))),
59
+ React.createElement(ModalContentView, null,
60
+ React.createElement(View, { style: { paddingBottom: safeAreaInsetBottom } }, children))))))))));
59
61
  };
60
62
  export { Modal };
@@ -42,8 +42,5 @@ declare const style: {
42
42
  padding: number;
43
43
  flexDirection: "row";
44
44
  };
45
- closeButton: {
46
- alignSelf: "flex-end";
47
- };
48
45
  };
49
46
  export { style };
@@ -55,8 +55,5 @@ const style = StyleSheet.create({
55
55
  padding: spaceM,
56
56
  flexDirection: "row",
57
57
  },
58
- closeButton: {
59
- alignSelf: "flex-end",
60
- },
61
58
  });
62
59
  export { style };
@@ -1,14 +1,16 @@
1
1
  import { FC } from "react";
2
- import { StyleProp, ViewStyle } from "react-native";
2
+ import { StyleProp, TouchableHighlightProps, ViewStyle } from "react-native";
3
3
  import { IconName, IconStyle } from "../../atoms/icon/Icon";
4
4
  interface ButtonIconStyle {
5
5
  readonly button: StyleProp<ViewStyle>;
6
6
  readonly icon: IconStyle;
7
7
  }
8
- interface ButtonIconProps {
8
+ interface ButtonIconBaseProps {
9
9
  readonly name: IconName;
10
+ readonly testID?: string;
10
11
  readonly style?: Partial<ButtonIconStyle>;
11
- readonly onPress: () => void;
12
+ }
13
+ interface ButtonIconProps extends Omit<TouchableHighlightProps, keyof ButtonIconBaseProps>, ButtonIconBaseProps {
12
14
  }
13
15
  declare const ButtonIcon: FC<ButtonIconProps>;
14
16
  export { ButtonIcon };
@@ -2,6 +2,6 @@ import React from "react";
2
2
  import { TouchableHighlight } from "react-native";
3
3
  import { Icon } from "../../atoms/icon/Icon";
4
4
  import { buttonIconUnderlayColor, style } from "./ButtonIcon.style";
5
- const ButtonIcon = ({ name, style: customStyle, onPress }) => (React.createElement(TouchableHighlight, { style: [style.buttonIcon, customStyle?.button], onPress: onPress, underlayColor: buttonIconUnderlayColor, testID: "button-icon" },
5
+ const ButtonIcon = ({ name, style: customStyle, testID = "button-icon", onPress, ...restProps }) => (React.createElement(TouchableHighlight, { style: [style.buttonIcon, customStyle?.button], onPress: onPress, underlayColor: buttonIconUnderlayColor, testID: testID, ...restProps },
6
6
  React.createElement(Icon, { name: name, style: customStyle?.icon })));
7
7
  export { ButtonIcon };
@@ -4,6 +4,7 @@ import { Text, TouchableHighlight, View } from "react-native";
4
4
  import { useParams } from "react-router-native";
5
5
  import "../../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
6
6
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
7
+ import { feedback as feedbackMock } from "../../../projection/feedback/feedback.mock";
7
8
  import { returnQuestions as returnQuestionsMock } from "../../../projection/returnQuestion/returnQuestions.mock";
8
9
  import { Body } from "../../components/layouts/body/Body";
9
10
  import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
@@ -11,11 +12,8 @@ import { Spinner } from "../../shared/components/atoms/spinner/Spinner";
11
12
  import { style } from "./Item.style";
12
13
  import { ProductVariantDescription } from "./components/productVariantDescription/ProductVariantDescription";
13
14
  import { ProductVariantSlider } from "./components/productVariantSlider/ProductVariantSlider";
15
+ import { ReturnQuestionsFeedback } from "./components/returnQuestionsFeedback/ReturnQuestionsFeedback";
14
16
  import { ReturnQuestionsForm } from "./components/returnQuestionsForm/ReturnQuestionsForm";
15
- // const feedback: FeedbackProjection = {
16
- // ["bb02cedd-09a7-43ed-8e78-ee5b3ad56914"]: "7f336540-4453-4280-9b5f-3bfd4e03ff25",
17
- // };
18
- const feedback = {};
19
17
  const Item = ({ customerId }) => {
20
18
  const { id } = useParams();
21
19
  const [checkout, status] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
@@ -23,19 +21,24 @@ const Item = ({ customerId }) => {
23
21
  const [returnQuestionsVisible, setReturnQuestionsVisible] = useState(false);
24
22
  const handleOnShowReturnQuestions = useCallback(() => setReturnQuestionsVisible(true), []);
25
23
  const handleOnHideReturnQuestions = useCallback(() => setReturnQuestionsVisible(false), []);
24
+ const handleOnEditFeedback = useCallback(() => void 0, []);
26
25
  if (status === QueryStatus.LOADING)
27
26
  return React.createElement(Spinner, null);
28
27
  const { price } = checkoutItem;
29
28
  const { media, brand, name, size, color } = checkoutItem.productVariant;
30
29
  const returnQuestions = returnQuestionsMock;
30
+ const feedback = feedbackMock;
31
31
  return (React.createElement(React.Fragment, null,
32
32
  React.createElement(SafeAreaScrollView, null,
33
33
  React.createElement(Body, null,
34
34
  React.createElement(View, { style: style.sliderContainer },
35
35
  React.createElement(ProductVariantSlider, { producVariantMedia: media })),
36
36
  React.createElement(ProductVariantDescription, { brand: brand, name: name, price: price, size: size, color: color }),
37
- React.createElement(TouchableHighlight, { onPress: handleOnShowReturnQuestions },
38
- React.createElement(Text, { style: { padding: 16 } }, "show return questions")))),
37
+ Object.entries(feedback).length !== 0 && (React.createElement(View, { style: style.feedbackContainer },
38
+ React.createElement(ReturnQuestionsFeedback, { feedback: feedback, returnQuestions: returnQuestions, onEditFeedback: handleOnEditFeedback }))),
39
+ React.createElement(View, { style: { flexDirection: "row", justifyContent: "center" } },
40
+ React.createElement(TouchableHighlight, { onPress: handleOnShowReturnQuestions },
41
+ React.createElement(Text, { style: { padding: 16 } }, "show return questions"))))),
39
42
  React.createElement(ReturnQuestionsForm, { feedback: feedback, returnQuestions: returnQuestions, visible: returnQuestionsVisible, onClose: handleOnHideReturnQuestions })));
40
43
  };
41
44
  export { Item };
@@ -1,7 +1,12 @@
1
1
  declare const style: {
2
2
  sliderContainer: {
3
- flex: number;
3
+ minHeight: number;
4
4
  marginBottom: number;
5
5
  };
6
+ feedbackContainer: {
7
+ marginVertical: number;
8
+ borderTopColor: string;
9
+ borderTopWidth: number;
10
+ };
6
11
  };
7
12
  export { style };
@@ -1,10 +1,15 @@
1
1
  import { StyleSheet } from "react-native";
2
2
  import { theme } from "../../theme/theme";
3
- const { spaceXL } = theme();
3
+ const { borderSize, colorGrayscaleM, spaceXL } = theme();
4
4
  const style = StyleSheet.create({
5
5
  sliderContainer: {
6
- flex: 1,
6
+ minHeight: 500,
7
7
  marginBottom: spaceXL,
8
8
  },
9
+ feedbackContainer: {
10
+ marginVertical: spaceXL,
11
+ borderTopColor: colorGrayscaleM,
12
+ borderTopWidth: borderSize,
13
+ },
9
14
  });
10
15
  export { style };
@@ -0,0 +1,10 @@
1
+ import { FC } from "react";
2
+ import { FeedbackProjection } from "../../../../../../projection/feedback/feedback";
3
+ import { ReturnQuestionProjection } from "../../../../../../projection/returnQuestion/returnQuestion";
4
+ interface ReturnQuestionsFeedbackProps {
5
+ readonly feedback: FeedbackProjection;
6
+ readonly returnQuestions: ReturnQuestionProjection[];
7
+ readonly onEditFeedback: () => void;
8
+ }
9
+ declare const ReturnQuestionsFeedback: FC<ReturnQuestionsFeedbackProps>;
10
+ export { ReturnQuestionsFeedback };
@@ -0,0 +1,32 @@
1
+ import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
2
+ import { useI18nMessage } from "@lookiero/i18n-react";
3
+ import React from "react";
4
+ import { View } from "react-native";
5
+ import { ReturnQuestionType, } from "../../../../../../projection/returnQuestion/returnQuestion";
6
+ import { ReturnQuestions } from "../../../../components/organisms/returnQuestions/ReturnQuestions";
7
+ import { ReturnQuestionFeedbackProvider } from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
8
+ import { ReturnQuestionItemProvider, } from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionItem";
9
+ import { HostDefaultReturnQuestionFeedbackItem } from "../../../../components/organisms/returnQuestions/components/hostDefaultReturnQuestionFeedbackItem/HostDefaultReturnQuestionFeedbackItem";
10
+ import { ReturnQuestionFeedbackItem } from "../../../../components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem";
11
+ import { I18nMessages, RETURN_QUESTIONS_PREFIX } from "../../../../i18n/i18n";
12
+ import { ButtonIcon } from "../../../../shared/components/molecules/buttonIcon/ButtonIcon";
13
+ import { style } from "./ReturnQuestionsFeedback.style";
14
+ const returnQuestionItems = {
15
+ [ReturnQuestionType.HOST_DEFAULT]: HostDefaultReturnQuestionFeedbackItem,
16
+ [ReturnQuestionType.HOST_TEXTAREA]: HostDefaultReturnQuestionFeedbackItem,
17
+ [ReturnQuestionType.HOST_SELECT]: ReturnQuestionFeedbackItem,
18
+ [ReturnQuestionType.HOST_STACK]: ReturnQuestionFeedbackItem,
19
+ [ReturnQuestionType.TEXTAREA]: ReturnQuestionFeedbackItem,
20
+ [ReturnQuestionType.OPTION]: ReturnQuestionFeedbackItem,
21
+ };
22
+ const ReturnQuestionsFeedback = ({ feedback, returnQuestions, onEditFeedback }) => {
23
+ const titleText = useI18nMessage({ id: I18nMessages.FEEDBACK_TITLE, prefix: RETURN_QUESTIONS_PREFIX });
24
+ return (React.createElement(View, null,
25
+ React.createElement(View, { style: style.titleContainer },
26
+ React.createElement(Text, { level: 2, style: style.title }, titleText),
27
+ React.createElement(ButtonIcon, { name: "pencil", onPress: onEditFeedback })),
28
+ React.createElement(ReturnQuestionFeedbackProvider, { feedback: feedback },
29
+ React.createElement(ReturnQuestionItemProvider, { returnQuestionItems: returnQuestionItems },
30
+ React.createElement(ReturnQuestions, { returnQuestions: returnQuestions })))));
31
+ };
32
+ export { ReturnQuestionsFeedback };
@@ -0,0 +1,12 @@
1
+ declare const style: {
2
+ titleContainer: {
3
+ flexDirection: "row";
4
+ alignItems: "center";
5
+ justifyContent: "space-between";
6
+ };
7
+ title: {
8
+ marginTop: number;
9
+ marginBottom: number;
10
+ };
11
+ };
12
+ export { style };
@@ -0,0 +1,15 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "../../../../theme/theme";
3
+ const { spaceL, spaceXL } = theme();
4
+ const style = StyleSheet.create({
5
+ titleContainer: {
6
+ flexDirection: "row",
7
+ alignItems: "center",
8
+ justifyContent: "space-between",
9
+ },
10
+ title: {
11
+ marginTop: spaceXL,
12
+ marginBottom: spaceL,
13
+ },
14
+ });
15
+ export { style };
@@ -1,7 +1,6 @@
1
1
  import { PortalHost } from "@gorhom/portal";
2
2
  import React from "react";
3
- import { ScrollView, View } from "react-native";
4
- import { useSafeAreaInsets } from "react-native-safe-area-context";
3
+ import { View } from "react-native";
5
4
  import { ReturnQuestionType, } from "../../../../../../projection/returnQuestion/returnQuestion";
6
5
  import { ReturnQuestions } from "../../../../components/organisms/returnQuestions/ReturnQuestions";
7
6
  import { ReturnQuestionFeedbackProvider } from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
@@ -12,9 +11,7 @@ import { HostStackReturnQuestionItem } from "../../../../components/organisms/re
12
11
  import { OptionReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem";
13
12
  import { TextareaReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem";
14
13
  import { Modal } from "../../../../shared/components/layouts/modal/Modal";
15
- import { theme } from "../../../../theme/theme";
16
14
  import { style } from "./ReturnQuestionsForm.style";
17
- const { spaceXL } = theme();
18
15
  const RETURN_QUESTION_FORM_PORTAL_HOST_NAME = "return-question-form-portal";
19
16
  const returnQuestionItems = {
20
17
  [ReturnQuestionType.HOST_DEFAULT]: HostDefaultReturnQuestionItem,
@@ -24,14 +21,10 @@ const returnQuestionItems = {
24
21
  [ReturnQuestionType.TEXTAREA]: TextareaReturnQuestionItem,
25
22
  [ReturnQuestionType.OPTION]: OptionReturnQuestionItem,
26
23
  };
27
- const ReturnQuestionsForm = ({ feedback, returnQuestions, onClose, visible }) => {
28
- const { bottom: safeAreaInsetBottom } = useSafeAreaInsets();
29
- return (React.createElement(ReturnQuestionFeedbackProvider, { feedback: feedback },
30
- React.createElement(ReturnQuestionItemProvider, { returnQuestionItems: returnQuestionItems },
31
- React.createElement(PortalHost, { name: RETURN_QUESTION_FORM_PORTAL_HOST_NAME }),
32
- React.createElement(Modal, { visible: visible, onClose: onClose, portalHostName: RETURN_QUESTION_FORM_PORTAL_HOST_NAME },
33
- React.createElement(ScrollView, null,
34
- React.createElement(View, { style: [style.returnQuestionsContainer, { paddingBottom: spaceXL + safeAreaInsetBottom }] },
35
- React.createElement(ReturnQuestions, { returnQuestions: returnQuestions, portalHostName: RETURN_QUESTION_FORM_PORTAL_HOST_NAME })))))));
36
- };
24
+ const ReturnQuestionsForm = ({ feedback, returnQuestions, onClose, visible }) => (React.createElement(ReturnQuestionFeedbackProvider, { feedback: feedback },
25
+ React.createElement(ReturnQuestionItemProvider, { returnQuestionItems: returnQuestionItems },
26
+ React.createElement(PortalHost, { name: RETURN_QUESTION_FORM_PORTAL_HOST_NAME }),
27
+ React.createElement(Modal, { visible: visible, onClose: onClose, portalHostName: RETURN_QUESTION_FORM_PORTAL_HOST_NAME, scroll: true },
28
+ React.createElement(View, { style: style.returnQuestionsContainer },
29
+ React.createElement(ReturnQuestions, { returnQuestions: returnQuestions, portalHostName: RETURN_QUESTION_FORM_PORTAL_HOST_NAME }))))));
37
30
  export { ReturnQuestionsForm };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.2.22",
3
+ "version": "0.2.24",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -1,10 +0,0 @@
1
- declare const style: {
2
- container: {
3
- flex: number;
4
- };
5
- scrollContainer: {
6
- flex: number;
7
- flexGrow: number;
8
- };
9
- };
10
- export { style };
@@ -1,11 +0,0 @@
1
- import { StyleSheet } from "react-native";
2
- const style = StyleSheet.create({
3
- container: {
4
- flex: 1,
5
- },
6
- scrollContainer: {
7
- flex: 1,
8
- flexGrow: 1,
9
- },
10
- });
11
- export { style };