@shophost/react 2.0.51 → 2.0.53

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.
@@ -6,6 +6,7 @@ export interface CartDrawerItemProps {
6
6
  image?: UploadedFile;
7
7
  price: string;
8
8
  quantity: number;
9
+ maxQuantity?: number | null;
9
10
  remove: () => void;
10
11
  updateQuantity: (quantity: number) => void;
11
12
  }
@@ -7,6 +7,7 @@ export interface CartItemProps {
7
7
  price: string;
8
8
  unitPrice: string;
9
9
  quantity: number;
10
+ maxQuantity?: number | null;
10
11
  remove: () => void;
11
12
  updateQuantity: (quantity: number) => void;
12
13
  }
@@ -13,8 +13,14 @@ export interface ModifierContainerProps {
13
13
  quantity: number;
14
14
  onIncrement: () => void;
15
15
  onDecrement: () => void;
16
+ onQuantityInput: (value: string) => void;
16
17
  isDecrementDisabled: boolean;
17
- onAddToCart: () => void;
18
+ isIncrementDisabled: boolean;
19
+ isSubmitting: boolean;
20
+ isOutOfStock: boolean;
21
+ maxQuantity: number | null;
22
+ stockMessage: string | null;
23
+ onAddToCart: () => Promise<void>;
18
24
  validationError: string | null;
19
25
  }) => React.ReactNode;
20
26
  }
@@ -8,10 +8,16 @@ export interface ModifiersDialogOptionRenderProps {
8
8
  }
9
9
  export interface ModifiersDialogFooterRenderProps {
10
10
  isDecrementDisabled: boolean;
11
- onAddToCart: () => void;
11
+ isIncrementDisabled: boolean;
12
+ isSubmitting: boolean;
13
+ isOutOfStock: boolean;
14
+ maxQuantity: number | null;
15
+ onAddToCart: () => Promise<void>;
12
16
  onDecrement: () => void;
13
17
  onIncrement: () => void;
18
+ onQuantityInput: (value: string) => void;
14
19
  quantity: number;
20
+ stockMessage: string | null;
15
21
  validationError: string | null;
16
22
  }
17
23
  export interface ModifiersDialogProps {
@@ -16,10 +16,18 @@ export interface QuantityControlProps {
16
16
  * Function to decrement quantity
17
17
  */
18
18
  onDecrement: () => void;
19
+ /**
20
+ * Function to set quantity from a typed input
21
+ */
22
+ onQuantityInput: (value: string) => void;
19
23
  /**
20
24
  * Whether decrement button should be disabled
21
25
  */
22
26
  isDecrementDisabled: boolean;
27
+ /**
28
+ * Whether increment button should be disabled
29
+ */
30
+ isIncrementDisabled: boolean;
23
31
  }) => React.ReactNode;
