@kiminix/tp-client 1.15.0 → 1.17.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/types/get-id.d.ts +2 -2
- package/dist/menus/preset/types/preset-menu.d.ts +2 -2
- package/dist/reservations/admin-apis.d.ts +14 -0
- package/dist/reservations/admin-apis.js +40 -0
- package/dist/reservations/types/admin/reserve-onmenu.d.ts +17 -0
- package/dist/reservations/types/admin/reserve-onmenu.js +1 -0
- package/dist/reservations/types/shared.d.ts +5 -4
- package/dist/types.d.ts +2 -1
- package/dist/utils/business-utils.d.ts +3 -3
- package/dist/utils/business-utils.js +4 -4
- package/dist/utils/menu-utils.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Licence } from "../../types";
|
|
2
2
|
export interface GoogleMap {
|
|
3
3
|
link: string;
|
|
4
4
|
image: string;
|
|
@@ -17,7 +17,7 @@ export interface Business {
|
|
|
17
17
|
id: string;
|
|
18
18
|
identifier: string;
|
|
19
19
|
name: string;
|
|
20
|
-
|
|
20
|
+
licence?: Licence;
|
|
21
21
|
createdAt: Date;
|
|
22
22
|
address: string;
|
|
23
23
|
googleMap?: GoogleMap;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Licence, LocalDate } from "../../../types";
|
|
2
2
|
export interface Price {
|
|
3
3
|
adult: number;
|
|
4
4
|
child?: number;
|
|
@@ -12,7 +12,7 @@ export interface DailyDiscount {
|
|
|
12
12
|
}
|
|
13
13
|
export interface PresetMenu {
|
|
14
14
|
id: string;
|
|
15
|
-
|
|
15
|
+
licence?: Licence;
|
|
16
16
|
excludedDays?: LocalDate[];
|
|
17
17
|
title: string;
|
|
18
18
|
description: string;
|
|
@@ -3,6 +3,7 @@ import { GetTransitionsRequest } from "../reservations/types/admin/get-available
|
|
|
3
3
|
import { GetByIdRequest } from "./types/admin/get-id";
|
|
4
4
|
import { PatchStatusRequest } from "./types/admin/patch-status";
|
|
5
5
|
import { Reservation } from "./types/shared";
|
|
6
|
+
import { Either } from "purify-ts";
|
|
6
7
|
export declare class ReservationsAdminAPIs {
|
|
7
8
|
static getPage(props: {
|
|
8
9
|
token?: string;
|
|
@@ -14,4 +15,17 @@ export declare class ReservationsAdminAPIs {
|
|
|
14
15
|
static getById({ token, id }: GetByIdRequest): Promise<Reservation>;
|
|
15
16
|
static getAvailableTransitions({ token, reservationId }: GetTransitionsRequest): Promise<ReservationStatus[]>;
|
|
16
17
|
static patchStatus({ token, id, status }: PatchStatusRequest): Promise<any>;
|
|
18
|
+
static reserveOnMenu(props: {
|
|
19
|
+
token?: string;
|
|
20
|
+
id: string;
|
|
21
|
+
user: {
|
|
22
|
+
firstName: string;
|
|
23
|
+
lastName: string;
|
|
24
|
+
phone?: string;
|
|
25
|
+
};
|
|
26
|
+
datetime: Date;
|
|
27
|
+
children: number;
|
|
28
|
+
adults: number;
|
|
29
|
+
notes?: string;
|
|
30
|
+
}): Promise<Either<Error, void>>;
|
|
17
31
|
}
|
|
@@ -36,6 +36,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
};
|
|
37
37
|
import axios from "axios";
|
|
38
38
|
import { base } from "../constants";
|
|
39
|
+
import { format } from "date-fns";
|
|
40
|
+
import { Left, Right } from "purify-ts";
|
|
39
41
|
var ReservationsAdminAPIs = /** @class */ (function () {
|
|
40
42
|
function ReservationsAdminAPIs() {
|
|
41
43
|
}
|
|
@@ -149,6 +151,44 @@ var ReservationsAdminAPIs = /** @class */ (function () {
|
|
|
149
151
|
});
|
|
150
152
|
});
|
|
151
153
|
};
|
|
154
|
+
ReservationsAdminAPIs.reserveOnMenu = function (props) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
156
|
+
return __generator(this, function (_a) {
|
|
157
|
+
switch (_a.label) {
|
|
158
|
+
case 0: return [4 /*yield*/, axios.post(base + "/reservations/admin/onmenu", {
|
|
159
|
+
id: props.id,
|
|
160
|
+
user: props.user,
|
|
161
|
+
datetime: format(props.datetime, "yyyy-MM-dd'T'HH:mm"),
|
|
162
|
+
children: props.children,
|
|
163
|
+
adults: props.adults,
|
|
164
|
+
notes: props.notes
|
|
165
|
+
}, {
|
|
166
|
+
headers: {
|
|
167
|
+
'Authorization': "".concat(props.token),
|
|
168
|
+
'Content-Type': 'application/json'
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
.then(function (_) { return Right(undefined); })
|
|
172
|
+
.catch(function (error) {
|
|
173
|
+
// handle error
|
|
174
|
+
if (error.response.status == 401)
|
|
175
|
+
return Left(Error("unauthorized"));
|
|
176
|
+
else if (error.response.status == 404)
|
|
177
|
+
return Left(Error("not_found"));
|
|
178
|
+
else if (error.response.status == 400) {
|
|
179
|
+
//unavailable_day
|
|
180
|
+
//inactive_manual_booking
|
|
181
|
+
var response = error.response.data;
|
|
182
|
+
return Left(Error(response.code));
|
|
183
|
+
}
|
|
184
|
+
else
|
|
185
|
+
return Left(Error('internal_error'));
|
|
186
|
+
})];
|
|
187
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
};
|
|
152
192
|
return ReservationsAdminAPIs;
|
|
153
193
|
}());
|
|
154
194
|
export { ReservationsAdminAPIs };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface ReserveOnMenuResponse {
|
|
2
|
+
id: string;
|
|
3
|
+
}
|
|
4
|
+
export interface ReserveOnMenuRequest {
|
|
5
|
+
token?: string;
|
|
6
|
+
id: string;
|
|
7
|
+
user: {
|
|
8
|
+
firstname: string;
|
|
9
|
+
lastname: string;
|
|
10
|
+
phone?: string;
|
|
11
|
+
};
|
|
12
|
+
date: Date;
|
|
13
|
+
time: Date;
|
|
14
|
+
children: number;
|
|
15
|
+
adults: number;
|
|
16
|
+
notes?: string;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -7,11 +7,11 @@ export interface Business {
|
|
|
7
7
|
address: string;
|
|
8
8
|
}
|
|
9
9
|
export interface User {
|
|
10
|
-
id
|
|
11
|
-
firstname
|
|
12
|
-
lastname
|
|
10
|
+
id?: string;
|
|
11
|
+
firstname?: string;
|
|
12
|
+
lastname?: string;
|
|
13
13
|
phone?: string;
|
|
14
|
-
verifiedPhone
|
|
14
|
+
verifiedPhone?: boolean;
|
|
15
15
|
}
|
|
16
16
|
export interface GuestDetails {
|
|
17
17
|
number: number;
|
|
@@ -32,6 +32,7 @@ export interface ReservationEvent {
|
|
|
32
32
|
}
|
|
33
33
|
export interface Reservation {
|
|
34
34
|
id: string;
|
|
35
|
+
isSetByAdmin: boolean;
|
|
35
36
|
createdAt: string;
|
|
36
37
|
business: Business;
|
|
37
38
|
user: User;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Licence } from "../types";
|
|
2
2
|
export declare class BusinessUtils {
|
|
3
|
-
static isLicenceActive(
|
|
4
|
-
static isLicenceActiveByDay(date: Date,
|
|
3
|
+
static isLicenceActive(licence?: Licence): boolean;
|
|
4
|
+
static isLicenceActiveByDay(date: Date, licence?: Licence): boolean;
|
|
5
5
|
}
|
|
@@ -4,13 +4,13 @@ var BusinessUtils = /** @class */ (function () {
|
|
|
4
4
|
function BusinessUtils() {
|
|
5
5
|
}
|
|
6
6
|
// licence is active if business has an available date that it is not expired
|
|
7
|
-
BusinessUtils.isLicenceActive = function (
|
|
7
|
+
BusinessUtils.isLicenceActive = function (licence) {
|
|
8
8
|
var today = new Date();
|
|
9
|
-
return (
|
|
9
|
+
return (licence === null || licence === void 0 ? void 0 : licence.to) ? isDayBefore(today, parseISO(licence.to)) : false;
|
|
10
10
|
};
|
|
11
11
|
// check if the business is active for a specific date
|
|
12
|
-
BusinessUtils.isLicenceActiveByDay = function (date,
|
|
13
|
-
return
|
|
12
|
+
BusinessUtils.isLicenceActiveByDay = function (date, licence) {
|
|
13
|
+
return licence ? isDayBetween(date, parseISO(licence.from), parseISO(licence.to)) : false;
|
|
14
14
|
};
|
|
15
15
|
return BusinessUtils;
|
|
16
16
|
}());
|
package/dist/utils/menu-utils.js
CHANGED
|
@@ -5,7 +5,7 @@ var MenuUtils = /** @class */ (function () {
|
|
|
5
5
|
}
|
|
6
6
|
MenuUtils.isMenuAvailableByDay = function (menu, date) {
|
|
7
7
|
var _a, _b;
|
|
8
|
-
var isLicenceActive = BusinessUtils.isLicenceActiveByDay(date, menu.
|
|
8
|
+
var isLicenceActive = BusinessUtils.isLicenceActiveByDay(date, menu.licence);
|
|
9
9
|
var isDayExcluded = (_b = (_a = menu.excludedDays) === null || _a === void 0 ? void 0 : _a.includes(toLocaleDate(date))) !== null && _b !== void 0 ? _b : false;
|
|
10
10
|
return isLicenceActive && !isDayExcluded;
|
|
11
11
|
};
|