@lookiero/checkout 0.3.17 → 0.3.19

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 (60) hide show
  1. package/dist/package.json +1 -1
  2. package/dist/src/domain/checkoutFeedback/command/giveCheckoutFeedback.d.ts +15 -0
  3. package/dist/src/domain/checkoutFeedback/command/giveCheckoutFeedback.js +7 -0
  4. package/dist/src/domain/checkoutFeedback/model/checkoutFeedback.d.ts +9 -0
  5. package/dist/src/domain/checkoutFeedback/model/checkoutFeedback.js +10 -0
  6. package/dist/src/domain/checkoutFeedback/model/checkoutFeedbackGiven.d.ts +13 -0
  7. package/dist/src/domain/checkoutFeedback/model/checkoutFeedbackGiven.js +4 -0
  8. package/dist/src/domain/checkoutFeedback/model/checkoutFeedbacks.d.ts +7 -0
  9. package/dist/src/domain/checkoutFeedback/model/feedbacks.d.ts +3 -0
  10. package/dist/src/domain/checkoutFeedback/model/feedbacks.js +1 -0
  11. package/dist/src/infrastructure/domain/checkoutFeedback/model/httpCheckoutFeedbacks.d.ts +16 -0
  12. package/dist/src/infrastructure/domain/checkoutFeedback/model/httpCheckoutFeedbacks.js +14 -0
  13. package/dist/src/infrastructure/domain/checkoutFeedback/model/httpCheckoutFeedbacksGive.d.ts +5 -0
  14. package/dist/src/infrastructure/domain/checkoutFeedback/model/httpCheckoutFeedbacksGive.js +13 -0
  15. package/dist/src/infrastructure/domain/checkoutFeedback/react/useGiveCheckoutFeedback.d.ts +17 -0
  16. package/dist/src/infrastructure/domain/checkoutFeedback/react/useGiveCheckoutFeedback.js +13 -0
  17. package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByIdView.d.ts +12 -0
  18. package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByIdView.js +9 -0
  19. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.d.ts +8 -0
  20. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.js +8 -0
  21. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.d.ts +7 -0
  22. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.js +4 -0
  23. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.d.ts +18 -0
  24. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.js +12 -0
  25. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/{CheckoutQuestionItem.d.ts → components/CheckoutQuestionItem.d.ts} +1 -1
  26. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/CheckoutQuestionItem.js +1 -0
  27. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.d.ts +1 -1
  28. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.style.d.ts +1 -0
  29. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.style.js +1 -0
  30. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.d.ts +3 -0
  31. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.js +12 -0
  32. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.style.d.ts +8 -0
  33. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.style.js +11 -0
  34. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.d.ts +3 -0
  35. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.js +13 -0
  36. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.style.d.ts +13 -0
  37. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.style.js +16 -0
  38. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.d.ts +2 -2
  39. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.js +8 -4
  40. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.style.d.ts +6 -0
  41. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.style.js +7 -0
  42. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.d.ts +3 -0
  43. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.js +15 -0
  44. package/dist/src/infrastructure/ui/i18n/i18n.d.ts +2 -1
  45. package/dist/src/infrastructure/ui/i18n/i18n.js +1 -0
  46. package/dist/src/infrastructure/ui/views/feedback/Feedback.js +33 -6
  47. package/dist/src/infrastructure/ui/views/feedback/Feedback.style.d.ts +9 -0
  48. package/dist/src/infrastructure/ui/views/feedback/Feedback.style.js +12 -0
  49. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.d.ts +7 -0
  50. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.js +20 -0
  51. package/dist/src/projection/checkoutFeedback/checkoutFeedback.d.ts +6 -0
  52. package/dist/src/projection/checkoutFeedback/checkoutFeedback.js +1 -0
  53. package/dist/src/projection/checkoutFeedback/feedback.d.ts +3 -0
  54. package/dist/src/projection/checkoutFeedback/feedback.js +1 -0
  55. package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackById.d.ts +25 -0
  56. package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackById.js +8 -0
  57. package/dist/src/projection/checkoutQuestion/checkoutQuestion.d.ts +0 -2
  58. package/dist/src/projection/checkoutQuestion/checkoutQuestion.js +0 -2
  59. package/package.json +1 -1
  60. /package/dist/src/{infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestionItem.js → domain/checkoutFeedback/model/checkoutFeedbacks.js} +0 -0
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.3.17",
3
+ "version": "0.3.19",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -0,0 +1,15 @@
1
+ import { Command } from "@lookiero/messaging";
2
+ import { Feedbacks } from "../model/feedbacks";
3
+ declare const GIVE_CHECKOUT_FEEDBACK = "give_checkout_feedback";
4
+ interface GiveCheckoutFeedbackPayload {
5
+ readonly aggregateId: string;
6
+ readonly feedbacks: Feedbacks;
7
+ }
8
+ interface GiveCheckoutFeedback extends Command<typeof GIVE_CHECKOUT_FEEDBACK>, GiveCheckoutFeedbackPayload {
9
+ }
10
+ interface GiveCheckoutFeedbackFunction {
11
+ (payload: GiveCheckoutFeedbackPayload): GiveCheckoutFeedback;
12
+ }
13
+ declare const giveCheckoutFeedback: GiveCheckoutFeedbackFunction;
14
+ export type { GiveCheckoutFeedback };
15
+ export { GIVE_CHECKOUT_FEEDBACK, giveCheckoutFeedback };
@@ -0,0 +1,7 @@
1
+ import { command } from "@lookiero/messaging";
2
+ const GIVE_CHECKOUT_FEEDBACK = "give_checkout_feedback";
3
+ const giveCheckoutFeedback = ({ aggregateId, ...payload }) => ({
4
+ ...command({ aggregateId, name: GIVE_CHECKOUT_FEEDBACK }),
5
+ ...payload,
6
+ });
7
+ export { GIVE_CHECKOUT_FEEDBACK, giveCheckoutFeedback };
@@ -0,0 +1,9 @@
1
+ import { AggregateRoot, CommandHandlerFunction } from "@lookiero/messaging";
2
+ import { GiveCheckoutFeedback } from "../command/giveCheckoutFeedback";
3
+ import { Feedbacks } from "./feedbacks";
4
+ interface CheckoutFeedback extends AggregateRoot {
5
+ readonly feedbacks: Feedbacks;
6
+ }
7
+ declare const giveCheckoutFeedbackHandler: CommandHandlerFunction<GiveCheckoutFeedback, CheckoutFeedback>;
8
+ export type { CheckoutFeedback };
9
+ export { giveCheckoutFeedbackHandler };
@@ -0,0 +1,10 @@
1
+ import { checkoutFeedbackGiven } from "./checkoutFeedbackGiven";
2
+ const giveCheckoutFeedbackHandler = () => async ({ aggregateRoot, command }) => {
3
+ const { aggregateId, feedbacks } = command;
4
+ return {
5
+ ...aggregateRoot,
6
+ feedbacks,
7
+ domainEvents: [checkoutFeedbackGiven({ aggregateId })],
8
+ };
9
+ };
10
+ export { giveCheckoutFeedbackHandler };
@@ -0,0 +1,13 @@
1
+ import { DomainEvent } from "@lookiero/messaging";
2
+ declare const CHECKOUT_FEEDBACK_GIVEN = "checkout_feedback_given";
3
+ interface CheckoutFeedbackGivenPayload {
4
+ readonly aggregateId: string;
5
+ }
6
+ interface CheckoutFeedbackGiven extends DomainEvent<typeof CHECKOUT_FEEDBACK_GIVEN>, CheckoutFeedbackGivenPayload {
7
+ }
8
+ interface CheckoutFeedbackGivenFunction {
9
+ (payload: CheckoutFeedbackGivenPayload): CheckoutFeedbackGiven;
10
+ }
11
+ declare const checkoutFeedbackGiven: CheckoutFeedbackGivenFunction;
12
+ export type { CheckoutFeedbackGiven };
13
+ export { CHECKOUT_FEEDBACK_GIVEN, checkoutFeedbackGiven };
@@ -0,0 +1,4 @@
1
+ import { domainEvent } from "@lookiero/messaging";
2
+ const CHECKOUT_FEEDBACK_GIVEN = "checkout_feedback_given";
3
+ const checkoutFeedbackGiven = ({ aggregateId }) => domainEvent({ aggregateId, name: CHECKOUT_FEEDBACK_GIVEN });
4
+ export { CHECKOUT_FEEDBACK_GIVEN, checkoutFeedbackGiven };
@@ -0,0 +1,7 @@
1
+ import { RepositoryGetFunction, RepositoryGetFunctionArgs, RepositorySaveFunction, RepositorySaveFunctionArgs } from "@lookiero/messaging";
2
+ import { CheckoutFeedback } from "./checkoutFeedback";
3
+ interface CheckoutFeedbacksGetFunction<CheckoutFeedbacksGetFunctionArgs extends RepositoryGetFunctionArgs> extends RepositoryGetFunction<CheckoutFeedback, CheckoutFeedbacksGetFunctionArgs> {
4
+ }
5
+ interface CheckoutFeedbacksSaveFunction<CheckoutFeedbacksSaveFunctionArgs extends RepositorySaveFunctionArgs> extends RepositorySaveFunction<CheckoutFeedback, CheckoutFeedbacksSaveFunctionArgs> {
6
+ }
7
+ export type { CheckoutFeedbacksGetFunction, CheckoutFeedbacksSaveFunction };
@@ -0,0 +1,3 @@
1
+ type CheckoutQuestionId = string;
2
+ type Feedbacks = Record<CheckoutQuestionId, CheckoutQuestionId | string>;
3
+ export type { Feedbacks };
@@ -0,0 +1,16 @@
1
+ import { RepositoryGetFunctionArgs, RepositorySaveFunctionArgs } from "@lookiero/messaging";
2
+ import { CheckoutFeedbacksGetFunction, CheckoutFeedbacksSaveFunction } from "../../../../domain/checkoutFeedback/model/checkoutFeedbacks";
3
+ import { HttpPostFunction } from "../../../delivery/http/httpClient";
4
+ interface HttpCheckoutFeedbacksGetFunctionArgs extends RepositoryGetFunctionArgs {
5
+ }
6
+ interface HttpCheckoutFeedbacksGetFunction extends CheckoutFeedbacksGetFunction<HttpCheckoutFeedbacksGetFunctionArgs> {
7
+ }
8
+ declare const getCheckoutFeedback: HttpCheckoutFeedbacksGetFunction;
9
+ interface HttpCheckoutFeedbacksSaveFunctionArgs extends RepositorySaveFunctionArgs {
10
+ readonly httpPost: HttpPostFunction;
11
+ }
12
+ interface HttpCheckoutFeedbacksSaveFunction extends CheckoutFeedbacksSaveFunction<HttpCheckoutFeedbacksSaveFunctionArgs> {
13
+ }
14
+ declare const saveCheckoutFeedback: HttpCheckoutFeedbacksSaveFunction;
15
+ export type { HttpCheckoutFeedbacksSaveFunction };
16
+ export { getCheckoutFeedback, saveCheckoutFeedback };
@@ -0,0 +1,14 @@
1
+ import invariant from "tiny-invariant";
2
+ import { viewCheckoutFeedbackById, } from "../../../../projection/checkoutFeedback/viewCheckoutFeedbackById";
3
+ import { httpCheckoutFeedbacksGive } from "./httpCheckoutFeedbacksGive";
4
+ const toDomain = (checkoutFeedback) => {
5
+ invariant(checkoutFeedback, "Not checkoutFeedback found!");
6
+ return {
7
+ aggregateId: checkoutFeedback.id,
8
+ feedbacks: checkoutFeedback.feedbacks,
9
+ domainEvents: [],
10
+ };
11
+ };
12
+ const getCheckoutFeedback = ({ queryBus }) => async (aggregateId) => toDomain(await queryBus(viewCheckoutFeedbackById({ checkoutFeedbackId: aggregateId })));
13
+ const saveCheckoutFeedback = ({ httpPost }) => async (aggregateRoot) => await httpCheckoutFeedbacksGive({ httpPost })(aggregateRoot);
14
+ export { getCheckoutFeedback, saveCheckoutFeedback };
@@ -0,0 +1,5 @@
1
+ import { HttpCheckoutFeedbacksSaveFunction } from "./httpCheckoutFeedbacks";
2
+ interface HttpCheckoutFeedbackGiveFunction extends HttpCheckoutFeedbacksSaveFunction {
3
+ }
4
+ declare const httpCheckoutFeedbacksGive: HttpCheckoutFeedbackGiveFunction;
5
+ export { httpCheckoutFeedbacksGive };
@@ -0,0 +1,13 @@
1
+ import { CHECKOUT_FEEDBACK_GIVEN, } from "../../../../domain/checkoutFeedback/model/checkoutFeedbackGiven";
2
+ const isCheckoutFeedbackGiven = (event) => event.name === CHECKOUT_FEEDBACK_GIVEN;
3
+ const httpCheckoutFeedbacksGive = ({ httpPost }) => async ({ aggregateId, feedbacks, domainEvents }) => {
4
+ const checkoutFeedbackGiven = domainEvents.find(isCheckoutFeedbackGiven);
5
+ if (!checkoutFeedbackGiven) {
6
+ return;
7
+ }
8
+ await httpPost({
9
+ endpoint: "/give-checkout-feedback",
10
+ body: { checkoutId: aggregateId, feedbacks },
11
+ });
12
+ };
13
+ export { httpCheckoutFeedbacksGive };
@@ -0,0 +1,17 @@
1
+ import { CommandStatus } from "@lookiero/messaging-react";
2
+ import { Feedbacks } from "../../../../domain/checkoutFeedback/model/feedbacks";
3
+ interface GiveCheckoutFeedbackFunctionArgs {
4
+ readonly feedbacks: Feedbacks;
5
+ }
6
+ interface GiveCheckoutFeedbackFunction {
7
+ (args: GiveCheckoutFeedbackFunctionArgs): Promise<void>;
8
+ }
9
+ type UseGiveCheckoutFeedback = [giveCheckoutFeedback: GiveCheckoutFeedbackFunction, status: CommandStatus];
10
+ interface UseGiveCheckoutFeedbackFunctionArgs {
11
+ readonly checkoutId: string;
12
+ }
13
+ interface UseGiveCheckoutFeedbackFunction {
14
+ (args: UseGiveCheckoutFeedbackFunctionArgs): UseGiveCheckoutFeedback;
15
+ }
16
+ declare const useGiveCheckoutFeedback: UseGiveCheckoutFeedbackFunction;
17
+ export { useGiveCheckoutFeedback };
@@ -0,0 +1,13 @@
1
+ import { useCommand } from "@lookiero/messaging-react";
2
+ import { useCallback } from "react";
3
+ import { giveCheckoutFeedback as giveCheckoutFeedbackCommand } from "../../../../domain/checkoutFeedback/command/giveCheckoutFeedback";
4
+ import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
5
+ const useGiveCheckoutFeedback = ({ checkoutId }) => {
6
+ const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
7
+ const giveCheckoutFeedback = useCallback(({ feedbacks }) => commandBus(giveCheckoutFeedbackCommand({
8
+ aggregateId: checkoutId,
9
+ feedbacks,
10
+ })), [checkoutId, commandBus]);
11
+ return [giveCheckoutFeedback, status];
12
+ };
13
+ export { useGiveCheckoutFeedback };
@@ -0,0 +1,12 @@
1
+ import { CheckoutFeedbackByIdView } from "../../../projection/checkoutFeedback/viewCheckoutFeedbackById";
2
+ import { HttpPostFunction } from "../../delivery/http/httpClient";
3
+ interface HttpCheckoutFeebackByIdView extends CheckoutFeedbackByIdView {
4
+ }
5
+ interface HttpCheckoutFeebackByIdViewFunctionArgs {
6
+ readonly httpPost: HttpPostFunction;
7
+ }
8
+ interface HttpCheckoutFeebackByIdViewFunction {
9
+ (args: HttpCheckoutFeebackByIdViewFunctionArgs): HttpCheckoutFeebackByIdView;
10
+ }
11
+ declare const httpCheckoutFeebackByIdView: HttpCheckoutFeebackByIdViewFunction;
12
+ export { httpCheckoutFeebackByIdView };
@@ -0,0 +1,9 @@
1
+ const httpCheckoutFeebackByIdView = ({ httpPost }) => async ({ checkoutFeedbackId, signal }) => {
2
+ const response = await httpPost({
3
+ endpoint: "/view-checkout-feedback-by-id",
4
+ body: { checkoutFeedbackId },
5
+ signal,
6
+ });
7
+ return !response.ok || response.status === 404 ? null : (await response.json()).result;
8
+ };
9
+ export { httpCheckoutFeebackByIdView };
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { CheckoutQuestionProjection } from "../../../../../projection/checkoutQuestion/checkoutQuestion";
3
+ interface CheckoutQuestionProps {
4
+ readonly checkoutQuestionParentId: string;
5
+ readonly checkoutQuestion: CheckoutQuestionProjection;
6
+ }
7
+ declare const _default: React.NamedExoticComponent<CheckoutQuestionProps>;
8
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import React, { memo } from "react";
2
+ import { useCheckoutQuestionItem } from "./behaviors/useCheckoutQuestionItem";
3
+ const CheckoutQuestion = ({ checkoutQuestion, checkoutQuestionParentId, }) => {
4
+ const Item = useCheckoutQuestionItem({ type: checkoutQuestion.type });
5
+ return (React.createElement(Item, { checkoutQuestion: checkoutQuestion, checkoutQuestionParentId: checkoutQuestionParentId },
6
+ React.createElement(React.Fragment, null, checkoutQuestion.children?.map((childCheckoutQuestion) => (React.createElement(CheckoutQuestion, { key: childCheckoutQuestion.id, checkoutQuestion: childCheckoutQuestion, checkoutQuestionParentId: checkoutQuestion.id }))))));
7
+ };
8
+ export default memo(CheckoutQuestion);
@@ -0,0 +1,7 @@
1
+ import { FC } from "react";
2
+ import { CheckoutQuestionProjection } from "../../../../../projection/checkoutQuestion/checkoutQuestion";
3
+ interface CheckoutQuestionsProps {
4
+ readonly checkoutQuestions: CheckoutQuestionProjection[];
5
+ }
6
+ declare const CheckoutQuestions: FC<CheckoutQuestionsProps>;
7
+ export { CheckoutQuestions };
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import CheckoutQuestion from "./CheckoutQuestion";
3
+ const CheckoutQuestions = ({ checkoutQuestions }) => (React.createElement(React.Fragment, null, checkoutQuestions.map((checkoutQuestion) => (React.createElement(CheckoutQuestion, { key: checkoutQuestion.id, checkoutQuestion: checkoutQuestion, checkoutQuestionParentId: "" })))));
4
+ export { CheckoutQuestions };
@@ -0,0 +1,18 @@
1
+ import { FC, ReactNode } from "react";
2
+ import { CheckoutQuestionType } from "../../../../../../projection/checkoutQuestion/checkoutQuestion";
3
+ import { CheckoutQuestionItem } from "../components/CheckoutQuestionItem";
4
+ type CheckoutQuestionItems = Record<CheckoutQuestionType, CheckoutQuestionItem>;
5
+ interface CheckoutQuestionItemContextProviderProps {
6
+ readonly checkoutQuestionItems: CheckoutQuestionItems;
7
+ readonly children: ReactNode;
8
+ }
9
+ declare const CheckoutQuestionItemProvider: FC<CheckoutQuestionItemContextProviderProps>;
10
+ interface UseCheckoutQuestionItemFunctionArgs {
11
+ readonly type: CheckoutQuestionType;
12
+ }
13
+ interface UseCheckoutQuestionItemFunction {
14
+ (args: UseCheckoutQuestionItemFunctionArgs): CheckoutQuestionItem;
15
+ }
16
+ declare const useCheckoutQuestionItem: UseCheckoutQuestionItemFunction;
17
+ export type { CheckoutQuestionItems };
18
+ export { useCheckoutQuestionItem, CheckoutQuestionItemProvider };
@@ -0,0 +1,12 @@
1
+ import React, { createContext, useContext, useMemo } from "react";
2
+ import invariant from "tiny-invariant";
3
+ const CheckoutQuestionItemContext = createContext({});
4
+ const CheckoutQuestionItemProvider = ({ checkoutQuestionItems, children, }) => (React.createElement(CheckoutQuestionItemContext.Provider, { value: checkoutQuestionItems }, children));
5
+ const useCheckoutQuestionItem = ({ type }) => {
6
+ const items = useContext(CheckoutQuestionItemContext);
7
+ const item = useMemo(() => items[type], [items, type]);
8
+ invariant(items, "Your are trying to use the useCheckoutQuestionItem hook without wrapping your app with the <CheckoutQuestionItemProvider>.");
9
+ invariant(item, `The provided CheckoutQuestionType (${type}) is NOT SUPPORTED`);
10
+ return item;
11
+ };
12
+ export { useCheckoutQuestionItem, CheckoutQuestionItemProvider };
@@ -1,5 +1,5 @@
1
1
  import { FC, ReactNode } from "react";
