@odynn/awayz-hotels 0.1.18 → 0.1.19

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,144 +1,150 @@
1
- import { useMemo as M } from "react";
2
- import { h as v } from "../../moment-BGjjqtLQ.js";
1
+ import { useState as L, useMemo as Q } from "react";
2
+ import { h as i } from "../../moment-BGjjqtLQ.js";
3
3
  import "../../arrayExtensions-cyilNkdJ.js";
4
- import T from "../../stores/useHotelsStore.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
- import { calculatePointsAsCash as j } from "../../utilities/pointsAsCashUtils.js";
7
- import { useQuery as o } from "@tanstack/react-query";
8
- const z = (t, c) => Math.abs(
9
- v(t.startOf("day")).diff(v(c.endOf("day")), "days")
10
- ), $ = (t) => {
11
- var d, h, f, k, D, p, y, b, C, g, m;
4
+ import U from "../../stores/useHotelsStore.js";
5
+ import { fetchTransferPartners as j, fetchPointsCheck as z, fetchAvailableRooms as J, fetchBestCheckout as V, combineUpdatedHotelData as O, fallbackBestCheckout as W } from "./useHotelDetails.api.js";
6
+ import { calculatePointsAsCash as X } from "../../utilities/pointsAsCashUtils.js";
7
+ import { useQuery as c } from "@tanstack/react-query";
8
+ const Y = (t, a) => Math.abs(
9
+ i(t.startOf("day")).diff(i(a.endOf("day")), "days")
10
+ ), ae = (t) => {
11
+ var k, f, d, p, m, y, b, C, g, v, F;
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: c, searchParams: e } = T(), a = M(() => e ? z(
17
- e.checkinDate,
18
- e.checkoutDate
19
- ) : 0, [e]), { data: O, isFetching: q } = o({
16
+ const { updateHotel: a, searchParams: o } = U(), [e, q] = L({
17
+ checkinDate: o == null ? void 0 : o.checkinDate,
18
+ checkoutDate: o == null ? void 0 : o.checkoutDate
19
+ }), s = Q(() => Y(e.checkinDate, e.checkoutDate), [e]), H = (x, E) => {
20
+ q({
21
+ checkinDate: i(x),
22
+ checkoutDate: i(E)
23
+ });
24
+ }, { data: R, isFetching: A } = c({
20
25
  queryKey: ["transferPartners", t.hotelGroup],
21
- queryFn: () => x(t.hotelGroup),
26
+ queryFn: () => j(t.hotelGroup),
22
27
  enabled: !!t.hotelGroup,
23
28
  placeholderData: []
24
29
  }), {
25
- data: H,
26
- isFetching: i,
27
- isFetched: R
28
- } = o({
30
+ data: B,
31
+ isFetching: n,
32
+ isFetched: G
33
+ } = c({
29
34
  queryKey: [
30
35
  "hotelPointsCheck",
31
36
  t.hotelId,
32
37
  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()
38
+ (k = e == null ? void 0 : e.checkinDate) == null ? void 0 : k.valueOf(),
39
+ (f = e == null ? void 0 : e.checkoutDate) == null ? void 0 : f.valueOf()
35
40
  ],
36
- queryFn: () => E({
41
+ queryFn: () => z({
37
42
  hotel: t,
38
43
  checkinDate: e.checkinDate,
39
44
  checkoutDate: e.checkoutDate,
40
- updateHotel: c
45
+ updateHotel: a
41
46
  }),
42
- enabled: !!e && !!e.checkinDate && !!e.checkoutDate && !!t.liveScrapingCheckNeeded,
47
+ enabled: !!e.checkinDate && !!e.checkoutDate && !!t.liveScrapingCheckNeeded,
43
48
  // We don't throw an error on fail so we can gracefully handle fallback
44
49
  retry: !1,
45
50
  placeholderData: {
46
51
  pointsHotelDetails: t,
47
52
  pointsRooms: t.rooms ?? []
48
53
  }
49
- }), { pointsRooms: A, pointsHotelDetails: s } = H || {
54
+ }), { pointsRooms: I, pointsHotelDetails: r } = B || {
50
55
  pointsHotelDetails: t,
51
56
  pointsRooms: []
52
57
  }, {
53
- data: B,
54
- isFetching: n,
55
- isFetched: G
56
- } = o({
58
+ data: K,
59
+ isFetching: u,
60
+ isFetched: S
61
+ } = c({
57
62
  queryKey: [
58
63
  "fetchAvailableRooms",
59
- (f = t.cashBookingOffers) == null ? void 0 : f.accommodationId,
60
- (k = e == null ? void 0 : e.checkinDate) == null ? void 0 : k.valueOf(),
61
- (D = e == null ? void 0 : e.checkoutDate) == null ? void 0 : D.valueOf(),
62
- e == null ? void 0 : e.guests,
63
- e == null ? void 0 : e.rooms
64
+ (d = t.cashBookingOffers) == null ? void 0 : d.accommodationId,
65
+ (p = e == null ? void 0 : e.checkinDate) == null ? void 0 : p.valueOf(),
66
+ (m = e == null ? void 0 : e.checkoutDate) == null ? void 0 : m.valueOf(),
67
+ o == null ? void 0 : o.guests,
68
+ o == null ? void 0 : o.rooms
64
69
  ],
65
- queryFn: () => L({
70
+ queryFn: () => J({
66
71
  hotel: t,
67
72
  checkinDate: e.checkinDate,
68
73
  checkoutDate: e.checkoutDate,
69
- guests: e.guests,
70
- rooms: e.rooms,
71
- updateHotel: c,
72
- numberOfNights: a
74
+ guests: o.guests,
75
+ rooms: o.rooms,
76
+ updateHotel: a,
77
+ numberOfNights: s
73
78
  }),
74
- enabled: !!e && !!e.checkinDate && !!e.checkoutDate && !!((p = t.cashBookingOffers) != null && p.accommodationId),
79
+ enabled: !!e.checkinDate && !!e.checkoutDate && !!((y = t.cashBookingOffers) != null && y.accommodationId),
75
80
  retry: !1,
76
81
  placeholderData: {
77
82
  cashHotelDetails: t,
78
83
  cashRooms: []
79
84
  }
80
- }), { cashRooms: I, cashHotelDetails: u } = B || {
85
+ }), { cashRooms: w, cashHotelDetails: h } = K || {
81
86
  cashHotelDetails: t,
82
87
  cashRooms: []
83
88
  }, {
84
- data: K,
85
- isFetching: w,
86
- isFetched: S
87
- } = o({
89
+ data: N,
90
+ isFetching: M,
91
+ isFetched: P
92
+ } = c({
88
93
  queryKey: [
89
94
  "bestCheckout",
90
95
  t.hotelId,
91
96
  t.hotelGroup,
92
- (y = e == null ? void 0 : e.checkinDate) == null ? void 0 : y.valueOf(),
93
- (b = e == null ? void 0 : e.checkoutDate) == null ? void 0 : b.valueOf()
97
+ (b = e == null ? void 0 : e.checkinDate) == null ? void 0 : b.valueOf(),
98
+ (C = e == null ? void 0 : e.checkoutDate) == null ? void 0 : C.valueOf()
94
99
  ],
95
- queryFn: () => Q(
96
- F(t, s, u),
97
- a
100
+ queryFn: () => V(
101
+ O(t, r, h),
102
+ s
98
103
  ),
99
- enabled: !i && (t.liveScrapingCheckNeeded ? R : !0) && !n && ((C = t.cashBookingOffers) != null && C.accommodationId ? G : !0) && a > 0,
104
+ enabled: !n && (t.liveScrapingCheckNeeded ? G : !0) && !u && ((g = t.cashBookingOffers) != null && g.accommodationId ? S : !0) && s > 0,
100
105
  retry: !1,
101
106
  placeholderData: {
102
- bestCheckout: U(t, a),
107
+ bestCheckout: W(t, s),
103
108
  isAvailable: !1
104
109
  }
105
- }), { bestCheckout: l, isAvailable: r } = K || {
110
+ }), { bestCheckout: l, isAvailable: D } = N || {
106
111
  isAvailable: !1
107
- }, { data: N } = o({
112
+ }, { data: T } = c({
108
113
  queryKey: [
109
114
  "pointsAsCash",
110
115
  t.hotelId,
111
116
  t.hotelGroup,
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()
117
+ (v = e == null ? void 0 : e.checkinDate) == null ? void 0 : v.valueOf(),
118
+ (F = e == null ? void 0 : e.checkoutDate) == null ? void 0 : F.valueOf()
114
119
  ],
115
- queryFn: () => j(l.totalCashCost),
116
- enabled: S && r,
120
+ queryFn: () => X(l.totalCashCost),
121
+ enabled: P && D,
117
122
  retry: !1
118
123
  });
119
124
  return {
120
- transferPartners: O,
121
- loadingTransferPartners: q,
125
+ transferPartners: R,
126
+ loadingTransferPartners: A,
122
127
  // Points Check
123
- pointsRooms: A,
124
- loadingLivePointsCheck: i,
128
+ pointsRooms: I,
129
+ loadingLivePointsCheck: n,
125
130
  // Cash Rooms
126
- cashRooms: I,
127
- loadingCashRooms: n,
131
+ cashRooms: w,
132
+ loadingCashRooms: u,
128
133
  // Best Checkout
129
134
  bestCheckout: l,
130
- loadingBestCheckout: w,
135
+ loadingBestCheckout: M,
131
136
  // Combined availability
132
- isAvailable: r,
137
+ isAvailable: D,
133
138
  // Points as Cash
134
- pointsAsCash: N,
135
- hotelDetails: F(
139
+ pointsAsCash: T,
140
+ hotelDetails: O(
136
141
  t,
137
- s,
138
- u
139
- )
142
+ r,
143
+ h
144
+ ),
145
+ updateDates: H
140
146
  };
141
147
  };
142
148
  export {
143
- $ as useHotelDetails
149
+ ae as useHotelDetails
144
150
  };
@@ -11,4 +11,5 @@ export declare const useHotelDetails: (hotel: IHotelDetails) => {
11
11
  isAvailable: boolean;
12
12
  pointsAsCash: import('../../main').IPointsAsCash | undefined;
13
13
  hotelDetails: IHotelDetails;
14
+ updateDates: (checkinDate: Date, checkoutDate: Date) => void;
14
15
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@odynn/awayz-hotels",
3
3
  "private": false,
4
- "version": "0.1.18",
4
+ "version": "0.1.19",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"