@kiminix/tp-client 1.35.0 → 1.37.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.
Files changed (69) hide show
  1. package/dist/business/types/get-all.d.ts +3 -19
  2. package/dist/business/types/get-id.d.ts +7 -16
  3. package/dist/business/types/shared.d.ts +3 -13
  4. package/dist/cashback/index.d.ts +0 -2
  5. package/dist/cashback/index.js +0 -3
  6. package/dist/cashback/user/types/resp-get-cashback.d.ts +14 -2
  7. package/dist/cashback/user/user-apis.d.ts +7 -2
  8. package/dist/cashback/user/user-apis.js +14 -36
  9. package/dist/deals/apis.d.ts +0 -1
  10. package/dist/deals/apis.js +12 -39
  11. package/dist/deals/index.d.ts +1 -0
  12. package/dist/deals/index.js +2 -0
  13. package/dist/deals/types.d.ts +7 -15
  14. package/dist/discounts/admin/admin-apis.d.ts +36 -0
  15. package/dist/{menus/preset/apis.js → discounts/admin/admin-apis.js} +57 -24
  16. package/dist/discounts/admin/types/get-available-datetimes.d.ts +7 -0
  17. package/dist/discounts/index.d.ts +2 -0
  18. package/dist/discounts/index.js +3 -0
  19. package/dist/index.d.ts +3 -3
  20. package/dist/index.js +5 -4
  21. package/dist/reservations/admin/admin-apis.d.ts +55 -18
  22. package/dist/reservations/admin/admin-apis.js +91 -48
  23. package/dist/reservations/admin/types.d.ts +19 -0
  24. package/dist/reservations/index.d.ts +3 -5
  25. package/dist/reservations/index.js +3 -5
  26. package/dist/reservations/shared/reservation-deal.d.ts +6 -5
  27. package/dist/reservations/shared/reservation.d.ts +7 -19
  28. package/dist/reservations/user/guest-apis.d.ts +84 -0
  29. package/dist/reservations/user/guest-apis.js +199 -0
  30. package/dist/reservations/user/types/response-api.d.ts +32 -0
  31. package/dist/reservations/user/user-apis.d.ts +43 -59
  32. package/dist/reservations/user/user-apis.js +58 -231
  33. package/dist/types.d.ts +1 -0
  34. package/dist/utils/date-utils.d.ts +2 -0
  35. package/dist/utils/date-utils.js +7 -1
  36. package/dist/utils/reservation-utils.d.ts +2 -0
  37. package/dist/utils/reservation-utils.js +6 -0
  38. package/package.json +2 -2
  39. package/dist/cashback/admin/admin-apis.d.ts +0 -7
  40. package/dist/cashback/admin/admin-apis.js +0 -85
  41. package/dist/cashback/admin/types/resp-get-cashback.d.ts +0 -12
  42. package/dist/menus/preset/admin-apis.d.ts +0 -8
  43. package/dist/menus/preset/admin-apis.js +0 -146
  44. package/dist/menus/preset/apis.d.ts +0 -11
  45. package/dist/menus/preset/discounts/admin-apis.d.ts +0 -7
  46. package/dist/menus/preset/discounts/admin-apis.js +0 -90
  47. package/dist/menus/preset/discounts/types/update-discount.d.ts +0 -9
  48. package/dist/menus/preset/index.d.ts +0 -7
  49. package/dist/menus/preset/index.js +0 -9
  50. package/dist/menus/preset/types/preset-menu.d.ts +0 -19
  51. package/dist/menus/preset/types/preset-menu.js +0 -1
  52. package/dist/menus/preset/types/special-discounts.d.ts +0 -12
  53. package/dist/menus/preset/types/special-discounts.js +0 -1
  54. package/dist/menus/preset/types/types.d.ts +0 -4
  55. package/dist/menus/preset/types/update-preset-menu.d.ts +0 -12
  56. package/dist/menus/preset/types/update-preset-menu.js +0 -1
  57. package/dist/reservations/admin/types/get-available-transitions.d.ts +0 -4
  58. package/dist/reservations/admin/types/get-available-transitions.js +0 -1
  59. package/dist/reservations/admin/types/get-id.d.ts +0 -4
  60. package/dist/reservations/admin/types/get-id.js +0 -1
  61. package/dist/reservations/user/types/resp-reservation-settings.d.ts +0 -22
  62. package/dist/reservations/user/types/resp-reservation-settings.js +0 -1
  63. package/dist/reservations/user/types/resp-save-reservation.d.ts +0 -3
  64. package/dist/reservations/user/types/resp-save-reservation.js +0 -1
  65. package/dist/utils/menu-utils.d.ts +0 -10
  66. package/dist/utils/menu-utils.js +0 -51
  67. /package/dist/{cashback/admin/types/resp-get-cashback.js → discounts/admin/types/get-available-datetimes.js} +0 -0
  68. /package/dist/{menus/preset/types → reservations/admin}/types.js +0 -0
  69. /package/dist/{menus/preset/discounts/types/update-discount.js → reservations/user/types/response-api.js} +0 -0
@@ -1,146 +0,0 @@
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 { Left, Right } from "purify-ts";
40
- // preset-menus module admin APIs
41
- var PresetMenusAdminAPIs = /** @class */ (function () {
42
- function PresetMenusAdminAPIs() {
43
- }
44
- PresetMenusAdminAPIs.getByBusiness = function (token) {
45
- return __awaiter(this, void 0, void 0, function () {
46
- return __generator(this, function (_a) {
47
- switch (_a.label) {
48
- case 0: return [4 /*yield*/, axios.get(base + "/preset-menus/admin", {
49
- headers: {
50
- 'Authorization': "".concat(token)
51
- }
52
- })
53
- .then(function (response) {
54
- return response.data;
55
- })
56
- .catch(function (error) {
57
- var _a, _b, _c;
58
- // handle error
59
- if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) == 401) {
60
- // unauthorized
61
- // unauthenticated
62
- throw ((new Error((_c = (_b = error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.code)));
63
- }
64
- else
65
- throw new Error('internal_error', error);
66
- })];
67
- case 1: return [2 /*return*/, _a.sent()];
68
- }
69
- });
70
- });
71
- };
72
- PresetMenusAdminAPIs.getByMenuID = function (menuId, token) {
73
- return __awaiter(this, void 0, void 0, function () {
74
- return __generator(this, function (_a) {
75
- switch (_a.label) {
76
- case 0: return [4 /*yield*/, axios.get(base + "/preset-menus/admin/id/".concat(menuId), {
77
- headers: {
78
- 'Authorization': "".concat(token)
79
- }
80
- })
81
- .then(function (response) {
82
- return response.data;
83
- })
84
- .catch(function (error) {
85
- var _a, _b, _c, _d, _e;
86
- // handle error
87
- if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) == 401) {
88
- // unauthorized
89
- // unauthenticated
90
- throw ((new Error((_c = (_b = error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.code)));
91
- }
92
- else if (((_d = error.response) === null || _d === void 0 ? void 0 : _d.status) == 404)
93
- throw new Error("not_found");
94
- else if (((_e = error.response) === null || _e === void 0 ? void 0 : _e.status) == 400)
95
- throw new Error("invalid_input");
96
- else
97
- throw new Error('internal_error', error);
98
- })];
99
- case 1: return [2 /*return*/, _a.sent()];
100
- }
101
- });
102
- });
103
- };
104
- PresetMenusAdminAPIs.update = function (_a) {
105
- var token = _a.token, id = _a.id, availability = _a.availability, minBookingTotal = _a.minBookingTotal, title = _a.title;
106
- return __awaiter(this, void 0, void 0, function () {
107
- return __generator(this, function (_b) {
108
- switch (_b.label) {
109
- case 0: return [4 /*yield*/, axios.patch(base + "/preset-menus/admin", {
110
- id: id,
111
- availability: availability,
112
- minBookingTotal: minBookingTotal,
113
- title: title
114
- }, {
115
- headers: {
116
- 'Authorization': "".concat(token)
117
- }
118
- })
119
- .then(function (response) {
120
- return Right(response.data);
121
- })
122
- .catch(function (error) {
123
- var _a, _b, _c, _d, _e;
124
- // handled error
125
- if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) == 401) {
126
- // unavailable_business
127
- // unauthorized
128
- // unauthenticated
129
- return (Left(new Error((_c = (_b = error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.code)));
130
- }
131
- else if (((_d = error.response) === null || _d === void 0 ? void 0 : _d.status) == 404)
132
- return (Left(new Error("not_found")));
133
- else if (((_e = error.response) === null || _e === void 0 ? void 0 : _e.status) == 400) {
134
- return (Left(new Error("invalid_input")));
135
- }
136
- else
137
- throw new Error('internal_error', error);
138
- })];
139
- case 1: return [2 /*return*/, _b.sent()];
140
- }
141
- });
142
- });
143
- };
144
- return PresetMenusAdminAPIs;
145
- }());
146
- export { PresetMenusAdminAPIs };
@@ -1,11 +0,0 @@
1
- import { PresetMenu } from "./types/preset-menu";
2
- import { LocalDate } from "../../types";
3
- import { SpecialDiscount } from "./types/special-discounts";
4
- export declare class PresetMenusAPIs {
5
- static getByBusiness(businessId: string): Promise<PresetMenu[]>;
6
- static getSpecialDiscounts(props: {
7
- businessId: string;
8
- code: string;
9
- date: LocalDate;
10
- }): Promise<SpecialDiscount[]>;
11
- }
@@ -1,7 +0,0 @@
1
- import { Either } from "purify-ts";
2
- import { PresetMenu } from "../types/preset-menu";
3
- import { UpsertDiscountRequest } from "./types/update-discount";
4
- export declare class PresetMenusDiscountAdminAPIs {
5
- static upsert({ token, id, // preset menu id
6
- days, isAvailable, adultPrice, childPrice, minBookingTotal }: UpsertDiscountRequest): Promise<Either<Error, PresetMenu>>;
7
- }
@@ -1,90 +0,0 @@
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 { Left, Right } from "purify-ts";
40
- // preset-menus module admin APIs
41
- var PresetMenusDiscountAdminAPIs = /** @class */ (function () {
42
- function PresetMenusDiscountAdminAPIs() {
43
- }
44
- PresetMenusDiscountAdminAPIs.upsert = function (_a) {
45
- var token = _a.token, id = _a.id, // preset menu id
46
- days = _a.days, isAvailable = _a.isAvailable, adultPrice = _a.adultPrice, childPrice = _a.childPrice, minBookingTotal = _a.minBookingTotal;
47
- return __awaiter(this, void 0, void 0, function () {
48
- return __generator(this, function (_b) {
49
- switch (_b.label) {
50
- case 0: return [4 /*yield*/, axios.patch(base + "/preset-menus/admin/discounts", {
51
- id: id,
52
- days: days,
53
- isAvailable: isAvailable,
54
- adultPrice: adultPrice,
55
- childPrice: childPrice,
56
- minBookingTotal: minBookingTotal
57
- }, {
58
- headers: {
59
- 'Authorization': "".concat(token)
60
- }
61
- })
62
- .then(function (response) {
63
- return Right(response.data);
64
- })
65
- // handled error
66
- .catch(function (error) {
67
- var _a, _b, _c, _d, _e, _f, _g;
68
- // unavailable_business
69
- // unauthorized
70
- // unauthenticated
71
- if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) == 401)
72
- return (Left(new Error((_c = (_b = error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.code)));
73
- else if (((_d = error.response) === null || _d === void 0 ? void 0 : _d.status) == 404)
74
- return (Left(new Error("not_found")));
75
- //invalid_child_discount
76
- //invalid_adult_discount
77
- //unauthorized_disable_discount
78
- else if (((_e = error.response) === null || _e === void 0 ? void 0 : _e.status) == 400)
79
- return (Left(new Error((_g = (_f = error.response) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.code)));
80
- else
81
- throw new Error('internal_error', error);
82
- })];
83
- case 1: return [2 /*return*/, _b.sent()];
84
- }
85
- });
86
- });
87
- };
88
- return PresetMenusDiscountAdminAPIs;
89
- }());
90
- export { PresetMenusDiscountAdminAPIs };
@@ -1,9 +0,0 @@
1
- export interface UpsertDiscountRequest {
2
- id: string;
3
- days: string[];
4
- isAvailable: Boolean;
5
- adultPrice: number;
6
- childPrice?: number;
7
- minBookingTotal?: number;
8
- token?: string;
9
- }
@@ -1,7 +0,0 @@
1
- export * from './types/preset-menu';
2
- export * from './types/types';
3
- export * from './types/update-preset-menu';
4
- export { PresetMenusAPIs } from './apis';
5
- export { PresetMenusAdminAPIs } from './admin-apis';
6
- export * from './discounts/types/update-discount';
7
- export { PresetMenusDiscountAdminAPIs } from './discounts/admin-apis';
@@ -1,9 +0,0 @@
1
- // preset-menus module
2
- export * from './types/preset-menu';
3
- export * from './types/types';
4
- export * from './types/update-preset-menu';
5
- export { PresetMenusAPIs } from './apis';
6
- export { PresetMenusAdminAPIs } from './admin-apis';
7
- // discount module
8
- export * from './discounts/types/update-discount';
9
- export { PresetMenusDiscountAdminAPIs } from './discounts/admin-apis';
@@ -1,19 +0,0 @@
1
- import { Licence, LocalDate } from "../../../types";
2
- import { Price } from "./types";
3
- export interface DailyDiscount {
4
- isAvailable: boolean;
5
- price: Price;
6
- minBookingTotal?: number;
7
- minPublishedDiscount: number;
8
- canDisableAfter?: number;
9
- }
10
- export interface PresetMenu {
11
- id: string;
12
- licence?: Licence;
13
- excludedDays?: LocalDate[];
14
- title: string;
15
- description: string;
16
- price: Price;
17
- minBookingTotal?: number;
18
- discount?: Map<LocalDate, DailyDiscount>;
19
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,12 +0,0 @@
1
- import { Price } from "./types";
2
- export interface Discount {
3
- price: Price;
4
- minBookingTotal?: number;
5
- }
6
- export interface SpecialDiscount {
7
- menuId: string;
8
- title: string;
9
- price: Price;
10
- minBookingTotal?: number;
11
- discount: Discount;
12
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- export interface Price {
2
- adult: number;
3
- child?: number;
4
- }
@@ -1,12 +0,0 @@
1
- import { LocalDate } from "../../../types";
2
- export interface UpdatePresetMenuRequest {
3
- id: string;
4
- title?: string;
5
- minBookingTotal?: number;
6
- availability?: Availability;
7
- token?: string;
8
- }
9
- export interface Availability {
10
- isAvailable: boolean;
11
- date: LocalDate;
12
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- export interface GetTransitionsRequest {
2
- token?: string;
3
- reservationId: string;
4
- }
@@ -1,4 +0,0 @@
1
- export interface GetByIdAdminRequest {
2
- token?: string;
3
- id: string;
4
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,22 +0,0 @@
1
- import { Price } from "../../../menus/preset/types/types";
2
- export interface ReservationSettings {
3
- menus: AvailableMenu[];
4
- deals: AvailableDeal[];
5
- }
6
- export interface AvailableDeal {
7
- id: string;
8
- label: string;
9
- isAvailable: boolean;
10
- }
11
- export interface AvailableMenu {
12
- id: string;
13
- title: string;
14
- price: Price;
15
- minBookingTotal: number | undefined;
16
- discount: AvailableDiscount | undefined;
17
- isAvailable: boolean;
18
- }
19
- export interface AvailableDiscount {
20
- price: Price;
21
- minBookingTotal: number | undefined;
22
- }
@@ -1,3 +0,0 @@
1
- export interface SaveReservationResponse {
2
- id: string;
3
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- import { DailyDiscount, PresetMenu } from "../menus/preset/types/preset-menu";
2
- import { LocalDate } from "../types";
3
- export declare class MenuUtils {
4
- static isMenuAvailableByDay(menu: PresetMenu, date: Date): boolean;
5
- static getDiscounts(menu: PresetMenu): Map<LocalDate, DailyDiscount>;
6
- static getAvailableDiscounts(menu: PresetMenu): Map<LocalDate, DailyDiscount>;
7
- static getMinAvailablePrice(menu: PresetMenu): number;
8
- static getAvailableDiscountByDay(menu: PresetMenu, date: Date): DailyDiscount | undefined;
9
- static getDiscountByDay(menu: PresetMenu, date: Date): DailyDiscount | undefined;
10
- }
@@ -1,51 +0,0 @@
1
- import { BusinessUtils } from "./business-utils";
2
- import { toLocaleDate } from "./date-utils";
3
- var MenuUtils = /** @class */ (function () {
4
- function MenuUtils() {
5
- }
6
- MenuUtils.isMenuAvailableByDay = function (menu, date) {
7
- var _a, _b;
8
- var isLicenceActive = BusinessUtils.isLicenceActiveByDay(date, menu.licence);
9
- var isDayExcluded = (_b = (_a = menu.excludedDays) === null || _a === void 0 ? void 0 : _a.includes(toLocaleDate(date))) !== null && _b !== void 0 ? _b : false;
10
- return isLicenceActive && !isDayExcluded;
11
- };
12
- MenuUtils.getDiscounts = function (menu) {
13
- var _a;
14
- // correct way to get daily discounts Map instance
15
- var discounts_ = (_a = menu.discount) !== null && _a !== void 0 ? _a : {};
16
- return new Map(Object.entries(discounts_));
17
- };
18
- MenuUtils.getAvailableDiscounts = function (menu) {
19
- var discounts = this.getDiscounts(menu);
20
- // filter available discounts
21
- var result = Array.from(discounts.entries())
22
- .filter(function (entry) {
23
- var _a;
24
- var dateAsString = entry[0], dailyDiscount = entry[1];
25
- var isDayExcluded = (_a = menu.excludedDays) === null || _a === void 0 ? void 0 : _a.includes(dateAsString);
26
- return dailyDiscount.isAvailable && !isDayExcluded;
27
- });
28
- return new Map(result);
29
- };
30
- // return min available price for the menu ( from today )
31
- MenuUtils.getMinAvailablePrice = function (menu) {
32
- var availableDiscounts = MenuUtils.getAvailableDiscounts(menu);
33
- var discounts = Array.from(availableDiscounts.values());
34
- // search the lower available price
35
- return discounts
36
- .reduce(function (min, discount) {
37
- return Math.min(min, discount.price.adult);
38
- }, menu.price.adult);
39
- };
40
- MenuUtils.getAvailableDiscountByDay = function (menu, date) {
41
- var discount = this.getDiscountByDay(menu, date);
42
- return (discount === null || discount === void 0 ? void 0 : discount.isAvailable) ? discount : undefined;
43
- };
44
- MenuUtils.getDiscountByDay = function (menu, date) {
45
- // correct way to get daily discount Map instance
46
- var discounts = MenuUtils.getDiscounts(menu);
47
- return discounts.get(toLocaleDate(date));
48
- };
49
- return MenuUtils;
50
- }());
51
- export { MenuUtils };