@lookiero/checkout 0.2.27-beta.8 → 0.2.28

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 (67) hide show
  1. package/dist/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.js +7 -17
  2. package/dist/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.js +6 -7
  3. package/dist/infrastructure/ui/shared/components/atoms/input/Input.d.ts +1 -0
  4. package/dist/infrastructure/ui/shared/components/atoms/input/Input.js +24 -15
  5. package/dist/infrastructure/ui/shared/components/atoms/input/Input.style.d.ts +3 -2
  6. package/dist/infrastructure/ui/shared/components/atoms/input/Input.style.js +5 -5
  7. package/dist/infrastructure/ui/shared/components/layouts/modal/Modal.js +1 -1
  8. package/dist/infrastructure/ui/shared/components/molecules/inputField/InputField.js +1 -1
  9. package/package.json +1 -1
  10. package/dist/infrastructure/delivery/_mock/bootstrap.mock.d.ts +0 -6
  11. package/dist/infrastructure/delivery/_mock/bootstrap.mock.js +0 -34
  12. package/dist/infrastructure/delivery/_mock/checkout.mock.d.ts +0 -9
  13. package/dist/infrastructure/delivery/_mock/checkout.mock.js +0 -46
  14. package/dist/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.d.ts +0 -15
  15. package/dist/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.js +0 -15
  16. package/dist/infrastructure/domain/react/useSetCheckoutIntroShown.d.ts +0 -10
  17. package/dist/infrastructure/domain/react/useSetCheckoutIntroShown.js +0 -9
  18. package/dist/infrastructure/domain/react/useUpdateUiSetting.d.ts +0 -14
  19. package/dist/infrastructure/domain/react/useUpdateUiSetting.js +0 -15
  20. package/dist/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.d.ts +0 -36
  21. package/dist/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.js +0 -30
  22. package/dist/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.d.ts +0 -60
  23. package/dist/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.js +0 -54
  24. package/dist/infrastructure/projection/httpFiveItemsDiscountByCustomerIdView.d.ts +0 -12
  25. package/dist/infrastructure/projection/httpFiveItemsDiscountByCustomerIdView.js +0 -7
  26. package/dist/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.d.ts +0 -12
  27. package/dist/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.js +0 -7
  28. package/dist/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.d.ts +0 -10
  29. package/dist/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.js +0 -9
  30. package/dist/infrastructure/projection/react/useViewCheckoutIntroShown.d.ts +0 -2
  31. package/dist/infrastructure/projection/react/useViewCheckoutIntroShown.js +0 -6
  32. package/dist/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.d.ts +0 -10
  33. package/dist/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.js +0 -9
  34. package/dist/infrastructure/projection/react/useViewFiveItemsDiscountByCustomerId.d.ts +0 -10
  35. package/dist/infrastructure/projection/react/useViewFiveItemsDiscountByCustomerId.js +0 -9
  36. package/dist/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.d.ts +0 -10
  37. package/dist/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.js +0 -9
  38. package/dist/infrastructure/projection/react/useViewUiSettingByKey.d.ts +0 -10
  39. package/dist/infrastructure/projection/react/useViewUiSettingByKey.js +0 -12
  40. package/dist/infrastructure/projection/storageUiSettingByKeyView.d.ts +0 -13
  41. package/dist/infrastructure/projection/storageUiSettingByKeyView.js +0 -15
  42. package/dist/infrastructure/ui/components/atoms/modal/Modal.d.ts +0 -7
  43. package/dist/infrastructure/ui/components/atoms/modal/Modal.js +0 -7
  44. package/dist/infrastructure/ui/components/atoms/modal/Modal.style.d.ts +0 -21
  45. package/dist/infrastructure/ui/components/atoms/modal/Modal.style.js +0 -24
  46. package/dist/infrastructure/ui/components/atoms/spinner/Spinner.d.ts +0 -3
  47. package/dist/infrastructure/ui/components/atoms/spinner/Spinner.js +0 -8
  48. package/dist/infrastructure/ui/components/atoms/spinner/Spinner.style.d.ts +0 -9
  49. package/dist/infrastructure/ui/components/atoms/spinner/Spinner.style.js +0 -10
  50. package/dist/infrastructure/ui/components/layouts/slider/Pagination.d.ts +0 -14
  51. package/dist/infrastructure/ui/components/layouts/slider/Pagination.js +0 -11
  52. package/dist/infrastructure/ui/components/layouts/slider/Pagination.style.d.ts +0 -23
  53. package/dist/infrastructure/ui/components/layouts/slider/Pagination.style.js +0 -27
  54. package/dist/infrastructure/ui/components/layouts/slider/Slider.d.ts +0 -20
  55. package/dist/infrastructure/ui/components/layouts/slider/Slider.js +0 -132
  56. package/dist/infrastructure/ui/components/layouts/slider/Slider.style.d.ts +0 -11
  57. package/dist/infrastructure/ui/components/layouts/slider/Slider.style.js +0 -12
  58. package/dist/infrastructure/ui/components/organisms/dropdown/Dropdown.d.ts +0 -15
  59. package/dist/infrastructure/ui/components/organisms/dropdown/Dropdown.js +0 -20
  60. package/dist/infrastructure/ui/components/organisms/dropdown/Dropdown.style.d.ts +0 -6
  61. package/dist/infrastructure/ui/components/organisms/dropdown/Dropdown.style.js +0 -9
  62. package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.style.d.ts +0 -10
  63. package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.style.js +0 -11
  64. package/dist/infrastructure/ui/views/item/components/actions/Actions.d.ts +0 -11
  65. package/dist/infrastructure/ui/views/item/components/actions/Actions.js +0 -24
  66. package/dist/infrastructure/ui/views/item/components/actions/Actions.style.d.ts +0 -20
  67. package/dist/infrastructure/ui/views/item/components/actions/Actions.style.js +0 -23
