@lookiero/checkout 0.3.20 → 0.3.21

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 (19) hide show
  1. package/dist/package.json +1 -1
  2. package/dist/src/infrastructure/delivery/mock/dataSourceCheckoutFeedbacks.js +6 -8
  3. package/dist/src/infrastructure/domain/checkoutFeedback/model/httpCheckoutFeedbacks.js +5 -4
  4. package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByCheckoutIdView.d.ts +12 -0
  5. package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByCheckoutIdView.js +9 -0
  6. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionFeedback.d.ts +3 -3
  7. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.d.ts +2 -2
  8. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.js +7 -2
  9. package/dist/src/projection/checkoutFeedback/checkoutFeedback.d.ts +2 -5
  10. package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId.d.ts +25 -0
  11. package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId.js +8 -0
  12. package/dist/src/projection/checkoutQuestion/checkoutQuestion.d.ts +1 -1
  13. package/package.json +1 -1
  14. package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByIdView.d.ts +0 -12
  15. package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByIdView.js +0 -9
  16. package/dist/src/projection/checkoutFeedback/feedback.d.ts +0 -3
  17. package/dist/src/projection/checkoutFeedback/feedback.js +0 -1
  18. package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackById.d.ts +0 -25
  19. package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackById.js +0 -8
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.3.20",
3
+ "version": "0.3.21",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -1,18 +1,16 @@
1
1
  import invariant from "tiny-invariant";
2
- import { viewCheckoutFeedbackById, } from "../../../projection/checkoutFeedback/viewCheckoutFeedbackById";
2
+ import { v4 as uuid } from "uuid";
3
+ import { viewCheckoutFeedbackByCheckoutId, } from "../../../projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId";
3
4
  const toCheckoutFeedbackDomain = (checkoutFeedback) => {
4
5
  invariant(checkoutFeedback, "No checkoutFeedback found!");
5
6
  return {
6
- aggregateId: checkoutFeedback.id,
7
- feedbacks: checkoutFeedback.feedbacks,
7
+ aggregateId: uuid(),
8
+ feedbacks: checkoutFeedback,
8
9
  domainEvents: [],
9
10
  };
10
11
  };
11
- const toCheckoutFeedbackProjection = (checkoutFeedback) => ({
12
- id: checkoutFeedback.aggregateId,
13
- feedbacks: checkoutFeedback.feedbacks,
14
- });
15
- const getCheckoutFeedback = ({ queryBus }) => async (aggregateId) => toCheckoutFeedbackDomain(await queryBus(viewCheckoutFeedbackById({ checkoutFeedbackId: aggregateId })));
12
+ const toCheckoutFeedbackProjection = (checkoutFeedback) => checkoutFeedback.feedbacks;
13
+ const getCheckoutFeedback = ({ queryBus }) => async (aggregateId) => toCheckoutFeedbackDomain(await queryBus(viewCheckoutFeedbackByCheckoutId({ checkoutId: aggregateId })));
16
14
  const saveCheckoutFeedback = ({ dataSource }) => async (aggregateRoot) => {
17
15
  dataSource.saveCheckoutFeedback(toCheckoutFeedbackProjection(aggregateRoot));
18
16
  };
@@ -1,14 +1,15 @@
1
1
  import invariant from "tiny-invariant";
2
- import { viewCheckoutFeedbackById, } from "../../../../projection/checkoutFeedback/viewCheckoutFeedbackById";
2
+ import { v4 as uuid } from "uuid";
3
+ import { viewCheckoutFeedbackByCheckoutId, } from "../../../../projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId";
3
4
  import { httpCheckoutFeedbacksGive } from "./httpCheckoutFeedbacksGive";
