storemw-core-client 1.0.1
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/.env +1 -0
- package/.vscode/launch.json +24 -0
- package/dist/config/config.d.ts +6 -0
- package/dist/config/config.js +13 -0
- package/dist/config/env.d.ts +7 -0
- package/dist/config/env.js +16 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.js +8 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +32 -0
- package/dist/lib/ApiService.d.ts +41 -0
- package/dist/lib/ApiService.js +143 -0
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/index.js +9 -0
- package/dist/lib/queryParams.d.ts +43 -0
- package/dist/lib/queryParams.js +99 -0
- package/dist/services/account/AccountService.d.ts +52 -0
- package/dist/services/account/AccountService.js +119 -0
- package/dist/services/auth/AuthService.d.ts +44 -0
- package/dist/services/auth/AuthService.js +76 -0
- package/dist/services/branch/BranchService.d.ts +124 -0
- package/dist/services/branch/BranchService.js +162 -0
- package/dist/services/business/BusinessService.d.ts +91 -0
- package/dist/services/business/BusinessService.js +153 -0
- package/dist/services/document/DocumentService.d.ts +578 -0
- package/dist/services/document/DocumentService.js +615 -0
- package/dist/services/index.d.ts +36 -0
- package/dist/services/index.js +97 -0
- package/dist/services/injection_field/InjectionFieldService.d.ts +113 -0
- package/dist/services/injection_field/InjectionFieldService.js +220 -0
- package/dist/services/inventory/InventoryService.d.ts +27 -0
- package/dist/services/inventory/InventoryService.js +231 -0
- package/dist/services/item/ItemService.d.ts +227 -0
- package/dist/services/item/ItemService.js +411 -0
- package/dist/services/location/LocationService.d.ts +154 -0
- package/dist/services/location/LocationService.js +256 -0
- package/dist/services/logistic/LogisticService.d.ts +104 -0
- package/dist/services/logistic/LogisticService.js +150 -0
- package/dist/services/permission/PermissionService.d.ts +296 -0
- package/dist/services/permission/PermissionService.js +576 -0
- package/dist/services/permission/config/custom/adminPermission.d.ts +4 -0
- package/dist/services/permission/config/custom/adminPermission.js +18 -0
- package/dist/services/permission/config/custom/config.d.ts +40 -0
- package/dist/services/permission/config/custom/config.js +23 -0
- package/dist/services/permission/config/default/adminPermission.d.ts +2 -0
- package/dist/services/permission/config/default/adminPermission.js +129 -0
- package/dist/services/permission/config/default/agentPermission.d.ts +2 -0
- package/dist/services/permission/config/default/agentPermission.js +43 -0
- package/dist/services/permission/config/default/customerPermission.d.ts +2 -0
- package/dist/services/permission/config/default/customerPermission.js +10 -0
- package/dist/services/permission/config/default/driverPermission.d.ts +2 -0
- package/dist/services/permission/config/default/driverPermission.js +4 -0
- package/dist/services/permission/config/default/workerPermission.d.ts +2 -0
- package/dist/services/permission/config/default/workerPermission.js +25 -0
- package/dist/services/rate/RateService.d.ts +201 -0
- package/dist/services/rate/RateService.js +303 -0
- package/dist/services/region/RegionService.d.ts +111 -0
- package/dist/services/region/RegionService.js +193 -0
- package/dist/services/repository/RepositoryService.d.ts +153 -0
- package/dist/services/repository/RepositoryService.js +243 -0
- package/dist/services/transaction/TransactionService.d.ts +153 -0
- package/dist/services/transaction/TransactionService.js +173 -0
- package/dist/services/user/BranchUserService.d.ts +129 -0
- package/dist/services/user/BranchUserService.js +193 -0
- package/dist/services/user/UserRoleService.d.ts +105 -0
- package/dist/services/user/UserRoleService.js +193 -0
- package/dist/services/user/UserService.d.ts +269 -0
- package/dist/services/user/UserService.js +477 -0
- package/dist/services/wallet/WalletService.d.ts +104 -0
- package/dist/services/wallet/WalletService.js +163 -0
- package/dist/utils/dateUtils.d.ts +6 -0
- package/dist/utils/dateUtils.js +28 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +13 -0
- package/package.json +27 -0
- package/src/config/config.ts +15 -0
- package/src/config/env.ts +18 -0
- package/src/config/index.ts +2 -0
- package/src/index.ts +41 -0
- package/src/lib/ApiService.ts +170 -0
- package/src/lib/index.ts +5 -0
- package/src/lib/queryParams.ts +162 -0
- package/src/services/account/AccountService.ts +232 -0
- package/src/services/auth/AuthService.ts +125 -0
- package/src/services/branch/BranchService.ts +330 -0
- package/src/services/business/BusinessService.ts +277 -0
- package/src/services/document/DocumentService.ts +1471 -0
- package/src/services/index.ts +73 -0
- package/src/services/injection_field/InjectionFieldService.ts +483 -0
- package/src/services/inventory/InventoryService.ts +314 -0
- package/src/services/item/ItemService.ts +707 -0
- package/src/services/location/LocationService.ts +505 -0
- package/src/services/logistic/LogisticService.ts +285 -0
- package/src/services/permission/PermissionService.ts +1069 -0
- package/src/services/permission/config/custom/adminPermission.ts +19 -0
- package/src/services/permission/config/custom/config.ts +39 -0
- package/src/services/permission/config/default/adminPermission.ts +129 -0
- package/src/services/permission/config/default/agentPermission.ts +42 -0
- package/src/services/permission/config/default/customerPermission.ts +9 -0
- package/src/services/permission/config/default/driverPermission.ts +4 -0
- package/src/services/permission/config/default/workerPermission.ts +25 -0
- package/src/services/rate/RateService.ts +570 -0
- package/src/services/region/RegionService.ts +353 -0
- package/src/services/repository/RepositoryService.ts +437 -0
- package/src/services/transaction/TransactionService.ts +404 -0
- package/src/services/user/BranchUserService.ts +381 -0
- package/src/services/user/UserRoleService.ts +342 -0
- package/src/services/user/UserService.ts +807 -0
- package/src/services/wallet/WalletService.ts +300 -0
- package/src/utils/dateUtils.ts +26 -0
- package/src/utils/index.ts +2 -0
- package/tsconfig.json +119 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocationService = exports.locationTargetTypes = exports.locationTypes = void 0;
|
|
4
|
+
const lib_1 = require("@/lib");
|
|
5
|
+
const lib_2 = require("@/lib");
|
|
6
|
+
exports.locationTypes = {
|
|
7
|
+
location: "location",
|
|
8
|
+
rack: "rack",
|
|
9
|
+
slot: "slot",
|
|
10
|
+
zone: "zone",
|
|
11
|
+
};
|
|
12
|
+
exports.locationTargetTypes = {
|
|
13
|
+
location: "location",
|
|
14
|
+
rack: "rack",
|
|
15
|
+
slot: "slot",
|
|
16
|
+
zone: "zone",
|
|
17
|
+
};
|
|
18
|
+
const getCreatePayload = (locationType, data) => {
|
|
19
|
+
if (locationType === "location" && "location" in data) {
|
|
20
|
+
return {
|
|
21
|
+
location: {
|
|
22
|
+
location_name: data.location.locationName,
|
|
23
|
+
location_type: data.location.locationType,
|
|
24
|
+
person_name: data.location.personName,
|
|
25
|
+
person_contact: data.location.personContact,
|
|
26
|
+
person_email: data.location.personEmail,
|
|
27
|
+
address_1: data.location.address1,
|
|
28
|
+
address_2: data.location.address2,
|
|
29
|
+
postcode: data.location.postcode,
|
|
30
|
+
state_id: data.location.stateId,
|
|
31
|
+
country_id: data.location.countryId,
|
|
32
|
+
area_id: data.location.areaId,
|
|
33
|
+
is_default: (data.location.isDefault === true) ? 1 : 0,
|
|
34
|
+
status: (data.location.status === true) ? 1 : 0,
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
if (locationType === "rack" && "rack" in data) {
|
|
39
|
+
return {
|
|
40
|
+
rack: {
|
|
41
|
+
location_id: data.rack.locationId,
|
|
42
|
+
rack_name: data.rack.rackName,
|
|
43
|
+
rack_type: data.rack.rackType,
|
|
44
|
+
sequence: data.rack.sequence,
|
|
45
|
+
is_default: (data.rack.isDefault === true) ? 1 : 0,
|
|
46
|
+
status: (data.rack.status === true) ? 1 : 0,
|
|
47
|
+
},
|
|
48
|
+
slots: data.slots?.map((i) => ({
|
|
49
|
+
slot_name: i.slotName,
|
|
50
|
+
status: (i.status === true) ? 1 : 0,
|
|
51
|
+
is_default: (i.isDefault === true) ? 1 : 0,
|
|
52
|
+
sequence: i.sequence
|
|
53
|
+
}))
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (locationType === "slot" && "slot" in data) {
|
|
57
|
+
return {
|
|
58
|
+
slot: {
|
|
59
|
+
rack_id: data.slot.rackId,
|
|
60
|
+
slot_name: data.slot.slotName,
|
|
61
|
+
status: (data.slot.status === true) ? 1 : 0,
|
|
62
|
+
is_default: (data.slot.isDefault === true) ? 1 : 0,
|
|
63
|
+
sequence: data.slot.sequence
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (locationType === "zone" && "zone" in data) {
|
|
68
|
+
return {
|
|
69
|
+
zone: {
|
|
70
|
+
location_id: data.zone.locationId,
|
|
71
|
+
zone_name: data.zone.zoneName,
|
|
72
|
+
sequence: data.zone.sequence,
|
|
73
|
+
is_default: (data.zone.isDefault === true) ? 1 : 0,
|
|
74
|
+
status: (data.zone.status === true) ? 1 : 0,
|
|
75
|
+
},
|
|
76
|
+
racks: data.racks.map((i) => ({
|
|
77
|
+
rack_id: i.rackId
|
|
78
|
+
})),
|
|
79
|
+
workers: data.worker.map((i) => ({
|
|
80
|
+
user_id: i.userId
|
|
81
|
+
}))
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const getUpdatePayload = (locationType, data) => {
|
|
86
|
+
if (locationType === "location" && "location" in data) {
|
|
87
|
+
return {
|
|
88
|
+
location: {
|
|
89
|
+
location_name: data.location.locationName,
|
|
90
|
+
location_type: data.location.locationType,
|
|
91
|
+
person_name: data.location.personName,
|
|
92
|
+
person_contact: data.location.personContact,
|
|
93
|
+
person_email: data.location.personEmail,
|
|
94
|
+
address_1: data.location.address1,
|
|
95
|
+
address_2: data.location.address2,
|
|
96
|
+
postcode: data.location.postcode,
|
|
97
|
+
state_id: data.location.stateId,
|
|
98
|
+
country_id: data.location.countryId,
|
|
99
|
+
area_id: data.location.areaId,
|
|
100
|
+
is_default: (data.location.isDefault === true) ? 1 : 0,
|
|
101
|
+
status: (data.location.status === true) ? 1 : 0,
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
if (locationType === "rack" && "rack" in data) {
|
|
106
|
+
return {
|
|
107
|
+
rack: {
|
|
108
|
+
location_id: data.rack.locationId,
|
|
109
|
+
rack_name: data.rack.rackName,
|
|
110
|
+
rack_type: data.rack.rackType,
|
|
111
|
+
sequence: data.rack.sequence,
|
|
112
|
+
is_default: (data.rack.isDefault === true) ? 1 : 0,
|
|
113
|
+
status: (data.rack.status === true) ? 1 : 0,
|
|
114
|
+
},
|
|
115
|
+
slots: data.slots?.map((i) => ({
|
|
116
|
+
slot_name: i.slotName,
|
|
117
|
+
status: (i.status === true) ? 1 : 0,
|
|
118
|
+
is_default: (i.isDefault === true) ? 1 : 0,
|
|
119
|
+
sequence: i.sequence
|
|
120
|
+
}))
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
if (locationType === "slot" && "slot" in data) {
|
|
124
|
+
return {
|
|
125
|
+
slot: {
|
|
126
|
+
slot_name: data.slot.slotName,
|
|
127
|
+
status: (data.slot.status === true) ? 1 : 0,
|
|
128
|
+
is_default: (data.slot.isDefault === true) ? 1 : 0,
|
|
129
|
+
sequence: data.slot.sequence
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
if (locationType === "zone" && "zone" in data) {
|
|
134
|
+
return {
|
|
135
|
+
zone: {
|
|
136
|
+
zone_name: data.zone.zoneName,
|
|
137
|
+
sequence: data.zone.sequence,
|
|
138
|
+
is_default: (data.zone.isDefault === true) ? 1 : 0,
|
|
139
|
+
status: (data.zone.status === true) ? 1 : 0,
|
|
140
|
+
},
|
|
141
|
+
racks: data.racks.map((i) => ({
|
|
142
|
+
zone_item_id: "", // ??
|
|
143
|
+
rack_id: i.rackId
|
|
144
|
+
})),
|
|
145
|
+
workers: data.worker.map((i) => ({
|
|
146
|
+
zone_item_id: "", // ??
|
|
147
|
+
user_id: i.userId
|
|
148
|
+
}))
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
const LocationService = (props) => {
|
|
153
|
+
const { locationType = "location", locationTargetType, ...rest } = props ?? {};
|
|
154
|
+
const { makeCall } = (0, lib_1.ApiService)(rest?.customToken ? { customToken: rest.customToken } : {});
|
|
155
|
+
const endpoint1 = "location";
|
|
156
|
+
const endpoint2 = "locations";
|
|
157
|
+
const list = async (props) => {
|
|
158
|
+
const { locationType: overrideLocationType } = props;
|
|
159
|
+
let _locationType = overrideLocationType || locationType;
|
|
160
|
+
let url;
|
|
161
|
+
if (_locationType === "location") { // only for location
|
|
162
|
+
url = (0, lib_2.buildApiListUrl)(`${endpoint2}/${_locationType}`, props);
|
|
163
|
+
}
|
|
164
|
+
else { // for rack, slot, zone
|
|
165
|
+
url = (0, lib_2.buildApiListUrl)(`${endpoint2}/${_locationType}/${props?.locationId}`, props);
|
|
166
|
+
}
|
|
167
|
+
const response = await makeCall({
|
|
168
|
+
url,
|
|
169
|
+
method: "get",
|
|
170
|
+
payload: {},
|
|
171
|
+
// configuration
|
|
172
|
+
});
|
|
173
|
+
return response;
|
|
174
|
+
};
|
|
175
|
+
const get = async (props) => {
|
|
176
|
+
const { id, locationType: overrideLocationType } = props;
|
|
177
|
+
const url = (0, lib_2.buildApiGetUrl)(`${endpoint1}/${overrideLocationType || locationType}/${id}`, props);
|
|
178
|
+
const response = await makeCall({
|
|
179
|
+
url,
|
|
180
|
+
method: "get",
|
|
181
|
+
payload: {},
|
|
182
|
+
// configuration
|
|
183
|
+
});
|
|
184
|
+
return response;
|
|
185
|
+
};
|
|
186
|
+
const create = async ({ data, locationType: overrideLocationType, locationTargetType: overrideLocationTargetType }) => {
|
|
187
|
+
let _locationType = overrideLocationType || locationType;
|
|
188
|
+
let payload = getCreatePayload(_locationType, data);
|
|
189
|
+
let url = `${endpoint1}`;
|
|
190
|
+
let postData = {
|
|
191
|
+
scope: {
|
|
192
|
+
target: overrideLocationTargetType || locationTargetType,
|
|
193
|
+
action: "",
|
|
194
|
+
},
|
|
195
|
+
payload
|
|
196
|
+
};
|
|
197
|
+
const response = await makeCall({
|
|
198
|
+
url,
|
|
199
|
+
method: "post",
|
|
200
|
+
payload: postData
|
|
201
|
+
});
|
|
202
|
+
return response;
|
|
203
|
+
};
|
|
204
|
+
const update = async ({ id, data, locationType: overrideLocationType, locationTargetType: overrideLocationTargetType }) => {
|
|
205
|
+
let url = `${endpoint1}/${id}`;
|
|
206
|
+
let _locationType = overrideLocationType || locationType;
|
|
207
|
+
let payload = getUpdatePayload(_locationType, data);
|
|
208
|
+
const postData = {
|
|
209
|
+
scope: {
|
|
210
|
+
target: overrideLocationTargetType || locationTargetType,
|
|
211
|
+
action: "",
|
|
212
|
+
},
|
|
213
|
+
payload
|
|
214
|
+
};
|
|
215
|
+
const response = await makeCall({
|
|
216
|
+
url,
|
|
217
|
+
method: "put",
|
|
218
|
+
payload: postData
|
|
219
|
+
});
|
|
220
|
+
return response;
|
|
221
|
+
};
|
|
222
|
+
const remove = async ({ ids, locationTargetType: overrideLocationTargetType }) => {
|
|
223
|
+
let url = `${endpoint2}/delete`;
|
|
224
|
+
const postData = {
|
|
225
|
+
scope: {
|
|
226
|
+
target: overrideLocationTargetType || locationTargetType,
|
|
227
|
+
},
|
|
228
|
+
payload: {
|
|
229
|
+
ids
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
const response = await makeCall({
|
|
233
|
+
url,
|
|
234
|
+
method: "post",
|
|
235
|
+
payload: postData
|
|
236
|
+
});
|
|
237
|
+
return response;
|
|
238
|
+
};
|
|
239
|
+
const getDataTypes = async ({ locationType: overrideLocationType }) => {
|
|
240
|
+
let url = `${endpoint2}/data_types/${overrideLocationType || locationType}`;
|
|
241
|
+
const response = await makeCall({
|
|
242
|
+
url,
|
|
243
|
+
method: "get",
|
|
244
|
+
});
|
|
245
|
+
return response;
|
|
246
|
+
};
|
|
247
|
+
return {
|
|
248
|
+
list,
|
|
249
|
+
get,
|
|
250
|
+
create,
|
|
251
|
+
update,
|
|
252
|
+
remove,
|
|
253
|
+
getDataTypes
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
exports.LocationService = LocationService;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { ApiServiceType } from '@/lib';
|
|
2
|
+
import { BuildApiListParamsProps, BuildApiGetParamsProps } from '@/lib';
|
|
3
|
+
export declare const logisticTypes: {
|
|
4
|
+
readonly transporter: "transporter";
|
|
5
|
+
};
|
|
6
|
+
export declare const logisticTargetTypes: {
|
|
7
|
+
readonly transporter: "transporter";
|
|
8
|
+
};
|
|
9
|
+
export declare const transportTypes: {
|
|
10
|
+
readonly ownVehicle: "Own Vehicle";
|
|
11
|
+
readonly courier: "Courier";
|
|
12
|
+
readonly etc: "ETC";
|
|
13
|
+
};
|
|
14
|
+
export type TransportType = typeof transportTypes[keyof typeof transportTypes];
|
|
15
|
+
export type LogisticType = typeof logisticTypes[keyof typeof logisticTypes];
|
|
16
|
+
export type LogisticTargetType = typeof logisticTargetTypes[keyof typeof logisticTargetTypes];
|
|
17
|
+
export type LogisticTargetKey = keyof typeof logisticTargetTypes;
|
|
18
|
+
export type LogisticServiceProps = ApiServiceType & {
|
|
19
|
+
logisticTargetType?: LogisticTargetType;
|
|
20
|
+
logisticType?: LogisticType;
|
|
21
|
+
};
|
|
22
|
+
export type ListLogisticProps = BuildApiListParamsProps & {
|
|
23
|
+
logisticType?: LogisticType;
|
|
24
|
+
};
|
|
25
|
+
export type GetLogisticProps = BuildApiGetParamsProps & {
|
|
26
|
+
id: number | string;
|
|
27
|
+
logisticType?: LogisticType;
|
|
28
|
+
};
|
|
29
|
+
export type CreateLogisticProps = {
|
|
30
|
+
logisticTargetType?: LogisticTargetType;
|
|
31
|
+
logisticType?: LogisticType;
|
|
32
|
+
data: {
|
|
33
|
+
transporter: {
|
|
34
|
+
label: string;
|
|
35
|
+
type: TransportType;
|
|
36
|
+
description: string;
|
|
37
|
+
remark: string;
|
|
38
|
+
status: boolean;
|
|
39
|
+
};
|
|
40
|
+
props: {
|
|
41
|
+
vehiclePlateNo: string;
|
|
42
|
+
vehicleModel: string;
|
|
43
|
+
vehicleBrand: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export type UpdateLogisticProps = {
|
|
48
|
+
id: number;
|
|
49
|
+
logisticTargetType?: LogisticTargetType;
|
|
50
|
+
logisticType?: LogisticType;
|
|
51
|
+
data: {
|
|
52
|
+
transporter: {
|
|
53
|
+
label: string;
|
|
54
|
+
type: TransportType;
|
|
55
|
+
description: string;
|
|
56
|
+
remark: string;
|
|
57
|
+
status: boolean;
|
|
58
|
+
};
|
|
59
|
+
props: {
|
|
60
|
+
vehiclePlateNo: string;
|
|
61
|
+
vehicleModel: string;
|
|
62
|
+
vehicleBrand: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export type RemoveLogisticProps = {
|
|
67
|
+
logisticTargetType?: LogisticTargetType;
|
|
68
|
+
ids: number[];
|
|
69
|
+
};
|
|
70
|
+
export type GetDataTypeLogisticProps = {
|
|
71
|
+
logisticType?: LogisticType;
|
|
72
|
+
};
|
|
73
|
+
export declare const LogisticService: (props?: LogisticServiceProps) => {
|
|
74
|
+
list: (props: ListLogisticProps) => Promise<{
|
|
75
|
+
status: boolean;
|
|
76
|
+
message: string;
|
|
77
|
+
data?: any;
|
|
78
|
+
}>;
|
|
79
|
+
get: (props: GetLogisticProps) => Promise<{
|
|
80
|
+
status: boolean;
|
|
81
|
+
message: string;
|
|
82
|
+
data?: any;
|
|
83
|
+
}>;
|
|
84
|
+
create: ({ data, logisticType: overrideLogisticType, logisticTargetType: overrideLogisticTargetType }: CreateLogisticProps) => Promise<{
|
|
85
|
+
status: boolean;
|
|
86
|
+
message: string;
|
|
87
|
+
data?: any;
|
|
88
|
+
}>;
|
|
89
|
+
update: ({ id, data, logisticType: overrideLogisticType, logisticTargetType: overrideLogisticTargetType }: UpdateLogisticProps) => Promise<{
|
|
90
|
+
status: boolean;
|
|
91
|
+
message: string;
|
|
92
|
+
data?: any;
|
|
93
|
+
}>;
|
|
94
|
+
remove: ({ ids, logisticTargetType: overrideLogisticTargetType }: RemoveLogisticProps) => Promise<{
|
|
95
|
+
status: boolean;
|
|
96
|
+
message: string;
|
|
97
|
+
data?: any;
|
|
98
|
+
}>;
|
|
99
|
+
getDataTypes: ({ logisticType: overrideLogisticType }: GetDataTypeLogisticProps) => Promise<{
|
|
100
|
+
status: boolean;
|
|
101
|
+
message: string;
|
|
102
|
+
data?: any;
|
|
103
|
+
}>;
|
|
104
|
+
};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogisticService = exports.transportTypes = exports.logisticTargetTypes = exports.logisticTypes = void 0;
|
|
4
|
+
const lib_1 = require("@/lib");
|
|
5
|
+
const lib_2 = require("@/lib");
|
|
6
|
+
exports.logisticTypes = {
|
|
7
|
+
transporter: "transporter"
|
|
8
|
+
};
|
|
9
|
+
exports.logisticTargetTypes = {
|
|
10
|
+
transporter: "transporter"
|
|
11
|
+
};
|
|
12
|
+
exports.transportTypes = {
|
|
13
|
+
ownVehicle: "Own Vehicle",
|
|
14
|
+
courier: "Courier",
|
|
15
|
+
etc: "ETC"
|
|
16
|
+
};
|
|
17
|
+
const getCreatePayload = (logisticType, data) => {
|
|
18
|
+
if (logisticType === "transporter") {
|
|
19
|
+
return {
|
|
20
|
+
transporter: {
|
|
21
|
+
label: data.transporter.label,
|
|
22
|
+
type: data.transporter.type,
|
|
23
|
+
description: data.transporter.description,
|
|
24
|
+
remark: data.transporter.remark,
|
|
25
|
+
status: (data.transporter.status === true) ? 1 : 0
|
|
26
|
+
},
|
|
27
|
+
props: {
|
|
28
|
+
vehicle_plate_no: data.props.vehiclePlateNo,
|
|
29
|
+
vehicle_model: data.props.vehicleModel,
|
|
30
|
+
vehicle_brand: data.props.vehicleBrand
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const getUpdatePayload = (logisticType, data) => {
|
|
36
|
+
if (logisticType === "transporter") {
|
|
37
|
+
return {
|
|
38
|
+
transporter: {
|
|
39
|
+
label: data.transporter.label,
|
|
40
|
+
type: data.transporter.type,
|
|
41
|
+
description: data.transporter.description,
|
|
42
|
+
remark: data.transporter.remark,
|
|
43
|
+
status: (data.transporter.status === true) ? 1 : 0
|
|
44
|
+
},
|
|
45
|
+
props: {
|
|
46
|
+
vehicle_plate_no: data.props.vehiclePlateNo,
|
|
47
|
+
vehicle_model: data.props.vehicleModel,
|
|
48
|
+
vehicle_brand: data.props.vehicleBrand
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const LogisticService = (props) => {
|
|
54
|
+
const { logisticType = "transporter", logisticTargetType, ...rest } = props ?? {};
|
|
55
|
+
const { makeCall } = (0, lib_1.ApiService)(rest?.customToken ? { customToken: rest.customToken } : {});
|
|
56
|
+
const endpoint1 = "logistic";
|
|
57
|
+
const endpoint2 = "logistics";
|
|
58
|
+
const list = async (props) => {
|
|
59
|
+
const { logisticType: overrideLogisticType } = props;
|
|
60
|
+
const url = (0, lib_2.buildApiListUrl)(`${endpoint2}/${overrideLogisticType || logisticType}`, props);
|
|
61
|
+
const response = await makeCall({
|
|
62
|
+
url,
|
|
63
|
+
method: "get",
|
|
64
|
+
payload: {},
|
|
65
|
+
// configuration
|
|
66
|
+
});
|
|
67
|
+
return response;
|
|
68
|
+
};
|
|
69
|
+
const get = async (props) => {
|
|
70
|
+
const { id, logisticType: overrideLogisticType } = props;
|
|
71
|
+
const url = (0, lib_2.buildApiGetUrl)(`${endpoint1}/${overrideLogisticType || logisticType}/${id}`, props);
|
|
72
|
+
const response = await makeCall({
|
|
73
|
+
url,
|
|
74
|
+
method: "get",
|
|
75
|
+
payload: {},
|
|
76
|
+
// configuration
|
|
77
|
+
});
|
|
78
|
+
return response;
|
|
79
|
+
};
|
|
80
|
+
const create = async ({ data, logisticType: overrideLogisticType, logisticTargetType: overrideLogisticTargetType }) => {
|
|
81
|
+
let _logisticType = overrideLogisticType || logisticType;
|
|
82
|
+
let payload = getCreatePayload(_logisticType, data);
|
|
83
|
+
let url = `${endpoint1}`;
|
|
84
|
+
let postData = {
|
|
85
|
+
scope: {
|
|
86
|
+
target: overrideLogisticTargetType || logisticTargetType,
|
|
87
|
+
action: "",
|
|
88
|
+
},
|
|
89
|
+
payload
|
|
90
|
+
};
|
|
91
|
+
const response = await makeCall({
|
|
92
|
+
url,
|
|
93
|
+
method: "post",
|
|
94
|
+
payload: postData
|
|
95
|
+
});
|
|
96
|
+
return response;
|
|
97
|
+
};
|
|
98
|
+
const update = async ({ id, data, logisticType: overrideLogisticType, logisticTargetType: overrideLogisticTargetType }) => {
|
|
99
|
+
let url = `${endpoint1}/${id}`;
|
|
100
|
+
let _logisticType = overrideLogisticType || logisticType;
|
|
101
|
+
let payload = getUpdatePayload(_logisticType, data);
|
|
102
|
+
const postData = {
|
|
103
|
+
scope: {
|
|
104
|
+
target: overrideLogisticTargetType || logisticTargetType,
|
|
105
|
+
action: "",
|
|
106
|
+
},
|
|
107
|
+
payload
|
|
108
|
+
};
|
|
109
|
+
const response = await makeCall({
|
|
110
|
+
url,
|
|
111
|
+
method: "put",
|
|
112
|
+
payload: postData
|
|
113
|
+
});
|
|
114
|
+
return response;
|
|
115
|
+
};
|
|
116
|
+
const remove = async ({ ids, logisticTargetType: overrideLogisticTargetType }) => {
|
|
117
|
+
let url = `${endpoint2}/delete`;
|
|
118
|
+
const postData = {
|
|
119
|
+
scope: {
|
|
120
|
+
target: overrideLogisticTargetType || logisticTargetType,
|
|
121
|
+
},
|
|
122
|
+
payload: {
|
|
123
|
+
ids
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const response = await makeCall({
|
|
127
|
+
url,
|
|
128
|
+
method: "post",
|
|
129
|
+
payload: postData
|
|
130
|
+
});
|
|
131
|
+
return response;
|
|
132
|
+
};
|
|
133
|
+
const getDataTypes = async ({ logisticType: overrideLogisticType }) => {
|
|
134
|
+
let url = `${endpoint1}/data_types/${overrideLogisticType || logisticType}`;
|
|
135
|
+
const response = await makeCall({
|
|
136
|
+
url,
|
|
137
|
+
method: "get",
|
|
138
|
+
});
|
|
139
|
+
return response;
|
|
140
|
+
};
|
|
141
|
+
return {
|
|
142
|
+
list,
|
|
143
|
+
get,
|
|
144
|
+
create,
|
|
145
|
+
update,
|
|
146
|
+
remove,
|
|
147
|
+
getDataTypes
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
exports.LogisticService = LogisticService;
|