24
32
  /**
25
33
  * Minimum quantity (default: 1)
@@ -3,9 +3,9 @@ import { LucideIcon } from 'lucide-react';
3
3
  import { default as React } from 'react';
4
4
  type Tone = "danger" | "info" | "neutral" | "success" | "warning";
5
5
  declare const formatAccountDate: (value: Date | string | null | undefined, fallback?: string, pattern?: string) => string;
6
- declare const formatOrderStatus: (status?: Order["status"]) => "Accepted" | "Preparing" | "On the way" | "Completed" | "Cancelled" | "Pending";
6
+ declare const formatOrderStatus: (status?: Order["status"]) => "Pending" | "Cancelled" | "Accepted" | "Preparing" | "On the way" | "Completed";
7
7
  declare const getOrderTone: (status?: Order["status"]) => Tone;
8
- declare const getReservationStatus: (reservation: Reservation) => "Cancelled" | "Pending" | "Confirmed";
8
+ declare const getReservationStatus: (reservation: Reservation) => "Pending" | "Confirmed" | "Cancelled";
9
9
  declare const getReservationTone: (reservation: Reservation) => Tone;
10
10
  declare const getInitials: (name?: string | null) => string;
11
11
  interface AccountPageShellProps {
@@ -1,6 +1,6 @@
1
1
  import { CartItem, Locale, LocalizedProduct, Product, ShippingMethod } from '../../../../client/src/index.ts';
2
2
  import { default as React } from 'react';
3
- import { AddToCartInput, AddToCartResult, CartContextType, RemoveCartItemInput, UpdateCartItemInput } from '../types/cart.types';
3
+ import { AddToCartInput, AddToCartResult, CartContextType, CartSyncResult, RemoveCartItemInput, UpdateCartItemInput } from '../types/cart.types';
4
4
  interface CartProviderProps {
5
5
  organizationId: string;
6
6
  children: React.ReactNode;
@@ -15,7 +15,7 @@ export declare const useCart: () => {
15
15
  loading: boolean;
16
16
  formattedCartItems: import('../types/cart.types').FormattedCartItem[];
17
17
  add: ({ productId, quantity, modifierGroups, product, onAdded, }: AddToCartInput) => Promise<AddToCartResult>;
18
- update: ({ productId, quantity, modifierGroups }: UpdateCartItemInput) => void;
18
+ update: ({ productId, quantity, modifierGroups }: UpdateCartItemInput) => Promise<CartSyncResult>;
19
19
  remove: ({ productId, modifierGroups }: RemoveCartItemInput) => void;
20
20
  addProductToCart: (product: Product | LocalizedProduct) => Promise<AddToCartResult>;
21
21
  clearCart: () => void;
@@ -37,6 +37,7 @@ export declare const useCart: () => {
37
37
  } | null>>;
38
38
  shippingMethod: ShippingMethod | null;
39
39
  setShippingMethod: React.Dispatch<React.SetStateAction<ShippingMethod | null>>;
40
+ replaceItems: (items: CartItem[]) => void;
40
41
  };
41
42
  export declare const useCartContext: () => CartContextType;
42
43
  export {};
@@ -9,7 +9,13 @@ interface ModifiersContextType {
9
9
  quantity: number;
10
10
  handleIncrement: () => void;
11
11
  handleDecrement: () => void;
12
- handleAddToCart: () => void;
12
+ handleQuantityInput: (value: string) => void;
13
+ isIncrementDisabled: boolean;
14
+ isSubmitting: boolean;
15
+ isOutOfStock: boolean;
16
+ maxQuantity: number | null;
17
+ stockMessage: string | null;
18
+ handleAddToCart: () => Promise<void>;
13
19
  validationError: string | null;
14
20
  modifierGroups: any[];
15
21
  isModifierSelected: (groupId: string, modifierId: string) => boolean;
@@ -30,6 +30,7 @@ export declare const enTranslations: {
30
30
  product: {
31
31
  addToCart: string;
32
32
  outOfStock: string;
33
+ stockAdjusted: string;
33
34
  quantity: string;
34
35
  price: string;
35
36
  total: string;
@@ -30,6 +30,7 @@ export declare const plTranslations: {
30
30
  product: {
31
31
  addToCart: string;
32
32
  outOfStock: string;
33
+ stockAdjusted: string;
33
34
  quantity: string;
34
35
  price: string;
35
36
  total: string;
@@ -31,6 +31,20 @@ export interface RemoveCartItemInput {
31
31
  export interface AddToCartResult {
32
32
  openedModifiers: boolean;
33
33
  }
34
+ export interface CartSyncOptions {
35
+ showAdjustmentAlert?: boolean;
36
+ }
37
+ export interface CartSyncResult {
38
+ adjustments: Array<{
39
+ modifierGroups?: CartItem["modifierGroups"];
40
+ productId: string;
41
+ reason: string;
42
+ requestedQuantity: number;
43
+ resolvedQuantity: number;
44
+ }>;
45
+ invalidProductIds: string[];
46
+ normalizedItems: CartItem[];
47
+ }
34
48
  export interface CartContextType {
35
49
  locale: string;
36
50
  organizationId: string;
@@ -38,7 +52,7 @@ export interface CartContextType {
38
52
  total: number;
39
53
  shipping?: number;
40
54
  subtotal: number;
41
- addItem: (item: CartItem) => void;
55
+ addItem: (item: CartItem, options?: CartSyncOptions) => Promise<CartSyncResult>;
42
56
  removeItem: (productId: string, modifierGroups?: {
43
57
  id: string;
44
58
  modifiers: {
@@ -52,7 +66,8 @@ export interface CartContextType {
52
66
  id: string;
53
67
  quantity?: number;
54
68
  }[];
55
- }[]) => void;
69
+ }[], options?: CartSyncOptions) => Promise<CartSyncResult>;
70
+ replaceItems: (items: CartItem[]) => void;
56
71
  clearCart: () => void;
57
72
  itemCount: number;
58
73
  totalAmount: number;
@@ -86,6 +101,9 @@ export interface FormattedCartItem {
86
101
  export type CartAction = {
87
102
  type: "INITIALIZE_CART";
88
103
  payload: CartItem[];
104
+ } | {
105
+ type: "REPLACE_ITEMS";
106
+ payload: CartItem[];
89
107
  } | {
90
108
  type: "SET_INITIALIZED";
91
109
  payload: boolean;