2
- import { CheckoutQuestionProjection } from "../../../../../projection/checkoutQuestion/checkoutQuestion";
2
+ import { CheckoutQuestionProjection } from "../../../../../../projection/checkoutQuestion/checkoutQuestion";
3
3
  interface CheckoutQuestionItemProps {
4
4
  readonly checkoutQuestion: CheckoutQuestionProjection;
5
5
  readonly checkoutQuestionParentId: string;
@@ -1,3 +1,3 @@
1
- import { CheckoutQuestionItem } from "../../CheckoutQuestionItem";
1
+ import { CheckoutQuestionItem } from "../CheckoutQuestionItem";
2
2
  declare const ButtonCheckoutQuestionItem: CheckoutQuestionItem;
3
3
  export { ButtonCheckoutQuestionItem };
@@ -1,6 +1,7 @@
1
1
  declare const style: {
2
2
  button: {
3
3
  borderRadius: number;
4
+ marginHorizontal: number;
4
5
  };
5
6
  };
6
7
  export { style };
@@ -4,6 +4,7 @@ const { inputSize } = theme();
4
4
  const style = StyleSheet.create({
5
5
  button: {
6
6
  borderRadius: inputSize / 2,
7
+ marginHorizontal: 12,
7
8
  },
8
9
  });
9
10
  export { style };
@@ -0,0 +1,3 @@
1
+ import { CheckoutQuestionItem } from "../CheckoutQuestionItem";
2
+ declare const HostDefaultCheckoutQuestionItem: CheckoutQuestionItem;
3
+ export { HostDefaultCheckoutQuestionItem };
@@ -0,0 +1,12 @@
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 { RETURN_QUESTIONS_PREFIX } from "../../../../../i18n/i18n";
5
+ import { style } from "./HostDefaultCheckoutQuestionItem.style";
6
+ const HostDefaultCheckoutQuestionItem = ({ checkoutQuestion, children, }) => {
7
+ const titleText = useI18nMessage({ id: checkoutQuestion.name, prefix: RETURN_QUESTIONS_PREFIX });
8
+ return (React.createElement(React.Fragment, null,
9
+ React.createElement(Text, { level: 3, style: style.title }, titleText),
10
+ children));
11
+ };
12
+ export { HostDefaultCheckoutQuestionItem };
@@ -0,0 +1,8 @@
1
+ declare const style: {
2
+ title: {
3
+ marginBottom: number;
4
+ marginTop: number;
5
+ textAlign: "center";
6
+ };
7
+ };
8
+ export { style };
@@ -0,0 +1,11 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "../../../../../theme/theme";
3
+ const { spaceL, spaceXXXL } = theme();
4
+ const style = StyleSheet.create({
5
+ title: {
6
+ marginBottom: spaceL,
7
+ marginTop: spaceXXXL,
8
+ textAlign: "center",
9
+ },
10
+ });
11
+ export { style };
@@ -0,0 +1,3 @@
1
+ import { CheckoutQuestionItem } from "../CheckoutQuestionItem";
2
+ declare const HostSelectCheckoutQuestionItem: CheckoutQuestionItem;
3
+ export { HostSelectCheckoutQuestionItem };
@@ -0,0 +1,13 @@
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 { CHECKOUT_QUESTIONS_PREFIX } from "../../../../../i18n/i18n";
6
+ import { style } from "./HostSelectCheckoutQuestionItem.style";
7
+ const HostSelectCheckoutQuestionItem = ({ checkoutQuestion, children, }) => {
8
+ const titleText = useI18nMessage({ id: checkoutQuestion.name, prefix: CHECKOUT_QUESTIONS_PREFIX });
9
+ return (React.createElement(React.Fragment, null,
10
+ React.createElement(Text, { level: 3, style: style.title }, titleText),
11
+ React.createElement(View, { style: style.content }, children)));
12
+ };
13
+ export { HostSelectCheckoutQuestionItem };
@@ -0,0 +1,13 @@
1
+ declare const containerUnderlayColor: string;
2
+ declare const style: {
3
+ content: {
4
+ flexDirection: "row";
5
+ justifyContent: "center";
6
+ };
7
+ title: {
8
+ marginBottom: number;
9
+ marginTop: number;
10
+ textAlign: "center";
11
+ };
12
+ };
13
+ export { style, containerUnderlayColor };
@@ -0,0 +1,16 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "../../../../../theme/theme";
3
+ const { spaceL, spaceXXXL, colorGrayscaleS } = theme();
4
+ const containerUnderlayColor = colorGrayscaleS;
5
+ const style = StyleSheet.create({
6
+ content: {
7
+ flexDirection: "row",
8
+ justifyContent: "center",
9
+ },
10
+ title: {
11
+ marginBottom: spaceL,
12
+ marginTop: spaceXXXL,
13
+ textAlign: "center",
14
+ },
15
+ });
16
+ export { style, containerUnderlayColor };
@@ -1,5 +1,5 @@
1
- import { CheckoutQuestionItem } from "../../CheckoutQuestionItem";
2
- type IconName = "icon_bad" | "icon_regular" | "icon_good";
1
+ import { CheckoutQuestionItem } from "../CheckoutQuestionItem";
2
+ type IconName = "checkout.checkout_question.icon.bad" | "checkout.checkout_question.icon.regular" | "checkout.checkout_question.icon.good";
3
3
  declare const IconCheckoutQuestionItem: CheckoutQuestionItem;
4
4
  export type { IconName };
5
5
  export { IconCheckoutQuestionItem };
@@ -1,19 +1,23 @@
1
1
  import React, { useCallback } from "react";
2
2
  import { Pressable } from "react-native";
3
3
  import invariant from "tiny-invariant";
4
+ import { style } from "./IconCheckoutQuestionItem.style";
4
5
  import { Happy } from "./icons/Happy";
5
6
  import { Normal } from "./icons/Normal";
6
7
  import { Sad } from "./icons/Sad";
7
8
  const ICON = {
8
- icon_bad: Sad,
9
- icon_regular: Normal,
10
- icon_good: Happy,
9
+ // eslint-disable-next-line @typescript-eslint/naming-convention
10
+ "checkout.checkout_question.icon.bad": Sad,
11
+ // eslint-disable-next-line @typescript-eslint/naming-convention
12
+ "checkout.checkout_question.icon.regular": Normal,
13
+ // eslint-disable-next-line @typescript-eslint/naming-convention
14
+ "checkout.checkout_question.icon.good": Happy,
11
15
  };
12
16
  const IconCheckoutQuestionItem = ({ checkoutQuestion }) => {
13
17
  const Icon = ICON[checkoutQuestion.name];
14
18
  const handleOnPress = useCallback(() => void 0, []);
15
19
  invariant(Icon, "CheckoutQuestion icon does not exist");
16
20
  return (React.createElement(Pressable, { onPress: handleOnPress },
17
- React.createElement(Icon, { testID: checkoutQuestion.name })));
21
+ React.createElement(Icon, { style: style.icon, testID: checkoutQuestion.name })));
18
22
  };