4
5
  const toDomain = (checkoutFeedback) => {
5
6
  invariant(checkoutFeedback, "Not checkoutFeedback found!");
6
7
  return {
7
- aggregateId: checkoutFeedback.id,
8
- feedbacks: checkoutFeedback.feedbacks,
8
+ aggregateId: uuid(),
9
+ feedbacks: checkoutFeedback,
9
10
  domainEvents: [],
10
11
  };
11
12
  };
12
- const getCheckoutFeedback = ({ queryBus }) => async (aggregateId) => toDomain(await queryBus(viewCheckoutFeedbackById({ checkoutFeedbackId: aggregateId })));
13
+ const getCheckoutFeedback = ({ queryBus }) => async (aggregateId) => toDomain(await queryBus(viewCheckoutFeedbackByCheckoutId({ checkoutId: aggregateId })));
13
14
  const saveCheckoutFeedback = ({ httpPost }) => async (aggregateRoot) => await httpCheckoutFeedbacksGive({ httpPost })(aggregateRoot);
14
15
  export { getCheckoutFeedback, saveCheckoutFeedback };
@@ -0,0 +1,12 @@
1
+ import { CheckoutFeedbackByCheckoutIdView } from "../../../projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId";
2
+ import { HttpPostFunction } from "../../delivery/http/httpClient";
3
+ interface HttpCheckoutFeebackByCheckoutIdView extends CheckoutFeedbackByCheckoutIdView {
4
+ }
5
+ interface HttpCheckoutFeebackByCheckoutIdViewFunctionArgs {
6
+ readonly httpPost: HttpPostFunction;
7
+ }
8
+ interface HttpCheckoutFeebackByCheckoutIdViewFunction {
9
+ (args: HttpCheckoutFeebackByCheckoutIdViewFunctionArgs): HttpCheckoutFeebackByCheckoutIdView;
10
+ }
11
+ declare const httpCheckoutFeebackByCheckoutIdView: HttpCheckoutFeebackByCheckoutIdViewFunction;
12
+ export { httpCheckoutFeebackByCheckoutIdView };
@@ -0,0 +1,9 @@
1
+ const httpCheckoutFeebackByCheckoutIdView = ({ httpPost }) => async ({ checkoutId, signal }) => {
2
+ const response = await httpPost({
3
+ endpoint: "/view-checkout-feedback-by-checkout-id",
4
+ body: { checkoutId },
5
+ signal,
6
+ });
7
+ return !response.ok || response.status === 404 ? null : (await response.json()).result;
8
+ };
9
+ export { httpCheckoutFeebackByCheckoutIdView };
@@ -1,5 +1,5 @@
1
1
  import { FC, ReactNode } from "react";
