@odynn/awayz-hotels 0.1.16 → 0.1.17

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,79 +1,77 @@
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
- import { EGuestType as C } from "../../services/booking/BookingService.enums.js";
6
- const w = async (o) => await f.getTransferPartners(
7
- l.toProgram(o)
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";
5
+ import { EGuestType as y } from "../../services/booking/BookingService.enums.js";
6
+ const w = async (o) => await m.getTransferPartners(
7
+ p.toProgram(o)
8
8
  ), T = async ({
9
9
  hotel: o,
10
10
  checkinDate: s,
11
11
  checkoutDate: a,
12
12
  updateHotel: t
13
13
  }) => {
14
- let e = !1, i = o, r = o.rooms ?? [];
15
- if (!o.liveScrapingCheckNeeded || o.hotelGroup === l.Marriott)
14
+ let n = o, i = o.rooms ?? [];
15
+ if (!o.liveScrapingCheckNeeded || o.hotelGroup === p.Marriott)
16
16
  return {
17
17
  pointsHotelDetails: o,
18
- pointsRooms: r,
19
- shouldFallbackBestCheckout: e
18
+ pointsRooms: i
20
19
  };
21
- const u = await f.hotelPointsCheck({
20
+ const r = await m.hotelPointsCheck({
22
21
  hotelGroup: o.hotelGroup,
23
22
  hotelId: o.hotelId,
24
23
  checkinDate: s,
25
24
  checkoutDate: a
26
25
  });
27
- if (u.success) {
28
- const n = u.data[0], c = !(n.points.pointsValue > 0) && o.bestValue === m.POINTS;
29
- i = {
26
+ if (r.success) {
27
+ const e = r.data[0], u = !(e.points.pointsValue > 0) && o.bestValue === l.POINTS;
28
+ n = {
30
29
  ...o,
31
- awardPoints: n.points.awardPointsValue ?? n.points.pointsValue,
32
- points: n.points.pointsValue,
33
- pointsType: n.points.pointsType,
34
- bestValue: c ? m.NONE : o.bestValue
35
- }, r = n.rooms ?? o.rooms ?? [], t(o.hotelId, o.hotelGroup, i), e = c;
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
35
  }
37
36
  return {
38
- pointsHotelDetails: i,
39
- pointsRooms: r,
40
- shouldFallbackBestCheckout: e
37
+ pointsHotelDetails: n,
38
+ pointsRooms: i
41
39
  };
42
40
  }, A = async ({
43
41
  hotel: o,
44
42
  checkinDate: s,
45
43
  checkoutDate: a,
46
44
  guests: t,
47
- rooms: e,
45
+ rooms: n,
48
46
  updateHotel: i,
49
47
  numberOfNights: r
50
48
  }) => {
51
- var c;
52
- if (!((c = o == null ? void 0 : o.cashBookingOffers) != null && c.accommodationId))
49
+ var f;
50
+ if (!((f = o == null ? void 0 : o.cashBookingOffers) != null && f.accommodationId))
53
51
  return {
54
52
  cashHotelDetails: o,
55
53
  cashRooms: []
56
54
  };
57
- const u = (h) => Array.from({ length: h }, () => ({ type: C.ADULT })), n = await d.getAvailableRooms({
55
+ const e = (d) => Array.from({ length: d }, () => ({ type: y.ADULT })), c = await h.getAvailableRooms({
58
56
  checkinDate: s,
59
57
  checkoutDate: a,
60
58
  accommodationId: o.cashBookingOffers.accommodationId,
61
- guests: u(t),
62
- rooms: e
63
- }), p = {
59
+ guests: e(t),
60
+ rooms: n
61
+ }), u = {
64
62
  ...o,
65
63
  cashValue: {
66
64
  ...o.cashValue,
67
- amount: n.cheapestRate / r || o.cashValue.amount || 0,
68
- currency: n.currency ?? o.cashValue.currency
65
+ amount: c.cheapestRate / r || o.cashValue.amount || 0,
66
+ currency: c.currency ?? o.cashValue.currency
69
67
  }
70
68
  };
71
- return i(o.hotelId, o.hotelGroup, p), {
72
- cashHotelDetails: p,
73
- cashRooms: n.availableRooms
69
+ return i(o.hotelId, o.hotelGroup, u), {
70
+ cashHotelDetails: u,
71
+ cashRooms: c.availableRooms
74
72
  };
75
- }, B = async (o, s) => {
76
- const { success: a, data: t } = await f.getRecommendations({
73
+ }, G = async (o, s) => {
74
+ const { success: a, data: t } = await m.getRecommendations({
77
75
  days: s,
78
76
  hotels: [o]
79
77
  });
@@ -81,27 +79,27 @@ const w = async (o) => await f.getTransferPartners(
81
79
  bestCheckout: t,
82
80
  isAvailable: t.nightlyPointsCost > 0 || t.nightlyCashCost > 0
83
81
  } : {
84
- bestCheckout: y(o, s),
82
+ bestCheckout: C(o, s),
85
83
  isAvailable: !1
86
84
  };
87
- }, y = (o, s) => {
88
- var t, e;
85
+ }, C = (o, s) => {
86
+ var t, n;
89
87
  return {
90
- bestCheckoutMethod: l.isHotelChain(o.hotelGroup) ? o.bestValue : m.CASH,
88
+ bestCheckoutMethod: p.isHotelChain(o.hotelGroup) ? o.bestValue : l.CASH,
91
89
  nightlyCashCost: ((t = o.cashValue) == null ? void 0 : t.amount) || 0,
92
90
  nightlyPointsCost: o.points || 0,
93
91
  awardPoints: o.points || 0,
94
- totalCashCost: (((e = o.cashValue) == null ? void 0 : e.amount) || 0) * s,
92
+ totalCashCost: (((n = o.cashValue) == null ? void 0 : n.amount) || 0) * s,
95
93
  totalPointsCost: (o.points || 0) * s,
96
94
  currency: "USD",
97
95
  sufficientPoints: !0,
98
- rewardsProgram: l.toProgram(o.hotelGroup),
96
+ rewardsProgram: p.toProgram(o.hotelGroup),
99
97
  optimalProgram: {
100
98
  programs: [],
101
99
  remainingPointsBalance: 0
102
100
  }
103
101
  };
104
- }, G = (o, s, a) => {
102
+ }, B = (o, s, a) => {
105
103
  let t = o;
106
104
  return s && (t = {
107
105
  ...o,
@@ -116,10 +114,10 @@ const w = async (o) => await f.getTransferPartners(
116
114
  }), t;
117
115
  };
118
116
  export {
119
- G as combineUpdatedHotelData,
120
- y as fallbackBestCheckout,
117
+ B as combineUpdatedHotelData,
118
+ C as fallbackBestCheckout,
121
119
  A as fetchAvailableRooms,
122
- B as fetchBestCheckout,
120
+ G as fetchBestCheckout,
123
121
  T as fetchPointsCheck,
124
122
  w as fetchTransferPartners
125
123
  };
@@ -1,14 +1,14 @@
1
1
  import { useMemo as M } from "react";
2
- import { h as F } from "../../moment-BGjjqtLQ.js";
2
+ import { h as v } from "../../moment-BGjjqtLQ.js";
3
3
  import "../../arrayExtensions-cyilNkdJ.js";
4
4
  import T from "../../stores/useHotelsStore.js";
5
- import { fetchTransferPartners as x, fetchPointsCheck as E, fetchAvailableRooms as L, fetchBestCheckout as Q, combineUpdatedHotelData as g, fallbackBestCheckout as U } from "./useHotelDetails.api.js";
5
+ import { fetchTransferPartners as x, fetchPointsCheck as E, fetchAvailableRooms as L, fetchBestCheckout as Q, combineUpdatedHotelData as F, fallbackBestCheckout as U } from "./useHotelDetails.api.js";
6
6
  import { calculatePointsAsCash as j } from "../../utilities/pointsAsCashUtils.js";
7
7
  import { useQuery as o } from "@tanstack/react-query";
8
8
  const z = (t, c) => Math.abs(
9
- F(t.startOf("day")).diff(F(c.endOf("day")), "days")
9
+ v(t.startOf("day")).diff(v(c.endOf("day")), "days")
10
10
  ), $ = (t) => {
11
- var r, d, k, f, D, p, y, b, C, v;
11
+ var d, h, f, k, D, p, y, b, C, g, m;
12
12
  if (!t)
13
13
  throw new Error(
14
14
  "Hotel is required in order to initiate the hotel details flow"
@@ -16,22 +16,22 @@ const z = (t, c) => Math.abs(
16
16
  const { updateHotel: c, searchParams: e } = T(), a = M(() => e ? z(
17
17
  e.checkinDate,
18
18
  e.checkoutDate
19
- ) : 0, [e]), { data: m, isFetching: O } = o({
19
+ ) : 0, [e]), { data: O, isFetching: q } = o({
20
20
  queryKey: ["transferPartners", t.hotelGroup],
21
21
  queryFn: () => x(t.hotelGroup),
22
22
  enabled: !!t.hotelGroup,
23
23
  placeholderData: []
24
24
  }), {
25
- data: q,
26
- isFetching: s,
27
- isFetched: H
25
+ data: H,
26
+ isFetching: i,
27
+ isFetched: R
28
28
  } = o({
29
29
  queryKey: [
30
30
  "hotelPointsCheck",
31
31
  t.hotelId,
32
32
  t.hotelGroup,
33
- (r = e == null ? void 0 : e.checkinDate) == null ? void 0 : r.valueOf(),
34
- (d = e == null ? void 0 : e.checkoutDate) == null ? void 0 : d.valueOf()
33
+ (d = e == null ? void 0 : e.checkinDate) == null ? void 0 : d.valueOf(),
34
+ (h = e == null ? void 0 : e.checkoutDate) == null ? void 0 : h.valueOf()
35
35
  ],
36
36
  queryFn: () => E({
37
37
  hotel: t,
@@ -44,22 +44,20 @@ const z = (t, c) => Math.abs(
44
44
  retry: !1,
45
45
  placeholderData: {
46
46
  pointsHotelDetails: t,
47
- pointsRooms: t.rooms ?? [],
48
- shouldFallbackBestCheckout: !1
47
+ pointsRooms: t.rooms ?? []
49
48
  }
50
- }), { pointsRooms: R, pointsHotelDetails: i, shouldFallbackBestCheckout: B } = q || {
49
+ }), { pointsRooms: A, pointsHotelDetails: s } = H || {
51
50
  pointsHotelDetails: t,
52
- pointsRooms: [],
53
- shouldFallbackBestCheckout: !1
51
+ pointsRooms: []
54
52
  }, {
55
- data: A,
53
+ data: B,
56
54
  isFetching: n,
57
55
  isFetched: G
58
56
  } = o({
59
57
  queryKey: [
60
58
  "fetchAvailableRooms",
61
- (k = t.cashBookingOffers) == null ? void 0 : k.accommodationId,
62
- (f = e == null ? void 0 : e.checkinDate) == null ? void 0 : f.valueOf(),
59
+ (f = t.cashBookingOffers) == null ? void 0 : f.accommodationId,
60
+ (k = e == null ? void 0 : e.checkinDate) == null ? void 0 : k.valueOf(),
63
61
  (D = e == null ? void 0 : e.checkoutDate) == null ? void 0 : D.valueOf(),
64
62
  e == null ? void 0 : e.guests,
65
63
  e == null ? void 0 : e.rooms
@@ -79,7 +77,7 @@ const z = (t, c) => Math.abs(
79
77
  cashHotelDetails: t,
80
78
  cashRooms: []
81
79
  }
82
- }), { cashRooms: I, cashHotelDetails: l } = A || {
80
+ }), { cashRooms: I, cashHotelDetails: u } = B || {
83
81
  cashHotelDetails: t,
84
82
  cashRooms: []
85
83
  }, {
@@ -95,49 +93,49 @@ const z = (t, c) => Math.abs(
95
93
  (b = e == null ? void 0 : e.checkoutDate) == null ? void 0 : b.valueOf()
96
94
  ],
97
95
  queryFn: () => Q(
98
- g(t, i, l),
96
+ F(t, s, u),
99
97
  a
100
98
  ),
101
- enabled: !s && (t.liveScrapingCheckNeeded ? H : !0) && !n && G && !B && a > 0,
99
+ enabled: !i && (t.liveScrapingCheckNeeded ? R : !0) && !n && ((C = t.cashBookingOffers) != null && C.accommodationId ? G : !0) && a > 0,
102
100
  retry: !1,
103
101
  placeholderData: {
104
102
  bestCheckout: U(t, a),
105
103
  isAvailable: !1
106
104
  }
107
- }), { bestCheckout: u, isAvailable: h } = K || {
105
+ }), { bestCheckout: l, isAvailable: r } = K || {
108
106
  isAvailable: !1
109
107
  }, { data: N } = o({
110
108
  queryKey: [
111
109
  "pointsAsCash",
112
110
  t.hotelId,
113
111
  t.hotelGroup,
114
- (C = e == null ? void 0 : e.checkinDate) == null ? void 0 : C.valueOf(),
115
- (v = e == null ? void 0 : e.checkoutDate) == null ? void 0 : v.valueOf()
112
+ (g = e == null ? void 0 : e.checkinDate) == null ? void 0 : g.valueOf(),
113
+ (m = e == null ? void 0 : e.checkoutDate) == null ? void 0 : m.valueOf()
116
114
  ],
117
- queryFn: () => j(u.totalCashCost),
118
- enabled: S && h,
115
+ queryFn: () => j(l.totalCashCost),
116
+ enabled: S && r,
119
117
  retry: !1
120
118
  });
121
119
  return {
122
- transferPartners: m,
123
- loadingTransferPartners: O,
120
+ transferPartners: O,
121
+ loadingTransferPartners: q,
124
122
  // Points Check
125
- pointsRooms: R,
126
- loadingLivePointsCheck: s,
123
+ pointsRooms: A,
124
+ loadingLivePointsCheck: i,
127
125
  // Cash Rooms
128
126
  cashRooms: I,
129
127
  loadingCashRooms: n,
130
128
  // Best Checkout
131
- bestCheckout: u,
129
+ bestCheckout: l,
132
130
  loadingBestCheckout: w,
133
131
  // Combined availability
134
- isAvailable: h,
132
+ isAvailable: r,
135
133
  // Points as Cash
136
134
  pointsAsCash: N,
137
- hotelDetails: g(
135
+ hotelDetails: F(
138
136
  t,
139
- i,
140
- l
137
+ s,
138
+ u
141
139
  )
142
140
  };
143
141
  };
@@ -7,7 +7,6 @@ export declare const fetchTransferPartners: (hotelGroup: string) => Promise<any>
7
7
  interface IPointsCheckResult {
8
8
  pointsHotelDetails: IHotelDetails;
9
9
  pointsRooms: IRoom[];
10
- shouldFallbackBestCheckout: boolean;
11
10
  }
12
11
  interface IHotelPointsCheckParams {
13
12
  hotel: IHotelDetails;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@odynn/awayz-hotels",
3
3
  "private": false,
4
- "version": "0.1.16",
4
+ "version": "0.1.17",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"