@@ -1,20 +1,10 @@
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
- ],
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,
12
7
  });
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);
8
+ return !response.ok || response.status === 404 ? undefined : toCheckoutProjection((await response.json()).result);
19
9
  };
20
10
  export { httpFirstAvailableCheckoutByCustomerIdView };
@@ -1,9 +1,8 @@
1
- const httpIsCheckoutEnabledByCustomerIdView = ({}) => async ({}) => {
2
- // const response = await httpGet({
3
- // endpoint: `/is-new-checkout-enabled/${customerId}`,
4
- // signal,
5
- // });
6
- // return !response.ok ? false : await response.json();
7
- return true;
1
+ const httpIsCheckoutEnabledByCustomerIdView = ({ httpGet }) => async ({ customerId, signal }) => {
2
+ const response = await httpGet({
3
+ endpoint: `/is-new-checkout-enabled/${customerId}`,
4
+ signal,
5
+ });
6
+ return !response.ok ? false : await response.json();
8
7
  };
9
8
  export { httpIsCheckoutEnabledByCustomerIdView };
@@ -3,6 +3,7 @@ import { StyleProp, TextInputProps, TextStyle } from "react-native";
3
3
  declare type InputStyle = StyleProp<TextStyle>;
4
4
  interface InputProps extends TextInputProps {
5
5
  readonly minHeight?: number;
6
+ readonly maxHeight?: number;
6
7
  readonly style?: InputStyle;
7
8
  }
8
9
  declare const Input: FC<InputProps>;
@@ -1,29 +1,38 @@
1
- import React, { useCallback, useState } from "react";
1
+ import React, { useCallback, useLayoutEffect, useRef, useState } from "react";
2
2
  import { Platform, TextInput, } from "react-native";
3
3
  import { theme } from "../../../../theme/theme";
4
- import { style } from "./Input.style";
5
- const DEFAULT_HEIGHT = 56;
4
+ import { style, borderSize, paddingVertical } from "./Input.style";
5
+ const MIN_HEIGHT = 56;
6
+ const MAX_HEIGHT = 242; // 10 lines
6
7
  const { colorGrayscaleL } = theme();
7
- const Input = ({ minHeight = DEFAULT_HEIGHT, style: customStyle, placeholderTextColor = colorGrayscaleL, onChange, onContentSizeChange, ...restOfProps }) => {
8
+ const clamp = (min, max, value) => Math.min(Math.max(min, value), max);
9
+ const Input = ({ minHeight = MIN_HEIGHT, maxHeight = MAX_HEIGHT, style: customStyle, placeholderTextColor = colorGrayscaleL, onChange, onContentSizeChange, value, multiline, ...restOfProps }) => {
8
10
  const [height, setHeight] = useState(minHeight);
9
11
  // When content height has became smaller the onContentSizeChange does in fact triggered but the internal height is incorrect.
10
12
  const handleOnContentSizeChange = useCallback((event) => {
11
13
  onContentSizeChange?.(event);
12
- if (Platform.OS === "web")
14
+ console.log("onContentSizeChange");
15
+ if (!multiline || Platform.OS === "web") {
13
16
  return;
14
- setHeight(Math.max(minHeight, event.nativeEvent.contentSize.height));
15
- }, [minHeight, onContentSizeChange]);
16
- // It's just update textarea height based on el.scrollHeight
17
- const handleOnChange = useCallback((event) => {
18
- onChange?.(event);
19
- if (Platform.OS !== "web")
17
+ }
18
+ const nativePadding = Platform.OS === "ios" ? paddingVertical * 2 : 0;
19
+ setHeight(clamp(minHeight, maxHeight, event.nativeEvent.contentSize.height + borderSize * 2 + nativePadding));
20
+ }, [maxHeight, minHeight, multiline, onContentSizeChange]);
21
+ const handleOnContentSizeChangeWeb = useCallback(() => {
22
+ if (!multiline || Platform.OS !== "web") {
20
23
  return;
24
+ }
21
25
  window.requestAnimationFrame(() => {
22
- const element = event.nativeEvent.target;
26
+ const element = textInputRef.current;
27
+ if (!element) {
28
+ return;
29
+ }
23
30
  element.style.height = "0px";
24
- element.style.height = `${Math.max(minHeight, element.scrollHeight)}px`;
31
+ element.style.height = `${clamp(minHeight, maxHeight, element.scrollHeight + borderSize * 2)}px`;
25
32
  });
26
- }, [minHeight, onChange]);
27
- return (React.createElement(TextInput, { ...restOfProps, placeholderTextColor: placeholderTextColor, style: [style.input, customStyle, { height }], testID: "input", textAlignVertical: "top", onChange: handleOnChange, onContentSizeChange: handleOnContentSizeChange }));
33
+ }, [maxHeight, minHeight, multiline]);
34
+ useLayoutEffect(handleOnContentSizeChangeWeb, [handleOnContentSizeChangeWeb, value]);
35
+ const textInputRef = useRef(null);
36
+ return (React.createElement(TextInput, { ...restOfProps, ref: textInputRef, multiline: multiline, placeholderTextColor: placeholderTextColor, style: [style.input, customStyle, { height }], testID: "input", textAlignVertical: "top", value: value, onChange: onChange, onContentSizeChange: handleOnContentSizeChange }));
28
37
  };