19
23
  export { IconCheckoutQuestionItem };
@@ -0,0 +1,6 @@
1
+ declare const style: {
2
+ icon: {
3
+ marginHorizontal: number;
4
+ };
5
+ };
6
+ export { style };
@@ -0,0 +1,7 @@
1
+ import { StyleSheet } from "react-native";
2
+ const style = StyleSheet.create({
3
+ icon: {
4
+ marginHorizontal: 12,
5
+ },
6
+ });
7
+ export { style };
@@ -0,0 +1,3 @@
1
+ import { CheckoutQuestionItem } from "../CheckoutQuestionItem";
2
+ declare const TextareaCheckoutQuestionItem: CheckoutQuestionItem;
3
+ export { TextareaCheckoutQuestionItem };
@@ -0,0 +1,15 @@
1
+ import { useI18nMessage } from "@lookiero/i18n-react";
2
+ import React, { useCallback, useState } from "react";
3
+ import { InputField } from "../../../../../../../shared/ui/components/molecules/inputField/InputField";
4
+ import { RETURN_QUESTIONS_PREFIX } from "../../../../../i18n/i18n";
5
+ const TEXTAREA_MIN_HEIGHT = 96;
6
+ const TextareaCheckoutQuestionItem = ({ checkoutQuestion }) => {
7
+ const placeholderText = useI18nMessage({
8
+ id: checkoutQuestion.placeholder,
9
+ prefix: RETURN_QUESTIONS_PREFIX,
10
+ });
11
+ const [value, setValue] = useState("");
12
+ const handleOnChange = useCallback((value) => setValue(value), []);
13
+ return (React.createElement(InputField, { label: placeholderText, minHeight: TEXTAREA_MIN_HEIGHT, placeholder: placeholderText, value: value, multiline: true, onChange: handleOnChange }));
14
+ };
15
+ export { TextareaCheckoutQuestionItem };
@@ -59,6 +59,7 @@ declare enum I18nMessages {
59
59
  CHECKOUT_SUCCESS_MODAL_BUTTON = "checkout.success_modal_button",
60
60
  CHECKOUT_DELIVERY_BANNER = "checkout.delivery_banner",
61
61
  HEADER_CHECKOUT_TITLE = "header.checkout_title",
62
- HEADER_COMPLETE_CHECKOUT_TITLE = "header.complete_checkout_title"
62
+ HEADER_COMPLETE_CHECKOUT_TITLE = "header.complete_checkout_title",
63
+ FEEDBACK_BUTTON = "feedback.button"
63
64
  }
