ingeniuscliq-core 0.3.43 → 0.3.45
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,40 +2525,60 @@ 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) => {
|
|
2528
|
+
addToCart: async (r, o, a = () => {
|
|
2529
|
+
}, s = () => {
|
|
2530
|
+
}, i = () => {
|
|
2531
|
+
}) => {
|
|
2529
2532
|
try {
|
|
2530
2533
|
t({ loading: !0, error: null }), await this.shopCartService.addToCart(r, o);
|
|
2531
|
-
let
|
|
2532
|
-
t(() => ({ cart:
|
|
2533
|
-
} catch (
|
|
2534
|
-
throw console.error(
|
|
2534
|
+
let c = await this.shopCartService.getCart();
|
|
2535
|
+
t(() => ({ cart: c.data.data, cartItems: c.data.data.items, loading: !1 })), a(c);
|
|
2536
|
+
} catch (c) {
|
|
2537
|
+
throw console.error(c), t((u) => ({ ...u, error: c, loading: !1 })), s(c), c;
|
|
2538
|
+
} finally {
|
|
2539
|
+
i();
|
|
2535
2540
|
}
|
|
2536
2541
|
},
|
|
2537
|
-
removeFromCart: async (r) => {
|
|
2542
|
+
removeFromCart: async (r, o = () => {
|
|
2543
|
+
}, a = () => {
|
|
2544
|
+
}, s = () => {
|
|
2545
|
+
}) => {
|
|
2538
2546
|
try {
|
|
2539
2547
|
t({ loading: !0, error: null }), await this.shopCartService.removeFromCart(r);
|
|
2540
|
-
let
|
|
2541
|
-
t(() => ({ cart:
|
|
2542
|
-
} catch (
|
|
2543
|
-
throw console.error(
|
|
2548
|
+
let i = await this.shopCartService.getCart();
|
|
2549
|
+
t(() => ({ cart: i.data.data, cartItems: i.data.data.items, loading: !1 })), o(i);
|
|
2550
|
+
} catch (i) {
|
|
2551
|
+
throw console.error(i), t((c) => ({ ...c, error: i, loading: !1 })), a(i), i;
|
|
2552
|
+
} finally {
|
|
2553
|
+
s();
|
|
2544
2554
|
}
|
|
2545
2555
|
},
|
|
2546
|
-
removeItemFromCart: async (r) => {
|
|
2556
|
+
removeItemFromCart: async (r, o = () => {
|
|
2557
|
+
}, a = () => {
|
|
2558
|
+
}, s = () => {
|
|
2559
|
+
}) => {
|
|
2547
2560
|
try {
|
|
2548
2561
|
t({ loading: !0, error: null }), await this.shopCartService.removeItemFromCart(r);
|
|
2549
|
-
let
|
|
2550
|
-
t(() => ({ cart:
|
|
2551
|
-
} catch (
|
|
2552
|
-
throw console.error(
|
|
2562
|
+
let i = await this.shopCartService.getCart();
|
|
2563
|
+
t(() => ({ cart: i.data.data, cartItems: i.data.data.items, loading: !1 })), o(i);
|
|
2564
|
+
} catch (i) {
|
|
2565
|
+
throw console.error(i), t((c) => ({ ...c, error: i, loading: !1 })), a(i), i;
|
|
2566
|
+
} finally {
|
|
2567
|
+
s();
|
|
2553
2568
|
}
|
|
2554
2569
|
},
|
|
2555
|
-
clearCart: async () => {
|
|
2570
|
+
clearCart: async (r = () => {
|
|
2571
|
+
}, o = () => {
|
|
2572
|
+
}, a = () => {
|
|
2573
|
+
}) => {
|
|
2556
2574
|
try {
|
|
2557
2575
|
t({ loading: !0, error: null }), await this.shopCartService.clearCart();
|
|
2558
|
-
let
|
|
2559
|
-
t(() => ({ cart:
|
|
2560
|
-
} catch (
|
|
2561
|
-
throw console.error(
|
|
2576
|
+
let s = await this.shopCartService.getCart();
|
|
2577
|
+
t(() => ({ cart: s.data.data, cartItems: s.data.data.items, loading: !1 })), r(s);
|
|
2578
|
+
} catch (s) {
|
|
2579
|
+
throw console.error(s), t((i) => ({ ...i, error: s, loading: !1 })), o(s), s;
|
|
2580
|
+
} finally {
|
|
2581
|
+
a();
|
|
2562
2582
|
}
|
|
2563
2583
|
},
|
|
2564
2584
|
getCartItems: () => n().cartItems,
|
|
@@ -2569,22 +2589,32 @@ class J5 {
|
|
|
2569
2589
|
setCartItems: (r) => {
|
|
2570
2590
|
t({ cartItems: r });
|
|
2571
2591
|
},
|
|
2572
|
-
fetchCart: async () => {
|
|
2592
|
+
fetchCart: async (r = () => {
|
|
2593
|
+
}, o = () => {
|
|
2594
|
+
}, a = () => {
|
|
2595
|
+
}) => {
|
|
2573
2596
|
try {
|
|
2574
2597
|
t({ loading: !0, error: null });
|
|
2575
|
-
let
|
|
2576
|
-
return t(() => ({ cart:
|
|
2577
|
-
} catch (
|
|
2578
|
-
throw console.error(
|
|
2598
|
+
let s = await this.shopCartService.getCart();
|
|
2599
|
+
return t(() => ({ cart: s.data.data, cartItems: s.data.data.items, loading: !1 })), r(s), s.data;
|
|
2600
|
+
} catch (s) {
|
|
2601
|
+
throw console.error(s), t((i) => ({ ...i, error: s, loading: !1 })), o(s), s;
|
|
2602
|
+
} finally {
|
|
2603
|
+
a();
|
|
2579
2604
|
}
|
|
2580
2605
|
},
|
|
2581
|
-
fetchCartItems: async () => {
|
|
2606
|
+
fetchCartItems: async (r = () => {
|
|
2607
|
+
}, o = () => {
|
|
2608
|
+
}, a = () => {
|
|
2609
|
+
}) => {
|
|
2582
2610
|
try {
|
|
2583
2611
|
t({ loading: !0, error: null });
|
|
2584
|
-
let
|
|
2585
|
-
return t(() => ({ cartItems:
|
|
2586
|
-
} catch (
|
|
2587
|
-
throw console.error(
|
|
2612
|
+
let s = await this.shopCartService.getCartItems();
|
|
2613
|
+
return t(() => ({ cartItems: s.data.data, loading: !1 })), r(s), s.data;
|
|
2614
|
+
} catch (s) {
|
|
2615
|
+
throw console.error(s), t((i) => ({ ...i, error: s, loading: !1 })), o(s), s;
|
|
2616
|
+
} finally {
|
|
2617
|
+
a();
|
|
2588
2618
|
}
|
|
2589
2619
|
},
|
|
2590
2620
|
reset: () => t(this.initialState)
|
|
@@ -16915,7 +16945,7 @@ function ll({ className: e, ...t }) {
|
|
|
16915
16945
|
"div",
|
|
16916
16946
|
{
|
|
16917
16947
|
"data-slot": "skeleton",
|
|
16918
|
-
className: _("bg-
|
|
16948
|
+
className: _("bg-gray-200 animate-pulse rounded-md", e),
|
|
16919
16949
|
...t
|
|
16920
16950
|
}
|
|
16921
16951
|
);
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { CoreShopCart, CoreCartItem } from '../CoreShopCart';
|
|
3
3
|
import { BaseApiResponse } from '../../../../types/contracts/BaseApiResponse';
|
|
4
|
+
import { CoreActions } from '../../../../types';
|
|
4
5
|
export interface ICartActions<T> {
|
|
5
|
-
addToCart: (product_id: string | number, quantity: number) => void;
|
|
6
|
-
removeFromCart: (product_id: string | number) => void;
|
|
7
|
-
removeItemFromCart: (product_id: string | number) => void;
|
|
8
|
-
clearCart: () => 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;
|
|
9
10
|
getCart: () => CoreShopCart<T>;
|
|
10
11
|
setCart: (cart: CoreShopCart<T>) => void;
|
|
11
12
|
getCartItems: () => CoreCartItem<T>[];
|
|
12
13
|
setCartItems: (cartItems: CoreCartItem<T>[]) => void;
|
|
13
|
-
fetchCart: () => Promise<BaseApiResponse<CoreShopCart<T>>>;
|
|
14
|
-
fetchCartItems: () => Promise<BaseApiResponse<CoreCartItem<T>[]>>;
|
|
14
|
+
fetchCart: (...actions: CoreActions) => Promise<BaseApiResponse<CoreShopCart<T>>>;
|
|
15
|
+
fetchCartItems: (...actions: CoreActions) => Promise<BaseApiResponse<CoreCartItem<T>[]>>;
|
|
15
16
|
}
|
|
16
17
|
export interface ICartActionsService<T> {
|
|
17
18
|
addToCart: (product_id: string | number, quantity: number) => Promise<AxiosResponse<BaseApiResponse<CoreCartItem<T>>>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type CoreActions = [
|
|
2
|
+
onSuccess?: CoreSuccessAction,
|
|
3
|
+
onError?: CoreErrorAction,
|
|
4
|
+
onFinish?: CoreFinishAction
|
|
5
|
+
];
|
|
6
|
+
export type CoreSuccessAction = (response: any) => void;
|
|
7
|
+
export type CoreErrorAction = (error: any) => void;
|
|
8
|
+
export type CoreFinishAction = () => void;
|