@odynn/awayz-hotels 0.6.15 → 0.6.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.
@@ -0,0 +1,4 @@
1
+ var R = /* @__PURE__ */ ((S) => (S.LOCATIONS = "LOCATIONS", S.CHECK_USER = "CHECK_USER", S.USER_REGIONS = "USER_REGIONS", S.CONVERT_CURRENCY = "CONVERT_CURRENCY", S.CLIENT_COMPONENT_KEY = "CLIENT_COMPONENT_KEY", S.SEARCH_LIMIT = "SEARCH_LIMIT", S.PROGRAMS = "PROGRAMS", S.USER_PROGRAMS = "USER_PROGRAMS", S.LINKED_USER_PROGRAMS = "LINKED_USER_PROGRAMS", S.BANKS = "BANKS", S.CARDS = "CARDS", S.USER_CARDS = "USER_CARDS", S.TRIPS = "TRIPS", S.UNCATEGORISED_BOOKINGS = "UNCATEGORISED_BOOKINGS", S.BOOKING = "BOOKING", S.VALUE_CENTS = "VALUE_CENTS", S.AVAILABILITY_ALERTS = "AVAILABILITY_ALERTS", S.ALERT_NOTIFICATIONS = "ALERT_NOTIFICATIONS", S.POINTS_AS_CASH = "POINTS_AS_CASH", S))(R || {});
2
+ export {
3
+ R as E
4
+ };
@@ -2,7 +2,7 @@ import { awayzClient as i } from "@odynn/awayz-core";
2
2
  import { useQuery as m, useMutation as y } from "@tanstack/react-query";
3
3
  import "../../moment-BGjjqtLQ.js";
4
4
  import "../../arrayExtensions-CFEBYUok.js";
5
- import { E as e } from "../../enums-DxmoBOKL.js";
5
+ import { E as e } from "../../enums-D9aZqf8G.js";
6
6
  import "react";
7
7
  import { AvailabilityAlertsService as r } from "../../services/availabilityAlerts/AvailabilityAlertsService.js";
