@odynn/awayz-hotels 0.13.0 → 0.13.2

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,24 +1,25 @@
1
- import { awayzClient as i } from "@odynn/awayz-core";
2
- import { useQuery as m, useMutation as y } from "@tanstack/react-query";
1
+ import { useAwayzContext as y, awayzClient as i } from "@odynn/awayz-core";
2
+ import { useQuery as c, useMutation as d } from "@tanstack/react-query";
3
3
  import "react/jsx-runtime";
4
4
  import "../../moment-BGjjqtLQ.js";
5
5
  import "../../arrayExtensions-CFEBYUok.js";
6
6
  import { E as e } from "../../enums-DPFgYLjY.js";
7
7
  import "react";
8
8
  import { AvailabilityAlertsService as r } from "../../services/availabilityAlerts/AvailabilityAlertsService.js";
9
- const N = () => {
10
- const {
11
- data: a = [],
9
+ const w = () => {
10
+ const { isAuthenticated: a } = y(), {
11
+ data: n = [],
12
12
  error: o,
13
- isPending: n
14
- } = m({
13
+ isPending: u
14
+ } = c({
15
15
  queryKey: [e.ALERT_NOTIFICATIONS],
16
- queryFn: () => r.getAlertNotifications()
16
+ queryFn: () => r.getAlertNotifications(),
17
+ enabled: a
17
18
  }), {
18
- mutate: u,
19
- error: l,
19
+ mutate: l,
20
+ error: s,
20
21
  isPending: A
21
- } = y({
22
+ } = d({
22
23
  mutationFn: async (t) => {
23
24
  await r.updateAvailabilityAlert(t);
24
25
  },
@@ -31,14 +32,14 @@ const N = () => {
31
32
  }
32
33
  });
33
34
  return {
34
- availabilityAlertNotifications: a,
35
- updateAcknowledgement: (t, s = !0) => u({ alertId: t, acknowledged: s }),
36
- mutateError: l,
35
+ availabilityAlertNotifications: n,
36
+ updateAcknowledgement: (t, m = !0) => l({ alertId: t, acknowledged: m }),
37
+ mutateError: s,
37
38
  mutatePending: A,
38
39
  fetchError: o,
39
- fetchPending: n
40
+ fetchPending: u
40
41
  };
41
42
  };
42
43
  export {
43
- N as useAvailabilityAlertNotifications
44
+ w as useAvailabilityAlertNotifications
44
45
  };
@@ -1,92 +1,94 @@
1
- import { awayzClient as v } from "@odynn/awayz-core";
2
- import { useQuery as f, useMutation as p } from "@tanstack/react-query";
1
+ import { useAwayzContext as p, awayzClient as v } from "@odynn/awayz-core";
2
+ import { useQuery as E, useMutation as b } from "@tanstack/react-query";
3
3
  import "react/jsx-runtime";
4
4
  import "../../moment-BGjjqtLQ.js";
5
5
  import "../../arrayExtensions-CFEBYUok.js";
6
6
  import { E as u } from "../../enums-DPFgYLjY.js";
7
7
  import "react";
8
- import { AvailabilityAlertsService as d } from "../../services/availabilityAlerts/AvailabilityAlertsService.js";
9
- const b = ({
10
- checkin: r,
8
+ import { AvailabilityAlertsService as w } from "../../services/availabilityAlerts/AvailabilityAlertsService.js";
9
+ const h = ({
10
+ checkin: e,
11
11
  checkout: t,
12
- hotelGroup: a,
13
- hotelId: o,
14
- name: n,
15
- hotelImage: l,
16
- hotelAddress: i,
17
- hotelDescription: s,
18
- hotelProgramName: A
12
+ hotelGroup: o,
13
+ hotelId: n,
14
+ name: l,
15
+ hotelImage: s,
16
+ hotelAddress: A,
17
+ hotelDescription: i,
18
+ hotelProgramName: d
19
19
  }) => {
20
- if (!o)
20
+ if (!n)
21
21
  throw new Error("Hotel ID is required");
22
- if (!r)
22
+ if (!e)
23
23
  throw new Error("Check-in date is required");
24
- if (new Date(r) <= /* @__PURE__ */ new Date())
24
+ if (new Date(e) <= /* @__PURE__ */ new Date())
25
25
  throw new Error("Check-in date must be in the future");
26
26
  if (!t)
27
27
  throw new Error("Check-out date is required");
28
28
  if (new Date(t) <= /* @__PURE__ */ new Date())
29
29
  throw new Error("Check-out date must be in the future");
30
- if (new Date(t) <= new Date(r))
30
+ if (new Date(t) <= new Date(e))
31
31
  throw new Error("Check-out date must be after check-in date");
32
- if (!n)
32
+ if (!l)
33
33
  throw new Error("Hotel name is required");
34
- if (!a)
34
+ if (!o)
35
35
  throw new Error("Hotel group is required");
36
- if (!l)
36
+ if (!s)
37
37
  throw new Error("Hotel image is required");
38
- if (!i)
38
+ if (!A)
39
39
  throw new Error("Hotel address is required");
40
- if (!s)
40
+ if (!i)
41
41
  throw new Error("Hotel description is required");
42
- if (!A)
42
+ if (!d)
43
43
  throw new Error("Hotel program name is required");
44
- }, h = ({
45
- alertId: r,
44
+ }, q = ({
45
+ alertId: e,
46
46
  checkin: t,
47
- checkout: a,
48
- hotelGroup: o,
49
- hotelId: n,
50
- name: l,
51
- hotelImage: i,
52
- hotelAddress: s,
53
- hotelDescription: A,
54
- hotelProgramName: w,
55
- archived: y,
56
- acknowledged: E
47
+ checkout: o,
48
+ hotelGroup: n,
49
+ hotelId: l,
50
+ name: s,
51
+ hotelImage: A,
52
+ hotelAddress: i,
53
+ hotelDescription: d,
54
+ hotelProgramName: y,
55
+ archived: c,
56
+ acknowledged: m
57
57
  }) => {
58
- if (!r)
58
+ if (!e)
59
59
  throw new Error("Alert ID is required");
60
60
  if (![
61
61
  t,
62
- a,
63
62
  o,
64
63
  n,
65
64
  l,
66
- i,
67
65
  s,
68
66
  A,
69
- w,
67
+ i,
68
+ d,
70
69
  y,
71
- E
70
+ c,
71
+ m
72
72
  ].some(
73
- (m) => m != null && m !== ""
73
+ (a) => a != null && a !== ""
74
74
  ))
75
75
  throw new Error("At least one field must be provided for update");
76
- }, H = () => {
77
- const { data: r = [] } = f({
76
+ }, D = () => {
77
+ const { isAuthenticated: e } = p(), { data: t = [] } = E({
78
78
  queryKey: [u.AVAILABILITY_ALERTS],
79
- queryFn: () => d.getMyActiveAlerts()
80
- }), { data: t = [] } = f({
79
+ queryFn: () => w.getMyActiveAlerts(),
80
+ enabled: e
81
+ }), { data: o = [] } = E({
81
82
  queryKey: [u.ALERT_NOTIFICATIONS],
82
- queryFn: () => d.getAlertNotifications()
83
+ queryFn: () => w.getAlertNotifications(),
84
+ enabled: e
83
85
  }), {
84
- mutate: a,
85
- isPending: o,
86
- isError: n,
87
- error: l
88
- } = p({
89
- mutationFn: async (e) => (b(e), await d.createAvailabilityAlert(e)),
86
+ mutate: n,
87
+ isPending: l,
88
+ isError: s,
89
+ error: A
90
+ } = b({
91
+ mutationFn: async (r) => (h(r), await w.createAvailabilityAlert(r)),
90
92
  onSuccess: () => {
91
93
  v.invalidateQueries({
92
94
  queryKey: [u.AVAILABILITY_ALERTS]
@@ -94,12 +96,12 @@ const b = ({
94
96
  }
95
97
  }), {
96
98
  mutate: i,
97
- isPending: s,
98
- isError: A,
99
- error: w,
100
- data: y
101
- } = p({
102
- mutationFn: async (e) => (h(e), d.updateAvailabilityAlert(e)),
99
+ isPending: d,
100
+ isError: y,
101
+ error: c,
102
+ data: m
103
+ } = b({
104
+ mutationFn: async (r) => (q(r), w.updateAvailabilityAlert(r)),
103
105
  onSuccess: () => {
104
106
  v.invalidateQueries({
105
107
  queryKey: [u.AVAILABILITY_ALERTS]
@@ -109,25 +111,25 @@ const b = ({
109
111
  }
110
112
  });
111
113
  return {
112
- activeAlerts: r,
113
- alertNotifications: t,
114
+ activeAlerts: t,
115
+ alertNotifications: o,
114
116
  // Mutation for creating a new availability alert
115
- createAvailabilityAlert: a,
116
- isCreateAvailabilityAlertPending: o,
117
- isCreateAvailabilityAlertError: n,
118
- createAvailabilityAlertError: l,
117
+ createAvailabilityAlert: n,
118
+ isCreateAvailabilityAlertPending: l,
119
+ isCreateAvailabilityAlertError: s,
120
+ createAvailabilityAlertError: A,
119
121
  // Mutation for updating/removing an existing alert
120
122
  updateAvailabilityAlert: i,
121
- isUpdateAvailabilityAlertPending: s,
122
- isUpdateAvailabilityAlertError: A,
123
- updateAvailabilityAlertError: w,
124
- updatedAvailabilityAlert: y,
123
+ isUpdateAvailabilityAlertPending: d,
124
+ isUpdateAvailabilityAlertError: y,
125
+ updateAvailabilityAlertError: c,
126
+ updatedAvailabilityAlert: m,
125
127
  // convenience function to update acknowledgment
126
- updateAcknowledgement: (e, c = !0) => i({ alertId: e, acknowledged: c })
128
+ updateAcknowledgement: (r, a = !0) => i({ alertId: r, acknowledged: a })
127
129
  };
128
130
  };
129
131
  export {
130
- H as useAvailabilityAlerts,
131
- b as validateCreateAvailabilityAlert,
132
- h as validateUpdateAvailabilityAlert
132
+ D as useAvailabilityAlerts,
133
+ h as validateCreateAvailabilityAlert,
134
+ q as validateUpdateAvailabilityAlert
133
135
  };
@@ -48,6 +48,7 @@ export interface IHotelDetails {
48
48
  liveScrapingCheckNeeded: boolean;
49
49
  partners: IHotelPartner[];
50
50
  hotelProgram?: IHotelProgram;
51
+ pointsProgramDisplay?: string;
51
52
  bestValue: string;
52
53
  pointsAsCash?: IHotelPointsAsCash;
53
54
  imagesS3?: string[];
@@ -8,4 +8,5 @@ export * from './components';
8
8
  export * from './configs';
9
9
  export * from './enums';
10
10
  export * from './hooks';
11
+ export { mapAccommodationResponse, mapRateResponse } from './services/booking/BookingService.mappers';
11
12
  export type { checkNthNightFree, IAirlineProgram, IHotelDetails, IPointsAsCash, IRate, IRoom };
@@ -80,6 +80,7 @@ export interface IHotelResultResponse {
80
80
  hotel_program?: IHotelProgramResponse & {
81
81
  logo: string;
82
82
  };
83
+ points_program_display?: string;
83
84
  best_value: string;
84
85
  points_as_cash?: IPointsAsCashResponse;
85
86
  cash_booking_offers?: ICashBookingOffersResponse;
package/dist/main.js CHANGED
@@ -1,33 +1,36 @@
1
- import { ESearchType as e } from "./services/hotel/HotelService.types.js";
1
+ import { ESearchType as t } from "./services/hotel/HotelService.types.js";
2
2
  import { HotelResult as l } from "./components/HotelResult/HotelResult.js";
3
- import { HotelResults as a } from "./components/HotelResults/HotelResults.js";
4
- import { Legend as p } from "./components/Legend/Legend.js";
5
- import { Ratings as m } from "./components/Banners/Ratings/Ratings.js";
6
- import { defaultLocationSortOrder as u, defaultSimilarityThreshold as S, duffelTestHotelLocation as n } from "./configs/defaults.js";
7
- import { EHotelSortOption as d, ESortingOrder as H } from "./enums/index.js";
8
- import { useAvailabilityAlertNotifications as h } from "./hooks/useAvailabilityAlertNotifications/useAvailabilityAlertNotifications.js";
9
- import { useAvailabilityAlerts as E } from "./hooks/useAvailabilityAlerts/useAvailabilityAlerts.js";
10
- import { useHotelDetails as b } from "./hooks/useHotelDetails/useHotelDetails.js";
11
- import { useHotelSearch as v } from "./hooks/useHotelSearch/useHotelSearch.js";
12
- import { useHotelSort as R } from "./hooks/useHotelSort/useHotelSort.js";
3
+ import { HotelResults as i } from "./components/HotelResults/HotelResults.js";
4
+ import { Legend as f } from "./components/Legend/Legend.js";
5
+ import { Ratings as s } from "./components/Banners/Ratings/Ratings.js";
6
+ import { defaultLocationSortOrder as u, defaultSimilarityThreshold as n, duffelTestHotelLocation as c } from "./configs/defaults.js";
7
+ import { EHotelSortOption as d, ESortingOrder as A } from "./enums/index.js";
8
+ import { useAvailabilityAlertNotifications as R } from "./hooks/useAvailabilityAlertNotifications/useAvailabilityAlertNotifications.js";
9
+ import { useAvailabilityAlerts as y } from "./hooks/useAvailabilityAlerts/useAvailabilityAlerts.js";
10
+ import { useHotelDetails as L } from "./hooks/useHotelDetails/useHotelDetails.js";
11
+ import { useHotelSearch as g } from "./hooks/useHotelSearch/useHotelSearch.js";
12
+ import { useHotelSort as O } from "./hooks/useHotelSort/useHotelSort.js";
13
13
  import { useLocationSearch as D } from "./hooks/useLocationSearch/useLocationSearch.js";
14
- import { EAvailabilityAlertStatus as j } from "./enums/EAvailabilityAlert.js";
14
+ import { mapAccommodationResponse as j, mapRateResponse as k } from "./services/booking/BookingService.mappers.js";
15
+ import { EAvailabilityAlertStatus as w } from "./enums/EAvailabilityAlert.js";
15
16
  export {
16
- j as EAvailabilityAlertStatus,
17
+ w as EAvailabilityAlertStatus,
17
18
  d as EHotelSortOption,
18
- e as ESearchType,
19
- H as ESortingOrder,
19
+ t as ESearchType,
20
+ A as ESortingOrder,
20
21
  l as HotelResult,
21
- a as HotelResults,
22
- p as Legend,
23
- m as Ratings,
22
+ i as HotelResults,
23
+ f as Legend,
24
+ s as Ratings,
24
25
  u as defaultLocationSortOrder,
25
- S as defaultSimilarityThreshold,
26
- n as duffelTestHotelLocation,
27
- h as useAvailabilityAlertNotifications,
28
- E as useAvailabilityAlerts,
29
- b as useHotelDetails,
30
- v as useHotelSearch,
31
- R as useHotelSort,
26
+ n as defaultSimilarityThreshold,
27
+ c as duffelTestHotelLocation,
28
+ j as mapAccommodationResponse,
29
+ k as mapRateResponse,
30
+ R as useAvailabilityAlertNotifications,
31
+ y as useAvailabilityAlerts,
32
+ L as useHotelDetails,
33
+ g as useHotelSearch,
34
+ O as useHotelSort,
32
35
  D as useLocationSearch
33
36
  };
@@ -81,7 +81,7 @@ const n = (e) => {
81
81
  beds: e.beds
82
82
  };
83
83
  }, T = (e) => {
84
- var a, t, i, s, o, _, m, c, u, r, l, y, g, f, h, C, v, b, k, A;
84
+ var a, t, i, s, o, _, m, c, u, r, l, y, g, f, h, C, v, b, k, P;
85
85
  if (e)
86
86
  return {
87
87
  searchRoomRateId: e.search_room_rate_id,
@@ -121,11 +121,11 @@ const n = (e) => {
121
121
  cheapestRateTotalAmount: n(e.cheapest_rate_total_amount),
122
122
  cheapestRateCurrency: e.cheapest_rate_currency ?? "",
123
123
  chain: { name: ((k = e.chain) == null ? void 0 : k.name) ?? "" },
124
- brand: { name: ((A = e.brand) == null ? void 0 : A.name) ?? "" },
124
+ brand: { name: ((P = e.brand) == null ? void 0 : P.name) ?? "" },
125
125
  supportedLoyaltyProgramme: e.supported_loyalty_programme,
126
126
  amenities: e.amenities ?? []
127
127
  };
128
- }, P = (e) => ({
128
+ }, A = (e) => ({
129
129
  bonus: (e == null ? void 0 : e.bonus) ?? 0,
130
130
  stepThreshold: (e == null ? void 0 : e.step_threshold) ?? 0
131
131
  }), R = (e) => ({
@@ -135,7 +135,7 @@ const n = (e) => {
135
135
  transferMinutes: e.transfer_minutes,
136
136
  minimumTransfer: e.minimum_transfer,
137
137
  transferDenominator: e.transfer_denominator,
138
- stepBonus: P(e.step_bonus)
138
+ stepBonus: A(e.step_bonus)
139
139
  }), N = (e) => {
140
140
  if (e)
141
141
  return {
@@ -145,7 +145,7 @@ const n = (e) => {
145
145
  transferMinutes: e.transfer_minutes,
146
146
  minimumTransfer: e.minimum_transfer,
147
147
  transferDenominator: e.transfer_denominator,
148
- stepBonus: P(e.step_bonus),
148
+ stepBonus: A(e.step_bonus),
149
149
  valueCent: e.value_cent,
150
150
  logo: e.logo
151
151
  };
@@ -214,6 +214,7 @@ const n = (e) => {
214
214
  liveScrapingCheckNeeded: e.live_scraping_check_needed,
215
215
  partners: ((u = e.partners) == null ? void 0 : u.map(R)) ?? [],
216
216
  hotelProgram: N(e.hotel_program),
217
+ pointsProgramDisplay: e.points_program_display,
217
218
  bestValue: e.best_value,
218
219
  pointsAsCash: I(e.points_as_cash),
219
220
  cashBookingOffers: T(e.cash_booking_offers),
@@ -239,7 +240,7 @@ const n = (e) => {
239
240
  },
240
241
  rooms: ((o = e.rooms) == null ? void 0 : o.map(p)) ?? []
241
242
  };
242
- }, O = (e) => {
243
+ }, D = (e) => {
243
244
  var a, t;
244
245
  return {
245
246
  partnerProgram: e.partner_program,
@@ -267,5 +268,5 @@ export {
267
268
  x as mapLiveHotelCheckResponse,
268
269
  w as mapRateResponse,
269
270
  p as mapRoomResponse,
270
- O as mapTransferPartnerResponse
271
+ D as mapTransferPartnerResponse
271
272
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@odynn/awayz-hotels",
3
3
  "private": false,
4
- "version": "0.13.0",
4
+ "version": "0.13.2",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"