ingeniuscliq-core 0.3.45 → 0.3.47

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.
package/dist/index.js CHANGED
@@ -2525,10 +2525,10 @@ class J5 {
2525
2525
  ...this.initialState,
2526
2526
  setLoading: (r) => t({ loading: r }),
2527
2527
  setError: (r) => t({ error: r }),
2528
- addToCart: async (r, o, a = () => {
2529
- }, s = () => {
2530
- }, i = () => {
2531
- }) => {
2528
+ addToCart: async (r, o, { onSuccess: a = () => {
2529
+ }, onError: s = () => {
2530
+ }, onFinish: i = () => {
2531
+ } } = {}) => {
2532
2532
  try {
2533
2533
  t({ loading: !0, error: null }), await this.shopCartService.addToCart(r, o);
2534
2534
  let c = await this.shopCartService.getCart();
@@ -2539,10 +2539,10 @@ class J5 {
2539
2539
  i();
2540
2540
  }
2541
2541
  },
2542
- removeFromCart: async (r, o = () => {
2543
- }, a = () => {
2544
- }, s = () => {
2545
- }) => {
2542
+ removeFromCart: async (r, { onSuccess: o = () => {
2543
+ }, onError: a = () => {
2544
+ }, onFinish: s = () => {
2545
+ } } = {}) => {
2546
2546
  try {
2547
2547
  t({ loading: !0, error: null }), await this.shopCartService.removeFromCart(r);
2548
2548
  let i = await this.shopCartService.getCart();
@@ -2553,10 +2553,10 @@ class J5 {
2553
2553
  s();
2554
2554
  }
2555
2555
  },
2556
- removeItemFromCart: async (r, o = () => {
2557
- }, a = () => {
2558
- }, s = () => {
2559
- }) => {
2556
+ removeItemFromCart: async (r, { onSuccess: o = () => {
2557
+ }, onError: a = () => {
2558
+ }, onFinish: s = () => {
2559
+ } } = {}) => {
2560
2560
  try {
2561
2561
  t({ loading: !0, error: null }), await this.shopCartService.removeItemFromCart(r);
2562
2562
  let i = await this.shopCartService.getCart();
@@ -2567,10 +2567,10 @@ class J5 {
2567
2567
  s();
2568
2568
  }
2569
2569
  },
2570
- clearCart: async (r = () => {
2571
- }, o = () => {
2572
- }, a = () => {
2573
- }) => {
2570
+ clearCart: async ({ onSuccess: r = () => {
2571
+ }, onError: o = () => {
2572
+ }, onFinish: a = () => {
2573
+ } } = {}) => {
2574
2574
  try {
2575
2575
  t({ loading: !0, error: null }), await this.shopCartService.clearCart();
2576
2576
  let s = await this.shopCartService.getCart();
@@ -2589,10 +2589,10 @@ class J5 {
2589
2589
  setCartItems: (r) => {
2590
2590
  t({ cartItems: r });
2591
2591
  },
2592
- fetchCart: async (r = () => {
2593
- }, o = () => {
2594
- }, a = () => {
2595
- }) => {
2592
+ fetchCart: async ({ onSuccess: r = () => {
2593
+ }, onError: o = () => {
2594
+ }, onFinish: a = () => {
2595
+ } } = {}) => {
2596
2596
  try {
2597
2597
  t({ loading: !0, error: null });
2598
2598
  let s = await this.shopCartService.getCart();
@@ -2603,10 +2603,10 @@ class J5 {
2603
2603
  a();
2604
2604
  }
2605
2605
  },
2606
- fetchCartItems: async (r = () => {
2607
- }, o = () => {
2608
- }, a = () => {
2609
- }) => {
2606
+ fetchCartItems: async ({ onSuccess: r = () => {
2607
+ }, onError: o = () => {
2608
+ }, onFinish: a = () => {
2609
+ } } = {}) => {
2610
2610
  try {
2611
2611
  t({ loading: !0, error: null });
2612
2612
  let s = await this.shopCartService.getCartItems();
@@ -8,8 +8,8 @@ export declare class CoreShopCartBuilder<T> implements CoreBuilder {
8
8
  build(): import('zustand').UseBoundStore<Omit<import('zustand').StoreApi<CoreShopCartStore<T>>, "persist"> & {
9
9
  persist: {
10
10
  setOptions: (options: Partial<import('zustand/middleware').PersistOptions<CoreShopCartStore<T>, {
11
- cart: import('../types').CoreShopCart<T>;
12
- cartItems: import('../types').CoreCartItem<T>[];
11
+ cart: import('../../../types').CoreShopCart<T>;
12
+ cartItems: import('../../../types').CoreCartItem<T>[];
13
13
  }>>) => void;
14
14
  clearStorage: () => void;
15
15
  rehydrate: () => Promise<void> | void;
@@ -17,8 +17,8 @@ export declare class CoreShopCartBuilder<T> implements CoreBuilder {
17
17
  onHydrate: (fn: (state: CoreShopCartStore<T>) => void) => () => void;
18
18
  onFinishHydration: (fn: (state: CoreShopCartStore<T>) => void) => () => void;
19
19
  getOptions: () => Partial<import('zustand/middleware').PersistOptions<CoreShopCartStore<T>, {
20
- cart: import('../types').CoreShopCart<T>;
21
- cartItems: import('../types').CoreCartItem<T>[];
20
+ cart: import('../../../types').CoreShopCart<T>;
21
+ cartItems: import('../../../types').CoreCartItem<T>[];
22
22
  }>>;
23
23
  };
24
24
  }>;
@@ -3,16 +3,16 @@ import { CoreShopCart, CoreCartItem } from '../CoreShopCart';
3
3
  import { BaseApiResponse } from '../../../../types/contracts/BaseApiResponse';
4
4
  import { CoreActions } from '../../../../types';
5
5
  export interface ICartActions<T> {
6
- addToCart: (product_id: string | number, quantity: number, ...actions: CoreActions) => void;
7
- removeFromCart: (product_id: string | number, ...actions: CoreActions) => void;
8
- removeItemFromCart: (product_id: string | number, ...actions: CoreActions) => void;
9
- clearCart: (...actions: CoreActions) => void;
6
+ addToCart: (product_id: string | number, quantity: number, actions?: CoreActions) => void;
7
+ removeFromCart: (product_id: string | number, actions?: CoreActions) => void;
8
+ removeItemFromCart: (product_id: string | number, actions?: CoreActions) => void;
9
+ clearCart: (actions?: CoreActions) => void;
10
10
  getCart: () => CoreShopCart<T>;
11
11
  setCart: (cart: CoreShopCart<T>) => void;
12
12
  getCartItems: () => CoreCartItem<T>[];
13
13
  setCartItems: (cartItems: CoreCartItem<T>[]) => void;
14
- fetchCart: (...actions: CoreActions) => Promise<BaseApiResponse<CoreShopCart<T>>>;
15
- fetchCartItems: (...actions: CoreActions) => Promise<BaseApiResponse<CoreCartItem<T>[]>>;
14
+ fetchCart: (actions?: CoreActions) => Promise<BaseApiResponse<CoreShopCart<T>>>;
15
+ fetchCartItems: (actions?: CoreActions) => Promise<BaseApiResponse<CoreCartItem<T>[]>>;
16
16
  }
17
17
  export interface ICartActionsService<T> {
18
18
  addToCart: (product_id: string | number, quantity: number) => Promise<AxiosResponse<BaseApiResponse<CoreCartItem<T>>>>;
@@ -1,8 +1,8 @@
1
- export type CoreActions = [
2
- onSuccess?: CoreSuccessAction,
3
- onError?: CoreErrorAction,
4
- onFinish?: CoreFinishAction
5
- ];
1
+ export interface CoreActions {
2
+ onSuccess?: CoreSuccessAction;
3
+ onError?: CoreErrorAction;
4
+ onFinish?: CoreFinishAction;
5
+ }
6
6
  export type CoreSuccessAction = (response: any) => void;
7
7
  export type CoreErrorAction = (error: any) => void;
8
8
  export type CoreFinishAction = () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ingeniuscliq-core",
3
- "version": "0.3.45",
3
+ "version": "0.3.47",
4
4
  "description": "IngeniusCliq Core UI y lógica compartida",
5
5
  "license": "MIT",
6
6
  "type": "module",