@lookiero/checkout 0.2.26 → 0.2.27-beta.1

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 (71) hide show
  1. package/dist/infrastructure/delivery/_mock/bootstrap.mock.d.ts +6 -0
  2. package/dist/infrastructure/delivery/_mock/bootstrap.mock.js +34 -0
  3. package/dist/infrastructure/delivery/_mock/checkout.mock.d.ts +9 -0
  4. package/dist/infrastructure/delivery/_mock/checkout.mock.js +46 -0
  5. package/dist/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.d.ts +15 -0
  6. package/dist/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.js +15 -0
  7. package/dist/infrastructure/domain/react/useSetCheckoutIntroShown.d.ts +10 -0
  8. package/dist/infrastructure/domain/react/useSetCheckoutIntroShown.js +9 -0
  9. package/dist/infrastructure/domain/react/useUpdateUiSetting.d.ts +14 -0
  10. package/dist/infrastructure/domain/react/useUpdateUiSetting.js +15 -0
  11. package/dist/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.js +17 -7
  12. package/dist/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.d.ts +36 -0
  13. package/dist/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.js +30 -0
  14. package/dist/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.d.ts +60 -0
  15. package/dist/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.js +54 -0
  16. package/dist/infrastructure/projection/httpFiveItemsDiscountByCustomerIdView.d.ts +12 -0
  17. package/dist/infrastructure/projection/httpFiveItemsDiscountByCustomerIdView.js +7 -0
  18. package/dist/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.d.ts +12 -0
  19. package/dist/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.js +7 -0
  20. package/dist/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.d.ts +10 -0
  21. package/dist/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.js +9 -0
  22. package/dist/infrastructure/projection/react/useViewCheckoutIntroShown.d.ts +2 -0
  23. package/dist/infrastructure/projection/react/useViewCheckoutIntroShown.js +6 -0
  24. package/dist/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.d.ts +10 -0
  25. package/dist/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.js +9 -0
  26. package/dist/infrastructure/projection/react/useViewFiveItemsDiscountByCustomerId.d.ts +10 -0
  27. package/dist/infrastructure/projection/react/useViewFiveItemsDiscountByCustomerId.js +9 -0
  28. package/dist/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.d.ts +10 -0
  29. package/dist/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.js +9 -0
  30. package/dist/infrastructure/projection/react/useViewUiSettingByKey.d.ts +10 -0
  31. package/dist/infrastructure/projection/react/useViewUiSettingByKey.js +12 -0
  32. package/dist/infrastructure/projection/storageUiSettingByKeyView.d.ts +13 -0
  33. package/dist/infrastructure/projection/storageUiSettingByKeyView.js +15 -0
  34. package/dist/infrastructure/ui/components/atoms/spinner/Spinner.d.ts +3 -0
  35. package/dist/infrastructure/ui/components/atoms/spinner/Spinner.js +8 -0
  36. package/dist/infrastructure/ui/components/atoms/spinner/Spinner.style.d.ts +9 -0
  37. package/dist/infrastructure/ui/components/atoms/spinner/Spinner.style.js +10 -0
  38. package/dist/infrastructure/ui/components/layouts/slider/Pagination.d.ts +14 -0
  39. package/dist/infrastructure/ui/components/layouts/slider/Pagination.js +11 -0
  40. package/dist/infrastructure/ui/components/layouts/slider/Pagination.style.d.ts +23 -0
  41. package/dist/infrastructure/ui/components/layouts/slider/Pagination.style.js +27 -0
  42. package/dist/infrastructure/ui/components/layouts/slider/Slider.d.ts +20 -0
  43. package/dist/infrastructure/ui/components/layouts/slider/Slider.js +132 -0
  44. package/dist/infrastructure/ui/components/layouts/slider/Slider.style.d.ts +11 -0
  45. package/dist/infrastructure/ui/components/layouts/slider/Slider.style.js +12 -0
  46. package/dist/infrastructure/ui/components/organisms/dropdown/Dropdown.d.ts +15 -0
  47. package/dist/infrastructure/ui/components/organisms/dropdown/Dropdown.js +20 -0
  48. package/dist/infrastructure/ui/components/organisms/dropdown/Dropdown.style.d.ts +6 -0
  49. package/dist/infrastructure/ui/components/organisms/dropdown/Dropdown.style.js +9 -0
  50. package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.js +1 -1
  51. package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.style.d.ts +10 -0
  52. package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.style.js +11 -0
  53. package/dist/infrastructure/ui/routing/CheckoutMiddleware.js +1 -1
  54. package/dist/infrastructure/ui/shared/components/layouts/modal/Modal.d.ts +4 -3
  55. package/dist/infrastructure/ui/shared/components/layouts/modal/Modal.js +3 -3
  56. package/dist/infrastructure/ui/views/item/components/actions/Actions.d.ts +11 -0
  57. package/dist/infrastructure/ui/views/item/components/actions/Actions.js +24 -0
  58. package/dist/infrastructure/ui/views/item/components/actions/Actions.style.d.ts +20 -0
  59. package/dist/infrastructure/ui/views/item/components/actions/Actions.style.js +23 -0
  60. package/dist/infrastructure/ui/views/item/components/getOutOfCheckoutModal/GetOutOfCheckoutModal.js +16 -14
  61. package/dist/infrastructure/ui/views/item/components/getOutOfCheckoutModal/GetOutOfCheckoutModal.style.d.ts +3 -0
  62. package/dist/infrastructure/ui/views/item/components/getOutOfCheckoutModal/GetOutOfCheckoutModal.style.js +3 -0
  63. package/dist/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.js +1 -1
  64. package/dist/infrastructure/ui/views/item/components/sizeChangeModal/SizeChangeModal.js +11 -9
  65. package/dist/infrastructure/ui/views/item/components/sizeChangeModal/SizeChangeModal.style.d.ts +3 -0
  66. package/dist/infrastructure/ui/views/item/components/sizeChangeModal/SizeChangeModal.style.js +3 -0
  67. package/dist/infrastructure/ui/views/item/components/sizeWithoutStockModal/SizeWithoutStockModal.js +11 -9
  68. package/dist/infrastructure/ui/views/item/components/sizeWithoutStockModal/SizeWithoutStockModal.style.d.ts +3 -0
  69. package/dist/infrastructure/ui/views/item/components/sizeWithoutStockModal/SizeWithoutStockModal.style.js +3 -0
  70. package/dist/infrastructure/ui/views/summary/Summary.js +5 -2
  71. package/package.json +4 -3