2
- import { FeedbackProjection } from "../../../../../../projection/checkoutFeedback/feedback";
2
+ import { CheckoutFeedbackProjection } from "../../../../../../projection/checkoutFeedback/checkoutFeedback";
3
3
  interface OnChangeCheckoutQuestionFeedbackFunctionArgs {
4
4
  readonly checkoutQuestionId: string;
5
5
  readonly checkoutQuestionFeedback: string | undefined;
@@ -8,7 +8,7 @@ interface OnChangeCheckoutQuestionFeedbackFunction {
8
8
  (args: OnChangeCheckoutQuestionFeedbackFunctionArgs): void;
9
9
  }
10
10
  interface CheckoutQuestionFeedbackContextProviderProps {
11
- readonly feedback: FeedbackProjection | undefined;
11
+ readonly feedback: CheckoutFeedbackProjection | undefined;
12
12
  readonly children: ReactNode;
13
13
  }
14
14
  declare const CheckoutQuestionFeedbackProvider: FC<CheckoutQuestionFeedbackContextProviderProps>;
@@ -23,7 +23,7 @@ interface UseCheckoutQuestionFeedbackForIdFunction {
23
23
  }
24
24
  declare const useCheckoutQuestionFeedbackForId: UseCheckoutQuestionFeedbackForIdFunction;
25
25
  interface UseCheckoutQuestionFeedbackFunction {
26
- (): FeedbackProjection;
26
+ (): CheckoutFeedbackProjection;
27
27
  }
28
28
  declare const useCheckoutQuestionFeedback: UseCheckoutQuestionFeedbackFunction;
29
29
  export { useCheckoutQuestionFeedbackForId, useCheckoutQuestionFeedback, CheckoutQuestionFeedbackProvider };
@@ -1,10 +1,10 @@
1
1
  import { FC } from "react";
2
- import { FeedbackProjection } from "../../../../../../projection/checkoutFeedback/feedback";
2
+ import { CheckoutFeedbackProjection } from "../../../../../../projection/checkoutFeedback/checkoutFeedback";
3
3
  import { CheckoutQuestionProjection } from "../../../../../../projection/checkoutQuestion/checkoutQuestion";
4
4
  interface CheckoutQuestionsFormProps {
5
5
  readonly checkoutQuestions: CheckoutQuestionProjection[];
6
6
  readonly submitButtonDisabled: boolean;
7
- readonly onSubmit: (feedback: FeedbackProjection) => void;
7
+ readonly onSubmit: (feedback: CheckoutFeedbackProjection) => void;
8
8
  }
9
9
  declare const CheckoutQuestionsForm: FC<CheckoutQuestionsFormProps>;
10
10
  export { CheckoutQuestionsForm };
@@ -1,6 +1,6 @@
1
1
  import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
2
2
  import { useI18nMessage } from "@lookiero/i18n-react";
3
- import React, { useCallback } from "react";
3
+ import React, { useCallback, useMemo } from "react";
4
4
  import { CheckoutQuestionType, } from "../../../../../../projection/checkoutQuestion/checkoutQuestion";
5
5
  import { CheckoutQuestions } from "../../../../components/organisms/checkoutQuestions/CheckoutQuestions";
6
6
  import { useCheckoutQuestionFeedback } from "../../../../components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionFeedback";
@@ -24,9 +24,14 @@ const CheckoutQuestionsForm = ({ checkoutQuestions, submitButtonDisabled, onSubm
24
24
  const buttonText = useI18nMessage({ id: I18nMessages.FEEDBACK_BUTTON });
25
25
  const feedback = useCheckoutQuestionFeedback();
26
26
  const handlePress = useCallback(() => onSubmit(feedback), [feedback, onSubmit]);
27
+ const filteredCheckoutQuestions = useMemo(() => {
28
+ const responses = Object.values(feedback);
29
+ return checkoutQuestions.filter((checkoutQuestion) => checkoutQuestion.showCondition.length === 0 ||
30
+ checkoutQuestion.showCondition.every((condition) => responses.includes(condition)));
31
+ }, [checkoutQuestions, feedback]);
27
32
  return (React.createElement(React.Fragment, null,
28
33
  React.createElement(CheckoutQuestionItemProvider, { checkoutQuestionItems: checkoutQuestionItems },
29
- React.createElement(CheckoutQuestions, { checkoutQuestions: checkoutQuestions })),
34
+ React.createElement(CheckoutQuestions, { checkoutQuestions: filteredCheckoutQuestions })),
30
35
  React.createElement(Button, { busy: submitButtonDisabled,
31
36
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
32
37
  // @ts-ignore
@@ -1,6 +1,3 @@
1
- import { FeedbackProjection } from "./feedback";
2
- interface CheckoutFeedbackProjection {
3
- readonly id: string;
4
- readonly feedbacks: FeedbackProjection;
5
- }
1
+ import { FeedbackProjection } from "../feedback/feedback";
2
+ type CheckoutFeedbackProjection = FeedbackProjection;
6
3
  export type { CheckoutFeedbackProjection };
@@ -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_CHECKOUT_ID = "view_checkout_feedback_by_checkout_id";
4
+ interface ViewCheckoutFeedbackByCheckoutIdPayload {
5
+ readonly checkoutId: string;
6
+ }
7
+ interface ViewCheckoutFeedbackByCheckoutId extends Query<typeof VIEW_CHECKOUT_FEEDBACK_BY_CHECKOUT_ID>, ViewCheckoutFeedbackByCheckoutIdPayload {
8
+ }
9
+ interface ViewCheckoutFeedbackByCheckoutIdFunction {
10
+ (payload: ViewCheckoutFeedbackByCheckoutIdPayload): ViewCheckoutFeedbackByCheckoutId;
11
+ }
12
+ declare const viewCheckoutFeedbackByCheckoutId: ViewCheckoutFeedbackByCheckoutIdFunction;
13
+ type ViewCheckoutFeedbackByCheckoutIdResult = CheckoutFeedbackProjection | null;
14
+ interface CheckoutFeedbackByCheckoutIdViewArgs extends CancelableQueryViewArgs {
15
+ readonly checkoutId: string;
16
+ }
17
+ interface CheckoutFeedbackByCheckoutIdView {
18
+ (args: CheckoutFeedbackByCheckoutIdViewArgs): Promise<ViewCheckoutFeedbackByCheckoutIdResult>;
19
+ }
20
+ interface ViewCheckoutFeedbackByCheckoutIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
21
+ readonly view: CheckoutFeedbackByCheckoutIdView;
22
+ }
23
+ declare const viewCheckoutFeedbackByCheckoutIdHandler: QueryHandlerFunction<ViewCheckoutFeedbackByCheckoutId, ViewCheckoutFeedbackByCheckoutIdResult, ViewCheckoutFeedbackByCheckoutIdHandlerFunctionArgs>;
24
+ export type { ViewCheckoutFeedbackByCheckoutId, CheckoutFeedbackByCheckoutIdView, ViewCheckoutFeedbackByCheckoutIdResult, };
25
+ export { VIEW_CHECKOUT_FEEDBACK_BY_CHECKOUT_ID, viewCheckoutFeedbackByCheckoutId, viewCheckoutFeedbackByCheckoutIdHandler, };
@@ -0,0 +1,8 @@
1
+ import { query, } from "@lookiero/messaging";
2
+ const VIEW_CHECKOUT_FEEDBACK_BY_CHECKOUT_ID = "view_checkout_feedback_by_checkout_id";
3
+ const viewCheckoutFeedbackByCheckoutId = (payload) => ({
4
+ ...query({ name: VIEW_CHECKOUT_FEEDBACK_BY_CHECKOUT_ID }),
5
+ ...payload,
6
+ });
7
+ const viewCheckoutFeedbackByCheckoutIdHandler = ({ view, signal }) => async ({ checkoutId }) => view({ checkoutId, signal });
8
+ export { VIEW_CHECKOUT_FEEDBACK_BY_CHECKOUT_ID, viewCheckoutFeedbackByCheckoutId, viewCheckoutFeedbackByCheckoutIdHandler, };
@@ -12,7 +12,7 @@ interface CheckoutQuestionProjection {
12
12
  readonly placeholder: string;
13
13
  readonly type: CheckoutQuestionType;
14
14
  readonly children?: CheckoutQuestionProjection[];
15
- readonly showCondition?: string[];
15
+ readonly showCondition: string[];
16
16
  }
17
17
  export { CheckoutQuestionType };
18
18
  export type { CheckoutQuestionProjection };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.3.20",
3
+ "version": "0.3.21",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -1,12 +0,0 @@
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 };
@@ -1,9 +0,0 @@
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 };
@@ -1,3 +0,0 @@
1
- type CheckoutQuestionId = string;
2
- type FeedbackProjection = Record<CheckoutQuestionId, CheckoutQuestionId | string>;
3
- export type { FeedbackProjection };
@@ -1 +0,0 @@
1
- export {};
@@ -1,25 +0,0 @@
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 };
@@ -1,8 +0,0 @@
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 };