ingeniuscliq-core 0.3.11 → 0.3.13
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import './index.css';var Bh = Object.defineProperty;
|
|
2
2
|
var Wh = (e, t, n) => t in e ? Bh(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var Se = (e, t, n) => Wh(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import Hh from "i18next";
|
|
@@ -2472,9 +2472,9 @@ class X5 {
|
|
|
2472
2472
|
setError: (r) => t({ error: r }),
|
|
2473
2473
|
addToCart: async (r, o) => {
|
|
2474
2474
|
try {
|
|
2475
|
-
t({ loading: !0, error: null });
|
|
2476
|
-
|
|
2477
|
-
t((
|
|
2475
|
+
t({ loading: !0, error: null }), await this.shopCartService.addToCart(r, o);
|
|
2476
|
+
let a = await this.shopCartService.getCart();
|
|
2477
|
+
t(() => ({ cart: a.data.data, cartItems: a.data.data.items, loading: !1 }));
|
|
2478
2478
|
} catch (a) {
|
|
2479
2479
|
throw console.error(a), t((s) => ({ ...s, error: a, loading: !1 })), a;
|
|
2480
2480
|
}
|
|
@@ -2550,13 +2550,22 @@ class Yv extends Xn {
|
|
|
2550
2550
|
getShippingMethods() {
|
|
2551
2551
|
return this.api.get(this.apiPrefix + "/shipment/shipping-methods/actives");
|
|
2552
2552
|
}
|
|
2553
|
+
getShippingAddresses() {
|
|
2554
|
+
return this.api.get(this.apiPrefix + "/shipment/addresses");
|
|
2555
|
+
}
|
|
2556
|
+
addShippingAddress(t) {
|
|
2557
|
+
return this.api.post(this.apiPrefix + "/shipment/addresses", t);
|
|
2558
|
+
}
|
|
2559
|
+
updateShippingAddress(t, n) {
|
|
2560
|
+
return this.api.put(this.apiPrefix + `/shipment/addresses/${t.id}`, n);
|
|
2561
|
+
}
|
|
2553
2562
|
}
|
|
2554
2563
|
class Z5 {
|
|
2555
2564
|
constructor(t = new Yv(), n = this.initialState) {
|
|
2556
2565
|
Se(this, "shipmentService");
|
|
2557
2566
|
Se(this, "initialState", {
|
|
2558
|
-
shipment: null,
|
|
2559
2567
|
shippingMethods: null,
|
|
2568
|
+
shippingAddresses: null,
|
|
2560
2569
|
loading: !1,
|
|
2561
2570
|
error: null
|
|
2562
2571
|
});
|
|
@@ -2567,10 +2576,10 @@ class Z5 {
|
|
|
2567
2576
|
Nn(
|
|
2568
2577
|
(t, n) => ({
|
|
2569
2578
|
...this.initialState,
|
|
2570
|
-
getShipment: () => n().shipment,
|
|
2571
|
-
setShipment: (r) => t({ shipment: r }),
|
|
2572
2579
|
getShippingMethods: () => n().shippingMethods,
|
|
2580
|
+
getShippingAddresses: () => n().shippingAddresses,
|
|
2573
2581
|
setShippingMethods: (r) => t({ shippingMethods: r }),
|
|
2582
|
+
setShippingAddresses: (r) => t({ shippingAddresses: r }),
|
|
2574
2583
|
fetchShippingMethods: async () => {
|
|
2575
2584
|
try {
|
|
2576
2585
|
t({ loading: !0, error: null });
|
|
@@ -2580,6 +2589,33 @@ class Z5 {
|
|
|
2580
2589
|
throw t((o) => ({ ...o, error: r, loading: !1 })), r;
|
|
2581
2590
|
}
|
|
2582
2591
|
},
|
|
2592
|
+
fetchShippingAddresses: async () => {
|
|
2593
|
+
try {
|
|
2594
|
+
t({ loading: !0, error: null });
|
|
2595
|
+
const r = await this.shipmentService.getShippingAddresses();
|
|
2596
|
+
return t({ shippingAddresses: r.data.data, loading: !1 }), r.data;
|
|
2597
|
+
} catch (r) {
|
|
2598
|
+
throw t((o) => ({ ...o, error: r, loading: !1 })), r;
|
|
2599
|
+
}
|
|
2600
|
+
},
|
|
2601
|
+
addShippingAddress: async (r) => {
|
|
2602
|
+
try {
|
|
2603
|
+
t({ loading: !0, error: null }), await this.shipmentService.addShippingAddress(r);
|
|
2604
|
+
const o = await this.shipmentService.getShippingAddresses();
|
|
2605
|
+
t({ shippingAddresses: o.data.data, loading: !1 });
|
|
2606
|
+
} catch (o) {
|
|
2607
|
+
throw t((a) => ({ ...a, error: o, loading: !1 })), o;
|
|
2608
|
+
}
|
|
2609
|
+
},
|
|
2610
|
+
updateShippingAddress: async (r, o) => {
|
|
2611
|
+
try {
|
|
2612
|
+
t({ loading: !0, error: null }), await this.shipmentService.updateShippingAddress(r, o);
|
|
2613
|
+
const a = await this.shipmentService.getShippingAddresses();
|
|
2614
|
+
t({ shippingAddresses: a.data.data, loading: !1 });
|
|
2615
|
+
} catch (a) {
|
|
2616
|
+
throw t((s) => ({ ...s, error: a, loading: !1 })), a;
|
|
2617
|
+
}
|
|
2618
|
+
},
|
|
2583
2619
|
setLoading: (r) => t({ loading: r }),
|
|
2584
2620
|
setError: (r) => t({ error: r }),
|
|
2585
2621
|
reset: () => t(this.initialState)
|
|
@@ -2587,8 +2623,8 @@ class Z5 {
|
|
|
2587
2623
|
{
|
|
2588
2624
|
name: "shipment-storage",
|
|
2589
2625
|
partialize: (t) => ({
|
|
2590
|
-
|
|
2591
|
-
|
|
2626
|
+
shippingMethods: t.shippingMethods,
|
|
2627
|
+
shippingAddresses: t.shippingAddresses
|
|
2592
2628
|
})
|
|
2593
2629
|
}
|
|
2594
2630
|
)
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { CoreBuilder } from '../../../classes/CoreBuilder';
|
|
2
2
|
import { CoreShipmentBaseService } from '../services/base';
|
|
3
|
-
import {
|
|
4
|
-
export declare class CoreShipmentBuilder implements CoreBuilder {
|
|
5
|
-
protected shipmentService: CoreShipmentBaseService
|
|
6
|
-
protected initialState: Pick<CoreShipmentStore<
|
|
7
|
-
constructor(service?: CoreShipmentBaseService, initialState?: any);
|
|
8
|
-
build(): import('zustand').UseBoundStore<Omit<import('zustand').StoreApi<CoreShipmentStore<
|
|
3
|
+
import { CoreShippingAddress, CoreShipmentStore, CoreShippingMethod } from '../types/CoreShipment';
|
|
4
|
+
export declare class CoreShipmentBuilder<T extends CoreShippingMethod, K extends CoreShippingAddress> implements CoreBuilder {
|
|
5
|
+
protected shipmentService: CoreShipmentBaseService<T, K>;
|
|
6
|
+
protected initialState: Pick<CoreShipmentStore<T, K>, "shippingMethods" | "shippingAddresses" | "loading" | "error">;
|
|
7
|
+
constructor(service?: CoreShipmentBaseService<T, K>, initialState?: any);
|
|
8
|
+
build(): import('zustand').UseBoundStore<Omit<import('zustand').StoreApi<CoreShipmentStore<T, K>>, "persist"> & {
|
|
9
9
|
persist: {
|
|
10
|
-
setOptions: (options: Partial<import('zustand/middleware').PersistOptions<CoreShipmentStore<
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
setOptions: (options: Partial<import('zustand/middleware').PersistOptions<CoreShipmentStore<T, K>, {
|
|
11
|
+
shippingMethods: T[] | null;
|
|
12
|
+
shippingAddresses: import('../../..').BasePagination<K> | null;
|
|
13
13
|
}>>) => void;
|
|
14
14
|
clearStorage: () => void;
|
|
15
15
|
rehydrate: () => Promise<void> | void;
|
|
16
16
|
hasHydrated: () => boolean;
|
|
17
|
-
onHydrate: (fn: (state: CoreShipmentStore<
|
|
18
|
-
onFinishHydration: (fn: (state: CoreShipmentStore<
|
|
19
|
-
getOptions: () => Partial<import('zustand/middleware').PersistOptions<CoreShipmentStore<
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
onHydrate: (fn: (state: CoreShipmentStore<T, K>) => void) => () => void;
|
|
18
|
+
onFinishHydration: (fn: (state: CoreShipmentStore<T, K>) => void) => () => void;
|
|
19
|
+
getOptions: () => Partial<import('zustand/middleware').PersistOptions<CoreShipmentStore<T, K>, {
|
|
20
|
+
shippingMethods: T[] | null;
|
|
21
|
+
shippingAddresses: import('../../..').BasePagination<K> | null;
|
|
22
22
|
}>>;
|
|
23
23
|
};
|
|
24
24
|
}>;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { BaseService } from '../../../services/base';
|
|
2
|
-
import { CoreShippingMethod } from '../types/CoreShipment';
|
|
3
|
-
import { BaseApiResponse } from '../../../types';
|
|
2
|
+
import { CoreShippingAddress, CoreShippingMethod } from '../types/CoreShipment';
|
|
3
|
+
import { BaseApiResponse, BaseApiResponsePagination } from '../../../types';
|
|
4
4
|
/**
|
|
5
5
|
* Base class that can be extended by concrete services
|
|
6
6
|
*/
|
|
7
|
-
export declare class CoreShipmentBaseService extends BaseService {
|
|
7
|
+
export declare class CoreShipmentBaseService<T extends CoreShippingMethod, K extends CoreShippingAddress> extends BaseService {
|
|
8
8
|
constructor();
|
|
9
|
-
getShippingMethods(): Promise<import('axios').AxiosResponse<BaseApiResponse<
|
|
9
|
+
getShippingMethods(): Promise<import('axios').AxiosResponse<BaseApiResponse<T[]>, any>>;
|
|
10
|
+
getShippingAddresses(): Promise<import('axios').AxiosResponse<BaseApiResponsePagination<K>, any>>;
|
|
11
|
+
addShippingAddress(newAddress: K): Promise<import('axios').AxiosResponse<BaseApiResponse<K>, any>>;
|
|
12
|
+
updateShippingAddress(addressId: Pick<K, 'id'>, updateAddress: Partial<K>): Promise<import('axios').AxiosResponse<BaseApiResponse<K>, any>>;
|
|
10
13
|
}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import { BaseApiResponse, BaseStore } from '../../../types';
|
|
1
|
+
import { BaseApiResponse, BaseApiResponsePagination, BasePagination, BaseStore } from '../../../types';
|
|
2
2
|
import { BaseType } from '../../../types/BaseType';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
setShippingMethods: (shippingMethods: K[] | null) => void;
|
|
14
|
-
getShippingMethods: () => K[] | null;
|
|
15
|
-
fetchShippingMethods: () => Promise<BaseApiResponse<K[]>>;
|
|
3
|
+
export interface CoreShipmentStore<T extends CoreShippingMethod, K extends CoreShippingAddress> extends BaseStore {
|
|
4
|
+
shippingMethods: T[] | null;
|
|
5
|
+
shippingAddresses: BasePagination<K> | null;
|
|
6
|
+
setShippingMethods: (shippingMethods: T[] | null) => void;
|
|
7
|
+
getShippingMethods: () => T[] | null;
|
|
8
|
+
fetchShippingMethods: () => Promise<BaseApiResponse<T[]>>;
|
|
9
|
+
setShippingAddresses: (shippingAddresses: BasePagination<K> | null) => void;
|
|
10
|
+
getShippingAddresses: () => BasePagination<K> | null;
|
|
11
|
+
fetchShippingAddresses: () => Promise<BaseApiResponsePagination<K>>;
|
|
12
|
+
addShippingAddress: (newAddress: K) => void;
|
|
16
13
|
}
|
|
17
14
|
export interface CoreShippingMethod extends BaseType {
|
|
18
15
|
name: string;
|
|
@@ -29,3 +26,10 @@ export interface CoreShippingCalculationForm {
|
|
|
29
26
|
value: string;
|
|
30
27
|
disabled: boolean;
|
|
31
28
|
}
|
|
29
|
+
export interface CoreShippingAddress extends BaseType {
|
|
30
|
+
label: string;
|
|
31
|
+
address: string;
|
|
32
|
+
province: string;
|
|
33
|
+
municipality: string;
|
|
34
|
+
is_default: boolean;
|
|
35
|
+
}
|