@kiminix/tp-client 1.3.0 → 1.5.0
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/business/admin-apis.d.ts +4 -0
- package/dist/business/admin-apis.js +72 -0
- package/dist/business/apis.js +9 -16
- package/dist/business/types/get-id.d.ts +1 -0
- package/dist/enum.d.ts +7 -0
- package/dist/enum.js +8 -0
- package/dist/iam/admin-apis.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/menus/preset/admin-apis.d.ts +4 -0
- package/dist/menus/preset/admin-apis.js +69 -0
- package/dist/menus/preset/apis.d.ts +4 -0
- package/dist/menus/preset/apis.js +61 -0
- package/dist/menus/preset/types/get-by-business.d.ts +20 -0
- package/dist/menus/preset/types/get-by-business.js +1 -0
- package/dist/reservations/admin-apis.js +45 -45
- package/dist/reservations/types/shared.d.ts +14 -3
- package/dist/reservations/types/shared.js +6 -0
- package/dist/reservations/user-apis.js +38 -40
- package/dist/utils/date-utils.d.ts +1 -1
- package/dist/utils/date-utils.js +5 -3
- package/dist/utils/menu-utils.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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 axios from "axios";
|
|
38
|
+
import { base } from "../constants";
|
|
39
|
+
// business module admin APIs
|
|
40
|
+
var BusinessAdminAPIs = /** @class */ (function () {
|
|
41
|
+
function BusinessAdminAPIs() {
|
|
42
|
+
}
|
|
43
|
+
BusinessAdminAPIs.get = function (token) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
switch (_a.label) {
|
|
47
|
+
case 0: return [4 /*yield*/, axios.get(base + "/business/admin", {
|
|
48
|
+
headers: {
|
|
49
|
+
'Authorization': "".concat(token)
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
.then(function (response) {
|
|
53
|
+
var data = response.data;
|
|
54
|
+
data.createdAt = new Date(data.createdAt);
|
|
55
|
+
// data.availableUntil = new Date(data.availableUntil)
|
|
56
|
+
return data;
|
|
57
|
+
})
|
|
58
|
+
.catch(function (error) {
|
|
59
|
+
// handle error
|
|
60
|
+
if (error.response.status == 401)
|
|
61
|
+
throw new Error("unauthorized");
|
|
62
|
+
else
|
|
63
|
+
throw new Error('internal_error', error);
|
|
64
|
+
})];
|
|
65
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
return BusinessAdminAPIs;
|
|
71
|
+
}());
|
|
72
|
+
export { BusinessAdminAPIs };
|
package/dist/business/apis.js
CHANGED
|
@@ -57,22 +57,15 @@ var BusinessAPIs = /** @class */ (function () {
|
|
|
57
57
|
};
|
|
58
58
|
BusinessAPIs.get = function (identifier) {
|
|
59
59
|
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return data;
|
|
70
|
-
})];
|
|
71
|
-
case 1: return [2 /*return*/, _b.sent()];
|
|
72
|
-
case 2:
|
|
73
|
-
_a = _b.sent();
|
|
74
|
-
throw new Error("internal_error");
|
|
75
|
-
case 3: return [2 /*return*/];
|
|
60
|
+
return __generator(this, function (_a) {
|
|
61
|
+
switch (_a.label) {
|
|
62
|
+
case 0: return [4 /*yield*/, axios.get(base + "/business/".concat(identifier))
|
|
63
|
+
.then(function (response) {
|
|
64
|
+
var data = response.data;
|
|
65
|
+
data.createdAt = new Date(data.createdAt);
|
|
66
|
+
return data;
|
|
67
|
+
})];
|
|
68
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
76
69
|
}
|
|
77
70
|
});
|
|
78
71
|
});
|
package/dist/enum.d.ts
CHANGED
|
@@ -13,3 +13,10 @@ export declare enum TimelineDirection {
|
|
|
13
13
|
Past = "past",
|
|
14
14
|
Next = "next"
|
|
15
15
|
}
|
|
16
|
+
export declare enum ReservationEventKind {
|
|
17
|
+
Confirmed = "confirmed",
|
|
18
|
+
Missed = "missed",
|
|
19
|
+
CanceledUser = "canceled_user",
|
|
20
|
+
CanceledBusiness = "canceled_business",
|
|
21
|
+
Updated = "updated"
|
|
22
|
+
}
|
package/dist/enum.js
CHANGED
|
@@ -16,3 +16,11 @@ export var TimelineDirection;
|
|
|
16
16
|
TimelineDirection["Past"] = "past";
|
|
17
17
|
TimelineDirection["Next"] = "next";
|
|
18
18
|
})(TimelineDirection || (TimelineDirection = {}));
|
|
19
|
+
export var ReservationEventKind;
|
|
20
|
+
(function (ReservationEventKind) {
|
|
21
|
+
ReservationEventKind["Confirmed"] = "confirmed";
|
|
22
|
+
ReservationEventKind["Missed"] = "missed";
|
|
23
|
+
ReservationEventKind["CanceledUser"] = "canceled_user";
|
|
24
|
+
ReservationEventKind["CanceledBusiness"] = "canceled_business";
|
|
25
|
+
ReservationEventKind["Updated"] = "updated";
|
|
26
|
+
})(ReservationEventKind || (ReservationEventKind = {}));
|
package/dist/iam/admin-apis.js
CHANGED
|
@@ -44,7 +44,7 @@ var IamAdminAPIs = /** @class */ (function () {
|
|
|
44
44
|
return __awaiter(this, void 0, void 0, function () {
|
|
45
45
|
return __generator(this, function (_a) {
|
|
46
46
|
switch (_a.label) {
|
|
47
|
-
case 0: return [4 /*yield*/, axios.post(base + "/iam/
|
|
47
|
+
case 0: return [4 /*yield*/, axios.post(base + "/iam/admin/sign-in", { identifier: identifier, password: password }, {
|
|
48
48
|
headers: {
|
|
49
49
|
// 'Authorization': `${user.token}`,
|
|
50
50
|
'Content-Type': 'application/json'
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { IamAdminAPIs } from './iam/admin-apis';
|
|
|
4
4
|
export { IamUserAPIs } from './iam/user-apis';
|
|
5
5
|
export { NotifyAPIs } from './notify/apis';
|
|
6
6
|
export { SitemapAPIs } from './sitemap/apis';
|
|
7
|
-
export { MenusAPIs } from './menus/apis';
|
|
7
|
+
export { PresetMenusAPIs as MenusAPIs } from './menus/preset/apis';
|
|
8
8
|
export { ReservationsUserAPIs } from './reservations/user-apis';
|
|
9
9
|
export { ReservationsAdminAPIs } from './reservations/admin-apis';
|
|
10
10
|
export { MenuUtils } from './utils/menu-utils';
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export { IamAdminAPIs } from './iam/admin-apis';
|
|
|
4
4
|
export { IamUserAPIs } from './iam/user-apis';
|
|
5
5
|
export { NotifyAPIs } from './notify/apis';
|
|
6
6
|
export { SitemapAPIs } from './sitemap/apis';
|
|
7
|
-
export { MenusAPIs } from './menus/apis';
|
|
7
|
+
export { PresetMenusAPIs as MenusAPIs } from './menus/preset/apis';
|
|
8
8
|
export { ReservationsUserAPIs } from './reservations/user-apis';
|
|
9
9
|
export { ReservationsAdminAPIs } from './reservations/admin-apis';
|
|
10
10
|
//
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
// preset-menus module admin APIs
|
|
40
|
+
var PresetMenusAdminAPIs = /** @class */ (function () {
|
|
41
|
+
function PresetMenusAdminAPIs() {
|
|
42
|
+
}
|
|
43
|
+
PresetMenusAdminAPIs.getByBusiness = function (token) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
switch (_a.label) {
|
|
47
|
+
case 0: return [4 /*yield*/, axios.get(base + "/preset-menus/admin", {
|
|
48
|
+
headers: {
|
|
49
|
+
'Authorization': "".concat(token)
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
.then(function (response) {
|
|
53
|
+
return response.data;
|
|
54
|
+
})
|
|
55
|
+
.catch(function (error) {
|
|
56
|
+
// handle error
|
|
57
|
+
if (error.response.status == 401)
|
|
58
|
+
throw new Error("unauthorized");
|
|
59
|
+
else
|
|
60
|
+
throw new Error('internal_error', error);
|
|
61
|
+
})];
|
|
62
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
return PresetMenusAdminAPIs;
|
|
68
|
+
}());
|
|
69
|
+
export { PresetMenusAdminAPIs };
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
// preset-menus module APIs
|
|
40
|
+
var PresetMenusAPIs = /** @class */ (function () {
|
|
41
|
+
function PresetMenusAPIs() {
|
|
42
|
+
}
|
|
43
|
+
PresetMenusAPIs.getByBusiness = function (businessId) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
switch (_a.label) {
|
|
47
|
+
case 0: return [4 /*yield*/, axios.get(base + "/preset-menus/user?business=".concat(businessId))
|
|
48
|
+
.then(function (response) {
|
|
49
|
+
return response.data;
|
|
50
|
+
})
|
|
51
|
+
.catch(function (error) {
|
|
52
|
+
throw new Error('internal_error', error);
|
|
53
|
+
})];
|
|
54
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
return PresetMenusAPIs;
|
|
60
|
+
}());
|
|
61
|
+
export { PresetMenusAPIs };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type LocalDate = string;
|
|
2
|
+
export interface Price {
|
|
3
|
+
adult: number;
|
|
4
|
+
child?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface DailyDiscount {
|
|
7
|
+
isAvailable: boolean;
|
|
8
|
+
price: Price;
|
|
9
|
+
minBookingTotal?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface PresetMenu {
|
|
12
|
+
id: string;
|
|
13
|
+
availableUntil?: LocalDate;
|
|
14
|
+
excludedDays?: LocalDate[];
|
|
15
|
+
title: string;
|
|
16
|
+
description: string;
|
|
17
|
+
price: Price;
|
|
18
|
+
minBookingTotal?: number;
|
|
19
|
+
discount?: Map<LocalDate, DailyDiscount>;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -44,20 +44,20 @@ var ReservationsAdminAPIs = /** @class */ (function () {
|
|
|
44
44
|
return __awaiter(this, void 0, void 0, function () {
|
|
45
45
|
return __generator(this, function (_d) {
|
|
46
46
|
switch (_d.label) {
|
|
47
|
-
case 0:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
case 0: return [4 /*yield*/, axios.get(base + "/reservations/admin?page=".concat(page, "&size=").concat(size, "&direction=").concat(direction), {
|
|
48
|
+
headers: {
|
|
49
|
+
'Authorization': "".concat(token)
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
.then(function (response) { return response.data; })
|
|
53
|
+
.catch(function (error) {
|
|
54
|
+
// handle error
|
|
55
|
+
if (error.response.status == 401)
|
|
56
|
+
throw new Error("unauthorized");
|
|
57
|
+
else
|
|
57
58
|
throw new Error('internal_error', error);
|
|
58
|
-
|
|
59
|
+
})];
|
|
59
60
|
case 1: return [2 /*return*/, _d.sent()];
|
|
60
|
-
case 2: throw Error('unauthorized');
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
63
|
});
|
|
@@ -67,24 +67,23 @@ var ReservationsAdminAPIs = /** @class */ (function () {
|
|
|
67
67
|
return __awaiter(this, void 0, void 0, function () {
|
|
68
68
|
return __generator(this, function (_b) {
|
|
69
69
|
switch (_b.label) {
|
|
70
|
-
case 0:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
70
|
+
case 0: return [4 /*yield*/, axios.get(base + "/reservations/admin/".concat(id), {
|
|
71
|
+
headers: {
|
|
72
|
+
'Authorization': "".concat(token),
|
|
73
|
+
'Content-Type': 'application/json'
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
.then(function (response) { return response.data; })
|
|
77
|
+
.catch(function (error) {
|
|
78
|
+
// handle error
|
|
79
|
+
if (error.response.status == 401)
|
|
80
|
+
throw new Error("unauthorized");
|
|
81
|
+
else if (error.response.status == 404)
|
|
82
|
+
throw new Error("not_found");
|
|
83
|
+
else
|
|
84
|
+
throw new Error('internal_error', error);
|
|
85
|
+
})];
|
|
86
86
|
case 1: return [2 /*return*/, _b.sent()];
|
|
87
|
-
case 2: throw new Error("unauthorized");
|
|
88
87
|
}
|
|
89
88
|
});
|
|
90
89
|
});
|
|
@@ -94,20 +93,20 @@ var ReservationsAdminAPIs = /** @class */ (function () {
|
|
|
94
93
|
return __awaiter(this, void 0, void 0, function () {
|
|
95
94
|
return __generator(this, function (_b) {
|
|
96
95
|
switch (_b.label) {
|
|
97
|
-
case 0:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
96
|
+
case 0: return [4 /*yield*/, axios.get(base + "/reservations/admin/".concat(reservationId, "/available-transitions"), {
|
|
97
|
+
headers: {
|
|
98
|
+
'Authorization': "".concat(token)
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
.then(function (response) { return response.data; })
|
|
102
|
+
.catch(function (error) {
|
|
103
|
+
// handle error
|
|
104
|
+
if (error.response.status == 401)
|
|
105
|
+
throw new Error("unauthorized");
|
|
106
|
+
else
|
|
107
107
|
throw new Error('internal_error', error);
|
|
108
|
-
|
|
108
|
+
})];
|
|
109
109
|
case 1: return [2 /*return*/, _b.sent()];
|
|
110
|
-
case 2: throw new Error("unauthorized");
|
|
111
110
|
}
|
|
112
111
|
});
|
|
113
112
|
});
|
|
@@ -117,7 +116,7 @@ var ReservationsAdminAPIs = /** @class */ (function () {
|
|
|
117
116
|
return __awaiter(this, void 0, void 0, function () {
|
|
118
117
|
return __generator(this, function (_b) {
|
|
119
118
|
switch (_b.label) {
|
|
120
|
-
case 0: return [4 /*yield*/, axios.patch(base + "/
|
|
119
|
+
case 0: return [4 /*yield*/, axios.patch(base + "/reservations/admin/".concat(id, "/").concat(status), {}, {
|
|
121
120
|
headers: {
|
|
122
121
|
'Authorization': "".concat(token)
|
|
123
122
|
}
|
|
@@ -125,10 +124,11 @@ var ReservationsAdminAPIs = /** @class */ (function () {
|
|
|
125
124
|
.then(function (response) { return response.data; })
|
|
126
125
|
.catch(function (error) {
|
|
127
126
|
// handle error
|
|
128
|
-
if (error.response.status ==
|
|
129
|
-
throw new Error("
|
|
127
|
+
if (error.response.status == 401)
|
|
128
|
+
throw new Error("unauthorized");
|
|
129
|
+
else if (error.response.status == 404)
|
|
130
|
+
throw new Error("not_found");
|
|
130
131
|
else if (error.response.status == 400) {
|
|
131
|
-
// unauthorized_action
|
|
132
132
|
var response = error.response.data;
|
|
133
133
|
throw new Error(response.code);
|
|
134
134
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReservationStatus } from "../../enum";
|
|
1
|
+
import { ReservationEventKind, ReservationStatus } from "../../enum";
|
|
2
2
|
export interface Business {
|
|
3
3
|
id: string;
|
|
4
4
|
identifier: string;
|
|
@@ -27,9 +27,8 @@ export interface OnMenuCommand {
|
|
|
27
27
|
deal: string;
|
|
28
28
|
}
|
|
29
29
|
export interface ReservationEvent {
|
|
30
|
-
|
|
30
|
+
kind: ReservationEventKind;
|
|
31
31
|
at: string;
|
|
32
|
-
message?: string;
|
|
33
32
|
}
|
|
34
33
|
export interface Reservation {
|
|
35
34
|
id: string;
|
|
@@ -43,4 +42,16 @@ export interface Reservation {
|
|
|
43
42
|
onMenuCommands: OnMenuCommand[];
|
|
44
43
|
deposit?: number;
|
|
45
44
|
events?: ReservationEvent[];
|
|
45
|
+
notes?: string;
|
|
46
|
+
cancellation?: Cancellation;
|
|
46
47
|
}
|
|
48
|
+
export interface Cancellation {
|
|
49
|
+
reason: CancellationReason;
|
|
50
|
+
notes?: string;
|
|
51
|
+
}
|
|
52
|
+
declare enum CancellationReason {
|
|
53
|
+
CustomerRequest = "customer_request",
|
|
54
|
+
UnreachableCustomer = "unreachable_customer",
|
|
55
|
+
Other = "other"
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -1 +1,7 @@
|
|
|
1
|
+
var CancellationReason;
|
|
2
|
+
(function (CancellationReason) {
|
|
3
|
+
CancellationReason["CustomerRequest"] = "customer_request";
|
|
4
|
+
CancellationReason["UnreachableCustomer"] = "unreachable_customer";
|
|
5
|
+
CancellationReason["Other"] = "other";
|
|
6
|
+
})(CancellationReason || (CancellationReason = {}));
|
|
1
7
|
export {};
|
|
@@ -45,22 +45,20 @@ var ReservationsUserAPIs = /** @class */ (function () {
|
|
|
45
45
|
return __awaiter(this, void 0, void 0, function () {
|
|
46
46
|
return __generator(this, function (_d) {
|
|
47
47
|
switch (_d.label) {
|
|
48
|
-
case 0:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
case 0: return [4 /*yield*/, axios.get(base + "/reservations/user?page=".concat(page, "&size=").concat(size, "&direction=").concat(direction), {
|
|
49
|
+
headers: {
|
|
50
|
+
'Authorization': "".concat(token)
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
.then(function (response) { return response.data; })
|
|
54
|
+
.catch(function (error) {
|
|
55
|
+
// handle error
|
|
56
|
+
if (error.response.status == 401)
|
|
57
|
+
throw new Error("unauthorized");
|
|
58
|
+
else
|
|
58
59
|
throw new Error('internal_error', error);
|
|
59
|
-
|
|
60
|
+
})];
|
|
60
61
|
case 1: return [2 /*return*/, _d.sent()];
|
|
61
|
-
case 2:
|
|
62
|
-
console.log('unauthorized');
|
|
63
|
-
return [2 /*return*/, []];
|
|
64
62
|
}
|
|
65
63
|
});
|
|
66
64
|
});
|
|
@@ -70,24 +68,23 @@ var ReservationsUserAPIs = /** @class */ (function () {
|
|
|
70
68
|
return __awaiter(this, void 0, void 0, function () {
|
|
71
69
|
return __generator(this, function (_b) {
|
|
72
70
|
switch (_b.label) {
|
|
73
|
-
case 0:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
71
|
+
case 0: return [4 /*yield*/, axios.get(base + "/reservations/user/".concat(id), {
|
|
72
|
+
headers: {
|
|
73
|
+
'Authorization': "".concat(token),
|
|
74
|
+
'Content-Type': 'application/json'
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
.then(function (response) { return response.data; })
|
|
78
|
+
.catch(function (error) {
|
|
79
|
+
// handle error
|
|
80
|
+
if (error.response.status == 401)
|
|
81
|
+
throw new Error("unauthorized");
|
|
82
|
+
else if (error.response.status == 404)
|
|
83
|
+
throw new Error("not_found");
|
|
84
|
+
else
|
|
85
|
+
throw new Error('internal_error', error);
|
|
86
|
+
})];
|
|
89
87
|
case 1: return [2 /*return*/, _b.sent()];
|
|
90
|
-
case 2: throw new Error("unauthorized");
|
|
91
88
|
}
|
|
92
89
|
});
|
|
93
90
|
});
|
|
@@ -96,7 +93,7 @@ var ReservationsUserAPIs = /** @class */ (function () {
|
|
|
96
93
|
return __awaiter(this, void 0, void 0, function () {
|
|
97
94
|
return __generator(this, function (_a) {
|
|
98
95
|
switch (_a.label) {
|
|
99
|
-
case 0: return [4 /*yield*/, axios.patch(base + "/user/
|
|
96
|
+
case 0: return [4 /*yield*/, axios.patch(base + "/reservations/user/".concat(id, "/cancel"), {}, {
|
|
100
97
|
headers: {
|
|
101
98
|
'Authorization': "".concat(token)
|
|
102
99
|
}
|
|
@@ -104,10 +101,11 @@ var ReservationsUserAPIs = /** @class */ (function () {
|
|
|
104
101
|
.then(function (response) { return response.data; })
|
|
105
102
|
.catch(function (error) {
|
|
106
103
|
// handle error
|
|
107
|
-
if (error.response.status ==
|
|
108
|
-
throw new Error("
|
|
104
|
+
if (error.response.status == 401)
|
|
105
|
+
throw new Error("unauthorized");
|
|
106
|
+
else if (error.response.status == 404)
|
|
107
|
+
throw new Error("not_found");
|
|
109
108
|
else if (error.response.status == 400) {
|
|
110
|
-
//unauthorized_action
|
|
111
109
|
//reservation_not_found
|
|
112
110
|
var response = error.response.data;
|
|
113
111
|
throw new Error(response.code);
|
|
@@ -127,10 +125,9 @@ var ReservationsUserAPIs = /** @class */ (function () {
|
|
|
127
125
|
return __generator(this, function (_b) {
|
|
128
126
|
switch (_b.label) {
|
|
129
127
|
case 0:
|
|
130
|
-
if (!token) return [3 /*break*/, 2];
|
|
131
128
|
datetime = new Date(date);
|
|
132
129
|
datetime.setHours(time.getHours(), time.getMinutes());
|
|
133
|
-
return [4 /*yield*/, axios.post(base + "/user/
|
|
130
|
+
return [4 /*yield*/, axios.post(base + "/reservations/user/onmenu", {
|
|
134
131
|
id: id,
|
|
135
132
|
datetime: format(datetime, "yyyy-MM-dd'T'HH:mm"),
|
|
136
133
|
children: children,
|
|
@@ -145,8 +142,10 @@ var ReservationsUserAPIs = /** @class */ (function () {
|
|
|
145
142
|
.then(function (response) { return response.data; })
|
|
146
143
|
.catch(function (error) {
|
|
147
144
|
// handle error
|
|
148
|
-
if (error.response.status ==
|
|
149
|
-
throw new Error("
|
|
145
|
+
if (error.response.status == 401)
|
|
146
|
+
throw new Error("unauthorized");
|
|
147
|
+
else if (error.response.status == 404)
|
|
148
|
+
throw new Error("not_found");
|
|
150
149
|
else if (error.response.status == 400) {
|
|
151
150
|
//banned_user
|
|
152
151
|
//unavailable_day
|
|
@@ -160,7 +159,6 @@ var ReservationsUserAPIs = /** @class */ (function () {
|
|
|
160
159
|
throw new Error('internal_error', error);
|
|
161
160
|
})];
|
|
162
161
|
case 1: return [2 /*return*/, _b.sent()];
|
|
163
|
-
case 2: throw new Error("unauthorized");
|
|
164
162
|
}
|
|
165
163
|
});
|
|
166
164
|
});
|
|
@@ -11,7 +11,7 @@ export declare function isDayBefore(date: Date, dateToCompare: Date, include?: B
|
|
|
11
11
|
* @param options
|
|
12
12
|
*/
|
|
13
13
|
export declare function toString(date: string, options?: Intl.DateTimeFormatOptions): string;
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function toTunisiaLocale(date: string): string;
|
|
15
15
|
/**
|
|
16
16
|
*
|
|
17
17
|
* @param date
|
package/dist/utils/date-utils.js
CHANGED
|
@@ -53,7 +53,9 @@ export function toString(date, options) {
|
|
|
53
53
|
);
|
|
54
54
|
return parseISO(date).toLocaleDateString("fr-FR", mergedOptions);
|
|
55
55
|
}
|
|
56
|
-
export function
|
|
56
|
+
export function toTunisiaLocale(date) {
|
|
57
|
+
// This is how we get Timezone auto from user OS, but for simplicity we will use Africa/Tunis
|
|
58
|
+
// const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
57
59
|
// request a weekday along with a long date. ex: 25 juin 2022 10:30
|
|
58
60
|
var options = {
|
|
59
61
|
year: "numeric",
|
|
@@ -61,9 +63,9 @@ export function toLocaleTime(date) {
|
|
|
61
63
|
day: "numeric",
|
|
62
64
|
hour: '2-digit',
|
|
63
65
|
minute: '2-digit',
|
|
64
|
-
timeZone: 'Africa/Tunis'
|
|
66
|
+
timeZone: 'Africa/Tunis'
|
|
65
67
|
};
|
|
66
|
-
return parseISO(date).
|
|
68
|
+
return parseISO(date).toLocaleString("fr-FR", options);
|
|
67
69
|
}
|
|
68
70
|
/**
|
|
69
71
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DailyDiscount, LocalDate, PresetMenu } from "../menus/types/get-
|
|
1
|
+
import { DailyDiscount, LocalDate, PresetMenu } from "../menus/preset/types/get-by-business";
|
|
2
2
|
export declare class MenuUtils {
|
|
3
3
|
static isMenuAvailable(menu: PresetMenu): boolean;
|
|
4
4
|
static isMenuAvailableByDay(menu: PresetMenu, date: Date): boolean;
|