ingeniuscliq-core 0.5.21 → 0.5.22
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/classes/CoreBaseBuilder.d.ts +67 -0
- package/dist/classes/CoreBaseBuilder.d.ts.map +1 -0
- package/dist/classes/CoreBaseBuilder.js +65 -0
- package/dist/classes/index.d.ts +1 -0
- package/dist/classes/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/modules/CoreAuth/classes/CoreAuthBuilder.d.ts +3 -2
- package/dist/modules/CoreAuth/classes/CoreAuthBuilder.d.ts.map +1 -1
- package/dist/modules/CoreAuth/classes/CoreAuthBuilder.js +153 -147
- package/dist/modules/CoreCustomization/classes/CoreCustomizationBuilder.d.ts +3 -2
- package/dist/modules/CoreCustomization/classes/CoreCustomizationBuilder.d.ts.map +1 -1
- package/dist/modules/CoreCustomization/classes/CoreCustomizationBuilder.js +66 -60
- package/dist/modules/CoreOrder/classes/CoreOrderBuilder.d.ts +3 -2
- package/dist/modules/CoreOrder/classes/CoreOrderBuilder.d.ts.map +1 -1
- package/dist/modules/CoreOrder/classes/CoreOrderBuilder.js +95 -89
- package/dist/modules/CorePayForm/classes/CorePayFormBuilder.d.ts +3 -2
- package/dist/modules/CorePayForm/classes/CorePayFormBuilder.d.ts.map +1 -1
- package/dist/modules/CorePayForm/classes/CorePayFormBuilder.js +50 -44
- package/dist/modules/CoreProduct/classes/CoreProductBuilder.d.ts +3 -2
- package/dist/modules/CoreProduct/classes/CoreProductBuilder.d.ts.map +1 -1
- package/dist/modules/CoreProduct/classes/CoreProductBuilder.js +119 -113
- package/dist/modules/CoreShipment/classes/CoreShipmentBuilder.d.ts +3 -2
- package/dist/modules/CoreShipment/classes/CoreShipmentBuilder.d.ts.map +1 -1
- package/dist/modules/CoreShipment/classes/CoreShipmentBuilder.js +170 -164
- package/dist/modules/CoreShopCart/classes/CoreShopCartBuilder.d.ts +3 -2
- package/dist/modules/CoreShopCart/classes/CoreShopCartBuilder.d.ts.map +1 -1
- package/dist/modules/CoreShopCart/classes/CoreShopCartBuilder.js +144 -138
- package/package.json +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { CoreOrderBaseService } from '../services/base';
|
|
2
2
|
import { CoreOrder, CoreOrderStore } from '../types/CoreOrder';
|
|
3
|
-
import {
|
|
4
|
-
export declare class CoreOrderBuilder<T>
|
|
3
|
+
import { CoreBaseBuilder } from '../../../classes/CoreBaseBuilder';
|
|
4
|
+
export declare class CoreOrderBuilder<T> extends CoreBaseBuilder<CoreOrderStore<T>> {
|
|
5
5
|
protected orderService: CoreOrderBaseService;
|
|
6
6
|
protected initialState: Pick<CoreOrderStore<T>, "orderDetails" | "orders" | "loading" | "error">;
|
|
7
7
|
constructor(orderService?: CoreOrderBaseService, initialState?: Partial<CoreOrderStore<T>>);
|
|
8
|
+
protected getBaseState(set: any, get: any): CoreOrderStore<T>;
|
|
8
9
|
build(): import('zustand').UseBoundStore<Omit<import('zustand').StoreApi<CoreOrderStore<T>>, "persist"> & {
|
|
9
10
|
persist: {
|
|
10
11
|
setOptions: (options: Partial<import('zustand/middleware').PersistOptions<CoreOrderStore<T>, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreOrderBuilder.d.ts","sourceRoot":"","sources":["../../../../src/modules/CoreOrder/classes/CoreOrderBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,cAAc,EAAiB,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"CoreOrderBuilder.d.ts","sourceRoot":"","sources":["../../../../src/modules/CoreOrder/classes/CoreOrderBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,cAAc,EAAiB,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAGnE,qBAAa,gBAAgB,CAAC,CAAC,CAAE,SAAQ,eAAe,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IACzE,SAAS,CAAC,YAAY,EAAE,oBAAoB,CAAC;IAC7C,SAAS,CAAC,YAAY,EAKjB,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC;gBAG5E,YAAY,GAAE,oBAAiD,EAC/D,YAAY,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAS3C,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,cAAc,CAAC,CAAC,CAAC;IA0GtD,KAAK;;;;;;;;;;;;;;;CAcb"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { create } from 'zustand';
|
|
2
2
|
import { persist } from '../../../node_modules/zustand/esm/middleware.js';
|
|
3
3
|
import { CoreOrderBaseService } from '../services/base.js';
|
|
4
|
+
import { CoreBaseBuilder } from '../../../classes/CoreBaseBuilder.js';
|
|
4
5
|
|
|
5
|
-
class CoreOrderBuilder {
|
|
6
|
+
class CoreOrderBuilder extends CoreBaseBuilder {
|
|
6
7
|
orderService;
|
|
7
8
|
initialState = {
|
|
8
9
|
orderDetails: {},
|
|
@@ -11,105 +12,110 @@ class CoreOrderBuilder {
|
|
|
11
12
|
error: null
|
|
12
13
|
};
|
|
13
14
|
constructor(orderService = new CoreOrderBaseService(), initialState) {
|
|
15
|
+
super();
|
|
14
16
|
this.orderService = orderService;
|
|
15
17
|
if (initialState) {
|
|
16
18
|
this.initialState = { ...this.initialState, ...initialState };
|
|
17
19
|
}
|
|
18
20
|
}
|
|
21
|
+
getBaseState(set, get) {
|
|
22
|
+
return {
|
|
23
|
+
...this.initialState,
|
|
24
|
+
// Setters
|
|
25
|
+
setLoading: (loading) => set({ loading }),
|
|
26
|
+
setError: (error) => set({ error }),
|
|
27
|
+
// Getters
|
|
28
|
+
getOrderDetails: () => get().orderDetails,
|
|
29
|
+
// Actions
|
|
30
|
+
createOrder: async (orderData, actions) => {
|
|
31
|
+
const { onSuccess = () => {
|
|
32
|
+
}, onError = () => {
|
|
33
|
+
}, onFinish = () => {
|
|
34
|
+
} } = actions || {};
|
|
35
|
+
try {
|
|
36
|
+
set({ loading: true, error: null });
|
|
37
|
+
const response = await this.orderService.createOrder(orderData);
|
|
38
|
+
const orderDetails = response.data.data.order;
|
|
39
|
+
set({
|
|
40
|
+
orderDetails,
|
|
41
|
+
loading: false
|
|
42
|
+
});
|
|
43
|
+
onSuccess(response);
|
|
44
|
+
return response.data;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
set({ loading: false, error });
|
|
47
|
+
onError(error);
|
|
48
|
+
throw error;
|
|
49
|
+
} finally {
|
|
50
|
+
onFinish();
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
fetchOrderDetails: async (orderId, actions) => {
|
|
54
|
+
const { onSuccess = () => {
|
|
55
|
+
}, onError = () => {
|
|
56
|
+
}, onFinish = () => {
|
|
57
|
+
} } = actions || {};
|
|
58
|
+
try {
|
|
59
|
+
set({ loading: true, error: null });
|
|
60
|
+
const response = await this.orderService.fetchOrderById(orderId);
|
|
61
|
+
const orderDetails = response.data.data;
|
|
62
|
+
set({
|
|
63
|
+
orderDetails,
|
|
64
|
+
loading: false
|
|
65
|
+
});
|
|
66
|
+
onSuccess(response);
|
|
67
|
+
return response.data;
|
|
68
|
+
} catch (error) {
|
|
69
|
+
set({ loading: false, error });
|
|
70
|
+
onError(error);
|
|
71
|
+
throw error;
|
|
72
|
+
} finally {
|
|
73
|
+
onFinish();
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
fetchOrders: async (params, actions) => {
|
|
77
|
+
const { onSuccess = () => {
|
|
78
|
+
}, onError = () => {
|
|
79
|
+
}, onFinish = () => {
|
|
80
|
+
} } = actions || {};
|
|
81
|
+
const { onlyFetch, ...queryParams } = params || {};
|
|
82
|
+
try {
|
|
83
|
+
if (!onlyFetch) {
|
|
84
|
+
set({ loading: true, error: null });
|
|
85
|
+
}
|
|
86
|
+
const response = await this.orderService.fetchOrders(queryParams);
|
|
87
|
+
const orders = response.data.data;
|
|
88
|
+
if (!onlyFetch) {
|
|
89
|
+
set({
|
|
90
|
+
orders,
|
|
91
|
+
loading: false
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
onSuccess(response);
|
|
95
|
+
return response.data;
|
|
96
|
+
} catch (error) {
|
|
97
|
+
if (!onlyFetch) {
|
|
98
|
+
set({ loading: false, error });
|
|
99
|
+
}
|
|
100
|
+
onError(error);
|
|
101
|
+
throw error;
|
|
102
|
+
} finally {
|
|
103
|
+
onFinish();
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
// Reset
|
|
107
|
+
reset: () => set({ ...this.initialState, ...this.extendInitialState() })
|
|
108
|
+
};
|
|
109
|
+
}
|
|
19
110
|
build() {
|
|
20
111
|
return create()(
|
|
21
112
|
persist(
|
|
22
|
-
(set, get) => (
|
|
23
|
-
...this.initialState,
|
|
24
|
-
// Setters
|
|
25
|
-
setLoading: (loading) => set({ loading }),
|
|
26
|
-
setError: (error) => set({ error }),
|
|
27
|
-
// Getters
|
|
28
|
-
getOrderDetails: () => get().orderDetails,
|
|
29
|
-
// Actions
|
|
30
|
-
createOrder: async (orderData, actions) => {
|
|
31
|
-
const { onSuccess = () => {
|
|
32
|
-
}, onError = () => {
|
|
33
|
-
}, onFinish = () => {
|
|
34
|
-
} } = actions || {};
|
|
35
|
-
try {
|
|
36
|
-
set({ loading: true, error: null });
|
|
37
|
-
const response = await this.orderService.createOrder(orderData);
|
|
38
|
-
const orderDetails = response.data.data.order;
|
|
39
|
-
set({
|
|
40
|
-
orderDetails,
|
|
41
|
-
loading: false
|
|
42
|
-
});
|
|
43
|
-
onSuccess(response);
|
|
44
|
-
return response.data;
|
|
45
|
-
} catch (error) {
|
|
46
|
-
set({ loading: false, error });
|
|
47
|
-
onError(error);
|
|
48
|
-
throw error;
|
|
49
|
-
} finally {
|
|
50
|
-
onFinish();
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
fetchOrderDetails: async (orderId, actions) => {
|
|
54
|
-
const { onSuccess = () => {
|
|
55
|
-
}, onError = () => {
|
|
56
|
-
}, onFinish = () => {
|
|
57
|
-
} } = actions || {};
|
|
58
|
-
try {
|
|
59
|
-
set({ loading: true, error: null });
|
|
60
|
-
const response = await this.orderService.fetchOrderById(orderId);
|
|
61
|
-
const orderDetails = response.data.data;
|
|
62
|
-
set({
|
|
63
|
-
orderDetails,
|
|
64
|
-
loading: false
|
|
65
|
-
});
|
|
66
|
-
onSuccess(response);
|
|
67
|
-
return response.data;
|
|
68
|
-
} catch (error) {
|
|
69
|
-
set({ loading: false, error });
|
|
70
|
-
onError(error);
|
|
71
|
-
throw error;
|
|
72
|
-
} finally {
|
|
73
|
-
onFinish();
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
fetchOrders: async (params, actions) => {
|
|
77
|
-
const { onSuccess = () => {
|
|
78
|
-
}, onError = () => {
|
|
79
|
-
}, onFinish = () => {
|
|
80
|
-
} } = actions || {};
|
|
81
|
-
const { onlyFetch, ...queryParams } = params || {};
|
|
82
|
-
try {
|
|
83
|
-
if (!onlyFetch) {
|
|
84
|
-
set({ loading: true, error: null });
|
|
85
|
-
}
|
|
86
|
-
const response = await this.orderService.fetchOrders(queryParams);
|
|
87
|
-
const orders = response.data.data;
|
|
88
|
-
if (!onlyFetch) {
|
|
89
|
-
set({
|
|
90
|
-
orders,
|
|
91
|
-
loading: false
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
onSuccess(response);
|
|
95
|
-
return response.data;
|
|
96
|
-
} catch (error) {
|
|
97
|
-
if (!onlyFetch) {
|
|
98
|
-
set({ loading: false, error });
|
|
99
|
-
}
|
|
100
|
-
onError(error);
|
|
101
|
-
throw error;
|
|
102
|
-
} finally {
|
|
103
|
-
onFinish();
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
// Reset
|
|
107
|
-
reset: () => set(this.initialState)
|
|
108
|
-
}),
|
|
113
|
+
(set, get) => this.buildStoreState(set, get),
|
|
109
114
|
{
|
|
110
115
|
name: "order-storage",
|
|
111
116
|
partialize: (state) => ({
|
|
112
|
-
orderDetails: state.orderDetails
|
|
117
|
+
orderDetails: state.orderDetails,
|
|
118
|
+
...this.extendPartialize(state)
|
|
113
119
|
})
|
|
114
120
|
}
|
|
115
121
|
)
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { CorePayFormBaseService } from '../services/base';
|
|
2
2
|
import { CorePayForm, CorePayFormStore } from '../types/CorePayForm';
|
|
3
|
-
import {
|
|
4
|
-
export declare class CorePayFormBuilder<T extends CorePayForm = CorePayForm>
|
|
3
|
+
import { CoreBaseBuilder } from '../../../classes/CoreBaseBuilder';
|
|
4
|
+
export declare class CorePayFormBuilder<T extends CorePayForm = CorePayForm> extends CoreBaseBuilder<CorePayFormStore<T>> {
|
|
5
5
|
protected payFormService: CorePayFormBaseService;
|
|
6
6
|
protected initialState: Pick<CorePayFormStore<T>, "payForms" | "loading" | "error">;
|
|
7
7
|
constructor(service?: CorePayFormBaseService, initialState?: Partial<CorePayFormStore<T>>);
|
|
8
|
+
protected getBaseState(set: any, get: any): CorePayFormStore<T>;
|
|
8
9
|
build(): import('zustand').UseBoundStore<Omit<import('zustand').StoreApi<CorePayFormStore<T>>, "persist"> & {
|
|
9
10
|
persist: {
|
|
10
11
|
setOptions: (options: Partial<import('zustand/middleware').PersistOptions<CorePayFormStore<T>, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CorePayFormBuilder.d.ts","sourceRoot":"","sources":["../../../../src/modules/CorePayForm/classes/CorePayFormBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"CorePayFormBuilder.d.ts","sourceRoot":"","sources":["../../../../src/modules/CorePayForm/classes/CorePayFormBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAGnE,qBAAa,kBAAkB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,CAAE,SAAQ,eAAe,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC/G,SAAS,CAAC,cAAc,EAAE,sBAAsB,CAAC;IACjD,SAAS,CAAC,YAAY,EAIjB,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC;gBAG/D,OAAO,GAAE,sBAAqD,EAC9D,YAAY,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAS7C,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,gBAAgB,CAAC,CAAC,CAAC;IAsDxD,KAAK;;;;;;;;;;;;;;;CAcb"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { create } from 'zustand';
|
|
2
2
|
import { persist } from '../../../node_modules/zustand/esm/middleware.js';
|
|
3
3
|
import { CorePayFormBaseService } from '../services/base.js';
|
|
4
|
+
import { CoreBaseBuilder } from '../../../classes/CoreBaseBuilder.js';
|
|
4
5
|
|
|
5
|
-
class CorePayFormBuilder {
|
|
6
|
+
class CorePayFormBuilder extends CoreBaseBuilder {
|
|
6
7
|
payFormService;
|
|
7
8
|
initialState = {
|
|
8
9
|
payForms: null,
|
|
@@ -10,60 +11,65 @@ class CorePayFormBuilder {
|
|
|
10
11
|
error: null
|
|
11
12
|
};
|
|
12
13
|
constructor(service = new CorePayFormBaseService(), initialState) {
|
|
14
|
+
super();
|
|
13
15
|
this.payFormService = service;
|
|
14
16
|
if (initialState) {
|
|
15
17
|
this.initialState = { ...this.initialState, ...initialState };
|
|
16
18
|
}
|
|
17
19
|
}
|
|
20
|
+
getBaseState(set, get) {
|
|
21
|
+
return {
|
|
22
|
+
...this.initialState,
|
|
23
|
+
// Setters
|
|
24
|
+
setLoading: (loading) => set({ loading }),
|
|
25
|
+
setError: (error) => set({ error }),
|
|
26
|
+
setPayForms: (payForms) => set({ payForms }),
|
|
27
|
+
// Getters
|
|
28
|
+
getPayForms: () => get().payForms,
|
|
29
|
+
// Actions
|
|
30
|
+
fetchPayForms: async (params, actions) => {
|
|
31
|
+
const { onSuccess = () => {
|
|
32
|
+
}, onError = () => {
|
|
33
|
+
}, onFinish = () => {
|
|
34
|
+
} } = actions || {};
|
|
35
|
+
const { onlyFetch, ...queryParams } = params || {};
|
|
36
|
+
try {
|
|
37
|
+
if (!onlyFetch) {
|
|
38
|
+
set({ loading: true, error: null });
|
|
39
|
+
}
|
|
40
|
+
const response = await this.payFormService.fetchPayForms(queryParams);
|
|
41
|
+
const payForms = response.data.data;
|
|
42
|
+
if (!onlyFetch) {
|
|
43
|
+
set({
|
|
44
|
+
payForms,
|
|
45
|
+
loading: false
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
onSuccess(response);
|
|
49
|
+
return payForms;
|
|
50
|
+
} catch (error) {
|
|
51
|
+
if (!onlyFetch) {
|
|
52
|
+
set({ loading: false, error });
|
|
53
|
+
}
|
|
54
|
+
onError(error);
|
|
55
|
+
throw error;
|
|
56
|
+
} finally {
|
|
57
|
+
onFinish();
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
// Reset
|
|
61
|
+
reset: () => set({ ...this.initialState, ...this.extendInitialState() })
|
|
62
|
+
};
|
|
63
|
+
}
|
|
18
64
|
build() {
|
|
19
65
|
return create()(
|
|
20
66
|
persist(
|
|
21
|
-
(set, get) => (
|
|
22
|
-
...this.initialState,
|
|
23
|
-
// Setters
|
|
24
|
-
setLoading: (loading) => set({ loading }),
|
|
25
|
-
setError: (error) => set({ error }),
|
|
26
|
-
setPayForms: (payForms) => set({ payForms }),
|
|
27
|
-
// Getters
|
|
28
|
-
getPayForms: () => get().payForms,
|
|
29
|
-
// Actions
|
|
30
|
-
fetchPayForms: async (params, actions) => {
|
|
31
|
-
const { onSuccess = () => {
|
|
32
|
-
}, onError = () => {
|
|
33
|
-
}, onFinish = () => {
|
|
34
|
-
} } = actions || {};
|
|
35
|
-
const { onlyFetch, ...queryParams } = params || {};
|
|
36
|
-
try {
|
|
37
|
-
if (!onlyFetch) {
|
|
38
|
-
set({ loading: true, error: null });
|
|
39
|
-
}
|
|
40
|
-
const response = await this.payFormService.fetchPayForms(queryParams);
|
|
41
|
-
const payForms = response.data.data;
|
|
42
|
-
if (!onlyFetch) {
|
|
43
|
-
set({
|
|
44
|
-
payForms,
|
|
45
|
-
loading: false
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
onSuccess(response);
|
|
49
|
-
return payForms;
|
|
50
|
-
} catch (error) {
|
|
51
|
-
if (!onlyFetch) {
|
|
52
|
-
set({ loading: false, error });
|
|
53
|
-
}
|
|
54
|
-
onError(error);
|
|
55
|
-
throw error;
|
|
56
|
-
} finally {
|
|
57
|
-
onFinish();
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
// Reset
|
|
61
|
-
reset: () => set(this.initialState)
|
|
62
|
-
}),
|
|
67
|
+
(set, get) => this.buildStoreState(set, get),
|
|
63
68
|
{
|
|
64
69
|
name: "payform-storage",
|
|
65
70
|
partialize: (state) => ({
|
|
66
|
-
payForms: state.payForms
|
|
71
|
+
payForms: state.payForms,
|
|
72
|
+
...this.extendPartialize(state)
|
|
67
73
|
})
|
|
68
74
|
}
|
|
69
75
|
)
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { CoreProductBaseService } from '../services/base';
|
|
2
2
|
import { CoreProduct, CoreProductStore } from '../types/CoreProduct';
|
|
3
3
|
import { CoreProductCategory } from '../types/CoreProductCategory';
|
|
4
|
-
import {
|
|
5
|
-
export declare class CoreProductBuilder<T extends CoreProduct = CoreProduct, K extends CoreProductCategory = CoreProductCategory>
|
|
4
|
+
import { CoreBaseBuilder } from '../../../classes/CoreBaseBuilder';
|
|
5
|
+
export declare class CoreProductBuilder<T extends CoreProduct = CoreProduct, K extends CoreProductCategory = CoreProductCategory> extends CoreBaseBuilder<CoreProductStore<T, K>> {
|
|
6
6
|
protected productService: CoreProductBaseService;
|
|
7
7
|
protected initialState: Pick<CoreProductStore<T, K>, "productDetails" | "products" | "categories" | "bestSellers" | "loading" | "error">;
|
|
8
8
|
constructor(service?: CoreProductBaseService, initialState?: Partial<CoreProductStore<T, K>>);
|
|
9
|
+
protected getBaseState(set: any, get: any): CoreProductStore<T, K>;
|
|
9
10
|
build(): import('zustand').UseBoundStore<Omit<import('zustand').StoreApi<CoreProductStore<T, K>>, "persist"> & {
|
|
10
11
|
persist: {
|
|
11
12
|
setOptions: (options: Partial<import('zustand/middleware').PersistOptions<CoreProductStore<T, K>, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreProductBuilder.d.ts","sourceRoot":"","sources":["../../../../src/modules/CoreProduct/classes/CoreProductBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAExE,OAAO,
|
|
1
|
+
{"version":3,"file":"CoreProductBuilder.d.ts","sourceRoot":"","sources":["../../../../src/modules/CoreProduct/classes/CoreProductBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAExE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAGnE,qBAAa,kBAAkB,CAC7B,CAAC,SAAS,WAAW,GAAG,WAAW,EACnC,CAAC,SAAS,mBAAmB,GAAG,mBAAmB,CACnD,SAAQ,eAAe,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/C,SAAS,CAAC,cAAc,EAAE,sBAAsB,CAAC;IACjD,SAAS,CAAC,YAAY,EAOjB,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,gBAAgB,GAAG,UAAU,GAAG,YAAY,GAAG,aAAa,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC;gBAGpH,OAAO,GAAE,sBAAqD,EAC9D,YAAY,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAShD,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC;IAqI3D,KAAK;;;;;;;;;;;;;;;;;;;;;CAiBb"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { create } from 'zustand';
|
|
2
2
|
import { persist } from '../../../node_modules/zustand/esm/middleware.js';
|
|
3
3
|
import { CoreProductBaseService } from '../services/base.js';
|
|
4
|
+
import { CoreBaseBuilder } from '../../../classes/CoreBaseBuilder.js';
|
|
4
5
|
|
|
5
|
-
class CoreProductBuilder {
|
|
6
|
+
class CoreProductBuilder extends CoreBaseBuilder {
|
|
6
7
|
productService;
|
|
7
8
|
initialState = {
|
|
8
9
|
productDetails: null,
|
|
@@ -13,132 +14,137 @@ class CoreProductBuilder {
|
|
|
13
14
|
error: null
|
|
14
15
|
};
|
|
15
16
|
constructor(service = new CoreProductBaseService(), initialState) {
|
|
17
|
+
super();
|
|
16
18
|
this.productService = service;
|
|
17
19
|
if (initialState) {
|
|
18
20
|
this.initialState = { ...this.initialState, ...initialState };
|
|
19
21
|
}
|
|
20
22
|
}
|
|
23
|
+
getBaseState(set, get) {
|
|
24
|
+
return {
|
|
25
|
+
...this.initialState,
|
|
26
|
+
// Setters
|
|
27
|
+
setProductDetails: (productDetails) => set({ productDetails }),
|
|
28
|
+
setCategories: (categories) => set({ categories }),
|
|
29
|
+
setProducts: (products) => set({ products }),
|
|
30
|
+
setLoading: (loading) => set({ loading }),
|
|
31
|
+
setError: (error) => set({ error }),
|
|
32
|
+
// Getters
|
|
33
|
+
getProducts: () => get().products,
|
|
34
|
+
getProductDetails: () => get().productDetails,
|
|
35
|
+
getCategories: () => get().categories,
|
|
36
|
+
// Actions
|
|
37
|
+
fetchProducts: async (params, actions) => {
|
|
38
|
+
const { onSuccess = () => {
|
|
39
|
+
}, onError = () => {
|
|
40
|
+
}, onFinish = () => {
|
|
41
|
+
} } = actions || {};
|
|
42
|
+
const { onlyFetch, ...queryParams } = params || {};
|
|
43
|
+
try {
|
|
44
|
+
if (!onlyFetch) {
|
|
45
|
+
set({ loading: true, error: null });
|
|
46
|
+
}
|
|
47
|
+
const response = await this.productService.getAllProducts(queryParams);
|
|
48
|
+
if (!onlyFetch) {
|
|
49
|
+
set({ products: response.data.data, loading: false });
|
|
50
|
+
}
|
|
51
|
+
onSuccess(response);
|
|
52
|
+
return response.data;
|
|
53
|
+
} catch (error) {
|
|
54
|
+
if (!onlyFetch) {
|
|
55
|
+
set((state) => ({ ...state, error, loading: false }));
|
|
56
|
+
}
|
|
57
|
+
onError(error);
|
|
58
|
+
throw error;
|
|
59
|
+
} finally {
|
|
60
|
+
onFinish();
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
fetchProductDetails: async (id) => {
|
|
64
|
+
const currentProduct = get().productDetails;
|
|
65
|
+
if (currentProduct && String(currentProduct.id) === String(id)) {
|
|
66
|
+
return {
|
|
67
|
+
data: currentProduct,
|
|
68
|
+
message: ""
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
set({ productDetails: null, loading: true, error: null });
|
|
72
|
+
try {
|
|
73
|
+
const response = await this.productService.getProductById(id);
|
|
74
|
+
set({ productDetails: response.data.data, loading: false });
|
|
75
|
+
return response.data;
|
|
76
|
+
} catch (error) {
|
|
77
|
+
set((state) => ({ ...state, error, loading: false }));
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
fetchCategories: async (params, actions) => {
|
|
82
|
+
const { onSuccess = () => {
|
|
83
|
+
}, onError = () => {
|
|
84
|
+
}, onFinish = () => {
|
|
85
|
+
} } = actions || {};
|
|
86
|
+
const { onlyFetch, ...queryParams } = params || {};
|
|
87
|
+
try {
|
|
88
|
+
if (!onlyFetch) {
|
|
89
|
+
set({ loading: true, error: null });
|
|
90
|
+
}
|
|
91
|
+
const response = await this.productService.getAllCategories(queryParams);
|
|
92
|
+
if (!onlyFetch) {
|
|
93
|
+
set({ categories: response.data.data, loading: false });
|
|
94
|
+
}
|
|
95
|
+
onSuccess(response);
|
|
96
|
+
return response.data;
|
|
97
|
+
} catch (error) {
|
|
98
|
+
if (!onlyFetch) {
|
|
99
|
+
set((state) => ({ ...state, error, loading: false }));
|
|
100
|
+
}
|
|
101
|
+
onError(error);
|
|
102
|
+
throw error;
|
|
103
|
+
} finally {
|
|
104
|
+
onFinish();
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
fetchBestSellers: async (params, actions) => {
|
|
108
|
+
const { onSuccess = () => {
|
|
109
|
+
}, onError = () => {
|
|
110
|
+
}, onFinish = () => {
|
|
111
|
+
} } = actions || {};
|
|
112
|
+
const { onlyFetch, ...queryParams } = params || {};
|
|
113
|
+
try {
|
|
114
|
+
if (!onlyFetch) {
|
|
115
|
+
set({ loading: true, error: null });
|
|
116
|
+
}
|
|
117
|
+
const response = await this.productService.fetchBestSellers(queryParams);
|
|
118
|
+
if (!onlyFetch) {
|
|
119
|
+
set({ loading: false, bestSellers: response.data.data });
|
|
120
|
+
}
|
|
121
|
+
onSuccess(response);
|
|
122
|
+
return response.data;
|
|
123
|
+
} catch (error) {
|
|
124
|
+
if (!onlyFetch) {
|
|
125
|
+
set((state) => ({ ...state, error, loading: false, bestSellers: null }));
|
|
126
|
+
}
|
|
127
|
+
onError(error);
|
|
128
|
+
throw error;
|
|
129
|
+
} finally {
|
|
130
|
+
onFinish();
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
reset: () => set({ ...this.initialState, ...this.extendInitialState() })
|
|
134
|
+
};
|
|
135
|
+
}
|
|
21
136
|
build() {
|
|
22
137
|
return create()(
|
|
23
138
|
persist(
|
|
24
|
-
(set, get) => (
|
|
25
|
-
...this.initialState,
|
|
26
|
-
// Setters
|
|
27
|
-
setProductDetails: (productDetails) => set({ productDetails }),
|
|
28
|
-
setCategories: (categories) => set({ categories }),
|
|
29
|
-
setProducts: (products) => set({ products }),
|
|
30
|
-
setLoading: (loading) => set({ loading }),
|
|
31
|
-
setError: (error) => set({ error }),
|
|
32
|
-
// Getters
|
|
33
|
-
getProducts: () => get().products,
|
|
34
|
-
getProductDetails: () => get().productDetails,
|
|
35
|
-
getCategories: () => get().categories,
|
|
36
|
-
// Actions
|
|
37
|
-
fetchProducts: async (params, actions) => {
|
|
38
|
-
const { onSuccess = () => {
|
|
39
|
-
}, onError = () => {
|
|
40
|
-
}, onFinish = () => {
|
|
41
|
-
} } = actions || {};
|
|
42
|
-
const { onlyFetch, ...queryParams } = params || {};
|
|
43
|
-
try {
|
|
44
|
-
if (!onlyFetch) {
|
|
45
|
-
set({ loading: true, error: null });
|
|
46
|
-
}
|
|
47
|
-
const response = await this.productService.getAllProducts(queryParams);
|
|
48
|
-
if (!onlyFetch) {
|
|
49
|
-
set({ products: response.data.data, loading: false });
|
|
50
|
-
}
|
|
51
|
-
onSuccess(response);
|
|
52
|
-
return response.data;
|
|
53
|
-
} catch (error) {
|
|
54
|
-
if (!onlyFetch) {
|
|
55
|
-
set((state) => ({ ...state, error, loading: false }));
|
|
56
|
-
}
|
|
57
|
-
onError(error);
|
|
58
|
-
throw error;
|
|
59
|
-
} finally {
|
|
60
|
-
onFinish();
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
fetchProductDetails: async (id) => {
|
|
64
|
-
const currentProduct = get().productDetails;
|
|
65
|
-
if (currentProduct && String(currentProduct.id) === String(id)) {
|
|
66
|
-
return {
|
|
67
|
-
data: currentProduct,
|
|
68
|
-
message: ""
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
set({ productDetails: null, loading: true, error: null });
|
|
72
|
-
try {
|
|
73
|
-
const response = await this.productService.getProductById(id);
|
|
74
|
-
set({ productDetails: response.data.data, loading: false });
|
|
75
|
-
return response.data;
|
|
76
|
-
} catch (error) {
|
|
77
|
-
set((state) => ({ ...state, error, loading: false }));
|
|
78
|
-
throw error;
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
fetchCategories: async (params, actions) => {
|
|
82
|
-
const { onSuccess = () => {
|
|
83
|
-
}, onError = () => {
|
|
84
|
-
}, onFinish = () => {
|
|
85
|
-
} } = actions || {};
|
|
86
|
-
const { onlyFetch, ...queryParams } = params || {};
|
|
87
|
-
try {
|
|
88
|
-
if (!onlyFetch) {
|
|
89
|
-
set({ loading: true, error: null });
|
|
90
|
-
}
|
|
91
|
-
const response = await this.productService.getAllCategories(queryParams);
|
|
92
|
-
if (!onlyFetch) {
|
|
93
|
-
set({ categories: response.data.data, loading: false });
|
|
94
|
-
}
|
|
95
|
-
onSuccess(response);
|
|
96
|
-
return response.data;
|
|
97
|
-
} catch (error) {
|
|
98
|
-
if (!onlyFetch) {
|
|
99
|
-
set((state) => ({ ...state, error, loading: false }));
|
|
100
|
-
}
|
|
101
|
-
onError(error);
|
|
102
|
-
throw error;
|
|
103
|
-
} finally {
|
|
104
|
-
onFinish();
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
fetchBestSellers: async (params, actions) => {
|
|
108
|
-
const { onSuccess = () => {
|
|
109
|
-
}, onError = () => {
|
|
110
|
-
}, onFinish = () => {
|
|
111
|
-
} } = actions || {};
|
|
112
|
-
const { onlyFetch, ...queryParams } = params || {};
|
|
113
|
-
try {
|
|
114
|
-
if (!onlyFetch) {
|
|
115
|
-
set({ loading: true, error: null });
|
|
116
|
-
}
|
|
117
|
-
const response = await this.productService.fetchBestSellers(queryParams);
|
|
118
|
-
if (!onlyFetch) {
|
|
119
|
-
set({ loading: false, bestSellers: response.data.data });
|
|
120
|
-
}
|
|
121
|
-
onSuccess(response);
|
|
122
|
-
return response.data;
|
|
123
|
-
} catch (error) {
|
|
124
|
-
if (!onlyFetch) {
|
|
125
|
-
set((state) => ({ ...state, error, loading: false, bestSellers: null }));
|
|
126
|
-
}
|
|
127
|
-
onError(error);
|
|
128
|
-
throw error;
|
|
129
|
-
} finally {
|
|
130
|
-
onFinish();
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
reset: () => set(this.initialState)
|
|
134
|
-
}),
|
|
139
|
+
(set, get) => this.buildStoreState(set, get),
|
|
135
140
|
{
|
|
136
141
|
name: "product-storage",
|
|
137
142
|
partialize: (state) => ({
|
|
138
143
|
productDetails: state.productDetails,
|
|
139
144
|
products: state.products,
|
|
140
145
|
categories: state.categories,
|
|
141
|
-
bestSellers: state.bestSellers
|
|
146
|
+
bestSellers: state.bestSellers,
|
|
147
|
+
...this.extendPartialize(state)
|
|
142
148
|
})
|
|
143
149
|
}
|
|
144
150
|
)
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CoreBaseBuilder } from '../../../classes/CoreBaseBuilder';
|
|
2
2
|
import { CoreShipmentBaseService } from '../services/base';
|
|
3
3
|
import { CoreShippingAddress, CoreShipmentStore, CoreShippingMethod, CoreShippingMethodTypes, CoreShipmentBeneficiary } from '../types/CoreShipment';
|
|
4
|
-
export declare class CoreShipmentBuilder<T extends CoreShippingMethod<Z>, K extends CoreShippingAddress, Z extends CoreShippingMethodTypes, Y extends CoreShipmentBeneficiary>
|
|
4
|
+
export declare class CoreShipmentBuilder<T extends CoreShippingMethod<Z>, K extends CoreShippingAddress, Z extends CoreShippingMethodTypes, Y extends CoreShipmentBeneficiary> extends CoreBaseBuilder<CoreShipmentStore<T, K, Z, Y>> {
|
|
5
5
|
protected shipmentService: CoreShipmentBaseService<T, K, Z, Y>;
|
|
6
6
|
protected initialState: Pick<CoreShipmentStore<T, K, Z, Y>, 'shippingMethods' | 'shippingAddresses' | 'beneficiaries' | 'selectedAddress' | 'loading' | 'error'>;
|
|
7
7
|
constructor(service?: CoreShipmentBaseService<T, K, Z, Y>, initialState?: any);
|
|
8
|
+
protected getBaseState(set: any, get: any): CoreShipmentStore<T, K, Z, Y>;
|
|
8
9
|
build(): import('zustand').UseBoundStore<Omit<import('zustand').StoreApi<CoreShipmentStore<T, K, Z, Y>>, "persist"> & {
|
|
9
10
|
persist: {
|
|
10
11
|
setOptions: (options: Partial<import('zustand/middleware').PersistOptions<CoreShipmentStore<T, K, Z, Y>, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreShipmentBuilder.d.ts","sourceRoot":"","sources":["../../../../src/modules/CoreShipment/classes/CoreShipmentBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"CoreShipmentBuilder.d.ts","sourceRoot":"","sources":["../../../../src/modules/CoreShipment/classes/CoreShipmentBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,EAGxB,MAAM,uBAAuB,CAAC;AAG/B,qBAAa,mBAAmB,CAC9B,CAAC,SAAS,kBAAkB,CAAC,CAAC,CAAC,EAC/B,CAAC,SAAS,mBAAmB,EAC7B,CAAC,SAAS,uBAAuB,EACjC,CAAC,SAAS,uBAAuB,CACjC,SAAQ,eAAe,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACtD,SAAS,CAAC,eAAe,EAAE,uBAAuB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/D,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,iBAAiB,GAAG,mBAAmB,GAAG,eAAe,GAAG,iBAAiB,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC;gBAG/J,OAAO,CAAC,EAAE,uBAAuB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC7C,YAAY,CAAC,EAAE,GAAG;IAcpB,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAgNlE,KAAK;;;;;;;;;;;;;;;;;;;CAgBb"}
|