@kiminix/tp-client 1.10.0 → 1.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ import { Available } from "../types";
2
+ export declare class BusinessUtils {
3
+ static isLicenceActive(available?: Available): boolean;
4
+ static isLicenceActiveByDay(date: Date, available?: Available): boolean;
5
+ }
@@ -0,0 +1,17 @@
1
+ import { parseISO } from "date-fns";
2
+ import { isDayBefore, isDayBetween } from "./date-utils";
3
+ var BusinessUtils = /** @class */ (function () {
4
+ function BusinessUtils() {
5
+ }
6
+ // licence is active if business has an available date that it is not expired
7
+ BusinessUtils.isLicenceActive = function (available) {
8
+ var today = new Date();
9
+ return (available === null || available === void 0 ? void 0 : available.to) ? isDayBefore(today, parseISO(available.to)) : false;
10
+ };
11
+ // check if the business is active for a specific date
12
+ BusinessUtils.isLicenceActiveByDay = function (date, available) {
13
+ return available ? isDayBetween(date, parseISO(available.from), parseISO(available.to)) : false;
14
+ };
15
+ return BusinessUtils;
16
+ }());
17
+ export { BusinessUtils };
@@ -1,7 +1,6 @@
1
- import { Available, LocalDate } from "../types";
2
1
  import { DailyDiscount, PresetMenu } from "../menus/preset/types/preset-menu";
2
+ import { LocalDate } from "../types";
3
3
  export declare class MenuUtils {
4
- static isBusinessAvailable(available?: Available): boolean;
5
4
  static isMenuAvailableByDay(menu: PresetMenu, date: Date): boolean;
6
5
  static getDiscounts(menu: PresetMenu): Map<LocalDate, DailyDiscount>;
7
6
  static getAvailableDiscounts(menu: PresetMenu): Map<LocalDate, DailyDiscount>;
@@ -1,19 +1,13 @@
1
- import { parseISO } from "date-fns";
2
- import { isDayBefore, isDayBetween, toLocaleDate } from "./date-utils";
1
+ import { BusinessUtils } from "./business-utils";
2
+ import { toLocaleDate } from "./date-utils";
3
3
  var MenuUtils = /** @class */ (function () {
4
4
  function MenuUtils() {
5
5
  }
6
- // business account is available if it has an available date that it is not expired
7
- MenuUtils.isBusinessAvailable = function (available) {
8
- var today = new Date();
9
- return (available === null || available === void 0 ? void 0 : available.to) ? isDayBefore(today, parseISO(available.to)) : false;
10
- };
11
6
  MenuUtils.isMenuAvailableByDay = function (menu, date) {
12
7
  var _a, _b;
13
- // check if the business is active for a specific date
14
- var isBusinessAvailable = (menu === null || menu === void 0 ? void 0 : menu.available) ? isDayBetween(date, parseISO(menu.available.from), parseISO(menu.available.to)) : false;
8
+ var isLicenceActive = BusinessUtils.isLicenceActiveByDay(date, menu.available);
15
9
  var isDayExcluded = (_b = (_a = menu.excludedDays) === null || _a === void 0 ? void 0 : _a.includes(toLocaleDate(date))) !== null && _b !== void 0 ? _b : false;
16
- return isBusinessAvailable && !isDayExcluded;
10
+ return isLicenceActive && !isDayExcluded;
17
11
  };
18
12
  MenuUtils.getDiscounts = function (menu) {
19
13
  var _a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiminix/tp-client",
3
- "version": "1.10.0",
3
+ "version": "1.11.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [