@odynn/awayz-hotels 0.1.19 → 0.1.21

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.
@@ -24,7 +24,7 @@ const w = async (o) => await m.getTransferPartners(
24
24
  checkoutDate: a
25
25
  });
26
26
  if (r.success) {
27
- const e = r.data[0], u = !(e.points.pointsValue > 0) && o.bestValue === l.POINTS;
27
+ const e = r.data, u = !(e.points.pointsValue > 0) && o.bestValue === l.POINTS;
28
28
  n = {
29
29
  ...o,
30
30
  awardPoints: e.points.awardPointsValue ?? e.points.pointsValue,
@@ -1,17 +1,30 @@
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({
1
+ import { useQuery as i } from "@tanstack/react-query";
2
+ import { HotelService as n } from "../../services/hotel/HotelService.js";
3
+ import "../../moment-BGjjqtLQ.js";
4
+ import "../../arrayExtensions-cyilNkdJ.js";
5
+ import { useState as c, useEffect as a } from "react";
6
+ const m = 500, u = (t, o = m) => {
7
+ const [e, r] = c(t);
8
+ return a(() => {
9
+ const s = setTimeout(() => {
10
+ r(t);
11
+ }, o);
12
+ return () => {
13
+ clearTimeout(s);
14
+ };
15
+ }, [t, o]), e;
16
+ }, d = (t) => {
17
+ const o = u(t), { data: e, isLoading: r } = i({
5
18
  queryKey: ["locations", o],
6
- queryFn: () => t.getLocations(o),
7
- enabled: !!o
19
+ queryFn: () => n.getLocations(t),
20
+ enabled: !!t
8
21
  // Only run the query if searchInput is not empty
9
22
  });
10
23
  return {
11
24
  locations: (e == null ? void 0 : e.data) || [],
12
- loading: i
25
+ loading: r
13
26
  };
14
27
  };
15
28
  export {
16
- c as useLocationSearch
29
+ d as useLocationSearch
17
30
  };
@@ -141,3 +141,18 @@ export interface IStepBonus {
141
141
  bonus: number;
142
142
  stepThreshold: number;
143
143
  }
144
+ export interface ILiveHotelCheck {
145
+ hotelName: string;
146
+ hotelNameKey: string;
147
+ country: string;
148
+ city: string;
149
+ state: string;
150
+ hotelId: string;
151
+ points: {
152
+ pointsType: string;
153
+ pointsValue: number;
154
+ awardPointsValue: number;
155
+ availability: boolean;
156
+ };
157
+ rooms: IRoom[];
158
+ }
@@ -14,6 +14,21 @@ interface IHotelPointsCheckParams {
14
14
  checkoutDate: Moment;
15
15
  updateHotel: (hotelId: string, hotelGroup: string, updated: IHotelDetails) => void;
16
16
  }
17
+ /**
18
+ * Fetches the points check for a given hotel and updates the hotel details accordingly.
19
+ *
20
+ * @param {IHotelPointsCheckParams} params - The parameters for the points check.
21
+ * @param {IHotelDetails} params.hotel - The hotel details.
22
+ * @param {string} params.checkinDate - The check-in date.
23
+ * @param {string} params.checkoutDate - The check-out date.
24
+ * @param {Function} params.updateHotel - The function to update the hotel details in the global store.
25
+ * @returns {Promise<IPointsCheckResult>} The result of the points check, including updated hotel details and rooms.
26
+ *
27
+ * @remarks
28
+ * - If live scraping is not needed or the hotel belongs to Marriott, the points check is skipped.
29
+ * - If points are available, the hotel details are updated with the points information.
30
+ * - If points are not available and the best value was points, the best value is updated to none.
31
+ */
17
32
  export declare const fetchPointsCheck: ({ hotel, checkinDate, checkoutDate, updateHotel }: IHotelPointsCheckParams) => Promise<IPointsCheckResult>;
18
33
  interface IRoomsResult {
19
34
  cashHotelDetails: IHotelDetails;
@@ -1,5 +1,5 @@
1
1
  import { IHotelPointsCheckArgs, ISearchByHotelIdRequest, ISearchHotelsParams, ISearchLocation } from './HotelService.types';
2
- import { IHotelDetails } from '../../components/HotelResult/HotelResult.types';
2
+ import { IHotelDetails, ILiveHotelCheck } from '../../components/HotelResult/HotelResult.types';
3
3
  import { TServiceResponse } from '@type-op/shared';
4
4
  import { IBestCheckout } from '../../hooks/useHotelDetails/useHotelDetails.types';
5
5
  declare class _HotelService {
@@ -7,7 +7,10 @@ declare class _HotelService {
7
7
  searchByCoords: (request: ISearchHotelsParams) => Promise<TServiceResponse<IHotelDetails[]>>;
8
8
  searchByHotelId: (request: ISearchByHotelIdRequest) => Promise<TServiceResponse<IHotelDetails[]>>;
9
9
  getTransferPartners: (program: string) => Promise<any>;
10
- hotelPointsCheck: (args: IHotelPointsCheckArgs) => Promise<any>;
10
+ hotelPointsCheck: (args: IHotelPointsCheckArgs) => Promise<{
11
+ success: any;
12
+ data: ILiveHotelCheck;
13
+ }>;
11
14
  getRecommendations: (args: any) => Promise<{
12
15
  success: boolean;
13
16
  data: IBestCheckout;
@@ -1,12 +1,13 @@
1
- var f = Object.defineProperty;
2
- var p = (t, e, a) => e in t ? f(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
3
- var c = (t, e, a) => p(t, typeof e != "symbol" ? e + "" : e, a);
1
+ var p = Object.defineProperty;
2
+ var f = (t, e, a) => e in t ? p(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
3
+ var c = (t, e, a) => f(t, typeof e != "symbol" ? e + "" : e, a);
4
4
  import { clientInstance as d } from "@odynn/awayz-auth";
5
5
  import { EDuffelEndpoints as h } from "../../configs/endpoints.js";
6
6
  import "../../moment-BGjjqtLQ.js";
7
7
  import "../../arrayExtensions-cyilNkdJ.js";
8
8
  import { c as u } from "../../objectUtils-CyIaVmog.js";
9
9
  import { E as s } from "../../DateFormats-DZD30Nea.js";
10
+ import "react";
10
11
  var v = /* @__PURE__ */ ((t) => (t.Hotel = "awayz_hotel_booking_id", t.Flight = "awayz_flight_booking_id", t.Offer = "flight_offer_id", t))(v || {});
11
12
  class g {
12
13
  constructor() {
@@ -14,8 +15,8 @@ class g {
14
15
  checkinDate: e,
15
16
  checkoutDate: a,
16
17
  accommodationId: i,
17
- rooms: n,
18
- guests: m
18
+ rooms: m,
19
+ guests: n
19
20
  }) => {
20
21
  try {
21
22
  const { data: o } = await d.post(
@@ -24,8 +25,8 @@ class g {
24
25
  check_in_date: e.format(s.ServerDate),
25
26
  check_out_date: a.format(s.ServerDate),
26
27
  accommodation_ids: [i],
27
- rooms: n,
28
- guests: m
28
+ rooms: m,
29
+ guests: n
29
30
  }
30
31
  ), r = o.data.results.getFirst(), _ = r.accommodation.rooms.map(
31
32
  (l) => u(l)
@@ -44,8 +45,8 @@ class g {
44
45
  });
45
46
  }
46
47
  }
47
- const D = new g();
48
+ const F = new g();
48
49
  export {
49
- D as BookingService,
50
+ F as BookingService,
50
51
  v as EBookingType
51
52
  };
@@ -6,10 +6,11 @@ import { s as T } from "../../stringUtils-CvWpky85.js";
6
6
  import "../../moment-BGjjqtLQ.js";
7
7
  import "../../arrayExtensions-cyilNkdJ.js";
8
8
  import { c as h } from "../../objectUtils-CyIaVmog.js";
9
- import { E as l } from "../../DateFormats-DZD30Nea.js";
9
+ import { E as m } from "../../DateFormats-DZD30Nea.js";
10
+ import "react";
10
11
  import { EHotelEndpoints as i } from "../../configs/endpoints.js";
11
12
  import { clientInstance as u } from "@odynn/awayz-auth";
12
- import { EBestCheckoutType as m } from "../../enums/EBestCheckoutType.js";
13
+ import { EBestCheckoutType as p } from "../../enums/EBestCheckoutType.js";
13
14
  import { EBestValueType as S } from "../../enums/EBestValueType.js";
14
15
  class H {
15
16
  constructor() {
@@ -33,9 +34,9 @@ class H {
33
34
  success: !0,
34
35
  data: e.data.cities.map(
35
36
  (o) => {
36
- const { search_id: p, search_type: _, description: d, coordinates: y, city: g } = o, n = {
37
- searchId: p,
38
- searchType: _,
37
+ const { search_id: _, search_type: l, description: d, coordinates: y, city: g } = o, n = {
38
+ searchId: _,
39
+ searchType: l,
39
40
  description: d,
40
41
  coordinates: y,
41
42
  city: g
@@ -121,13 +122,16 @@ class H {
121
122
  const e = {
122
123
  hotel_group: a.hotelGroup,
123
124
  hotel_id: a.hotelId,
124
- check_in_date: a.checkinDate.format(l.ServerDate),
125
- check_out_date: a.checkoutDate.format(l.ServerDate)
125
+ check_in_date: a.checkinDate.format(m.ServerDate),
126
+ check_out_date: a.checkoutDate.format(m.ServerDate)
126
127
  }, { data: t } = await u.post(
127
128
  i.HOTEL_POINTS_CHECK,
128
129
  e
129
130
  );
130
- return t;
131
+ return {
132
+ success: t.success,
133
+ data: h(t.data[0])
134
+ };
131
135
  });
132
136
  r(this, "getRecommendations", async (a) => {
133
137
  try {
@@ -146,7 +150,7 @@ class H {
146
150
  cash_or_points: ["cash", "points"]
147
151
  }
148
152
  ), t = e.data[0];
149
- return console.log({ data: t }), {
153
+ return {
150
154
  success: !0,
151
155
  data: {
152
156
  totalPointsCost: t.total_hotel_points_cost,
@@ -157,7 +161,7 @@ class H {
157
161
  sufficientPoints: t.user_has_sufficient_points,
158
162
  awardPoints: t.award_points,
159
163
  rewardsProgram: t.hotel_rewards_program,
160
- bestCheckoutMethod: t.best_user_checkout_method === S.CASH ? m.CASH : m.POINTS,
164
+ bestCheckoutMethod: t.best_user_checkout_method === S.CASH ? p.CASH : p.POINTS,
161
165
  optimalProgram: {
162
166
  remainingPointsBalance: t.optimal_user_program_checkout.primary_offer_remaining_points_balance,
163
167
  programs: t.optimal_user_program_checkout.programs.map(
@@ -180,7 +184,7 @@ class H {
180
184
  });
181
185
  }
182
186
  }
183
- const G = new H();
187
+ const L = new H();
184
188
  export {
185
- G as HotelService
189
+ L as HotelService
186
190
  };
@@ -7,6 +7,7 @@ import { EWalletEndpoints as i } from "../../configs/endpoints.js";
7
7
  import "../../moment-BGjjqtLQ.js";
8
8
  import "../../arrayExtensions-cyilNkdJ.js";
9
9
  import { c as a } from "../../objectUtils-CyIaVmog.js";
10
+ import "react";
10
11
  class u {
11
12
  constructor() {
12
13
  s(this, "getAwards", async () => {
@@ -43,7 +44,7 @@ class u {
43
44
  });
44
45
  }
45
46
  }
46
- const A = new u();
47
+ const W = new u();
47
48
  export {
48
- A as WalletService
49
+ W as WalletService
49
50
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@odynn/awayz-hotels",
3
3
  "private": false,
4
- "version": "0.1.19",
4
+ "version": "0.1.21",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -65,7 +65,7 @@
65
65
  ]
66
66
  },
67
67
  "dependencies": {
68
- "@odynn/awayz-auth": "^0.1.15",
68
+ "@odynn/awayz-auth": "^0.1.17",
69
69
  "@tanstack/react-query": "^5.66.9"
70
70
  }
71
71
  }