@odynn/awayz-hotels 0.1.15 → 0.1.16

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