@kiminix/tp-client 2.10.1 → 2.10.2
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/menus/admin/admin-apis.d.ts +1 -28
- package/dist/menus/admin/admin-apis.js +0 -78
- package/dist/menus/admin/api/create-bill-api.d.ts +13 -0
- package/dist/menus/admin/api/create-bill-api.js +59 -0
- package/dist/menus/admin/api/get-bill-by-id-api.d.ts +22 -0
- package/dist/menus/admin/api/get-bill-by-id-api.js +59 -0
- package/dist/menus/admin/api/get-bills-api.d.ts +22 -0
- package/dist/menus/admin/api/get-bills-api.js +67 -0
- package/dist/menus/admin/api/get-menu-api.d.ts +28 -0
- package/dist/menus/admin/api/get-menu-api.js +72 -0
- package/dist/menus/admin/api/get-product-api.d.ts +28 -0
- package/dist/menus/admin/api/get-product-api.js +67 -0
- package/dist/menus/admin/api/update-product-api.d.ts +20 -0
- package/dist/menus/admin/api/update-product-api.js +59 -0
- package/dist/menus/index.d.ts +10 -7
- package/dist/menus/index.js +11 -9
- package/dist/menus/shared/utils.d.ts +10 -0
- package/dist/menus/shared/utils.js +38 -0
- package/package.json +1 -1
- package/dist/menus/admin/types/create-bill-request.d.ts +0 -5
- package/dist/menus/admin/types/create-bill-request.js +0 -1
- package/dist/menus/admin/types/get-bills-response.d.ts +0 -11
- package/dist/menus/admin/types/get-bills-response.js +0 -1
- package/dist/menus/admin/types/get-menu-response.d.ts +0 -21
- package/dist/menus/admin/types/get-menu-response.js +0 -10
- package/dist/menus/admin/types/get-product-response.d.ts +0 -20
- package/dist/menus/admin/types/get-product-response.js +0 -6
- package/dist/menus/admin/types/update-product-request.d.ts +0 -12
- package/dist/menus/admin/types/update-product-request.js +0 -1
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import { Order } from "../shared/types";
|
|
2
1
|
import { OrderStatus } from "../../enum";
|
|
2
|
+
import { Order } from "../shared/types";
|
|
3
3
|
import { CallWaiter, CallWaiterStatus } from "./types/get-calls-response";
|
|
4
|
-
import { Category } from "./types/get-menu-response";
|
|
5
|
-
import { Product } from "./types/get-product-response";
|
|
6
|
-
import { UpdateProductRequest } from "./types/update-product-request";
|
|
7
|
-
import { Bill } from "./types/get-bills-response";
|
|
8
4
|
import { QrCode } from "./types/get-qrcodes-response";
|
|
9
5
|
import { SearchOrdersApi } from "./types/search-orders-request";
|
|
10
|
-
import { CreateBillRequest } from "./types/create-bill-request";
|
|
11
6
|
export declare class MenuAdminAPIs {
|
|
12
7
|
static updateOrders(props: {
|
|
13
8
|
token?: string;
|
|
@@ -23,17 +18,6 @@ export declare class MenuAdminAPIs {
|
|
|
23
18
|
token?: string;
|
|
24
19
|
request: SearchOrdersApi;
|
|
25
20
|
}): Promise<Order[]>;
|
|
26
|
-
static createBill(props: {
|
|
27
|
-
token?: string;
|
|
28
|
-
request: CreateBillRequest;
|
|
29
|
-
}): Promise<void>;
|
|
30
|
-
static getBills(props: {
|
|
31
|
-
token?: string;
|
|
32
|
-
timestamp: number;
|
|
33
|
-
page: number;
|
|
34
|
-
size: number;
|
|
35
|
-
sort: "asc" | "desc";
|
|
36
|
-
}): Promise<Bill[]>;
|
|
37
21
|
static getCalls(props: {
|
|
38
22
|
token?: string;
|
|
39
23
|
status: CallWaiterStatus[];
|
|
@@ -47,17 +31,6 @@ export declare class MenuAdminAPIs {
|
|
|
47
31
|
deviceId: string;
|
|
48
32
|
qrCodeId: string;
|
|
49
33
|
}): Promise<undefined>;
|
|
50
|
-
static getMenu(props: {
|
|
51
|
-
token?: string;
|
|
52
|
-
}): Promise<Category[]>;
|
|
53
|
-
static getProduct(props: {
|
|
54
|
-
token?: string;
|
|
55
|
-
id: string;
|
|
56
|
-
}): Promise<Product>;
|
|
57
|
-
static updateProduct(props: {
|
|
58
|
-
token?: string;
|
|
59
|
-
request: UpdateProductRequest;
|
|
60
|
-
}): Promise<void>;
|
|
61
34
|
static getQrCodes(props: {
|
|
62
35
|
token?: string;
|
|
63
36
|
}): Promise<QrCode[]>;
|
|
@@ -89,42 +89,6 @@ var MenuAdminAPIs = /** @class */ (function () {
|
|
|
89
89
|
});
|
|
90
90
|
});
|
|
91
91
|
};
|
|
92
|
-
MenuAdminAPIs.createBill = function (props) {
|
|
93
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
94
|
-
return __generator(this, function (_a) {
|
|
95
|
-
return [2 /*return*/, RequestUtils.send(function () {
|
|
96
|
-
return axios.post(base + "/menus/admin/bills", props.request, {
|
|
97
|
-
headers: {
|
|
98
|
-
'Authorization': "".concat(props.token)
|
|
99
|
-
}
|
|
100
|
-
})
|
|
101
|
-
.then(function (_) { return undefined; });
|
|
102
|
-
})];
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
|
-
MenuAdminAPIs.getBills = function (props) {
|
|
107
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
-
return __generator(this, function (_a) {
|
|
109
|
-
return [2 /*return*/, RequestUtils.send(function () {
|
|
110
|
-
var queryParams = [
|
|
111
|
-
"timestamp=".concat(props.timestamp),
|
|
112
|
-
"page=".concat(props.page),
|
|
113
|
-
"size=".concat(props.size),
|
|
114
|
-
"sort=".concat(props.sort)
|
|
115
|
-
]
|
|
116
|
-
.filter(function (value) { return value; })
|
|
117
|
-
.join("&");
|
|
118
|
-
return axios.get(base + "/menus/admin/bills?".concat(queryParams), {
|
|
119
|
-
headers: {
|
|
120
|
-
'Authorization': "".concat(props.token)
|
|
121
|
-
}
|
|
122
|
-
})
|
|
123
|
-
.then(function (response) { return response.data; });
|
|
124
|
-
})];
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
};
|
|
128
92
|
MenuAdminAPIs.getCalls = function (props) {
|
|
129
93
|
return __awaiter(this, void 0, void 0, function () {
|
|
130
94
|
return __generator(this, function (_a) {
|
|
@@ -165,48 +129,6 @@ var MenuAdminAPIs = /** @class */ (function () {
|
|
|
165
129
|
});
|
|
166
130
|
});
|
|
167
131
|
};
|
|
168
|
-
MenuAdminAPIs.getMenu = function (props) {
|
|
169
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
170
|
-
return __generator(this, function (_a) {
|
|
171
|
-
return [2 /*return*/, RequestUtils.send(function () {
|
|
172
|
-
return axios.get(base + "/menus/admin", {
|
|
173
|
-
headers: {
|
|
174
|
-
'Authorization': "".concat(props.token)
|
|
175
|
-
}
|
|
176
|
-
})
|
|
177
|
-
.then(function (response) { return response.data; });
|
|
178
|
-
})];
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
};
|
|
182
|
-
MenuAdminAPIs.getProduct = function (props) {
|
|
183
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
184
|
-
return __generator(this, function (_a) {
|
|
185
|
-
return [2 /*return*/, RequestUtils.send(function () {
|
|
186
|
-
return axios.get(base + "/menus/admin/products/".concat(props.id), {
|
|
187
|
-
headers: {
|
|
188
|
-
'Authorization': "".concat(props.token)
|
|
189
|
-
}
|
|
190
|
-
})
|
|
191
|
-
.then(function (response) { return response.data; });
|
|
192
|
-
})];
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
};
|
|
196
|
-
MenuAdminAPIs.updateProduct = function (props) {
|
|
197
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
198
|
-
return __generator(this, function (_a) {
|
|
199
|
-
return [2 /*return*/, RequestUtils.send(function () {
|
|
200
|
-
return axios.patch(base + "/menus/admin/products", props.request, {
|
|
201
|
-
headers: {
|
|
202
|
-
'Authorization': "".concat(props.token)
|
|
203
|
-
}
|
|
204
|
-
})
|
|
205
|
-
.then(function (_) { return undefined; });
|
|
206
|
-
})];
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
};
|
|
210
132
|
MenuAdminAPIs.getQrCodes = function (props) {
|
|
211
133
|
return __awaiter(this, void 0, void 0, function () {
|
|
212
134
|
return __generator(this, function (_a) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class CreateBillAPI {
|
|
2
|
+
static create(props: {
|
|
3
|
+
token?: string;
|
|
4
|
+
request: CreateBillAPI.Request;
|
|
5
|
+
}): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export declare namespace CreateBillAPI {
|
|
8
|
+
interface Request {
|
|
9
|
+
orders: string[];
|
|
10
|
+
discount?: number;
|
|
11
|
+
name?: string;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import axios from "axios";
|
|
38
|
+
import { base } from "../../../constants";
|
|
39
|
+
import { RequestUtils } from "../../../utils/request-utils";
|
|
40
|
+
var CreateBillAPI = /** @class */ (function () {
|
|
41
|
+
function CreateBillAPI() {
|
|
42
|
+
}
|
|
43
|
+
CreateBillAPI.create = function (props) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
return [2 /*return*/, RequestUtils.send(function () {
|
|
47
|
+
return axios.post(base + "/menus/admin/bills", props.request, {
|
|
48
|
+
headers: {
|
|
49
|
+
'Authorization': "".concat(props.token)
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
.then(function (_) { return undefined; });
|
|
53
|
+
})];
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
return CreateBillAPI;
|
|
58
|
+
}());
|
|
59
|
+
export { CreateBillAPI };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Order } from "../../shared/types";
|
|
2
|
+
export declare class GetBillAdminAPI {
|
|
3
|
+
static get(props: {
|
|
4
|
+
token?: string;
|
|
5
|
+
id: string;
|
|
6
|
+
}): Promise<GetBillAdminAPI.Bill>;
|
|
7
|
+
}
|
|
8
|
+
export declare namespace GetBillAdminAPI {
|
|
9
|
+
interface Bill {
|
|
10
|
+
id: string;
|
|
11
|
+
businessId: string;
|
|
12
|
+
number: number;
|
|
13
|
+
discount?: number;
|
|
14
|
+
total: number;
|
|
15
|
+
ordersRef: string[];
|
|
16
|
+
ordersCount: number;
|
|
17
|
+
name?: string | undefined;
|
|
18
|
+
createdAt: string;
|
|
19
|
+
updatedAt?: string | undefined;
|
|
20
|
+
orders: Order[];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { RequestUtils } from "../../../utils/request-utils";
|
|
38
|
+
import { base } from "../../../constants";
|
|
39
|
+
import axios from "axios";
|
|
40
|
+
var GetBillAdminAPI = /** @class */ (function () {
|
|
41
|
+
function GetBillAdminAPI() {
|
|
42
|
+
}
|
|
43
|
+
GetBillAdminAPI.get = function (props) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
return [2 /*return*/, RequestUtils.send(function () {
|
|
47
|
+
return axios.get(base + "/menus/admin/bills/".concat(props.id), {
|
|
48
|
+
headers: {
|
|
49
|
+
'Authorization': "".concat(props.token)
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
.then(function (response) { return response.data; });
|
|
53
|
+
})];
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
return GetBillAdminAPI;
|
|
58
|
+
}());
|
|
59
|
+
export { GetBillAdminAPI };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare class GetBillsAdminAPI {
|
|
2
|
+
static get(props: {
|
|
3
|
+
token?: string;
|
|
4
|
+
timestamp: number;
|
|
5
|
+
page: number;
|
|
6
|
+
size: number;
|
|
7
|
+
sort: "asc" | "desc";
|
|
8
|
+
}): Promise<GetBillsAdminAPI.Bill[]>;
|
|
9
|
+
}
|
|
10
|
+
export declare namespace GetBillsAdminAPI {
|
|
11
|
+
interface Bill {
|
|
12
|
+
id: string;
|
|
13
|
+
businessId: string;
|
|
14
|
+
number: number;
|
|
15
|
+
total: number;
|
|
16
|
+
ordersRef: string[];
|
|
17
|
+
ordersCount: number;
|
|
18
|
+
name?: string | undefined;
|
|
19
|
+
createdAt: string;
|
|
20
|
+
updatedAt?: string | undefined;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import axios from "axios";
|
|
38
|
+
import { base } from "../../../constants";
|
|
39
|
+
import { RequestUtils } from "../../../utils/request-utils";
|
|
40
|
+
var GetBillsAdminAPI = /** @class */ (function () {
|
|
41
|
+
function GetBillsAdminAPI() {
|
|
42
|
+
}
|
|
43
|
+
GetBillsAdminAPI.get = function (props) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
return [2 /*return*/, RequestUtils.send(function () {
|
|
47
|
+
var queryParams = [
|
|
48
|
+
"timestamp=".concat(props.timestamp),
|
|
49
|
+
"page=".concat(props.page),
|
|
50
|
+
"size=".concat(props.size),
|
|
51
|
+
"sort=".concat(props.sort)
|
|
52
|
+
]
|
|
53
|
+
.filter(function (value) { return value; })
|
|
54
|
+
.join("&");
|
|
55
|
+
return axios.get(base + "/menus/admin/bills?".concat(queryParams), {
|
|
56
|
+
headers: {
|
|
57
|
+
'Authorization': "".concat(props.token)
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
.then(function (response) { return response.data; });
|
|
61
|
+
})];
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
return GetBillsAdminAPI;
|
|
66
|
+
}());
|
|
67
|
+
export { GetBillsAdminAPI };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare class GetMenuAdminAPI {
|
|
2
|
+
static get(props: {
|
|
3
|
+
token?: string;
|
|
4
|
+
}): Promise<GetMenuAdminAPI.Category[]>;
|
|
5
|
+
}
|
|
6
|
+
export declare namespace GetMenuAdminAPI {
|
|
7
|
+
interface Category {
|
|
8
|
+
label: string;
|
|
9
|
+
id: string;
|
|
10
|
+
isPublic: boolean;
|
|
11
|
+
products: Product[];
|
|
12
|
+
}
|
|
13
|
+
class Product {
|
|
14
|
+
id: string;
|
|
15
|
+
label: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
picture: string;
|
|
18
|
+
variants: Variant[];
|
|
19
|
+
}
|
|
20
|
+
function isAvailable(product: Product): boolean;
|
|
21
|
+
interface Variant {
|
|
22
|
+
id: string;
|
|
23
|
+
label?: string;
|
|
24
|
+
isAvailable: boolean;
|
|
25
|
+
price: number;
|
|
26
|
+
discount?: number;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { RequestUtils } from "../../../utils/request-utils";
|
|
38
|
+
import { base } from "../../../constants";
|
|
39
|
+
import axios from "axios";
|
|
40
|
+
var GetMenuAdminAPI = /** @class */ (function () {
|
|
41
|
+
function GetMenuAdminAPI() {
|
|
42
|
+
}
|
|
43
|
+
GetMenuAdminAPI.get = function (props) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
return [2 /*return*/, RequestUtils.send(function () {
|
|
47
|
+
return axios.get(base + "/menus/admin", {
|
|
48
|
+
headers: {
|
|
49
|
+
'Authorization': "".concat(props.token)
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
.then(function (response) { return response.data; });
|
|
53
|
+
})];
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
return GetMenuAdminAPI;
|
|
58
|
+
}());
|
|
59
|
+
export { GetMenuAdminAPI };
|
|
60
|
+
(function (GetMenuAdminAPI) {
|
|
61
|
+
var Product = /** @class */ (function () {
|
|
62
|
+
function Product() {
|
|
63
|
+
}
|
|
64
|
+
return Product;
|
|
65
|
+
}());
|
|
66
|
+
GetMenuAdminAPI.Product = Product;
|
|
67
|
+
function isAvailable(product) {
|
|
68
|
+
return product.variants.map(function (variant) { return variant.isAvailable; })
|
|
69
|
+
.reduce(function (a, b) { return a || b; }, false);
|
|
70
|
+
}
|
|
71
|
+
GetMenuAdminAPI.isAvailable = isAvailable;
|
|
72
|
+
})(GetMenuAdminAPI || (GetMenuAdminAPI = {}));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare class GetProductAdminAPI {
|
|
2
|
+
static get(props: {
|
|
3
|
+
token?: string;
|
|
4
|
+
id: string;
|
|
5
|
+
}): Promise<GetProductAdminAPI.Product>;
|
|
6
|
+
}
|
|
7
|
+
export declare namespace GetProductAdminAPI {
|
|
8
|
+
class Product {
|
|
9
|
+
id: string;
|
|
10
|
+
label: string;
|
|
11
|
+
category: Category;
|
|
12
|
+
description?: string;
|
|
13
|
+
picture: string;
|
|
14
|
+
variants: Variant[];
|
|
15
|
+
}
|
|
16
|
+
interface Category {
|
|
17
|
+
id: string;
|
|
18
|
+
label: string;
|
|
19
|
+
isPublic: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface Variant {
|
|
22
|
+
id: string;
|
|
23
|
+
label?: string;
|
|
24
|
+
isAvailable: boolean;
|
|
25
|
+
price: number;
|
|
26
|
+
discount?: number;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { RequestUtils } from "../../../utils/request-utils";
|
|
38
|
+
import { base } from "../../../constants";
|
|
39
|
+
import axios from "axios";
|
|
40
|
+
var GetProductAdminAPI = /** @class */ (function () {
|
|
41
|
+
function GetProductAdminAPI() {
|
|
42
|
+
}
|
|
43
|
+
GetProductAdminAPI.get = function (props) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
return [2 /*return*/, RequestUtils.send(function () {
|
|
47
|
+
return axios.get(base + "/menus/admin/products/".concat(props.id), {
|
|
48
|
+
headers: {
|
|
49
|
+
'Authorization': "".concat(props.token)
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
.then(function (response) { return response.data; });
|
|
53
|
+
})];
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
return GetProductAdminAPI;
|
|
58
|
+
}());
|
|
59
|
+
export { GetProductAdminAPI };
|
|
60
|
+
(function (GetProductAdminAPI) {
|
|
61
|
+
var Product = /** @class */ (function () {
|
|
62
|
+
function Product() {
|
|
63
|
+
}
|
|
64
|
+
return Product;
|
|
65
|
+
}());
|
|
66
|
+
GetProductAdminAPI.Product = Product;
|
|
67
|
+
})(GetProductAdminAPI || (GetProductAdminAPI = {}));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare class UpdateProductAdminAPI {
|
|
2
|
+
static update(props: {
|
|
3
|
+
token?: string;
|
|
4
|
+
request: UpdateProductAdminAPI.Request;
|
|
5
|
+
}): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export declare namespace UpdateProductAdminAPI {
|
|
8
|
+
interface Request {
|
|
9
|
+
id: string;
|
|
10
|
+
label?: string | undefined;
|
|
11
|
+
description?: string | undefined;
|
|
12
|
+
variant?: Variant | undefined;
|
|
13
|
+
}
|
|
14
|
+
interface Variant {
|
|
15
|
+
id: string;
|
|
16
|
+
label?: string | undefined;
|
|
17
|
+
isAvailable?: boolean | undefined;
|
|
18
|
+
price?: number | undefined;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import axios from "axios";
|
|
38
|
+
import { base } from "../../../constants";
|
|
39
|
+
import { RequestUtils } from "../../../utils/request-utils";
|
|
40
|
+
var UpdateProductAdminAPI = /** @class */ (function () {
|
|
41
|
+
function UpdateProductAdminAPI() {
|
|
42
|
+
}
|
|
43
|
+
UpdateProductAdminAPI.update = function (props) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
return [2 /*return*/, RequestUtils.send(function () {
|
|
47
|
+
return axios.patch(base + "/menus/admin/products", props.request, {
|
|
48
|
+
headers: {
|
|
49
|
+
'Authorization': "".concat(props.token)
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
.then(function (_) { return undefined; });
|
|
53
|
+
})];
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
return UpdateProductAdminAPI;
|
|
58
|
+
}());
|
|
59
|
+
export { UpdateProductAdminAPI };
|
package/dist/menus/index.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
export { MenuGuestAPIs } from './user/guest-apis';
|
|
1
2
|
export * from "./user/types/get-menu-response";
|
|
2
3
|
export * from './user/types/get-qrcode-response';
|
|
3
|
-
export * from "./user/types/post-order";
|
|
4
4
|
export * from "./user/types/post-call-waiter-request";
|
|
5
|
-
export
|
|
5
|
+
export * from "./user/types/post-order";
|
|
6
|
+
export * from "./admin/api/create-bill-api";
|
|
7
|
+
export * from "./admin/api/get-bill-by-id-api";
|
|
8
|
+
export * from "./admin/api/get-bills-api";
|
|
9
|
+
export * from "./admin/api/get-menu-api";
|
|
10
|
+
export * from "./admin/api/get-product-api";
|
|
11
|
+
export * from "./admin/api/update-product-api";
|
|
6
12
|
export * from "./admin/types/get-calls-response";
|
|
7
|
-
import * as AdminMenuResponse from "./admin/types/get-menu-response";
|
|
8
|
-
export { AdminMenuResponse };
|
|
9
|
-
import * as AdminProductResponse from "./admin/types/get-product-response";
|
|
10
|
-
export { AdminProductResponse };
|
|
11
|
-
import * as AdminQrCodesResponse from "./admin/types/get-qrcodes-response";
|
|
12
13
|
export { AdminQrCodesResponse };
|
|
14
|
+
import * as AdminQrCodesResponse from "./admin/types/get-qrcodes-response";
|
|
13
15
|
export { MenuAdminAPIs } from './admin/admin-apis';
|
|
14
16
|
export * from "./shared/types";
|
|
17
|
+
export * from "./shared/utils";
|
package/dist/menus/index.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
// user module
|
|
2
|
+
export { MenuGuestAPIs } from './user/guest-apis';
|
|
2
3
|
export * from "./user/types/get-menu-response";
|
|
3
4
|
export * from './user/types/get-qrcode-response';
|
|
4
|
-
export * from "./user/types/post-order";
|
|
5
5
|
export * from "./user/types/post-call-waiter-request";
|
|
6
|
-
export
|
|
6
|
+
export * from "./user/types/post-order";
|
|
7
7
|
// admin module
|
|
8
|
+
export * from "./admin/api/create-bill-api";
|
|
9
|
+
export * from "./admin/api/get-bill-by-id-api";
|
|
10
|
+
export * from "./admin/api/get-bills-api";
|
|
11
|
+
export * from "./admin/api/get-menu-api";
|
|
12
|
+
export * from "./admin/api/get-product-api";
|
|
13
|
+
export * from "./admin/api/update-product-api";
|
|
8
14
|
export * from "./admin/types/get-calls-response";
|
|
9
|
-
// export api of get calls
|
|
10
|
-
import * as AdminMenuResponse from "./admin/types/get-menu-response";
|
|
11
|
-
export { AdminMenuResponse };
|
|
12
|
-
// export api of get product
|
|
13
|
-
import * as AdminProductResponse from "./admin/types/get-product-response";
|
|
14
|
-
export { AdminProductResponse };
|
|
15
|
-
import * as AdminQrCodesResponse from "./admin/types/get-qrcodes-response";
|
|
16
15
|
export { AdminQrCodesResponse };
|
|
16
|
+
// export api of admin get-qrcodes
|
|
17
|
+
import * as AdminQrCodesResponse from "./admin/types/get-qrcodes-response";
|
|
17
18
|
export { MenuAdminAPIs } from './admin/admin-apis';
|
|
18
19
|
// shared module
|
|
19
20
|
export * from "./shared/types";
|
|
21
|
+
export * from "./shared/utils";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OrderItem } from "./types";
|
|
2
|
+
export declare namespace OrderUtils {
|
|
3
|
+
type OrderItemGroup = {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
items: OrderItem[];
|
|
7
|
+
};
|
|
8
|
+
function groupByCategory(items: OrderItem[]): OrderItemGroup[];
|
|
9
|
+
function merge(items: OrderItem[]): OrderItem[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export var OrderUtils;
|
|
2
|
+
(function (OrderUtils) {
|
|
3
|
+
function groupByCategory(items) {
|
|
4
|
+
var groups = items === null || items === void 0 ? void 0 : items.reduce(function (acc, item) {
|
|
5
|
+
// if categoryId is not in acc, create it
|
|
6
|
+
if (!acc[item.categoryId]) {
|
|
7
|
+
acc[item.categoryId] = {
|
|
8
|
+
id: item.categoryId,
|
|
9
|
+
label: item.categoryLabel,
|
|
10
|
+
items: [],
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
// then add the item to it
|
|
14
|
+
acc[item.categoryId].items.push(item);
|
|
15
|
+
return acc;
|
|
16
|
+
}, {});
|
|
17
|
+
return Object.values(groups);
|
|
18
|
+
}
|
|
19
|
+
OrderUtils.groupByCategory = groupByCategory;
|
|
20
|
+
/// merge items with same productId and variantId and sum their quantity
|
|
21
|
+
function merge(items) {
|
|
22
|
+
var groupedItems = items
|
|
23
|
+
.reduce(function (acc, item) {
|
|
24
|
+
var id = "".concat(item.productId, "-").concat(item.variantId);
|
|
25
|
+
if (!acc[id]) {
|
|
26
|
+
acc[id] = item;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
acc[id].quantity = acc[id].quantity + item.quantity;
|
|
30
|
+
}
|
|
31
|
+
;
|
|
32
|
+
return acc;
|
|
33
|
+
}, {});
|
|
34
|
+
// Convertir l'objet en tableau
|
|
35
|
+
return Object.values(groupedItems);
|
|
36
|
+
}
|
|
37
|
+
OrderUtils.merge = merge;
|
|
38
|
+
})(OrderUtils || (OrderUtils = {}));
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export interface Category {
|
|
2
|
-
label: string;
|
|
3
|
-
id: string;
|
|
4
|
-
isPublic: boolean;
|
|
5
|
-
products: Product[];
|
|
6
|
-
}
|
|
7
|
-
export declare class Product {
|
|
8
|
-
id: string;
|
|
9
|
-
label: string;
|
|
10
|
-
description?: string;
|
|
11
|
-
picture: string;
|
|
12
|
-
variants: Variant[];
|
|
13
|
-
}
|
|
14
|
-
export declare function isAvailable(product: Product): boolean;
|
|
15
|
-
export interface Variant {
|
|
16
|
-
id: string;
|
|
17
|
-
label?: string;
|
|
18
|
-
isAvailable: boolean;
|
|
19
|
-
price: number;
|
|
20
|
-
discount?: number;
|
|
21
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
var Product = /** @class */ (function () {
|
|
2
|
-
function Product() {
|
|
3
|
-
}
|
|
4
|
-
return Product;
|
|
5
|
-
}());
|
|
6
|
-
export { Product };
|
|
7
|
-
export function isAvailable(product) {
|
|
8
|
-
return product.variants.map(function (variant) { return variant.isAvailable; })
|
|
9
|
-
.reduce(function (a, b) { return a || b; }, false);
|
|
10
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare class Product {
|
|
2
|
-
id: string;
|
|
3
|
-
label: string;
|
|
4
|
-
category: Category;
|
|
5
|
-
description?: string;
|
|
6
|
-
picture: string;
|
|
7
|
-
variants: Variant[];
|
|
8
|
-
}
|
|
9
|
-
export interface Category {
|
|
10
|
-
id: string;
|
|
11
|
-
label: string;
|
|
12
|
-
isPublic: boolean;
|
|
13
|
-
}
|
|
14
|
-
export interface Variant {
|
|
15
|
-
id: string;
|
|
16
|
-
label?: string;
|
|
17
|
-
isAvailable: boolean;
|
|
18
|
-
price: number;
|
|
19
|
-
discount?: number;
|
|
20
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface UpdateProductRequest {
|
|
2
|
-
id: string;
|
|
3
|
-
label?: string | undefined;
|
|
4
|
-
description?: string | undefined;
|
|
5
|
-
variant?: VariantUpdate | undefined;
|
|
6
|
-
}
|
|
7
|
-
export interface VariantUpdate {
|
|
8
|
-
id: string;
|
|
9
|
-
label?: string | undefined;
|
|
10
|
-
isAvailable?: boolean | undefined;
|
|
11
|
-
price?: number | undefined;
|
|
12
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|