64
65
  export { I18nMessages, COLOR_I18N_PREFIX, RETURN_QUESTIONS_PREFIX, RETURN_QUESTIONS_FEEDBACK_PREFIX, CHECKOUT_QUESTIONS_PREFIX, };
@@ -61,5 +61,6 @@ var I18nMessages;
61
61
  I18nMessages["CHECKOUT_DELIVERY_BANNER"] = "checkout.delivery_banner";
62
62
  I18nMessages["HEADER_CHECKOUT_TITLE"] = "header.checkout_title";
63
63
  I18nMessages["HEADER_COMPLETE_CHECKOUT_TITLE"] = "header.complete_checkout_title";
64
+ I18nMessages["FEEDBACK_BUTTON"] = "feedback.button";
64
65
  })(I18nMessages || (I18nMessages = {}));
65
66
  export { I18nMessages, COLOR_I18N_PREFIX, RETURN_QUESTIONS_PREFIX, RETURN_QUESTIONS_FEEDBACK_PREFIX, CHECKOUT_QUESTIONS_PREFIX, };
@@ -1,8 +1,35 @@
1
- import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
2
- import React from "react";
3
- import { View } from "react-native";
4
- const Feedback = () => {
5
- return (React.createElement(View, null,
6
- React.createElement(Text, null, "Feedback view")));
1
+ import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
2
+ import { useI18nMessage } from "@lookiero/i18n-react";
3
+ import { QueryStatus } from "@lookiero/messaging-react";
4
+ import React, { useCallback } from "react";
5
+ import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
6
+ import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
7
+ import { useListCheckoutQuestionsByCheckoutId } from "../../../projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId";
8
+ import { Body } from "../../components/layouts/body/Body";
9
+ import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
10
+ import { I18nMessages } from "../../i18n/i18n";
11
+ import { style } from "./Feedback.style";
12
+ import { CheckoutQuestionsForm } from "./components/checkoutQuestionsForm/CheckoutQuestionsForm";
13
+ const Feedback = ({ customerId }) => {
14
+ const buttonText = useI18nMessage({ id: I18nMessages.FEEDBACK_BUTTON });
15
+ const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
16
+ const [checkoutQuestions, checkoutQuestionsStatus] = useListCheckoutQuestionsByCheckoutId({
17
+ checkoutId: checkout?.id,
18
+ });
19
+ const handlePress = useCallback(() => void 0, []);
20
+ const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
21
+ const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus) && dependenciesLoadedStatuses.includes(checkoutQuestionsStatus);
22
+ if (!dependenciesLoaded)
23
+ return React.createElement(Spinner, null);
24
+ return (React.createElement(SafeAreaScrollView, null,
25
+ React.createElement(Body, { style: { column: style.bodyColumn } },
26
+ React.createElement(CheckoutQuestionsForm, { checkoutQuestions: checkoutQuestions || [] }),
27
+ React.createElement(Button
28
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
29
+ // @ts-ignore
30
+ , {
31
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
32
+ // @ts-ignore
33
+ style: style.button, onPress: handlePress }, buttonText))));
7
34
  };