8
8
  const E = () => {
@@ -3,7 +3,7 @@ import { useQuery as f, useMutation as p } from "@tanstack/react-query";
3
3
  import "../../moment-BGjjqtLQ.js";
4
4
  import "../../arrayExtensions-CFEBYUok.js";
5
5
  import { c as b } from "../../objectUtils-DOsrxUF7.js";
6
- import { E as u } from "../../enums-DxmoBOKL.js";
6
+ import { E as u } from "../../enums-D9aZqf8G.js";
7
7
  import "react";
8
8
  import { AvailabilityAlertsService as w } from "../../services/availabilityAlerts/AvailabilityAlertsService.js";
9
9
  const h = ({
@@ -1,31 +1,35 @@
1
+ import "../../moment-BGjjqtLQ.js";
2
+ import "../../arrayExtensions-CFEBYUok.js";
3
+ import { a as C } from "../../index-yqIid8Pw.js";
4
+ import "react";
1
5
  import { HotelChains as p } from "../../definitions/HotelChains.js";
2
- import { EBestCheckoutType as h } from "../../enums/EBestCheckoutType.js";
6
+ import { EBestCheckoutType as f } from "../../enums/EBestCheckoutType.js";
3
7
  import { BookingService as y } from "../../services/booking/BookingService.js";
4
- import { EGuestType as C } from "../../services/booking/BookingService.enums.js";
5
- import { HotelService as f } from "../../services/hotel/HotelService.js";
6
- const w = async (s) => await f.getTransferPartners(
7
- p.toProgram(s)
8
- ), T = (s) => !!s.hotelGroup && !!s.hotelId && !!s.checkinDate && !!s.checkoutDate && !!s.rooms && !!s.guests, A = async ({
9
- hotel: s,
10
- checkinDate: t,
11
- checkoutDate: o,
8
+ import { EGuestType as d } from "../../services/booking/BookingService.enums.js";
9
+ import { HotelService as h } from "../../services/hotel/HotelService.js";
10
+ const G = async (t) => await h.getTransferPartners(
11
+ p.toProgram(t)
12
+ ), I = (t) => !!t.hotelGroup && !!t.hotelId && !!t.checkinDate && !!t.checkoutDate && !!t.rooms && !!t.guests, v = async ({
13
+ hotel: t,
14
+ checkinDate: o,
15
+ checkoutDate: s,
12
16
  updateHotel: a,
13
17
  signal: e
14
18
  }) => {
15
- let r = s, c = s.rooms ?? [];
16
- if (!s.liveScrapingCheckNeeded || s.hotelGroup === p.Marriott)
19
+ let r = t, c = t.rooms ?? [];
20
+ if (!t.liveScrapingCheckNeeded || t.hotelGroup === p.Marriott)
17
21
  return {
18
- pointsHotelDetails: s,
22
+ pointsHotelDetails: t,
19
23
  pointsRooms: c
20
24
  };
21
25
  let u = !1, i = null;
22
26
  try {
23
- const n = await f.hotelPointsCheck(
27
+ const n = await h.hotelPointsCheck(
24
28
  {
25
- hotelGroup: s.hotelGroup,
26
- hotelId: s.hotelId,
27
- checkinDate: t,
28
- checkoutDate: o
29
+ hotelGroup: t.hotelGroup,
30
+ hotelId: t.hotelId,
31
+ checkinDate: o,
32
+ checkoutDate: s
29
33
  },
30
34
  e
31
35
  );
@@ -34,106 +38,106 @@ const w = async (s) => await f.getTransferPartners(
34
38
  u = !1, i = null;
35
39
  }
36
40
  if (u) {
37
- const n = i, m = !(n.points.pointsValue > 0) && s.bestValue === h.POINTS;
41
+ const n = i, m = !(n.points.pointsValue > 0) && t.bestValue === f.POINTS;
38
42
  r = {
39
- ...s,
43
+ ...t,
40
44
  awardPoints: n.points.awardPointsValue ?? n.points.pointsValue,
41
45
  points: n.points.pointsValue,
42
46
  pointsType: n.points.pointsType,
43
- bestValue: m ? h.NONE : s.bestValue
44
- }, c = n.rooms ?? s.rooms ?? [], a(s.hotelId, s.hotelGroup, r);
47
+ bestValue: m ? f.NONE : t.bestValue
48
+ }, c = n.rooms ?? t.rooms ?? [], a(t.hotelId, t.hotelGroup, r);
45
49
  }
46
50
  return {
47
51
  pointsHotelDetails: r,
48
52
  pointsRooms: c
49
53
  };
50
- }, B = async ({
51
- hotel: s,
52
- checkinDate: t,
53
- checkoutDate: o,
54
+ }, E = async ({
55
+ hotel: t,
56
+ checkinDate: o,
57
+ checkoutDate: s,
54
58
  guests: a,
55
59
  rooms: e,
56
60
  updateHotel: r,
57
61
  numberOfNights: c
58
62
  }) => {
59
63
  var l;
60
- if (!((l = s == null ? void 0 : s.cashBookingOffers) != null && l.accommodationId))
64
+ if (!((l = t == null ? void 0 : t.cashBookingOffers) != null && l.accommodationId))
61
65
  return {
62
- cashHotelDetails: s,
66
+ cashHotelDetails: t,
63
67
  cashRooms: []
64
68
  };
65
- const u = (m) => Array.from({ length: m }, () => ({ type: C.ADULT })), i = await y.getAvailableRooms({
66
- checkinDate: t,
67
- checkoutDate: o,
68
- accommodationId: s.cashBookingOffers.accommodationId,
69
+ const u = (m) => Array.from({ length: m }, () => ({ type: d.ADULT })), i = await y.getAvailableRooms({
70
+ checkinDate: o,
71
+ checkoutDate: s,
72
+ accommodationId: t.cashBookingOffers.accommodationId,
69
73
  guests: u(a),
70
74
  rooms: e
71
75
  }), n = {
72
- ...s,
76
+ ...t,
73
77
  cashValue: {
74
- ...s.cashValue,
75
- amount: i.cheapestRate / c || s.cashValue.amount || 0,
76
- currency: i.currency ?? s.cashValue.currency
78
+ ...t.cashValue,
79
+ amount: i.cheapestRate / c || t.cashValue.amount || 0,
80
+ currency: i.currency ?? t.cashValue.currency
77
81
  }
78
82
  };
79
- return r(s.hotelId, s.hotelGroup, n), {
83
+ return r(t.hotelId, t.hotelGroup, n), {
80
84
  cashHotelDetails: n,
81
85
  cashRooms: i.availableRooms
82
86
  };
83
- }, G = async (s, t, o) => {
84
- const { success: a, data: e } = await f.getRecommendations({
85
- days: t,
86
- hotel: s
87
+ }, U = async (t, o, s) => {
88
+ const { success: a, data: e } = await h.getRecommendations({
89
+ days: o,
90
+ hotel: t
87
91
  });
88
92
  return a && e ? {
89
93
  bestCheckout: {
90
94
  ...e,
91
- nightlyPointsCost: o ? e.awardPoints : e.nightlyPointsCost
95
+ nightlyPointsCost: s ? e.awardPoints : e.nightlyPointsCost
92
96
  },
93
97
  isAvailable: e.nightlyPointsCost > 0 || e.nightlyCashCost > 0
94
98
  } : {
95
- bestCheckout: d(s, t),
99
+ bestCheckout: P(t, o),
96
100
  isAvailable: !1
97
101
  };
98
- }, d = (s, t) => {
102
+ }, P = (t, o) => {
99
103
  var r, c, u, i;
100
- const o = ((r = s.cashBookingOffers) == null ? void 0 : r.cheapestRateTotalAmount) ?? ((c = s.cashValue) == null ? void 0 : c.amount) ?? 0, a = ((u = s.cashBookingOffers) == null ? void 0 : u.cheapestRateCurrency) ?? ((i = s.cashValue) == null ? void 0 : i.currency) ?? "USD";
104
+ const s = ((r = t.cashBookingOffers) == null ? void 0 : r.cheapestRateTotalAmount) ?? ((c = t.cashValue) == null ? void 0 : c.amount) ?? 0, a = ((u = t.cashBookingOffers) == null ? void 0 : u.cheapestRateCurrency) ?? ((i = t.cashValue) == null ? void 0 : i.currency) ?? C;
101
105
  return {
102
- bestCheckoutMethod: p.isHotelChain(s.hotelGroup) ? s.bestValue : h.CASH,
103
- nightlyCashCost: o,
104
- nightlyPointsCost: s.points || 0,
105
- awardPoints: s.points || 0,
106
- totalCashCost: o * t,
107
- totalPointsCost: (s.points || 0) * t,
106
+ bestCheckoutMethod: p.isHotelChain(t.hotelGroup) ? t.bestValue : f.CASH,
107
+ nightlyCashCost: s,
108
+ nightlyPointsCost: t.points || 0,
109
+ awardPoints: t.points || 0,
110
+ totalCashCost: s * o,
111
+ totalPointsCost: (t.points || 0) * o,
108
112
  currency: a,
109
113
  sufficientPoints: !0,
110
- rewardsProgram: p.toProgram(s.hotelGroup),
114
+ rewardsProgram: p.toProgram(t.hotelGroup),
111
115
  optimalProgram: {
112
116
  programs: [],
113
117
  remainingPointsBalance: 0,
114
118
  totalProgramPointsValuation: 0
115
119
  }
116
120
  };
117
- }, I = (s, t, o) => {
118
- let a = s;
119
- return t && (a = {
120
- ...s,
121
- points: t.points,
122
- awardPoints: t.awardPoints,
123
- pointsType: t.pointsType,
124
- bestValue: t.bestValue
125
- }), o && (a = {
121
+ }, O = (t, o, s) => {
122
+ let a = t;
123
+ return o && (a = {
124
+ ...t,
125
+ points: o.points,
126
+ awardPoints: o.awardPoints,
127
+ pointsType: o.pointsType,
128
+ bestValue: o.bestValue
129
+ }), s && (a = {
126
130
  ...a,
127
- cashValue: o.cashValue,
128
- rooms: o.rooms
131
+ cashValue: s.cashValue,
132
+ rooms: s.rooms
129
133
  }), a;
130
134
  };
131
135
  export {
132
- I as combineUpdatedHotelData,
133
- d as fallbackBestCheckout,
134
- B as fetchAvailableRooms,
135
- G as fetchBestCheckout,
136
- A as fetchPointsCheck,
137
- w as fetchTransferPartners,
138
- T as isPartialHotelDetails
136
+ O as combineUpdatedHotelData,
137
+ P as fallbackBestCheckout,
138
+ E as fetchAvailableRooms,
139
+ U as fetchBestCheckout,
140
+ v as fetchPointsCheck,
141
+ G as fetchTransferPartners,
142
+ I as isPartialHotelDetails
139
143
  };
@@ -1,95 +1,97 @@
1
- import { g as oe } from "../../dateUtils-C1hKW8MF.js";
2
- import { E as N } from "../../DateFormats-DZD30Nea.js";
1
+ import { g as ae } from "../../dateUtils-C1hKW8MF.js";
2
+ import { a as ce } from "../../index-yqIid8Pw.js";
3
+ import { E as T } from "../../DateFormats-DZD30Nea.js";
3
4
  import "../../arrayExtensions-CFEBYUok.js";
4
- import { useState as ce, useMemo as D } from "react";
5
- import ae from "../../stores/useHotelsStore.js";
6
- import { isPartialHotelDetails as se, fetchTransferPartners as ie, fetchPointsCheck as re, fetchAvailableRooms as ne, combineUpdatedHotelData as T, fallbackBestCheckout as le, fetchBestCheckout as he } from "./useHotelDetails.api.js";
7
- import { useAwayzContext as ue, useWallet as De } from "@odynn/awayz-core";
5
+ import { useState as se, useMemo as D } from "react";
6
+ import ie from "../../stores/useHotelsStore.js";
7
+ import { isPartialHotelDetails as re, fetchTransferPartners as ne, fetchPointsCheck as le, fetchAvailableRooms as he, combineUpdatedHotelData as U, fallbackBestCheckout as ue, fetchBestCheckout as De } from "./useHotelDetails.api.js";
8
+ import { useAwayzContext as fe, useWallet as me } from "@odynn/awayz-core";
8
9
  import { useQuery as r } from "@tanstack/react-query";
9
10
  import { h as n } from "../../moment-BGjjqtLQ.js";
10
- import { livePointsCheckTimeout as fe } from "../../configs/defaults.js";
11
- import { HotelChains as me } from "../../definitions/HotelChains.js";
12
- import { IhgFreeNightCards as ke } from "../../definitions/IhgFreeNightCards.js";
13
- import { HotelService as de } from "../../services/hotel/HotelService.js";
14
- import { calculatePointsAsCash as pe } from "../../utilities/pointsAsCashUtils.js";
15
- const ge = "USD", we = (c) => {
16
- var b, H, R, O, q, A, S, G, _, B, w, K, P, E;
17
- if (!c)
11
+ import { livePointsCheckTimeout as ke } from "../../configs/defaults.js";
12
+ import { HotelChains as de } from "../../definitions/HotelChains.js";
13
+ import { IhgFreeNightCards as pe } from "../../definitions/IhgFreeNightCards.js";
14
+ import { HotelService as ge } from "../../services/hotel/HotelService.js";
15
+ import { calculatePointsAsCash as ye } from "../../utilities/pointsAsCashUtils.js";
16
+ const Pe = (a) => {
17
+ var H, R, O, q, A, S, _, G, B, w, K, P, E, N;
18
+ if (!a)
18
19
  throw new Error(
19
20
  "Hotel is required in order to initiate the hotel details flow"
20
21
  );
21
- const { user: f } = ue(), { updateHotel: p, searchParams: o } = ae(), s = se(c), [e, U] = ce({
22
- checkinDate: s ? n(c.checkinDate) : o == null ? void 0 : o.checkinDate,
23
- checkoutDate: s ? n(c.checkoutDate) : o == null ? void 0 : o.checkoutDate
22
+ const { user: f, config: m } = fe(), { updateHotel: g, searchParams: o } = ie(), s = re(a), [e, W] = se({
23
+ checkinDate: s ? n(a.checkinDate) : o == null ? void 0 : o.checkinDate,
24
+ checkoutDate: s ? n(a.checkoutDate) : o == null ? void 0 : o.checkoutDate
24
25
  }), {
25
26
  data: i,
26
- isFetching: W,
27
- isFetched: m
27
+ isFetching: x,
28
+ isFetched: k
28
29
  } = r({
29
30
  queryKey: [
30
31
  "hotelDetails",
31
- c.hotelId,
32
- c.hotelGroup,
33
- (b = e == null ? void 0 : e.checkinDate) == null ? void 0 : b.valueOf(),
34
- (H = e == null ? void 0 : e.checkoutDate) == null ? void 0 : H.valueOf()
32
+ a.hotelId,
33
+ a.hotelGroup,
34
+ (H = e == null ? void 0 : e.checkinDate) == null ? void 0 : H.valueOf(),
35
+ (R = e == null ? void 0 : e.checkoutDate) == null ? void 0 : R.valueOf()
35
36
  ],
36
37
  queryFn: () => {
37
- var a;
38
- return de.searchByHotelId({
39
- hotel_group: c.hotelGroup,
40
- hotel_id: c.hotelId,
38
+ var c;
39
+ return ge.searchByHotelId({
40
+ hotel_group: a.hotelGroup,
41
+ hotel_id: a.hotelId,
41
42
  check_in_date: n(e.checkinDate).format(
42
- N.ServerDate
43
+ T.ServerDate
43
44
  ),
44
45
  check_out_date: n(e.checkoutDate).format(
45
- N.ServerDate
46
+ T.ServerDate
46
47
  ),
47
- guests: c.guests,
48
- rooms: c.rooms,
49
- currency: ((a = f == null ? void 0 : f.userRegion) == null ? void 0 : a.currency) || ge,
50
- cash_or_points: ["cash", "points"]
48
+ guests: a.guests,
49
+ rooms: a.rooms,
50
+ currency: ((c = f == null ? void 0 : f.userRegion) == null ? void 0 : c.currency) || ce,
51
+ cash_or_points: ["cash", "points"],
52
+ use_duffel: m == null ? void 0 : m.useDuffel
51
53
  });
52
54
  },
53
55
  enabled: s && !!e.checkinDate && !!e.checkoutDate,
54
56
  retry: !1
55
57
  }), t = D(() => {
56
- var a;
57
- return s ? i != null && i.success && ((a = i.data) != null && a[0]) ? i.data[0] : {} : c;
58
- }, [s, i, c]), h = D(() => oe(e.checkinDate, e.checkoutDate), [e]), x = (a, l) => {
59
- U({
60
- checkinDate: n(a),
58
+ var c;
59
+ return s ? i != null && i.success && ((c = i.data) != null && c[0]) ? i.data[0] : {} : a;
60
+ }, [s, i, a]), h = D(() => ae(e.checkinDate, e.checkoutDate), [e]), L = (c, l) => {
61
+ W({
62
+ checkinDate: n(c),
61
63
  checkoutDate: n(l)
62
64
  });
63
- }, { userCards: u } = De(), g = D(() => (t == null ? void 0 : t.hotelGroup) === me.IHG ? ke.some(
64
- (a) => u == null ? void 0 : u.some((l) => l.name === a)
65
- ) : !0, [u]), { data: L, isFetching: z } = r({
65
+ }, { userCards: u } = me(), y = D(() => (t == null ? void 0 : t.hotelGroup) === de.IHG ? pe.some(
66
+ (c) => u == null ? void 0 : u.some((l) => l.name === c)
67
+ ) : !0, [u]), { data: z, isFetching: I } = r({
66
68
  queryKey: ["transferPartners", t.hotelGroup],
67
- queryFn: () => ie(t.hotelGroup),
69
+ queryFn: () => ne(t.hotelGroup),
68
70
  enabled: !!t.hotelGroup,
69
71
  placeholderData: []
70
72
  }), {
71
- data: I,
72
- isFetching: y,
73
- isFetched: M
73
+ data: M,
74
+ isFetching: v,
75
+ isFetched: Q
74
76
  } = r({
75
77
  queryKey: [
76
78
  "hotelPointsCheck",
77
79
  t.hotelId,
78
80
  t.hotelGroup,
79
- (R = e == null ? void 0 : e.checkinDate) == null ? void 0 : R.valueOf(),
80
- (O = e == null ? void 0 : e.checkoutDate) == null ? void 0 : O.valueOf()
81
+ (O = e == null ? void 0 : e.checkinDate) == null ? void 0 : O.valueOf(),
82
+ (q = e == null ? void 0 : e.checkoutDate) == null ? void 0 : q.valueOf()
81
83
  ],
82
- queryFn: ({ signal: a }) => {
83
- const l = AbortSignal.timeout(fe), te = AbortSignal.any([a, l]);
84
- return re({
84
+ queryFn: ({ signal: c }) => {
85
+ const l = AbortSignal.timeout(ke), oe = AbortSignal.any([c, l]);
86
+ return le({
85
87
  hotel: t,
86
88
  checkinDate: e.checkinDate,
87
89
  checkoutDate: e.checkoutDate,
88
- updateHotel: p,
89
- signal: te
90
+ updateHotel: g,
91
+ signal: oe
90
92
  });
91
93
  },
92
- enabled: !!e.checkinDate && !!e.checkoutDate && !!t.liveScrapingCheckNeeded && (!s || m),
94
+ enabled: !!e.checkinDate && !!e.checkoutDate && !!t.liveScrapingCheckNeeded && (!s || k),
93
95
  // We don't throw an error on fail so we can gracefully handle fallback
94
96
  retry: !1,
95
97
  refetchOnWindowFocus: !1,
@@ -98,107 +100,107 @@ const ge = "USD", we = (c) => {
98
100
  pointsHotelDetails: t,
99
101
  pointsRooms: t.rooms ?? []
100
102
  }
101
- }), { pointsRooms: Q, pointsHotelDetails: k } = I || {
103
+ }), { pointsRooms: Y, pointsHotelDetails: d } = M || {
102
104
  pointsHotelDetails: t,
103
105
  pointsRooms: []
104
106
  }, {
105
- data: Y,
106
- isFetching: v,
107
- isFetched: j
107
+ data: j,
108
+ isFetching: C,
109
+ isFetched: J
108
110
  } = r({
109
111
  queryKey: [
110
112
  "fetchAvailableRooms",
111
- (q = t.cashBookingOffers) == null ? void 0 : q.accommodationId,
112
- (A = e == null ? void 0 : e.checkinDate) == null ? void 0 : A.valueOf(),
113
- (S = e == null ? void 0 : e.checkoutDate) == null ? void 0 : S.valueOf(),
113
+ (A = t.cashBookingOffers) == null ? void 0 : A.accommodationId,
114
+ (S = e == null ? void 0 : e.checkinDate) == null ? void 0 : S.valueOf(),
115
+ (_ = e == null ? void 0 : e.checkoutDate) == null ? void 0 : _.valueOf(),
114
116
  o == null ? void 0 : o.guests,
115
117
  o == null ? void 0 : o.rooms
116
118
  ],
117
- queryFn: () => ne({
119
+ queryFn: () => he({
118
120
  hotel: t,
119
121
  checkinDate: e.checkinDate,
120
122
  checkoutDate: e.checkoutDate,
121
123
  guests: o.guests,
122
124
  rooms: o.rooms,
123
- updateHotel: p,
125
+ updateHotel: g,
124
126
  numberOfNights: h
125
127
  }),
126
- enabled: !!e.checkinDate && !!e.checkoutDate && !!((G = t.cashBookingOffers) != null && G.accommodationId) && (!s || m),
128
+ enabled: !!e.checkinDate && !!e.checkoutDate && !!((G = t.cashBookingOffers) != null && G.accommodationId) && (!s || k),
127
129
  retry: !1,
128
130
  placeholderData: {
129
131
  cashHotelDetails: t,
130
132
  cashRooms: []
131
133
  }
132
- }), { cashRooms: J, cashHotelDetails: d } = Y || {
134
+ }), { cashRooms: V, cashHotelDetails: p } = j || {
133
135
  cashHotelDetails: t,
134
136
  cashRooms: []
135
- }, V = D(
136
- () => T(t, k, d),
137
- [t, k, d]
137
+ }, X = D(
138
+ () => U(t, d, p),
139
+ [t, d, p]
138
140
  ), {
139
- data: X,
140
- isFetching: Z,
141
- isFetched: $
141
+ data: Z,
142
+ isFetching: $,
143
+ isFetched: ee
142
144
  } = r({
143
145
  queryKey: [
144
146
  "bestCheckout",
145
147
  t.hotelId,
146
148
  t.hotelGroup,
147
- (_ = e == null ? void 0 : e.checkinDate) == null ? void 0 : _.valueOf(),
148
- (B = e == null ? void 0 : e.checkoutDate) == null ? void 0 : B.valueOf(),
149
- g
149
+ (B = e == null ? void 0 : e.checkinDate) == null ? void 0 : B.valueOf(),
150
+ (w = e == null ? void 0 : e.checkoutDate) == null ? void 0 : w.valueOf(),
151
+ y
150
152
  ],
151
- queryFn: () => he(
152
- V,
153
+ queryFn: () => De(
154
+ X,
153
155
  h,
154
- g
156
+ y
155
157
  ),
156
- enabled: !((w = t.hotelId) != null && w.startsWith("duff_")) && !y && (t.liveScrapingCheckNeeded ? M : !0) && !v && ((K = t.cashBookingOffers) != null && K.accommodationId ? j : !0) && h > 0 && t.points >= 0 && (!s || m),
158
+ enabled: !((K = t.hotelId) != null && K.startsWith("duff_")) && !v && (t.liveScrapingCheckNeeded ? Q : !0) && !C && ((P = t.cashBookingOffers) != null && P.accommodationId ? J : !0) && h > 0 && t.points >= 0 && (!s || k),
157
159
  retry: !1,
158
160
  placeholderData: {
159
- bestCheckout: le(t, h),
161
+ bestCheckout: ue(t, h),
160
162
  isAvailable: !1
161
163
  }
162
- }), { bestCheckout: C, isAvailable: F } = X || {
164
+ }), { bestCheckout: F, isAvailable: b } = Z || {
163
165
  isAvailable: !1
164
- }, { data: ee } = r({
166
+ }, { data: te } = r({
165
167
  queryKey: [
166
168
  "pointsAsCash",
167
169
  t.hotelId,
168
170
  t.hotelGroup,
169
- (P = e == null ? void 0 : e.checkinDate) == null ? void 0 : P.valueOf(),
170
- (E = e == null ? void 0 : e.checkoutDate) == null ? void 0 : E.valueOf()
171
+ (E = e == null ? void 0 : e.checkinDate) == null ? void 0 : E.valueOf(),
172
+ (N = e == null ? void 0 : e.checkoutDate) == null ? void 0 : N.valueOf()
171
173
  ],
172
- queryFn: () => pe(C.totalCashCost),
173
- enabled: $ && F,
174
+ queryFn: () => ye(F.totalCashCost),
175
+ enabled: ee && b,
174
176
  retry: !1
175
177
  });
176
178
  return {
177
- transferPartners: L || [],
178
- loadingTransferPartners: z,
179
+ transferPartners: z || [],
180
+ loadingTransferPartners: I,
179
181
  // Hotel Details
180
- loadingHotelDetails: W,
182
+ loadingHotelDetails: x,
181
183
  // Points Check
182
- pointsRooms: Q || [],
183
- loadingLivePointsCheck: y,
184
+ pointsRooms: Y || [],
185
+ loadingLivePointsCheck: v,
184
186
  // Cash Rooms
185
- cashRooms: J || [],
186
- loadingCashRooms: v,
187
+ cashRooms: V || [],
188
+ loadingCashRooms: C,
187
189
  // Best Checkout
188
- bestCheckout: C,
189
- loadingBestCheckout: Z,
190
+ bestCheckout: F,
191
+ loadingBestCheckout: $,
190
192
  // Combined availability
191
- isAvailable: F,
193
+ isAvailable: b,
192
194
  // Points as Cash
193
- pointsAsCash: ee,
194
- hotelDetails: T(
195
+ pointsAsCash: te,
196
+ hotelDetails: U(
195
197
  t,
196
- k,
197
- d
198
+ d,
199
+ p
198
200
  ),
199
- updateDates: x
201
+ updateDates: L
200
202
  };
201
203
  };
202
204
  export {
203
- we as useHotelDetails
205
+ Pe as useHotelDetails
204
206
  };
@@ -1,51 +1,52 @@
1
- import { useAwayzContext as P, useWallet as T, awayzClient as d } from "@odynn/awayz-core";
1
+ import { useAwayzContext as P, useWallet as A, awayzClient as d } from "@odynn/awayz-core";
2
2
  import { useMutation as m } from "@tanstack/react-query";
3
- import { g as B } from "../../dateUtils-C1hKW8MF.js";
4
- import { E as p } from "../../enums-DxmoBOKL.js";
3
+ import { g as N } from "../../dateUtils-C1hKW8MF.js";
4
+ import { D as B, a as p } from "../../index-yqIid8Pw.js";
5
+ import { E as f } from "../../enums-D9aZqf8G.js";
5
6
  import "../../arrayExtensions-CFEBYUok.js";
6
7
  import "react";
7
- import { h as a } from "../../moment-BGjjqtLQ.js";
8
- import { HotelChains as s } from "../../definitions/HotelChains.js";
9
- import { HotelService as f } from "../../services/hotel/HotelService.js";
10
- import { ESearchType as k } from "../../services/hotel/HotelService.types.js";
8
+ import { h as u } from "../../moment-BGjjqtLQ.js";
9
+ import { HotelChains as i } from "../../definitions/HotelChains.js";
10
+ import { HotelService as k } from "../../services/hotel/HotelService.js";
11
+ import { ESearchType as y } from "../../services/hotel/HotelService.types.js";
11
12
  import G from "../../stores/useHotelsStore.js";
12
- import { checkNthNightFree as x } from "../../utilities/hotelUtils/freeNightUtils.js";
13
- const A = (t) => {
13
+ import { checkNthNightFree as F } from "../../utilities/hotelUtils/freeNightUtils.js";
14
+ const x = (t) => {
14
15
  if (!t.checkinDate || !t.checkoutDate)
15
16
  throw new Error("Check-in and checkout dates are required.");
16
17
  if (!t.coordinates)
17
18
  throw new Error("Coordinates are required.");
18
- t.hotelGroups && t.hotelGroups.forEach((i) => {
19
- if (!s.toList().includes(i))
19
+ t.hotelGroups && t.hotelGroups.forEach((h) => {
20
+ if (!i.toList().includes(h))
20
21
  throw new Error(
21
- `Invalid hotel group: ${i}. Please use one of the following: ${s.toList().join(
22
+ `Invalid hotel group: ${h}. Please use one of the following: ${i.toList().join(
22
23
  ", "
23
24
  )}`
24
25
  );
25
26
  });
26
- }, N = (t) => {
27
+ }, R = (t) => {
27
28
  if (!t.checkinDate || !t.checkoutDate)
28
29
  throw new Error("Check-in and checkout dates are required.");
29
30
  if (!t.hotelName)
30
31
  throw new Error("Hotel name is required");
31
32
  if (!t.hotelGroup)
32
33
  throw new Error("Hotel group is required");
33
- if (!s.toList().includes(t.hotelGroup))
34
+ if (!i.toList().includes(t.hotelGroup))
34
35
  throw new Error(
35
- `Invalid hotel group: ${t.hotelGroup}. Please use one of the following: ${s.toList().join(", ")}`
36
+ `Invalid hotel group: ${t.hotelGroup}. Please use one of the following: ${i.toList().join(", ")}`
36
37
  );
37
- }, Y = () => {
38
- const { setHotels: t, hotels: i, setSearchParams: l } = G(), { config: u } = P(), { userCards: y } = T(), {
39
- mutate: D,
38
+ }, Z = () => {
39
+ const { setHotels: t, hotels: h, setSearchParams: l } = G(), { config: r } = P(), { userCards: D } = A(), {
40
+ mutate: _,
40
41
  isPending: w,
41
- status: S,
42
- isError: _,
43
- error: E
42
+ status: E,
43
+ isError: S,
44
+ error: C
44
45
  } = m({
45
46
  mutationFn: async (e) => {
46
- A(e), t([]), l({
47
- checkinDate: a(e.checkinDate),
48
- checkoutDate: a(e.checkoutDate),
47
+ x(e), t([]), l({
48
+ checkinDate: u(e.checkinDate),
49
+ checkoutDate: u(e.checkoutDate),
49
50
  guests: e.guests || 2,
50
51
  rooms: e.rooms || 1
51
52
  });
@@ -55,56 +56,57 @@ const A = (t) => {
55
56
  guests: e.guests || 2,
56
57
  rooms: e.rooms || 1,
57
58
  cash_or_points: e.cashOrPoints || ["cash", "points"],
58
- currency: e.currency || "USD",
59
+ currency: e.currency || p,
59
60
  lat: e.coordinates.latitude,
60
61
  lon: e.coordinates.longitude,
61
62
  search_range: e.searchRange || 10,
62
- range_type: e.rangeType || "mi",
63
- hotel_groups: e.hotelGroups || s.toList(),
64
- type: e.searchType || k.CITY,
65
- external_inventory: (u == null ? void 0 : u.externalInventory) || !1
63
+ range_type: e.rangeType || B,
64
+ hotel_groups: e.hotelGroups || i.toList(),
65
+ type: e.searchType || y.CITY,
66
+ external_inventory: (r == null ? void 0 : r.externalInventory) || !1,
67
+ use_duffel: r == null ? void 0 : r.useDuffel
66
68
  };
67
69
  return {
68
- ...await f.searchByCoords(o),
70
+ ...await k.searchByCoords(o),
69
71
  checkinDate: e.checkinDate,
70
72
  checkoutDate: e.checkoutDate
71
73
  };
72
74
  },
73
75
  onSuccess: (e) => {
74
76
  if (e.success) {
75
- const { checkinDate: o, checkoutDate: r } = e, n = B(o, r), h = e.data.map((c) => ({
76
- ...c,
77
- nthNightFree: x({
78
- hotel: c,
79
- cards: y ?? [],
77
+ const { checkinDate: o, checkoutDate: c } = e, n = N(o, c), a = e.data.map((s) => ({
78
+ ...s,
79
+ nthNightFree: F({
80
+ hotel: s,
81
+ cards: D ?? [],
80
82
  nights: n
81
83
  })
82
84
  }));
83
- t(h);
85
+ t(a);
84
86
  }
85
87
  },
86
88
  onSettled: () => {
87
- d.invalidateQueries({ queryKey: [p.SEARCH_LIMIT] });
89
+ d.invalidateQueries({ queryKey: [f.SEARCH_LIMIT] });
88
90
  }
89
91
  });
90
- function C(e, o) {
91
- let r = 0;
92
- const n = e.length < o.length ? e : o, h = e.length >= o.length ? e : o;
93
- for (let c = 0; c < n.length; c++)
94
- e[c] === o[c] && r++;
95
- return r / h.length;
92
+ function I(e, o) {
93
+ let c = 0;
94
+ const n = e.length < o.length ? e : o, a = e.length >= o.length ? e : o;
95
+ for (let s = 0; s < n.length; s++)
96
+ e[s] === o[s] && c++;
97
+ return c / a.length;
96
98
  }
97
99
  const {
98
100
  mutate: H,
99
- isPending: I,
100
- status: v,
101
- isError: L,
101
+ isPending: L,
102
+ status: T,
103
+ isError: v,
102
104
  error: q
103
105
  } = m({
104
106
  mutationFn: async (e) => {
105
- N(e), t([]), l({
106
- checkinDate: a(e.checkinDate),
107
- checkoutDate: a(e.checkoutDate),
107
+ R(e), t([]), l({
108
+ checkinDate: u(e.checkinDate),
109
+ checkoutDate: u(e.checkoutDate),
108
110
  guests: e.guests || 2,
109
111
  rooms: e.rooms || 1
110
112
  });
@@ -114,42 +116,43 @@ const A = (t) => {
114
116
  guests: e.guests || 2,
115
117
  rooms: e.rooms || 1,
116
118
  cash_or_points: e.cashOrPoints || ["cash", "points"],
117
- currency: e.currency || "USD",
119
+ currency: e.currency || p,
118
120
  lat: e.coordinates.latitude,
119
121
  lon: e.coordinates.longitude,
120
122
  search_range: 0.5,
121
123
  range_type: "km",
122
124
  hotel_groups: [e.hotelGroup],
123
- type: k.HOTEL,
124
- external_inventory: !1
125
- }, r = await f.searchByCoords(o);
126
- if (!r.success)
127
- throw new Error(r.message || "Hotel search failed");
125
+ type: y.HOTEL,
126
+ external_inventory: !1,
127
+ use_duffel: r == null ? void 0 : r.useDuffel
128
+ }, c = await k.searchByCoords(o);
129
+ if (!c.success)
130
+ throw new Error(c.message || "Hotel search failed");
128
131
  const n = 0.8;
129
- return r.data.filter(
130
- (c) => C(c.name.toLowerCase(), e.hotelName.toLowerCase()) >= n
132
+ return c.data.filter(
133
+ (s) => I(s.name.toLowerCase(), e.hotelName.toLowerCase()) >= n
131
134
  );
132
135
  },
133
136
  onSuccess: (e) => {
134
137
  t(e);
135
138
  },
136
139
  onSettled: () => {
137
- d.invalidateQueries({ queryKey: [p.SEARCH_LIMIT] });
140
+ d.invalidateQueries({ queryKey: [f.SEARCH_LIMIT] });
138
141
  }
139
142
  });
140
143
  return {
141
- results: i,
142
- loading: S === "pending" || v === "pending" || w || I,
143
- isCoordsSearchError: _,
144
- coordsSearchError: E,
145
- isHotelIdSearchError: L,
144
+ results: h,
145
+ loading: E === "pending" || T === "pending" || w || L,
146
+ isCoordsSearchError: S,
147
+ coordsSearchError: C,
148
+ isHotelIdSearchError: v,
146
149
  hotelIdSearchError: q,
147
- searchByCoords: D,
150
+ searchByCoords: _,
148
151
  searchByHotelId: H
149
152
  };
150
153
  };
151
154
  export {
152
- Y as useHotelSearch,
153
- A as validateSearchByCoordsArgs,
154
- N as validateSearchByHotelIdArgs
155
+ Z as useHotelSearch,
156
+ x as validateSearchByCoordsArgs,
157
+ R as validateSearchByHotelIdArgs
155
158
  };
@@ -2,7 +2,7 @@ import { useQuery as u } from "@tanstack/react-query";
2
2
  import { HotelService as l } from "../../services/hotel/HotelService.js";
3
3
  import "../../moment-BGjjqtLQ.js";
4
4
  import "../../arrayExtensions-CFEBYUok.js";
5
- import { E as d } from "../../enums-DxmoBOKL.js";
5
+ import { E as d } from "../../enums-D9aZqf8G.js";
6
6
  import { useState as f, useEffect as L } from "react";
7
7
  import { defaultSimilarityThreshold as p, defaultLocationSortOrder as y, duffelTestHotelLocation as T } from "../../configs/defaults.js";
8
8
  import { sortLocationResults as E } from "../../utilities/hotelUtils/hotelUtils.js";
@@ -0,0 +1,5 @@
1
+ const D = "USD", U = "mi";
2
+ export {
3
+ U as D,
4
+ D as a
5
+ };
@@ -31,6 +31,12 @@ export interface ISearchByCoordsParams extends ISearchByParams {
31
31
  * @type ESearchType
32
32
  */
33
33
  searchType?: ESearchType;
34
+ /**
35
+ * Optional use duffel
36
+ * @default 'True'
37
+ * @type boolean
38
+ */
39
+ useDuffel?: boolean;
34
40
  }
35
41
  export interface ISearchByHotelIdParams extends ISearchByParams {
36
42
  /**
@@ -49,6 +55,12 @@ export interface ISearchByHotelIdParams extends ISearchByParams {
49
55
  * @type string
50
56
  */
51
57
  hotelName: string;
58
+ /**
59
+ * Optional use duffel
60
+ * @default 'True'
61
+ * @type boolean
62
+ */
63
+ useDuffel?: boolean;
52
64
  }
53
65
  interface ISearchByParams {
54
66
  /**
@@ -14,6 +14,7 @@ export interface ISearchHotelsParams {
14
14
  cash_or_points: string[];
15
15
  currency: string;
16
16
  external_inventory: boolean;
17
+ use_duffel?: boolean;
17
18
  }
18
19
  export declare enum ESearchType {
19
20
  HOTEL = "Hotel Search",
@@ -157,6 +158,7 @@ export interface ISearchByHotelIdRequest {
157
158
  rooms: number;
158
159
  currency: string;
159
160
  cash_or_points: string[];
161
+ use_duffel?: boolean;
160
162
  }
161
163
  export interface IBestCheckoutResponse {
162
164
  award_points: number;
@@ -61,8 +61,7 @@ class v {
61
61
  var s, o;
62
62
  try {
63
63
  const { data: t } = await _.post(l.SEARCH_HOTELS, {
64
- ...a,
65
- use_duffel: !0
64
+ ...a
66
65
  });
67
66
  return t != null && t.success ? {
68
67
  success: !0,
@@ -84,8 +83,7 @@ class v {
84
83
  var s, o;
85
84
  try {
86
85
  const { data: t } = await _.post(l.GET_HOTEL_DATA, {
87
- ...a,
88
- use_duffel: !0
86
+ ...a
89
87
  });
90
88
  return t != null && t.success ? {
91
89
  success: !0,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@odynn/awayz-hotels",
3
3
  "private": false,
4
- "version": "0.6.15",
4
+ "version": "0.6.17",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -1,4 +0,0 @@
1
- var S = /* @__PURE__ */ ((R) => (R.LOCATIONS = "LOCATIONS", R.CHECK_USER = "CHECK_USER", R.USER_REGIONS = "USER_REGIONS", R.CONVERT_CURRENCY = "CONVERT_CURRENCY", R.CLIENT_COMPONENT_KEY = "CLIENT_COMPONENT_KEY", R.SEARCH_LIMIT = "SEARCH_LIMIT", R.PROGRAMS = "PROGRAMS", R.USER_PROGRAMS = "USER_PROGRAMS", R.LINKED_USER_PROGRAMS = "LINKED_USER_PROGRAMS", R.BANKS = "BANKS", R.CARDS = "CARDS", R.USER_CARDS = "USER_CARDS", R.TRIPS = "TRIPS", R.UNCATEGORISED_BOOKINGS = "UNCATEGORISED_BOOKINGS", R.BOOKING = "BOOKING", R.VALUE_CENTS = "VALUE_CENTS", R.AVAILABILITY_ALERTS = "AVAILABILITY_ALERTS", R.ALERT_NOTIFICATIONS = "ALERT_NOTIFICATIONS", R))(S || {});
2
- export {
3
- S as E
4
- };