29
38
  export { Input };
@@ -1,3 +1,5 @@
1
+ declare const borderSize: number;
2
+ declare const paddingVertical: number;
1
3
  declare const style: {
2
4
  input: {
3
5
  lineHeight?: number | undefined;
@@ -7,7 +9,6 @@ declare const style: {
7
9
  fontSize: number;
8
10
  letterSpacing: number;
9
11
  outlineStyle: string;
10
- overflow: "hidden";
11
12
  paddingBottom: number;
12
13
  paddingHorizontal: number;
13
14
  paddingTop: number;
@@ -15,4 +16,4 @@ declare const style: {
15
16
  whiteSpace: string;
16
17
  };
17
18
  };
18
- export { style };
19
+ export { style, borderSize, paddingVertical };
@@ -1,7 +1,8 @@
1
1
  import { Platform, StyleSheet } from "react-native";
2
2
  import { theme } from "../../../../theme/theme";
3
3
  const { borderSize, colorContent, fontBodySize3, fontBodyHeight3, fontBodyLetterSpacing3, fontMap, spaceM } = theme();
4
- // paddingVertical not working in multiline mode
4
+ const paddingVertical = spaceM;
5
+ // paddingVertical not working in iOS in multiline mode
5
6
  const style = StyleSheet.create({
6
7
  input: {
7
8
  borderWidth: borderSize,
@@ -10,10 +11,9 @@ const style = StyleSheet.create({
10
11
  fontSize: fontBodySize3,
11
12
  letterSpacing: fontBodyLetterSpacing3,
12
13
  outlineStyle: "none",
13
- overflow: "hidden",
14
- paddingBottom: spaceM,
14
+ paddingBottom: paddingVertical,
15
15
  paddingHorizontal: spaceM,
16
- paddingTop: spaceM,
16
+ paddingTop: paddingVertical,
17
17
  textOverflow: "ellipsis",
18
18
  whiteSpace: "nowrap",
19
19
  ...Platform.select({
@@ -23,4 +23,4 @@ const style = StyleSheet.create({
23
23
  }),
24
24
  },
25
25
  });
26
- export { style };
26
+ export { style, borderSize, paddingVertical };
@@ -13,7 +13,7 @@ const { spaceXXL } = theme();
13
13
  const TRANSITION_MODAL_SCALE = 0.9;
14
14
  const DEFAULT_SAFEAREA_INSET_TOP = spaceXXL;
15
15
  const Modal = ({ children, visible, header, portalHostName, onClose, showCloseButton = false, size = { M: "2/3", L: "1/3" }, style: customStyle, scroll = false, }) => {
16
- const { height: screenHeight } = Dimensions.get("screen");
16
+ const { height: screenHeight } = Dimensions.get(Platform.OS === "web" ? "window" : "screen");
17
17
  const { top: safeAreaInsetTop, bottom: safeAreaInsetBottom } = useSafeAreaInsets();
18
18
  // On Android safeAreaInsetTop won't return the actual value.
19
19
  const screenSizeWithoutInsets = screenHeight - (Platform.OS === "android" ? DEFAULT_SAFEAREA_INSET_TOP : safeAreaInsetTop);
@@ -19,7 +19,7 @@ const InputField = ({ label, placeholder, value, multiline = false, minHeight, e
19
19
  field: [style.field, customStyle?.field],
20
20
  fieldText: [{ color }, customStyle?.fieldText],
21
21
  } }),
22
- React.createElement(Input, { minHeight: minHeight, multiline: multiline, placeholder: placeholder, placeholderTextColor: isFocused ? colorGrayscaleL : colorBase, style: [!!icon ? { paddingRight: inputPaddingRightWithIcon } : {}, { borderColor: color }, customStyle?.input], value: value, onBlur: handleOnBlur, onChangeText: handleOnChange, onFocus: handleOnFocus, ...inputRestProps }),
22
+ React.createElement(Input, { minHeight: minHeight, multiline: multiline, placeholder: placeholder, placeholderTextColor: isFocused ? colorGrayscaleL : colorBase, style: [!!icon && { paddingRight: inputPaddingRightWithIcon }, { borderColor: color }, customStyle?.input], value: value, onBlur: handleOnBlur, onChangeText: handleOnChange, onFocus: handleOnFocus, ...inputRestProps }),
23
23
  !!icon && React.createElement(Icon, { name: icon, style: [style.icon, { color }, customStyle?.icon] }),
24
24
  !!error && React.createElement(Error, { error: error, style: [style.error, customStyle?.error] })));
25
25
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.2.27-beta.8",
3
+ "version": "0.2.28",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -1,6 +0,0 @@
1
- import { BuildBootstrapFunctionReturn } from "@lookiero/messaging-react";
2
- interface BootstrapFunction {
3
- (): BuildBootstrapFunctionReturn;
4
- }
5
- declare const bootstrap: BootstrapFunction;
6
- export { bootstrap };
@@ -1,34 +0,0 @@
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 };
@@ -1,9 +0,0 @@
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 };
@@ -1,46 +0,0 @@
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 };
@@ -1,15 +0,0 @@
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 };
@@ -1,15 +0,0 @@
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 };
@@ -1,10 +0,0 @@
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 };
@@ -1,9 +0,0 @@
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 };
@@ -1,14 +0,0 @@
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 };
@@ -1,15 +0,0 @@
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,36 +0,0 @@
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, };
@@ -1,30 +0,0 @@
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, };
@@ -1,60 +0,0 @@
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 };
@@ -1,54 +0,0 @@
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 };
@@ -1,12 +0,0 @@
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 };
@@ -1,7 +0,0 @@
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 };
@@ -1,12 +0,0 @@
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 };
@@ -1,7 +0,0 @@
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 };
@@ -1,10 +0,0 @@
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 };
@@ -1,9 +0,0 @@
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 };
@@ -1,2 +0,0 @@
1
- declare const useViewCheckoutIntroShown: () => import("@lookiero/messaging-react").UseQueryFunctionResult<import("../../../projection/uiSetting/viewUiSettingByKey").UiSettingProjection>;
2
- export { useViewCheckoutIntroShown };