@@ -0,0 +1,6 @@
1
+ import { BuildBootstrapFunctionReturn } from "@lookiero/messaging-react";
2
+ interface BootstrapFunction {
3
+ (): BuildBootstrapFunctionReturn;
4
+ }
5
+ declare const bootstrap: BootstrapFunction;
6
+ export { bootstrap };
@@ -0,0 +1,34 @@
1
+ import { bootstrap as messagingBootstrap } from "@lookiero/messaging-react";
2
+ import { UPDATE_UI_SETTING } from "../../../domain/uiSetting/command/updateUiSetting";
3
+ import { updateUiSettingHandler } from "../../../domain/uiSetting/model/uiSetting";
4
+ import { CheckoutItemStatus } from "../../../projection/checkout/checkout";
5
+ import { viewFirstAvailableCheckoutByCustomerIdHandler, VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, } from "../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
6
+ import { viewFiveItemsDiscountByCustomerIdHandler, VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, } from "../../../projection/checkout/viewFiveItemsDiscountByCustomerId";
7
+ import { viewIsCheckoutAccessibleByCustomerIdHandler, VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, } from "../../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
8
+ import { viewIsCheckoutEnabledByCustomerIdHandler, VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, } from "../../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
9
+ import { viewUiSettingByKeyHandler, VIEW_UI_SETTING_BY_KEY } from "../../../projection/uiSetting/viewUiSettingByKey";
10
+ import { getUiSetting, saveUiSetting } from "../../domain/uiSetting/model/storageUiSettings";
11
+ import { read, write } from "../../persistence/asyncStorageStorage";
12
+ import { storageUiSettingByKeyView } from "../../projection/uiSetting/storageUiSettingByKeyView";
13
+ import { CHECKOUT_MESSAGING_REACT_ID } from "../bootstrap";
14
+ import { startedCheckoutWithItems } from "./checkout.mock";
15
+ const firstAvailableCheckoutByCustomerIdView = async () => startedCheckoutWithItems({ status: [CheckoutItemStatus.KEPT, CheckoutItemStatus.INITIAL] });
16
+ const isCheckoutEnabledByCustomerIdView = async () => true;
17
+ const fiveItemsDiscountByCustomerIdView = async () => 25;
18
+ const bootstrap = () => messagingBootstrap({ id: CHECKOUT_MESSAGING_REACT_ID })
19
+ .query(VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, viewFirstAvailableCheckoutByCustomerIdHandler, {
20
+ view: firstAvailableCheckoutByCustomerIdView,
21
+ })
22
+ .query(VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, viewIsCheckoutEnabledByCustomerIdHandler, {
23
+ view: isCheckoutEnabledByCustomerIdView,
24
+ })
25
+ .query(VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerIdHandler, {})
26
+ .query(VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, viewFiveItemsDiscountByCustomerIdHandler, {
27
+ view: fiveItemsDiscountByCustomerIdView,
28
+ })
29
+ .query(VIEW_UI_SETTING_BY_KEY, viewUiSettingByKeyHandler, {
30
+ view: storageUiSettingByKeyView({ read }),
31
+ })
32
+ .command(UPDATE_UI_SETTING, updateUiSettingHandler, {})(getUiSetting, saveUiSetting, { read, write })
33
+ .build();
34
+ export { bootstrap };
@@ -0,0 +1,9 @@
1
+ import { CheckoutItemStatus, CheckoutProjection } from "../../../projection/checkout/checkout";
2
+ interface StartedCheckoutWithStatusFunctionArgs {
3
+ readonly status: CheckoutItemStatus[];
4
+ }
5
+ interface StartedCheckoutWithStatusFunction {
6
+ (args: StartedCheckoutWithStatusFunctionArgs): CheckoutProjection;
7
+ }
8
+ declare const startedCheckoutWithItems: StartedCheckoutWithStatusFunction;
9
+ export { startedCheckoutWithItems };
@@ -0,0 +1,46 @@
1
+ import { v4 as uuid } from "uuid";
2
+ import { CheckoutStatus } from "../../../domain/checkout/model/checkout";
3
+ import { Currency, MediaPerspective, } from "../../../projection/checkout/checkout";
4
+ const checkoutItem = ({ status }) => ({
5
+ id: uuid(),
6
+ status,
7
+ productVariant: {
8
+ id: uuid(),
9
+ media: [
10
+ {
11
+ id: uuid(),
12
+ url: "https://cdn-catalog-back-prod.envs.lookiero.tech/d2/65/d2655b80-7745-4537-bb17-eb38f960a8de.jpg",
13
+ perspective: MediaPerspective.FRONT,
14
+ },
15
+ ],
16
+ brand: "CKS",
17
+ name: "Sari Tshirt lines",
18
+ price: {
19
+ amount: 3999,
20
+ currency: Currency.EUR,
21
+ },
22
+ size: {
23
+ id: uuid(),
24
+ lookiero: "M",
25
+ uk: "M",
26
+ it: "M",
27
+ europe: "M",
28
+ unique: false,
29
+ },
30
+ color: {
31
+ id: uuid(),
32
+ label: "black_C2",
33
+ },
34
+ },
35
+ });
36
+ const checkoutWithItems = ({ items }) => ({
37
+ id: uuid(),
38
+ status: CheckoutStatus.STARTED,
39
+ customerId: uuid(),
40
+ boxId: uuid(),
41
+ bookingId: uuid(),
42
+ expiresOn: new Date("2022-09-20"),
43
+ items,
44
+ });
45
+ const startedCheckoutWithItems = ({ status }) => checkoutWithItems({ items: status.map((status) => checkoutItem({ status })) });
46
+ export { startedCheckoutWithItems };
@@ -0,0 +1,15 @@
1
+ import { CommandStatus } from "@lookiero/messaging-react";
2
+ interface BookFunction {
3
+ (): Promise<void>;
4
+ }
5
+ declare type UseBookSizeReplaceableProductVariantsForCheckoutItem = [book: BookFunction, status: CommandStatus];
6
+ interface UseBookSizeReplaceableProductVariantsForCheckoutItemFunctionArgs {
7
+ readonly checkoutId: string;
8
+ readonly checkoutItemId: string;
9
+ readonly checkoutBookingId: string;
10
+ }
11
+ interface UseBookSizeReplaceableProductVariantsForCheckoutItemFunction {
12
+ (args: UseBookSizeReplaceableProductVariantsForCheckoutItemFunctionArgs): UseBookSizeReplaceableProductVariantsForCheckoutItem;
13
+ }
14
+ declare const useBookSizeReplaceableProductVariantsForCheckoutItem: UseBookSizeReplaceableProductVariantsForCheckoutItemFunction;
15
+ export { useBookSizeReplaceableProductVariantsForCheckoutItem };
@@ -0,0 +1,15 @@
1
+ import { useCommand } from "@lookiero/messaging-react";
2
+ import { useCallback } from "react";
3
+ import { v4 as uuid } from "uuid";
4
+ import { bookSizeReplaceableProductVariantsForCheckoutItem } from "../../../domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem";
5
+ const useBookSizeReplaceableProductVariantsForCheckoutItem = ({ checkoutId, checkoutItemId, checkoutBookingId }) => {
6
+ const [commandBus, status] = useCommand();
7
+ const book = useCallback(async () => await commandBus(bookSizeReplaceableProductVariantsForCheckoutItem({
8
+ aggregateId: uuid(),
9
+ checkoutId,
10
+ checkoutItemId,
11
+ checkoutBookingId,
12
+ })), [checkoutBookingId, checkoutId, checkoutItemId, commandBus]);
13
+ return [book, status];
14
+ };
15
+ export { useBookSizeReplaceableProductVariantsForCheckoutItem };
@@ -0,0 +1,10 @@
1
+ import { CommandStatus } from "@lookiero/messaging-react";
2
+ interface SetCheckoutIntroShownFunction {
3
+ (): Promise<void>;
4
+ }
5
+ declare type UseSetCheckoutIntroShown = [setCheckoutIntroShown: SetCheckoutIntroShownFunction, status: CommandStatus];
6
+ interface UseSetCheckoutIntroShownFunction {
7
+ (): UseSetCheckoutIntroShown;
8
+ }
9
+ declare const useSetCheckoutIntroShown: UseSetCheckoutIntroShownFunction;
10
+ export { useSetCheckoutIntroShown };
@@ -0,0 +1,9 @@
1
+ import { useCallback } from "react";
2
+ import { UISettings } from "../../ui/settings/UISettings";
3
+ import { useUpdateUiSetting } from "./useUpdateUiSetting";
4
+ const useSetCheckoutIntroShown = () => {
5
+ const [update, status] = useUpdateUiSetting();
6
+ const setCheckoutIntroShown = useCallback(() => update({ key: UISettings.CHECKOUT_INTRO_SHOWN, value: true }), [update]);
7
+ return [setCheckoutIntroShown, status];
8
+ };
9
+ export { useSetCheckoutIntroShown };
@@ -0,0 +1,14 @@
1
+ import { CommandStatus } from "@lookiero/messaging-react";
2
+ interface UpdateFunctionArgs {
3
+ readonly key: string;
4
+ readonly value: unknown;
5
+ }
6
+ interface UpdateFunction {
7
+ (args: UpdateFunctionArgs): Promise<void>;
8
+ }
9
+ declare type UseUpdateUiSetting = [update: UpdateFunction, status: CommandStatus];
10
+ interface UseUpdateUiSettingFunction {
11
+ (): UseUpdateUiSetting;
12
+ }
13
+ declare const useUpdateUiSetting: UseUpdateUiSettingFunction;
14
+ export { useUpdateUiSetting };
@@ -0,0 +1,15 @@
1
+ import { useCommand } from "@lookiero/messaging-react";
2
+ import { useCallback } from "react";
3
+ import { v4 as uuid } from "uuid";
4
+ import { updateUiSetting } from "../../../domain/uiSetting/command/updateUiSetting";
5
+ import { CHECKOUT_MESSAGING_REACT_ID } from "../../delivery/bootstrap";
6
+ const useUpdateUiSetting = () => {
7
+ const [commandBus, status] = useCommand({ contextId: CHECKOUT_MESSAGING_REACT_ID });
8
+ const update = useCallback(async ({ key, value }) => await commandBus(updateUiSetting({
9
+ aggregateId: uuid(),
10
+ key,
11
+ value,
12
+ })), [commandBus]);
13
+ return [update, status];
14
+ };
15
+ export { useUpdateUiSetting };
@@ -1,10 +1,20 @@
1
- import { toCheckoutProjection } from "./checkout";
2
- const httpFirstAvailableCheckoutByCustomerIdView = ({ httpPost }) => async ({ customerId, signal }) => {
3
- const response = await httpPost({
4
- endpoint: "/view-first-available-checkout-by-customer-id",
5
- body: { customer_id: customerId },
6
- signal,
1
+ import { CheckoutItemStatus } from "../../../domain/checkoutItem/model/checkoutItem";
2
+ import { startedCheckoutWithStatusProjection } from "./checkout.mock";
3
+ const httpFirstAvailableCheckoutByCustomerIdView = ({}) => async ({}) => {
4
+ return startedCheckoutWithStatusProjection({
5
+ status: [
6
+ CheckoutItemStatus.INITIAL,
7
+ CheckoutItemStatus.INITIAL,
8
+ CheckoutItemStatus.INITIAL,
9
+ CheckoutItemStatus.INITIAL,
10
+ CheckoutItemStatus.INITIAL,
11
+ ],
7
12
  });
8
- return !response.ok || response.status === 404 ? undefined : toCheckoutProjection((await response.json()).result);
13
+ // const response = await httpPost({
14
+ // endpoint: "/view-first-available-checkout-by-customer-id",
15
+ // body: { customer_id: customerId },
16
+ // signal,
17
+ // });
18
+ // return !response.ok || response.status === 404 ? undefined : toCheckoutProjection((await response.json()).result);
9
19
  };
10
20
  export { httpFirstAvailableCheckoutByCustomerIdView };
@@ -0,0 +1,36 @@
1
+ import { BookedSizeReplaceableProductVariantsProjection, BookedSizeReplaceableProductVariantsForCheckoutItemView } from "../../projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem";
2
+ import { HttpPostFunction } from "../delivery/http/httpClient";
3
+ interface SizeFormatDto {
4
+ readonly size: string;
5
+ readonly format: string;
6
+ readonly length?: string;
7
+ }
8
+ interface SizeDto {
9
+ readonly id: string;
10
+ readonly europe: SizeFormatDto;
11
+ readonly it: SizeFormatDto;
12
+ readonly lookiero: SizeFormatDto;
13
+ readonly uk: SizeFormatDto;
14
+ }
15
+ interface ProductVariantDto {
16
+ readonly id: string;
17
+ readonly size: SizeDto;
18
+ }
19
+ interface BookedSizeReplaceableProductVariantsDto {
20
+ readonly booking: string | null;
21
+ readonly product_variants: ProductVariantDto[];
22
+ }
23
+ interface ToBookedSizeReplaceableProductVariantsFunction {
24
+ (bookedSizeReplaceableProductVariants: BookedSizeReplaceableProductVariantsDto): BookedSizeReplaceableProductVariantsProjection;
25
+ }
26
+ declare const toBookedSizeReplaceableProductVariants: ToBookedSizeReplaceableProductVariantsFunction;
27
+ interface HttpBookedSizeReplaceableProductVariantsForCheckoutItemView extends BookedSizeReplaceableProductVariantsForCheckoutItemView {
28
+ }
29
+ interface HttpBookedSizeReplaceableProductVariantsForCheckoutItemViewFunctionArgs {
30
+ readonly httpPost: HttpPostFunction;
31
+ }
32
+ interface HttpBookedSizeReplaceableProductVariantsForCheckoutItemViewFunction {
33
+ (args: HttpBookedSizeReplaceableProductVariantsForCheckoutItemViewFunctionArgs): HttpBookedSizeReplaceableProductVariantsForCheckoutItemView;
34
+ }
35
+ declare const httpBookedSizeReplaceableProductVariantsForCheckoutItemView: HttpBookedSizeReplaceableProductVariantsForCheckoutItemViewFunction;
36
+ export { BookedSizeReplaceableProductVariantsDto, toBookedSizeReplaceableProductVariants, httpBookedSizeReplaceableProductVariantsForCheckoutItemView, };
@@ -0,0 +1,30 @@
1
+ const toSize = (size) => ({
2
+ id: size.id,
3
+ europe: size.europe,
4
+ it: size.it,
5
+ lookiero: size.lookiero,
6
+ uk: size.uk,
7
+ });
8
+ const toProductVariant = (productVariant) => ({
9
+ id: productVariant.id,
10
+ size: toSize(productVariant.size),
11
+ });
12
+ const toBookedSizeReplaceableProductVariants = (bookedSizeReplaceableProductVariants) => ({
13
+ booking: bookedSizeReplaceableProductVariants.booking,
14
+ productVariants: bookedSizeReplaceableProductVariants.product_variants.map(toProductVariant),
15
+ });
16
+ const httpBookedSizeReplaceableProductVariantsForCheckoutItemView = ({ httpPost }) => async ({ checkoutItemId }) => {
17
+ try {
18
+ const response = await httpPost({
19
+ endpoint: "/view-booked-size-replaceable-product-variants-for-checkout-item",
20
+ body: { checkout_item_id: checkoutItemId },
21
+ });
22
+ return response.status === 404
23
+ ? undefined
24
+ : toBookedSizeReplaceableProductVariants((await response.json()).result);
25
+ }
26
+ catch (ignored) {
27
+ throw new Error("Could not fetch BookedSizeReplaceableProductVariantsForCheckoutItem");
28
+ }
29
+ };
30
+ export { toBookedSizeReplaceableProductVariants, httpBookedSizeReplaceableProductVariantsForCheckoutItemView, };
@@ -0,0 +1,60 @@
1
+ import { CheckoutItemStatus, CheckoutProjection, CheckoutStatus, Currency, FirstAvailableCheckoutByCustomerIdView, MediaPerspective } from "../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
2
+ import { HttpPostFunction } from "../delivery/http/httpClient";
3
+ interface CheckoutDto {
4
+ readonly id: string;
5
+ readonly customer_id: string;
6
+ readonly box_id: string;
7
+ readonly booking_id: string;
8
+ readonly status: CheckoutStatus;
9
+ readonly expires_on: string;
10
+ readonly items: {
11
+ readonly id: string;
12
+ readonly status: CheckoutItemStatus;
13
+ readonly product_variant: {
14
+ readonly id: string;
15
+ readonly media: {
16
+ readonly id: string;
17
+ readonly url: string;
18
+ readonly perspective: MediaPerspective;
19
+ }[];
20
+ readonly brand: string;
21
+ readonly name: string;
22
+ readonly price: {
23
+ readonly amount: number;
24
+ readonly currency: Currency;
25
+ readonly discounted_price?: {
26
+ readonly amount: number;
27
+ readonly percentage: number;
28
+ };
29
+ };
30
+ readonly size: {
31
+ readonly id: string;
32
+ readonly lookiero: string;
33
+ readonly uk: string;
34
+ readonly it: string;
35
+ readonly europe: string;
36
+ readonly unique: boolean;
37
+ readonly visual_order?: number;
38
+ };
39
+ readonly color: {
40
+ readonly id: string;
41
+ readonly label: string;
42
+ };
43
+ };
44
+ readonly replaced_for?: string;
45
+ }[];
46
+ }
47
+ interface ToCheckoutProjectionFunction {
48
+ (checkoutDto: CheckoutDto): CheckoutProjection;
49
+ }
50
+ declare const toCheckoutProjection: ToCheckoutProjectionFunction;
51
+ interface HttpFirstAvailableCheckoutByCustomerIdView extends FirstAvailableCheckoutByCustomerIdView {
52
+ }
53
+ interface HttpFirstAvailableCheckoutByCustomerIdViewFunctionArgs {
54
+ readonly httpPost: HttpPostFunction;
55
+ }
56
+ interface HttpFirstAvailableCheckoutByCustomerIdViewFunction {
57
+ (args: HttpFirstAvailableCheckoutByCustomerIdViewFunctionArgs): HttpFirstAvailableCheckoutByCustomerIdView;
58
+ }
59
+ declare const httpFirstAvailableCheckoutByCustomerIdView: HttpFirstAvailableCheckoutByCustomerIdViewFunction;
60
+ export { CheckoutDto, toCheckoutProjection, httpFirstAvailableCheckoutByCustomerIdView };
@@ -0,0 +1,54 @@
1
+ const toCheckoutProjection = (checkoutDto) => ({
2
+ id: checkoutDto.id,
3
+ customerId: checkoutDto.customer_id,
4
+ boxId: checkoutDto.box_id,
5
+ bookingId: checkoutDto.booking_id,
6
+ status: checkoutDto.status,
7
+ expiresOn: new Date(checkoutDto.expires_on),
8
+ items: checkoutDto.items.map((item) => ({
9
+ id: item.id,
10
+ status: item.status,
11
+ replacedFor: item.replaced_for,
12
+ productVariant: {
13
+ id: item.product_variant.id,
14
+ media: item.product_variant.media.map((media) => ({
15
+ id: media.id,
16
+ url: media.url,
17
+ perspective: media.perspective,
18
+ })),
19
+ brand: item.product_variant.brand,
20
+ name: item.product_variant.name,
21
+ price: {
22
+ amount: item.product_variant.price.amount,
23
+ currency: item.product_variant.price.currency,
24
+ discountedPrice: item.product_variant.price.discounted_price
25
+ ? {
26
+ amount: item.product_variant.price.discounted_price.amount,
27
+ percentage: item.product_variant.price.discounted_price.percentage,
28
+ }
29
+ : undefined,
30
+ },
31
+ size: {
32
+ id: item.product_variant.size.id,
33
+ lookiero: item.product_variant.size.lookiero,
34
+ uk: item.product_variant.size.uk,
35
+ it: item.product_variant.size.it,
36
+ europe: item.product_variant.size.europe,
37
+ unique: item.product_variant.size.unique,
38
+ visualOrder: item.product_variant.size.visual_order,
39
+ },
40
+ color: {
41
+ id: item.product_variant.color.id,
42
+ label: item.product_variant.color.label,
43
+ },
44
+ },
45
+ })),
46
+ });
47
+ const httpFirstAvailableCheckoutByCustomerIdView = ({ httpPost }) => async ({ customerId }) => {
48
+ const response = await httpPost({
49
+ endpoint: "/view-first-available-checkout-by-customer-id",
50
+ body: { customer_id: customerId },
51
+ });
52
+ return !response.ok || response.status === 404 ? undefined : toCheckoutProjection((await response.json()).result);
53
+ };
54
+ export { toCheckoutProjection, httpFirstAvailableCheckoutByCustomerIdView };
@@ -0,0 +1,12 @@
1
+ import { FiveItemsDiscountByCustomerIdView } from "../../projection/checkout/viewFiveItemsDiscountByCustomerId";
2
+ import { HttpGetFunction } from "../delivery/http/httpClient";
3
+ interface HttpFiveItemsDiscountByCustomerIdView extends FiveItemsDiscountByCustomerIdView {
4
+ }
5
+ interface HttpFiveItemsDiscountByCustomerIdViewFunctionArgs {
6
+ readonly httpGet: HttpGetFunction;
7
+ }
8
+ interface HttpFiveItemsDiscountByCustomerIdViewFunction {
9
+ (args: HttpFiveItemsDiscountByCustomerIdViewFunctionArgs): HttpFiveItemsDiscountByCustomerIdView;
10
+ }
11
+ declare const httpFiveItemsDiscountByCustomerIdView: HttpFiveItemsDiscountByCustomerIdViewFunction;
12
+ export { httpFiveItemsDiscountByCustomerIdView };
@@ -0,0 +1,7 @@
1
+ const httpFiveItemsDiscountByCustomerIdView = ({ httpGet }) => async ({ customerId }) => {
2
+ const response = await httpGet({
3
+ endpoint: `/view-five-items-discount-by-customer-id/${customerId}`,
4
+ });
5
+ return !response.ok ? 0 : await response.json();
6
+ };
7
+ export { httpFiveItemsDiscountByCustomerIdView };
@@ -0,0 +1,12 @@
1
+ import { IsCheckoutEnabledByCustomerIdView } from "../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
2
+ import { HttpGetFunction } from "../delivery/http/httpClient";
3
+ interface HttpIsCheckoutEnabledByCustomerIdView extends IsCheckoutEnabledByCustomerIdView {
4
+ }
5
+ interface HttpIsCheckoutEnabledByCustomerIdViewFunctionArgs {
6
+ readonly httpGet: HttpGetFunction;
7
+ }
8
+ interface HttpIsCheckoutEnabledByCustomerIdViewFunction {
9
+ (args: HttpIsCheckoutEnabledByCustomerIdViewFunctionArgs): HttpIsCheckoutEnabledByCustomerIdView;
10
+ }
11
+ declare const httpIsCheckoutEnabledByCustomerIdView: HttpIsCheckoutEnabledByCustomerIdViewFunction;
12
+ export { httpIsCheckoutEnabledByCustomerIdView };
@@ -0,0 +1,7 @@
1
+ const httpIsCheckoutEnabledByCustomerIdView = ({ httpGet }) => async ({ customerId }) => {
2
+ const response = await httpGet({
3
+ endpoint: `/is-new-checkout-enabled/${customerId}`,
4
+ });
5
+ return !response.ok ? false : await response.json();
6
+ };
7
+ export { httpIsCheckoutEnabledByCustomerIdView };
@@ -0,0 +1,10 @@
1
+ import { UseQueryFunctionResult } from "@lookiero/messaging-react";
2
+ import { BookedSizeReplaceableProductVariantsProjection } from "../../../projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem";
3
+ interface UseViewBookedSizeReplaceableProductVariantsForCheckoutItemFunctionArgs {
4
+ readonly checkoutItemId: string;
5
+ }
6
+ interface UseViewBookedSizeReplaceableProductVariantsForCheckoutItemFunction {
7
+ (args: UseViewBookedSizeReplaceableProductVariantsForCheckoutItemFunctionArgs): UseQueryFunctionResult<BookedSizeReplaceableProductVariantsProjection>;
8
+ }
9
+ declare const useViewBookedSizeReplaceableProductVariantsForCheckoutItem: UseViewBookedSizeReplaceableProductVariantsForCheckoutItemFunction;
10
+ export { useViewBookedSizeReplaceableProductVariantsForCheckoutItem };
@@ -0,0 +1,9 @@
1
+ import { useQuery } from "@lookiero/messaging-react";
2
+ import { viewBookedSizeReplaceableProductVariantsForCheckoutItem, } from "../../../projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem";
3
+ import { CHECKOUT_MESSAGING_REACT_ID } from "../../delivery/bootstrap";
4
+ const useViewBookedSizeReplaceableProductVariantsForCheckoutItem = ({ checkoutItemId }) => useQuery({
5
+ query: viewBookedSizeReplaceableProductVariantsForCheckoutItem({ checkoutItemId }),
6
+ contextId: CHECKOUT_MESSAGING_REACT_ID,
7
+ options: { staleTime: Infinity },
8
+ });
9
+ export { useViewBookedSizeReplaceableProductVariantsForCheckoutItem };
@@ -0,0 +1,2 @@
1
+ declare const useViewCheckoutIntroShown: () => import("@lookiero/messaging-react").UseQueryFunctionResult<import("../../../projection/uiSetting/viewUiSettingByKey").UiSettingProjection>;
2
+ export { useViewCheckoutIntroShown };
@@ -0,0 +1,6 @@
1
+ import { UISettings } from "../../ui/settings/UISettings";
2
+ import { useViewUiSettingByKey } from "./useViewUiSettingByKey";
3
+ const useViewCheckoutIntroShown = () => useViewUiSettingByKey({
4
+ key: UISettings.CHECKOUT_INTRO_SHOWN,
5
+ });
6
+ export { useViewCheckoutIntroShown };
@@ -0,0 +1,10 @@
1
+ import { UseQueryFunctionResult } from "@lookiero/messaging-react";
2
+ import { CheckoutProjection } from "../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
3
+ interface UseViewFirstAvailableCheckoutByCustomerIdFunctionArgs {
4
+ readonly customerId: string;
5
+ }
6
+ interface UseViewFirstAvailableCheckoutByCustomerIdFunction {
7
+ (args: UseViewFirstAvailableCheckoutByCustomerIdFunctionArgs): UseQueryFunctionResult<CheckoutProjection>;
8
+ }
9
+ declare const useViewFirstAvailableCheckoutByCustomerId: UseViewFirstAvailableCheckoutByCustomerIdFunction;
10
+ export { useViewFirstAvailableCheckoutByCustomerId };
@@ -0,0 +1,9 @@
1
+ import { useQuery } from "@lookiero/messaging-react";
2
+ import { viewFirstAvailableCheckoutByCustomerId, } from "../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
3
+ import { CHECKOUT_MESSAGING_REACT_ID } from "../../delivery/bootstrap";
4
+ const useViewFirstAvailableCheckoutByCustomerId = ({ customerId }) => useQuery({
5
+ query: viewFirstAvailableCheckoutByCustomerId({ customerId }),
6
+ contextId: CHECKOUT_MESSAGING_REACT_ID,
7
+ options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
8
+ });
9
+ export { useViewFirstAvailableCheckoutByCustomerId };
@@ -0,0 +1,10 @@
1
+ import { UseQueryFunctionResult } from "@lookiero/messaging-react";
2
+ import { FiveItemsDiscountByCustomerIdProjection } from "../../../projection/checkout/viewFiveItemsDiscountByCustomerId";
3
+ interface UseViewFiveItemsDiscountByCustomerIdFunctionArgs {
4
+ readonly customerId: string;
5
+ }
6
+ interface UseViewFiveItemsDiscountByCustomerIdFunction {
7
+ (args: UseViewFiveItemsDiscountByCustomerIdFunctionArgs): UseQueryFunctionResult<FiveItemsDiscountByCustomerIdProjection>;
8
+ }
9
+ declare const useViewFiveItemsDiscountByCustomerId: UseViewFiveItemsDiscountByCustomerIdFunction;
10
+ export { useViewFiveItemsDiscountByCustomerId };
@@ -0,0 +1,9 @@
1
+ import { useQuery } from "@lookiero/messaging-react";
2
+ import { viewFiveItemsDiscountByCustomerId, } from "../../../projection/checkout/viewFiveItemsDiscountByCustomerId";
3
+ import { CHECKOUT_MESSAGING_REACT_ID } from "../../delivery/bootstrap";
4
+ const useViewFiveItemsDiscountByCustomerId = ({ customerId }) => useQuery({
5
+ query: viewFiveItemsDiscountByCustomerId({ customerId }),
6
+ contextId: CHECKOUT_MESSAGING_REACT_ID,
7
+ options: { staleTime: Infinity },
8
+ });
9
+ export { useViewFiveItemsDiscountByCustomerId };
@@ -0,0 +1,10 @@
1
+ import { UseQueryFunctionResult } from "@lookiero/messaging-react";
2
+ import { IsCheckoutAccessibleByCustomerIdProjection } from "../../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
3
+ interface UseViewIsCheckoutAccessibleByCustomerIdFunctionArgs {
4
+ readonly customerId: string | undefined;
5
+ }
6
+ interface UseViewIsCheckoutAccessibleByCustomerIdFunction {
7
+ (args: UseViewIsCheckoutAccessibleByCustomerIdFunctionArgs): UseQueryFunctionResult<IsCheckoutAccessibleByCustomerIdProjection>;
8
+ }
9
+ declare const useViewIsCheckoutAccessibleByCustomerId: UseViewIsCheckoutAccessibleByCustomerIdFunction;
10
+ export { useViewIsCheckoutAccessibleByCustomerId };
@@ -0,0 +1,9 @@
1
+ import { useQuery } from "@lookiero/messaging-react";
2
+ import { viewIsCheckoutAccessibleByCustomerId, } from "../../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
3
+ import { CHECKOUT_MESSAGING_REACT_ID } from "../../delivery/bootstrap";
4
+ const useViewIsCheckoutAccessibleByCustomerId = ({ customerId }) => useQuery({
5
+ query: viewIsCheckoutAccessibleByCustomerId({ customerId }),
6
+ contextId: CHECKOUT_MESSAGING_REACT_ID,
7
+ options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
8
+ });
9
+ export { useViewIsCheckoutAccessibleByCustomerId };
@@ -0,0 +1,10 @@
1
+ import { UseQueryFunctionResult } from "@lookiero/messaging-react";
2
+ import { UiSettingProjection } from "../../../projection/uiSetting/viewUiSettingByKey";
3
+ interface UseViewUiSettingByKeyFunctionArgs {
4
+ readonly key: string;
5
+ }
6
+ interface UseViewUiSettingByKeyFunction {
7
+ (args: UseViewUiSettingByKeyFunctionArgs): UseQueryFunctionResult<UiSettingProjection>;
8
+ }
9
+ declare const useViewUiSettingByKey: UseViewUiSettingByKeyFunction;
10
+ export { useViewUiSettingByKey };
@@ -0,0 +1,12 @@
1
+ import { useQuery } from "@lookiero/messaging-react";
2
+ import { UI_SETTING_UPDATED } from "../../../domain/uiSetting/model/uiSettingUpdated";
3
+ import { viewUiSettingByKey } from "../../../projection/uiSetting/viewUiSettingByKey";
4
+ import { CHECKOUT_MESSAGING_REACT_ID } from "../../delivery/bootstrap";
5
+ const isUiSettingUpdated = (event) => event.name === UI_SETTING_UPDATED;
6
+ const useViewUiSettingByKey = ({ key }) => useQuery({
7
+ query: viewUiSettingByKey({ key }),
8
+ contextId: CHECKOUT_MESSAGING_REACT_ID,
9
+ invalidation: isUiSettingUpdated,
10
+ options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
11
+ });
12
+ export { useViewUiSettingByKey };
@@ -0,0 +1,13 @@
1
+ import { UiSettingByKeyView } from "../../projection/uiSetting/viewUiSettingByKey";
2
+ import { ReadFunction } from "../persistence/storage";
3
+ import { UiSettingDto } from "../persistence/uiSettingData";
4
+ interface StorageUiSettingByKeyView extends UiSettingByKeyView {
5
+ }
6
+ interface StorageUiSettingByKeyViewFunctionArgs {
7
+ readonly read: ReadFunction<UiSettingDto>;
8
+ }
9
+ interface StorageUiSettingByKeyViewFunction {
10
+ (args: StorageUiSettingByKeyViewFunctionArgs): StorageUiSettingByKeyView;
11
+ }
12
+ declare const storageUiSettingByKeyView: StorageUiSettingByKeyViewFunction;
13
+ export { storageUiSettingByKeyView };
@@ -0,0 +1,15 @@
1
+ const toUiSettingProjection = (uiSettingDto) => ({
2
+ id: uiSettingDto.id,
3
+ key: uiSettingDto.key,
4
+ value: uiSettingDto.value,
5
+ });
6
+ const storageUiSettingByKeyView = ({ read }) => async ({ key }) => {
7
+ try {
8
+ const uiSettingDto = await read(key);
9
+ return uiSettingDto ? toUiSettingProjection(uiSettingDto) : undefined;
10
+ }
11
+ catch (ignored) {
12
+ throw new Error("Could not fetch the uiSetting");
13
+ }
14
+ };
15
+ export { storageUiSettingByKeyView };
@@ -0,0 +1,3 @@
1
+ import { FC } from "react";
2
+ declare const Spinner: FC;
3
+ export { Spinner };
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { ActivityIndicator, View } from "react-native";
3
+ import { theme } from "../../../theme/theme";
4
+ import { style } from "./Spinner.style";
5
+ const { colorPrimary } = theme();
6
+ const Spinner = () => (React.createElement(View, { style: style.container },
7
+ React.createElement(ActivityIndicator, { size: "large", color: colorPrimary })));
8
+ export { Spinner };
@@ -0,0 +1,9 @@
1
+ declare const style: {
2
+ container: {
3
+ display: "flex";
4
+ flex: number;
5
+ alignItems: "center";
6
+ justifyContent: "center";
7
+ };
8
+ };
9
+ export { style };