@odynn/awayz-hotels 0.6.1 → 0.6.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.
@@ -61,7 +61,7 @@ const QA = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAyAAAAGiCAYAAAAfl6KSAA
61
61
  if (a.stopPropagation(), E) E(A);
62
62
  else
63
63
  throw new Error("Could not display availability calendar.");
64
- }, s = S && typeof A.nthNightFree == "number" && A.nthNightFree > 0;
64
+ }, s = typeof A.nthNightFree == "number" && A.nthNightFree > 0;
65
65
  return /* @__PURE__ */ C(
66
66
  "div",
67
67
  {
@@ -115,7 +115,7 @@ const QA = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAyAAAAGiCAYAAAAfl6KSAA
115
115
  /* @__PURE__ */ Q(k, {}),
116
116
  /* @__PURE__ */ Q("p", { children: "Free Night" })
117
117
  ] }),
118
- s && /* @__PURE__ */ C("div", { children: [
118
+ S && s && /* @__PURE__ */ C("div", { children: [
119
119
  /* @__PURE__ */ Q(G, {}),
120
120
  /* @__PURE__ */ C("p", { children: [
121
121
  Y(A.nthNightFree),
@@ -1,133 +1,134 @@
1
- import { HotelChains as l } from "../../definitions/HotelChains.js";
1
+ import { HotelChains as p } from "../../definitions/HotelChains.js";
2
2
  import { EBestCheckoutType as m } from "../../enums/EBestCheckoutType.js";
3
- import { BookingService as d } from "../../services/booking/BookingService.js";
4
- import { EGuestType as y } from "../../services/booking/BookingService.enums.js";
5
- import { HotelService as f } from "../../services/hotel/HotelService.js";
6
- const w = async (t) => await f.getTransferPartners(
7
- l.toProgram(t)
3
+ import { BookingService as y } from "../../services/booking/BookingService.js";
4
+ import { EGuestType as C } from "../../services/booking/BookingService.enums.js";
5
+ import { HotelService as h } from "../../services/hotel/HotelService.js";
6
+ const w = async (s) => await h.getTransferPartners(
7
+ p.toProgram(s)
8
8
  ), T = async ({
9
- hotel: t,
10
- checkinDate: o,
11
- checkoutDate: e,
12
- updateHotel: a
9
+ hotel: s,
10
+ checkinDate: t,
11
+ checkoutDate: n,
12
+ updateHotel: e
13
13
  }) => {
14
- let s = t, i = t.rooms ?? [];
15
- if (!t.liveScrapingCheckNeeded || t.hotelGroup === l.Marriott)
14
+ let a = s, i = s.rooms ?? [];
15
+ if (!s.liveScrapingCheckNeeded || s.hotelGroup === p.Marriott)
16
16
  return {
17
- pointsHotelDetails: t,
17
+ pointsHotelDetails: s,
18
18
  pointsRooms: i
19
19
  };
20
20
  let r = !1, c = null;
21
21
  try {
22
- const n = await f.hotelPointsCheck({
23
- hotelGroup: t.hotelGroup,
24
- hotelId: t.hotelId,
25
- checkinDate: o,
26
- checkoutDate: e
22
+ const o = await h.hotelPointsCheck({
23
+ hotelGroup: s.hotelGroup,
24
+ hotelId: s.hotelId,
25
+ checkinDate: t,
26
+ checkoutDate: n
27
27
  });
28
- r = n.success, c = n.data;
28
+ r = o.success, c = o.data;
29
29
  } catch {
30
30
  r = !1, c = null;
31
31
  }
32
32
  if (r) {
33
- const n = c, u = !(n.points.pointsValue > 0) && t.bestValue === m.POINTS;
34
- s = {
35
- ...t,
36
- awardPoints: n.points.awardPointsValue ?? n.points.pointsValue,
37
- points: n.points.pointsValue,
38
- pointsType: n.points.pointsType,
39
- bestValue: u ? m.NONE : t.bestValue
40
- }, i = n.rooms ?? t.rooms ?? [], a(t.hotelId, t.hotelGroup, s);
33
+ const o = c, u = !(o.points.pointsValue > 0) && s.bestValue === m.POINTS;
34
+ a = {
35
+ ...s,
36
+ awardPoints: o.points.awardPointsValue ?? o.points.pointsValue,
37
+ points: o.points.pointsValue,
38
+ pointsType: o.points.pointsType,
39
+ bestValue: u ? m.NONE : s.bestValue
40
+ }, i = o.rooms ?? s.rooms ?? [], e(s.hotelId, s.hotelGroup, a);
41
41
  }
42
42
  return {
43
- pointsHotelDetails: s,
43
+ pointsHotelDetails: a,
44
44
  pointsRooms: i
45
45
  };
46
46
  }, A = async ({
47
- hotel: t,
48
- checkinDate: o,
49
- checkoutDate: e,
50
- guests: a,
51
- rooms: s,
47
+ hotel: s,
48
+ checkinDate: t,
49
+ checkoutDate: n,
50
+ guests: e,
51
+ rooms: a,
52
52
  updateHotel: i,
53
53
  numberOfNights: r
54
54
  }) => {
55
55
  var u;
56
- if (!((u = t == null ? void 0 : t.cashBookingOffers) != null && u.accommodationId))
56
+ if (!((u = s == null ? void 0 : s.cashBookingOffers) != null && u.accommodationId))
57
57
  return {
58
- cashHotelDetails: t,
58
+ cashHotelDetails: s,
59
59
  cashRooms: []
60
60
  };
61
- const c = (h) => Array.from({ length: h }, () => ({ type: y.ADULT })), n = await d.getAvailableRooms({
62
- checkinDate: o,
63
- checkoutDate: e,
64
- accommodationId: t.cashBookingOffers.accommodationId,
65
- guests: c(a),
66
- rooms: s
67
- }), p = {
68
- ...t,
61
+ const c = (f) => Array.from({ length: f }, () => ({ type: C.ADULT })), o = await y.getAvailableRooms({
62
+ checkinDate: t,
63
+ checkoutDate: n,
64
+ accommodationId: s.cashBookingOffers.accommodationId,
65
+ guests: c(e),
66
+ rooms: a
67
+ }), l = {
68
+ ...s,
69
69
  cashValue: {
70
- ...t.cashValue,
71
- amount: n.cheapestRate / r || t.cashValue.amount || 0,
72
- currency: n.currency ?? t.cashValue.currency
70
+ ...s.cashValue,
71
+ amount: o.cheapestRate / r || s.cashValue.amount || 0,
72
+ currency: o.currency ?? s.cashValue.currency
73
73
  }
74
74
  };
75
- return i(t.hotelId, t.hotelGroup, p), {
76
- cashHotelDetails: p,
77
- cashRooms: n.availableRooms
75
+ return i(s.hotelId, s.hotelGroup, l), {
76
+ cashHotelDetails: l,
77
+ cashRooms: o.availableRooms
78
78
  };
79
- }, G = async (t, o, e) => {
80
- const { success: a, data: s } = await f.getRecommendations({
81
- days: o,
82
- hotel: t
79
+ }, B = async (s, t, n) => {
80
+ const { success: e, data: a } = await h.getRecommendations({
81
+ days: t,
82
+ hotel: s
83
83
  });
84
- return a && s ? {
84
+ return e && a ? {
85
85
  bestCheckout: {
86
- ...s,
87
- nightlyPointsCost: e ? s.awardPoints : s.nightlyPointsCost
86
+ ...a,
87
+ nightlyPointsCost: n ? a.awardPoints : a.nightlyPointsCost
88
88
  },
89
- isAvailable: s.nightlyPointsCost > 0 || s.nightlyCashCost > 0
89
+ isAvailable: a.nightlyPointsCost > 0 || a.nightlyCashCost > 0
90
90
  } : {
91
- bestCheckout: P(t, o),
91
+ bestCheckout: d(s, t),
92
92
  isAvailable: !1
93
93
  };
94
- }, P = (t, o) => {
95
- var a, s;
94
+ }, d = (s, t) => {
95
+ var i, r, c, o;
96
+ const n = ((i = s.cashBookingOffers) == null ? void 0 : i.cheapestRateTotalAmount) ?? ((r = s.cashValue) == null ? void 0 : r.amount) ?? 0, e = ((c = s.cashBookingOffers) == null ? void 0 : c.cheapestRateCurrency) ?? ((o = s.cashValue) == null ? void 0 : o.currency) ?? "USD";
96
97
  return {
97
- bestCheckoutMethod: l.isHotelChain(t.hotelGroup) ? t.bestValue : m.CASH,
98
- nightlyCashCost: ((a = t.cashValue) == null ? void 0 : a.amount) || 0,
99
- nightlyPointsCost: t.points || 0,
100
- awardPoints: t.points || 0,
101
- totalCashCost: (((s = t.cashValue) == null ? void 0 : s.amount) || 0) * o,
102
- totalPointsCost: (t.points || 0) * o,
103
- currency: "USD",
98
+ bestCheckoutMethod: p.isHotelChain(s.hotelGroup) ? s.bestValue : m.CASH,
99
+ nightlyCashCost: n,
100
+ nightlyPointsCost: s.points || 0,
101
+ awardPoints: s.points || 0,
102
+ totalCashCost: n * t,
103
+ totalPointsCost: (s.points || 0) * t,
104
+ currency: e,
104
105
  sufficientPoints: !0,
105
- rewardsProgram: l.toProgram(t.hotelGroup),
106
+ rewardsProgram: p.toProgram(s.hotelGroup),
106
107
  optimalProgram: {
107
108
  programs: [],
108
109
  remainingPointsBalance: 0,
109
110
  totalProgramPointsValuation: 0
110
111
  }
111
112
  };
112
- }, B = (t, o, e) => {
113
- let a = t;
114
- return o && (a = {
115
- ...t,
116
- points: o.points,
117
- awardPoints: o.awardPoints,
118
- pointsType: o.pointsType,
119
- bestValue: o.bestValue
120
- }), e && (a = {
121
- ...a,
122
- cashValue: e.cashValue,
123
- rooms: e.rooms
124
- }), a;
113
+ }, G = (s, t, n) => {
114
+ let e = s;
115
+ return t && (e = {
116
+ ...s,
117
+ points: t.points,
118
+ awardPoints: t.awardPoints,
119
+ pointsType: t.pointsType,
120
+ bestValue: t.bestValue
121
+ }), n && (e = {
122
+ ...e,
123
+ cashValue: n.cashValue,
124
+ rooms: n.rooms
125
+ }), e;
125
126
  };
126
127
  export {
127
- B as combineUpdatedHotelData,
128
- P as fallbackBestCheckout,
128
+ G as combineUpdatedHotelData,
129
+ d as fallbackBestCheckout,
129
130
  A as fetchAvailableRooms,
130
- G as fetchBestCheckout,
131
+ B as fetchBestCheckout,
131
132
  T as fetchPointsCheck,
132
133
  w as fetchTransferPartners
133
134
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@odynn/awayz-hotels",
3
3
  "private": false,
4
- "version": "0.6.1",
4
+ "version": "0.6.3",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -66,7 +66,7 @@
66
66
  ]
67
67
  },
68
68
  "dependencies": {
69
- "@odynn/awayz-core": "^0.6.0",
69
+ "@odynn/awayz-core": ">= 0.6.0",
70
70
  "@tanstack/react-query": "^5.66.9",
71
71
  "string-comparison": "^1.3.0"
72
72
  }