@odynn/awayz-hotels 0.2.2 → 0.2.3

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.
@@ -1,23 +1,24 @@
1
- import { jsxs as a, jsx as s } from "react/jsx-runtime";
2
- import { a as d, b as i } from "../../../index-D8bHwbxH.js";
1
+ import { jsxs as a, jsx as n } from "react/jsx-runtime";
2
+ import { a as m, b as d } from "../../../index-D8bHwbxH.js";
3
3
  import '../../../assets/Ratings.css';var p = /* @__PURE__ */ ((r) => (r.INHERIT = "inherit", r.PRIMARY = "primary", r.LIGHT = "light", r.DARK = "dark", r))(p || {});
4
- const o = ({
4
+ const u = ({
5
5
  starRating: r,
6
6
  userRating: e,
7
- color: n = "dark",
7
+ color: t = "dark",
8
8
  fill: c = !1,
9
- starColor: l = "primary"
9
+ starColor: s = "primary"
10
10
  /* PRIMARY */
11
11
  }) => {
12
- if (!r && !e) return null;
13
- const m = !e || e === 0 || e.toString().toLowerCase() === "none", t = r ? c ? /* @__PURE__ */ s(d, { className: l }) : /* @__PURE__ */ s(i, { className: l }) : null;
14
- return /* @__PURE__ */ a("div", { className: `rating ${n}`, children: [
15
- t,
12
+ const l = !e || e === 0 || e.toString().toLowerCase() === "none";
13
+ if (!r && l) return null;
14
+ const i = r ? c ? /* @__PURE__ */ n(m, { className: s }) : /* @__PURE__ */ n(d, { className: s }) : null;
15
+ return /* @__PURE__ */ a("div", { className: `rating ${t}`, children: [
16
+ i,
16
17
  r ? /* @__PURE__ */ a("p", { children: [
17
18
  r,
18
19
  "-star"
19
20
  ] }) : null,
20
- m ? null : /* @__PURE__ */ a("p", { children: [
21
+ l ? null : /* @__PURE__ */ a("p", { children: [
21
22
  "(",
22
23
  e,
23
24
  " rating)"
@@ -26,5 +27,5 @@ const o = ({
26
27
  };
27
28
  export {
28
29
  p as ERatingColor,
29
- o as default
30
+ u as default
30
31
  };
@@ -1,81 +1,87 @@
1
- import { HotelService as m } from "../../services/hotel/HotelService.js";
2
- import { BookingService as h } from "../../services/booking/BookingService.js";
3
- import { HotelChains as p } from "../../definitions/HotelChains.js";
4
- import { EBestCheckoutType as l } from "../../enums/EBestCheckoutType.js";
1
+ import { HotelService as f } from "../../services/hotel/HotelService.js";
2
+ import { BookingService as d } from "../../services/booking/BookingService.js";
3
+ import { HotelChains as l } from "../../definitions/HotelChains.js";
4
+ import { EBestCheckoutType as m } from "../../enums/EBestCheckoutType.js";
5
5
  import { EGuestType as y } from "../../services/booking/BookingService.enums.js";
6
- const w = async (o) => await m.getTransferPartners(
7
- p.toProgram(o)
6
+ const w = async (o) => await f.getTransferPartners(
7
+ l.toProgram(o)
8
8
  ), T = async ({
9
9
  hotel: o,
10
10
  checkinDate: s,
11
- checkoutDate: a,
11
+ checkoutDate: n,
12
12
  updateHotel: t
13
13
  }) => {
14
- let n = o, i = o.rooms ?? [];
15
- if (!o.liveScrapingCheckNeeded || o.hotelGroup === p.Marriott)
14
+ let e = o, i = o.rooms ?? [];
15
+ if (!o.liveScrapingCheckNeeded || o.hotelGroup === l.Marriott)
16
16
  return {
17
17
  pointsHotelDetails: o,
18
18
  pointsRooms: i
19
19
  };
20
- const r = await m.hotelPointsCheck({
21
- hotelGroup: o.hotelGroup,
22
- hotelId: o.hotelId,
23
- checkinDate: s,
24
- checkoutDate: a
25
- });
26
- if (r.success) {
27
- const e = r.data, u = !(e.points.pointsValue > 0) && o.bestValue === l.POINTS;
28
- n = {
20
+ let r = !1, c = null;
21
+ try {
22
+ const a = await f.hotelPointsCheck({
23
+ hotelGroup: o.hotelGroup,
24
+ hotelId: o.hotelId,
25
+ checkinDate: s,
26
+ checkoutDate: n
27
+ });
28
+ r = a.success, c = a.data;
29
+ } catch {
30
+ r = !1, c = null;
31
+ }
32
+ if (r) {
33
+ const a = c, u = !(a.points.pointsValue > 0) && o.bestValue === m.POINTS;
34
+ e = {
29
35
  ...o,
30
- awardPoints: e.points.awardPointsValue ?? e.points.pointsValue,
31
- points: e.points.pointsValue,
32
- pointsType: e.points.pointsType,
33
- bestValue: u ? l.NONE : o.bestValue
34
- }, i = e.rooms ?? o.rooms ?? [], t(o.hotelId, o.hotelGroup, n);
36
+ awardPoints: a.points.awardPointsValue ?? a.points.pointsValue,
37
+ points: a.points.pointsValue,
38
+ pointsType: a.points.pointsType,
39
+ bestValue: u ? m.NONE : o.bestValue
40
+ }, i = a.rooms ?? o.rooms ?? [], t(o.hotelId, o.hotelGroup, e);
35
41
  }
36
42
  return {
37
- pointsHotelDetails: n,
43
+ pointsHotelDetails: e,
38
44
  pointsRooms: i
39
45
  };
40
46
  }, A = async ({
41
47
  hotel: o,
42
48
  checkinDate: s,
43
- checkoutDate: a,
49
+ checkoutDate: n,
44
50
  guests: t,
45
- rooms: n,
51
+ rooms: e,
46
52
  updateHotel: i,
47
53
  numberOfNights: r
48
54
  }) => {
49
- var f;
50
- if (!((f = o == null ? void 0 : o.cashBookingOffers) != null && f.accommodationId))
55
+ var u;
56
+ if (!((u = o == null ? void 0 : o.cashBookingOffers) != null && u.accommodationId))
51
57
  return {
52
58
  cashHotelDetails: o,
53
59
  cashRooms: []
54
60
  };
55
- const e = (d) => Array.from({ length: d }, () => ({ type: y.ADULT })), c = await h.getAvailableRooms({
61
+ const c = (h) => Array.from({ length: h }, () => ({ type: y.ADULT })), a = await d.getAvailableRooms({
56
62
  checkinDate: s,
57
- checkoutDate: a,
63
+ checkoutDate: n,
58
64
  accommodationId: o.cashBookingOffers.accommodationId,
59
- guests: e(t),
60
- rooms: n
61
- }), u = {
65
+ guests: c(t),
66
+ rooms: e
67
+ }), p = {
62
68
  ...o,
63
69
  cashValue: {
64
70
  ...o.cashValue,
65
- amount: c.cheapestRate / r || o.cashValue.amount || 0,
66
- currency: c.currency ?? o.cashValue.currency
71
+ amount: a.cheapestRate / r || o.cashValue.amount || 0,
72
+ currency: a.currency ?? o.cashValue.currency
67
73
  }
68
74
  };
69
- return i(o.hotelId, o.hotelGroup, u), {
70
- cashHotelDetails: u,
71
- cashRooms: c.availableRooms
75
+ return i(o.hotelId, o.hotelGroup, p), {
76
+ cashHotelDetails: p,
77
+ cashRooms: a.availableRooms
72
78
  };
73
79
  }, G = async (o, s) => {
74
- const { success: a, data: t } = await m.getRecommendations({
80
+ const { success: n, data: t } = await f.getRecommendations({
75
81
  days: s,
76
82
  hotels: [o]
77
83
  });
78
- return a ? {
84
+ return n ? {
79
85
  bestCheckout: t,
80
86
  isAvailable: t.nightlyPointsCost > 0 || t.nightlyCashCost > 0
81
87
  } : {
@@ -83,23 +89,23 @@ const w = async (o) => await m.getTransferPartners(
83
89
  isAvailable: !1
84
90
  };
85
91
  }, C = (o, s) => {
86
- var t, n;
92
+ var t, e;
87
93
  return {
88
- bestCheckoutMethod: p.isHotelChain(o.hotelGroup) ? o.bestValue : l.CASH,
94
+ bestCheckoutMethod: l.isHotelChain(o.hotelGroup) ? o.bestValue : m.CASH,
89
95
  nightlyCashCost: ((t = o.cashValue) == null ? void 0 : t.amount) || 0,
90
96
  nightlyPointsCost: o.points || 0,
91
97
  awardPoints: o.points || 0,
92
- totalCashCost: (((n = o.cashValue) == null ? void 0 : n.amount) || 0) * s,
98
+ totalCashCost: (((e = o.cashValue) == null ? void 0 : e.amount) || 0) * s,
93
99
  totalPointsCost: (o.points || 0) * s,
94
100
  currency: "USD",
95
101
  sufficientPoints: !0,
96
- rewardsProgram: p.toProgram(o.hotelGroup),
102
+ rewardsProgram: l.toProgram(o.hotelGroup),
97
103
  optimalProgram: {
98
104
  programs: [],
99
105
  remainingPointsBalance: 0
100
106
  }
101
107
  };
102
- }, B = (o, s, a) => {
108
+ }, B = (o, s, n) => {
103
109
  let t = o;
104
110
  return s && (t = {
105
111
  ...o,
@@ -107,10 +113,10 @@ const w = async (o) => await m.getTransferPartners(
107
113
  awardPoints: s.awardPoints,
108
114
  pointsType: s.pointsType,
109
115
  bestValue: s.bestValue
110
- }), a && (t = {
116
+ }), n && (t = {
111
117
  ...t,
112
- cashValue: a.cashValue,
113
- rooms: a.rooms
118
+ cashValue: n.cashValue,
119
+ rooms: n.rooms
114
120
  }), t;
115
121
  };
116
122
  export {
@@ -51,5 +51,5 @@ interface IFetchBestCheckoutResponse {
51
51
  }
52
52
  export declare const fetchBestCheckout: (hotel: IHotelDetails, numberOfNights: number) => Promise<IFetchBestCheckoutResponse>;
53
53
  export declare const fallbackBestCheckout: (selectedHotelData: IHotelDetails, numberOfNights: number) => IBestCheckout;
54
- export declare const combineUpdatedHotelData: (base: IHotelDetails, liveScaperData: IHotelDetails, cashRoomsData: IHotelDetails) => IHotelDetails;
54
+ export declare const combineUpdatedHotelData: (base: IHotelDetails, liveScraperData: IHotelDetails, cashRoomsData: IHotelDetails) => IHotelDetails;
55
55
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@odynn/awayz-hotels",
3
3
  "private": false,
4
- "version": "0.2.2",
4
+ "version": "0.2.3",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"