8
35
  export { Feedback };
@@ -0,0 +1,9 @@
1
+ declare const style: {
2
+ bodyColumn: {
3
+ paddingHorizontal: number;
4
+ };
5
+ button: {
6
+ marginTop: number;
7
+ };
8
+ };
9
+ export { style };
@@ -0,0 +1,12 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "../../theme/theme";
3
+ const { spaceXL } = theme();
4
+ const style = StyleSheet.create({
5
+ bodyColumn: {
6
+ paddingHorizontal: spaceXL,
7
+ },
8
+ button: {
9
+ marginTop: 65,
10
+ },
11
+ });
12
+ export { style };
@@ -0,0 +1,7 @@
1
+ import { FC } from "react";
2
+ import { CheckoutQuestionProjection } from "../../../../../../projection/checkoutQuestion/checkoutQuestion";
3
+ interface CheckoutQuestionsFormProps {
4
+ readonly checkoutQuestions: CheckoutQuestionProjection[];
5
+ }
6
+ declare const CheckoutQuestionsForm: FC<CheckoutQuestionsFormProps>;
7
+ export { CheckoutQuestionsForm };
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import { CheckoutQuestionType, } from "../../../../../../projection/checkoutQuestion/checkoutQuestion";
3
+ import { CheckoutQuestions } from "../../../../components/organisms/checkoutQuestions/CheckoutQuestions";
4
+ import { CheckoutQuestionItemProvider, } from "../../../../components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem";
5
+ import { ButtonCheckoutQuestionItem } from "../../../../components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem";
6
+ import { HostDefaultCheckoutQuestionItem } from "../../../../components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem";
7
+ import { HostSelectCheckoutQuestionItem } from "../../../../components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem";
8
+ import { IconCheckoutQuestionItem } from "../../../../components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem";
9
+ import { TextareaCheckoutQuestionItem } from "../../../../components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem";
10
+ const checkoutQuestionItems = {
11
+ [CheckoutQuestionType.HOST_DEFAULT]: HostDefaultCheckoutQuestionItem,
12
+ [CheckoutQuestionType.HOST_TEXTAREA]: HostDefaultCheckoutQuestionItem,
13
+ [CheckoutQuestionType.HOST_SELECT]: HostSelectCheckoutQuestionItem,
14
+ [CheckoutQuestionType.TEXTAREA]: TextareaCheckoutQuestionItem,
15
+ [CheckoutQuestionType.ICON]: IconCheckoutQuestionItem,
16
+ [CheckoutQuestionType.BUTTON]: ButtonCheckoutQuestionItem,
17
+ };
18
+ const CheckoutQuestionsForm = ({ checkoutQuestions }) => (React.createElement(CheckoutQuestionItemProvider, { checkoutQuestionItems: checkoutQuestionItems },
19
+ React.createElement(CheckoutQuestions, { checkoutQuestions: checkoutQuestions })));
20
+ export { CheckoutQuestionsForm };
@@ -0,0 +1,6 @@
1
+ import { FeedbackProjection } from "./feedback";
2
+ interface CheckoutFeedbackProjection {
3
+ readonly id: string;
4
+ readonly feedbacks: FeedbackProjection;
5
+ }
6
+ export type { CheckoutFeedbackProjection };
@@ -0,0 +1,3 @@
1
+ type CheckoutQuestionId = string;
2
+ type FeedbackProjection = Record<CheckoutQuestionId, CheckoutQuestionId | string>;
3
+ export type { FeedbackProjection };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ import { CancelableQueryViewArgs, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
+ import { CheckoutFeedbackProjection } from "./checkoutFeedback";
3
+ declare const VIEW_CHECKOUT_FEEDBACK_BY_ID = "view_checkout_feedback_by_id";
4
+ interface ViewCheckoutFeedbackByIdPayload {
5
+ readonly checkoutFeedbackId: string;
6
+ }
7
+ interface ViewCheckoutFeedbackById extends Query<typeof VIEW_CHECKOUT_FEEDBACK_BY_ID>, ViewCheckoutFeedbackByIdPayload {
8
+ }
9
+ interface ViewCheckoutFeedbackByIdFunction {
10
+ (payload: ViewCheckoutFeedbackByIdPayload): ViewCheckoutFeedbackById;
11
+ }
12
+ declare const viewCheckoutFeedbackById: ViewCheckoutFeedbackByIdFunction;
13
+ type ViewCheckoutFeedbackByIdResult = CheckoutFeedbackProjection | null;
14
+ interface CheckoutFeedbackByIdViewArgs extends CancelableQueryViewArgs {
15
+ readonly checkoutFeedbackId: string;
16
+ }
17
+ interface CheckoutFeedbackByIdView {
18
+ (args: CheckoutFeedbackByIdViewArgs): Promise<ViewCheckoutFeedbackByIdResult>;
19
+ }
20
+ interface ViewCheckoutFeedbackByIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
21
+ readonly view: CheckoutFeedbackByIdView;
22
+ }
23
+ declare const viewCheckoutFeedbackByIdHandler: QueryHandlerFunction<ViewCheckoutFeedbackById, ViewCheckoutFeedbackByIdResult, ViewCheckoutFeedbackByIdHandlerFunctionArgs>;
24
+ export type { ViewCheckoutFeedbackById, CheckoutFeedbackByIdView, ViewCheckoutFeedbackByIdResult };
25
+ export { VIEW_CHECKOUT_FEEDBACK_BY_ID, viewCheckoutFeedbackById, viewCheckoutFeedbackByIdHandler };
@@ -0,0 +1,8 @@
1
+ import { query, } from "@lookiero/messaging";
2
+ const VIEW_CHECKOUT_FEEDBACK_BY_ID = "view_checkout_feedback_by_id";
3
+ const viewCheckoutFeedbackById = (payload) => ({
4
+ ...query({ name: VIEW_CHECKOUT_FEEDBACK_BY_ID }),
5
+ ...payload,
6
+ });
7
+ const viewCheckoutFeedbackByIdHandler = ({ view, signal }) => async ({ checkoutFeedbackId }) => view({ checkoutFeedbackId, signal });
8
+ export { VIEW_CHECKOUT_FEEDBACK_BY_ID, viewCheckoutFeedbackById, viewCheckoutFeedbackByIdHandler };
@@ -2,9 +2,7 @@ declare enum CheckoutQuestionType {
2
2
  HOST_DEFAULT = "HOST_DEFAULT",
3
3
  HOST_TEXTAREA = "HOST_TEXTAREA",
4
4
  HOST_SELECT = "HOST_SELECT",
5
- HOST_STACK = "HOST_STACK",
6
5
  TEXTAREA = "TEXTAREA",
7
- OPTION = "OPTION",
8
6
  ICON = "ICON",
9
7
  BUTTON = "BUTTON"
10
8
  }
@@ -3,9 +3,7 @@ var CheckoutQuestionType;
3
3
  CheckoutQuestionType["HOST_DEFAULT"] = "HOST_DEFAULT";
4
4
  CheckoutQuestionType["HOST_TEXTAREA"] = "HOST_TEXTAREA";
5
5
  CheckoutQuestionType["HOST_SELECT"] = "HOST_SELECT";
6
- CheckoutQuestionType["HOST_STACK"] = "HOST_STACK";
7
6
  CheckoutQuestionType["TEXTAREA"] = "TEXTAREA";
8
- CheckoutQuestionType["OPTION"] = "OPTION";
9
7
  CheckoutQuestionType["ICON"] = "ICON";
10
8
  CheckoutQuestionType["BUTTON"] = "BUTTON";
11
9
  })(CheckoutQuestionType || (CheckoutQuestionType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.3.17",
3
+ "version": "0.3.19",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [