@lookiero/checkout 0.2.27-beta.9 → 0.2.29

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/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.js +9 -7
  4. package/dist/infrastructure/ui/shared/components/atoms/input/Input.style.d.ts +1 -1
  5. package/dist/infrastructure/ui/shared/components/atoms/input/Input.style.js +4 -4
  6. package/dist/infrastructure/ui/shared/components/molecules/selectField/SelectField.d.ts +24 -0
  7. package/dist/infrastructure/ui/shared/components/molecules/selectField/SelectField.js +26 -0
  8. package/dist/infrastructure/ui/shared/components/molecules/selectField/SelectField.style.d.ts +15 -0
  9. package/dist/infrastructure/ui/shared/components/molecules/selectField/SelectField.style.js +18 -0
  10. package/dist/infrastructure/ui/views/item/components/productVariantActions/ProductVariantActions.js +3 -4
  11. package/dist/infrastructure/ui/views/item/components/productVariantActions/ProductVariantActions.style.d.ts +4 -5
  12. package/dist/infrastructure/ui/views/item/components/productVariantActions/ProductVariantActions.style.js +4 -5
  13. package/package.json +1 -1
  14. package/dist/infrastructure/delivery/_mock/bootstrap.mock.d.ts +0 -6
  15. package/dist/infrastructure/delivery/_mock/bootstrap.mock.js +0 -34
  16. package/dist/infrastructure/delivery/_mock/checkout.mock.d.ts +0 -9
  17. package/dist/infrastructure/delivery/_mock/checkout.mock.js +0 -46
  18. package/dist/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.d.ts +0 -15
  19. package/dist/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.js +0 -15
  20. package/dist/infrastructure/domain/react/useSetCheckoutIntroShown.d.ts +0 -10
  21. package/dist/infrastructure/domain/react/useSetCheckoutIntroShown.js +0 -9
  22. package/dist/infrastructure/domain/react/useUpdateUiSetting.d.ts +0 -14
  23. package/dist/infrastructure/domain/react/useUpdateUiSetting.js +0 -15
  24. package/dist/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.d.ts +0 -36
  25. package/dist/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.js +0 -30
  26. package/dist/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.d.ts +0 -60
  27. package/dist/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.js +0 -54
  28. package/dist/infrastructure/projection/httpFiveItemsDiscountByCustomerIdView.d.ts +0 -12
  29. package/dist/infrastructure/projection/httpFiveItemsDiscountByCustomerIdView.js +0 -7
  30. package/dist/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.d.ts +0 -12
  31. package/dist/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.js +0 -7
  32. package/dist/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.d.ts +0 -10
  33. package/dist/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.js +0 -9
  34. package/dist/infrastructure/projection/react/useViewCheckoutIntroShown.d.ts +0 -2
  35. package/dist/infrastructure/projection/react/useViewCheckoutIntroShown.js +0 -6
  36. package/dist/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.d.ts +0 -10
  37. package/dist/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.js +0 -9
  38. package/dist/infrastructure/projection/react/useViewFiveItemsDiscountByCustomerId.d.ts +0 -10
  39. package/dist/infrastructure/projection/react/useViewFiveItemsDiscountByCustomerId.js +0 -9
  40. package/dist/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.d.ts +0 -10
  41. package/dist/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.js +0 -9
  42. package/dist/infrastructure/projection/react/useViewUiSettingByKey.d.ts +0 -10
  43. package/dist/infrastructure/projection/react/useViewUiSettingByKey.js +0 -12
  44. package/dist/infrastructure/projection/storageUiSettingByKeyView.d.ts +0 -13
  45. package/dist/infrastructure/projection/storageUiSettingByKeyView.js +0 -15
  46. package/dist/infrastructure/ui/components/atoms/modal/Modal.d.ts +0 -7
  47. package/dist/infrastructure/ui/components/atoms/modal/Modal.js +0 -7
  48. package/dist/infrastructure/ui/components/atoms/modal/Modal.style.d.ts +0 -21
  49. package/dist/infrastructure/ui/components/atoms/modal/Modal.style.js +0 -24
  50. package/dist/infrastructure/ui/components/atoms/spinner/Spinner.d.ts +0 -3
  51. package/dist/infrastructure/ui/components/atoms/spinner/Spinner.js +0 -8
  52. package/dist/infrastructure/ui/components/atoms/spinner/Spinner.style.d.ts +0 -9
  53. package/dist/infrastructure/ui/components/atoms/spinner/Spinner.style.js +0 -10
  54. package/dist/infrastructure/ui/components/layouts/slider/Pagination.d.ts +0 -14
  55. package/dist/infrastructure/ui/components/layouts/slider/Pagination.js +0 -11
  56. package/dist/infrastructure/ui/components/layouts/slider/Pagination.style.d.ts +0 -23
  57. package/dist/infrastructure/ui/components/layouts/slider/Pagination.style.js +0 -27
  58. package/dist/infrastructure/ui/components/layouts/slider/Slider.d.ts +0 -20
  59. package/dist/infrastructure/ui/components/layouts/slider/Slider.js +0 -132
  60. package/dist/infrastructure/ui/components/layouts/slider/Slider.style.d.ts +0 -11
  61. package/dist/infrastructure/ui/components/layouts/slider/Slider.style.js +0 -12
  62. package/dist/infrastructure/ui/components/organisms/dropdown/Dropdown.d.ts +0 -15
  63. package/dist/infrastructure/ui/components/organisms/dropdown/Dropdown.js +0 -20
  64. package/dist/infrastructure/ui/components/organisms/dropdown/Dropdown.style.d.ts +0 -6
  65. package/dist/infrastructure/ui/components/organisms/dropdown/Dropdown.style.js +0 -9
  66. package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.style.d.ts +0 -10
  67. package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.style.js +0 -11
  68. package/dist/infrastructure/ui/views/item/components/actions/Actions.d.ts +0 -11
  69. package/dist/infrastructure/ui/views/item/components/actions/Actions.js +0 -24
  70. package/dist/infrastructure/ui/views/item/components/actions/Actions.style.d.ts +0 -20
  71. 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 };
@@ -6,18 +6,20 @@ const MIN_HEIGHT = 56;
6
6
  const MAX_HEIGHT = 242; // 10 lines
7
7
  const { colorGrayscaleL } = theme();
8
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, ...restOfProps }) => {
9
+ const Input = ({ minHeight = MIN_HEIGHT, maxHeight = MAX_HEIGHT, style: customStyle, placeholderTextColor = colorGrayscaleL, onChange, onContentSizeChange, value, multiline, ...restOfProps }) => {
10
10
  const [height, setHeight] = useState(minHeight);
11
11
  // When content height has became smaller the onContentSizeChange does in fact triggered but the internal height is incorrect.
12
12
  const handleOnContentSizeChange = useCallback((event) => {
13
13
  onContentSizeChange?.(event);
14
- if (Platform.OS === "web") {
14
+ console.log("onContentSizeChange");
15
+ if (!multiline || Platform.OS === "web") {
15
16
  return;
16
17
  }
17
- setHeight(clamp(minHeight, maxHeight, event.nativeEvent.contentSize.height + borderSize * 2 + paddingVertical * 2));
18
- }, [maxHeight, minHeight, onContentSizeChange]);
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]);
19
21
  const handleOnContentSizeChangeWeb = useCallback(() => {
20
- if (Platform.OS !== "web") {
22
+ if (!multiline || Platform.OS !== "web") {
21
23
  return;
22
24
  }
23
25
  window.requestAnimationFrame(() => {
@@ -28,9 +30,9 @@ const Input = ({ minHeight = MIN_HEIGHT, maxHeight = MAX_HEIGHT, style: customSt
28
30
  element.style.height = "0px";
29
31
  element.style.height = `${clamp(minHeight, maxHeight, element.scrollHeight + borderSize * 2)}px`;
30
32
  });
31
- }, [maxHeight, minHeight]);
33
+ }, [maxHeight, minHeight, multiline]);
32
34
  useLayoutEffect(handleOnContentSizeChangeWeb, [handleOnContentSizeChangeWeb, value]);
33
35
  const textInputRef = useRef(null);
34
- return (React.createElement(TextInput, { ...restOfProps, ref: textInputRef, placeholderTextColor: placeholderTextColor, style: [style.input, customStyle, { height }], testID: "input", textAlignVertical: "top", value: value, onChange: onChange, onContentSizeChange: handleOnContentSizeChange }));
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 }));
35
37
  };
36
38
  export { Input };
@@ -1,4 +1,5 @@
1
1
  declare const borderSize: number;
2
+ declare const paddingVertical: number;
2
3
  declare const style: {
3
4
  input: {
4
5
  lineHeight?: number | undefined;
@@ -15,5 +16,4 @@ declare const style: {
15
16
  whiteSpace: string;
16
17
  };
17
18
  };
18
- declare const paddingVertical: number;
19
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,9 +11,9 @@ const style = StyleSheet.create({
10
11
  fontSize: fontBodySize3,
11
12
  letterSpacing: fontBodyLetterSpacing3,
12
13
  outlineStyle: "none",
13
- paddingBottom: spaceM,
14
+ paddingBottom: paddingVertical,
14
15
  paddingHorizontal: spaceM,
15
- paddingTop: spaceM,
16
+ paddingTop: paddingVertical,
16
17
  textOverflow: "ellipsis",
17
18
  whiteSpace: "nowrap",
18
19
  ...Platform.select({
@@ -22,5 +23,4 @@ const style = StyleSheet.create({
22
23
  }),
23
24
  },
24
25
  });
25
- const paddingVertical = spaceM;
26
26
  export { style, borderSize, paddingVertical };
@@ -0,0 +1,24 @@
1
+ import { FC } from "react";
2
+ import { StyleProp, TextStyle, TouchableHighlightProps, ViewStyle } from "react-native";
3
+ interface SelectFieldStyle {
4
+ readonly selectField: StyleProp<ViewStyle>;
5
+ readonly modalContent: StyleProp<ViewStyle>;
6
+ readonly option: StyleProp<ViewStyle>;
7
+ readonly optionText: StyleProp<TextStyle>;
8
+ }
9
+ interface Option {
10
+ readonly label: string;
11
+ readonly value: string;
12
+ }
13
+ interface SelectFieldBaseProps {
14
+ readonly placeholder: string;
15
+ readonly value: string | undefined;
16
+ readonly options: Option[];
17
+ readonly style?: Partial<SelectFieldStyle>;
18
+ readonly onChange?: (value: string) => void;
19
+ }
20
+ interface SelectFieldProps extends Omit<TouchableHighlightProps, keyof SelectFieldBaseProps>, SelectFieldBaseProps {
21
+ }
22
+ declare const SelectField: FC<SelectFieldProps>;
23
+ export type { Option };
24
+ export { SelectField };
@@ -0,0 +1,26 @@
1
+ import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
2
+ import React, { useCallback, useMemo, useState } from "react";
3
+ import { TouchableHighlight, View } from "react-native";
4
+ import { theme } from "../../../../theme/theme";
5
+ import { Modal } from "../../layouts/modal/Modal";
6
+ import { InputField } from "../inputField/InputField";
7
+ import { style } from "./SelectField.style";
8
+ const { colorGrayscaleS } = theme();
9
+ const SelectField = ({ placeholder, value, options, style: customStyle, onChange = () => void 0, ...touchableRestProps }) => {
10
+ const [modalVisible, setModalVisible] = useState(false);
11
+ const handleOnPressSelectField = useCallback(() => setModalVisible(true), []);
12
+ const handleOnModalClose = useCallback(() => setModalVisible(false), []);
13
+ const handleOnPressOption = useCallback((value) => {
14
+ onChange(value);
15
+ handleOnModalClose();
16
+ }, [handleOnModalClose, onChange]);
17
+ const selectedValue = useMemo(() => options.find((option) => option.value === value), [options, value]);
18
+ return (React.createElement(React.Fragment, null,
19
+ React.createElement(TouchableHighlight, { style: customStyle?.selectField, underlayColor: colorGrayscaleS, onPress: handleOnPressSelectField, ...touchableRestProps },
20
+ React.createElement(View, { pointerEvents: "none" },
21
+ React.createElement(InputField, { editable: false, icon: "arrow-down", label: placeholder, value: selectedValue?.label }))),
22
+ React.createElement(Modal, { visible: modalVisible, scroll: true, onClose: handleOnModalClose },
23
+ React.createElement(View, { style: [style.modalContent, customStyle?.modalContent] }, options.map(({ label, value }) => (React.createElement(TouchableHighlight, { key: value, style: [style.option, customStyle?.option], underlayColor: colorGrayscaleS, onPress: () => handleOnPressOption(value) },
24
+ React.createElement(Text, { level: 3, style: [style.optionText, customStyle?.optionText] }, label))))))));
25
+ };
26
+ export { SelectField };
@@ -0,0 +1,15 @@
1
+ declare const style: {
2
+ modalContent: {
3
+ paddingBottom: number;
4
+ paddingHorizontal: number;
5
+ };
6
+ option: {
7
+ borderBottomColor: string;
8
+ borderBottomWidth: number;
9
+ paddingVertical: number;
10
+ };
11
+ optionText: {
12
+ lineHeight: number;
13
+ };
14
+ };
15
+ export { style };
@@ -0,0 +1,18 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "../../../../theme/theme";
3
+ const { borderSize, colorGrayscaleS, spaceM, spaceXL } = theme();
4
+ const style = StyleSheet.create({
5
+ modalContent: {
6
+ paddingBottom: spaceXL,
7
+ paddingHorizontal: spaceXL,
8
+ },
9
+ option: {
10
+ borderBottomColor: colorGrayscaleS,
11
+ borderBottomWidth: borderSize,
12
+ paddingVertical: spaceM,
13
+ },
14
+ optionText: {
15
+ lineHeight: 24,
16
+ },
17
+ });
18
+ export { style };
@@ -1,22 +1,21 @@
1
1
  import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
2
2
  import { BUTTON_VARIANT } from "@lookiero/aurora-next/build/components/atoms/Button/Button.definition";
3
- import { InputField } from "@lookiero/aurora-next/build/components/atoms/InputField/InputField";
4
3
  import { useI18nMessage } from "@lookiero/i18n-react";
5
4
  import React, { useMemo } from "react";
6
5
  import { View } from "react-native";
7
6
  import { I18nMessages } from "../../../../i18n/i18n";
7
+ import { SelectField } from "../../../../shared/components/molecules/selectField/SelectField";
8
8
  import { style } from "./ProductVariantActions.style";
9
9
  const ProductVariantActions = ({ sizes, size, onKeep, onReplace, onReturn }) => {
10
10
  const sizeSelectorLabelText = useI18nMessage({ id: I18nMessages.ITEM_SIZES_LABEL });
11
11
  const keepButtonText = useI18nMessage({ id: I18nMessages.ITEM_KEEP_BUTTON });
12
12
  const returnButtonText = useI18nMessage({ id: I18nMessages.ITEM_RETURN_BUTTON });
13
- const sizeSelectorOptions = useMemo(() => sizes.map((size) => ({ name: size.lookiero, value: size.id })), [sizes]);
13
+ const sizeSelectorOptions = useMemo(() => sizes.map((size) => ({ label: size.lookiero, value: size.id })), [sizes]);
14
14
  const disabledSizeSelector = useMemo(() => sizeSelectorOptions.length === 1 && sizeSelectorOptions[0]?.value === size.id, [sizeSelectorOptions, size.id]);
15
15
  return (React.createElement(View, { style: style.container },
16
16
  React.createElement(Button, { onPress: onKeep }, keepButtonText),
17
17
  React.createElement(View, { style: style.row },
18
- !size.unique && (React.createElement(View, { style: style.dropdownContainer },
19
- React.createElement(InputField, { disabled: disabledSizeSelector, icon: "arrow-down", label: sizeSelectorLabelText, name: "size-selector", options: sizeSelectorOptions, testID: "size-selector", value: size.id, onChange: onReplace }))),
18
+ !size.unique && (React.createElement(SelectField, { disabled: disabledSizeSelector, options: sizeSelectorOptions, placeholder: sizeSelectorLabelText || "", style: { selectField: style.sizeSelector }, testID: "size-selector", value: size.id, onChange: onReplace })),
20
19
  React.createElement(View, { style: style.returnButtonContainer },
21
20
  React.createElement(Button, { variant: BUTTON_VARIANT.SECONDARY, onPress: onReturn }, returnButtonText)))));
22
21
  };
@@ -2,11 +2,6 @@ declare const style: {
2
2
  container: {
3
3
  width: string;
4
4
  };
5
- dropdownContainer: {
6
- flex: number;
7
- marginRight: number;
8
- zIndex: number;
9
- };
10
5
  returnButtonContainer: {
11
6
  flex: number;
12
7
  };
@@ -15,5 +10,9 @@ declare const style: {
15
10
  flexDirection: "row";
16
11
  marginTop: number;
17
12
  };
13
+ sizeSelector: {
14
+ flex: number;
15
+ marginRight: number;
16
+ };
18
17
  };
19
18
  export { style };
@@ -5,11 +5,6 @@ const style = StyleSheet.create({
5
5
  container: {
6
6
  width: "100%",
7
7
  },
8
- dropdownContainer: {
9
- flex: 1,
10
- marginRight: spaceL,
11
- zIndex: 4,
12
- },
13
8
  returnButtonContainer: {
14
9
  flex: 1,
15
10
  },
@@ -18,5 +13,9 @@ const style = StyleSheet.create({
18
13
  flexDirection: "row",
19
14
  marginTop: spaceL,
20
15
  },
16
+ sizeSelector: {
17
+ flex: 1,
18
+ marginRight: spaceL,
19
+ },
21
20
  });
22
21
  export { style };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.2.27-beta.9",
3
+ "version": "0.2.29",
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 };