@odynn/awayz-hotels 0.1.7 → 0.1.9

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,38 +1,38 @@
1
1
  import { useState as i, useEffect as N, useMemo as M } from "react";
2
- import { HotelChains as h } from "../../definitions/HotelChains.js";
2
+ import { HotelChains as p } from "../../definitions/HotelChains.js";
3
3
  import { HotelService as C } from "../../services/hotel/HotelService.js";
4
- import { h as b } from "../../moment-CwOqp704.js";
4
+ import { h as w } from "../../moment-CwOqp704.js";
5
5
  import "../../arrayExtensions-fPXUw0L-.js";
6
- import { EBestCheckoutType as w } from "../../enums/EBestCheckoutType.js";
6
+ import { EBestCheckoutType as k } from "../../enums/EBestCheckoutType.js";
7
7
  import { BookingService as H } from "../../services/booking/BookingService.js";
8
8
  import { EGuestType as U } from "../../services/booking/BookingService.enums.js";
9
9
  import q from "../../stores/useHotelsStore.js";
10
10
  const x = (t, d) => Math.abs(
11
- b(t.startOf("day")).diff(b(d.endOf("day")), "days")
11
+ w(t.startOf("day")).diff(w(d.endOf("day")), "days")
12
12
  ), Z = (t) => {
13
13
  if (!t)
14
14
  throw new Error(
15
15
  "Hotel is required in order to initiate the hotel details flow"
16
16
  );
17
- const { updateHotel: d, searchParams: n } = q(), [k, p] = i(t), [L, V] = i(!1), [B, v] = i([]), [R, y] = i(), [S, f] = i([]), [A, G] = i([]), [g, r] = i({
17
+ const { updateHotel: d, searchParams: n } = q(), [y, h] = i(t), [V, L] = i(!1), [B, v] = i([]), [S, P] = i(), [R, f] = i([]), [A, G] = i([]), [g, r] = i({
18
18
  pointsCheckLoading: !1,
19
19
  bestCheckoutLoading: !1,
20
20
  accommodationLoading: !1
21
21
  });
22
22
  N(() => {
23
- O(), D();
23
+ E(), I();
24
24
  }, [t]);
25
- const D = async () => {
25
+ const I = async () => {
26
26
  const [o, a] = await Promise.all(
27
27
  [
28
- I(n.checkinDate, n.checkoutDate),
29
- E()
28
+ T(n.checkinDate, n.checkoutDate),
29
+ O()
30
30
  ]
31
31
  );
32
- o && a && T(t);
33
- }, I = async (o, a) => {
32
+ o && a && D(t);
33
+ }, T = async (o, a) => {
34
34
  let s = t, c = !0;
35
- if (!t.liveScrapingCheckNeeded || t.hotelGroup === h.Marriott)
35
+ if (!t.liveScrapingCheckNeeded || t.hotelGroup === p.Marriott)
36
36
  return c;
37
37
  try {
38
38
  r((u) => ({ ...u, pointsCheckLoading: !0 }));
@@ -43,32 +43,32 @@ const x = (t, d) => Math.abs(
43
43
  checkoutDate: a
44
44
  });
45
45
  if (e) {
46
- const m = !(e.data.points.pointsValue > 0);
46
+ const m = !(e.data.points.pointsValue > 0) && t.bestValue === k.POINTS;
47
47
  s = {
48
48
  ...t,
49
49
  awardPoints: e.data.points.awardPointsValue ?? e.data.points.pointsValue,
50
50
  points: e.data.points.pointsValue,
51
51
  pointsType: e.data.points.pointsType,
52
- bestValue: m ? w.NONE : t.bestValue
53
- }, p(s), d(t.hotelId, t.hotelGroup, s), G(e.data.rooms ?? t.rooms ?? []), m && (P(s), c = !1);
52
+ bestValue: m ? k.NONE : t.bestValue
53
+ }, h(s), d(t.hotelId, t.hotelGroup, s), G(e.data.rooms ?? t.rooms ?? []), m && (b(s), c = !1);
54
54
  }
55
55
  } catch {
56
56
  }
57
57
  return r((e) => ({ ...e, pointsCheckLoading: !1 })), c;
58
- }, T = async (o) => {
58
+ }, D = async (o) => {
59
59
  r((s) => ({ ...s, bestCheckoutLoading: !0 }));
60
60
  const a = await C.getRecommendations({
61
61
  days: l,
62
62
  hotels: [o ?? t]
63
63
  });
64
- a.success && a.data ? (y(a.data), V(
64
+ a.success && a.data ? (P(a.data), L(
65
65
  a.data.nightlyPointsCost > 0 || a.data.nightlyCashCost > 0
66
- )) : P(o), r((s) => ({ ...s, bestCheckoutLoading: !1 }));
67
- }, P = (o) => {
66
+ )) : b(o), r((s) => ({ ...s, bestCheckoutLoading: !1 }));
67
+ }, b = (o) => {
68
68
  const a = {
69
- bestCheckoutMethod: h.isHotelChain(
69
+ bestCheckoutMethod: p.isHotelChain(
70
70
  o.hotelGroup
71
- ) ? o.bestValue : w.CASH,
71
+ ) ? o.bestValue : k.CASH,
72
72
  nightlyCashCost: o.cashValue.amount,
73
73
  nightlyPointsCost: o.points,
74
74
  awardPoints: o.points,
@@ -76,16 +76,16 @@ const x = (t, d) => Math.abs(
76
76
  totalPointsCost: o.points * l,
77
77
  currency: o.cashValue.currency,
78
78
  sufficientPoints: !0,
79
- rewardsProgram: h.toProgram(o.hotelGroup),
79
+ rewardsProgram: p.toProgram(o.hotelGroup),
80
80
  optimalProgram: {
81
81
  programs: [],
82
82
  remainingPointsBalance: 0
83
83
  }
84
84
  };
85
- r((s) => ({ ...s, bestCheckoutLoading: !1 })), y(a);
86
- }, E = async (o) => {
85
+ r((s) => ({ ...s, bestCheckoutLoading: !1 })), P(a);
86
+ }, O = async (o) => {
87
87
  var c;
88
- let a = k, s = !0;
88
+ let a = y, s = !0;
89
89
  try {
90
90
  if (!((c = t == null ? void 0 : t.cashBookingOffers) != null && c.accommodationId))
91
91
  throw new Error("No accommodation id found");
@@ -106,7 +106,7 @@ const x = (t, d) => Math.abs(
106
106
  amount: u.cheapestRate / l || a.cashValue.amount || 0,
107
107
  currency: u.currency ?? a.cashValue.currency
108
108
  }
109
- }, p(a), f(u.availableRooms), p(a), d(t.hotelId, t.hotelGroup, a);
109
+ }, h(a), f(u.availableRooms), h(a), d(t.hotelId, t.hotelGroup, a);
110
110
  } catch {
111
111
  f([]);
112
112
  }
@@ -114,19 +114,19 @@ const x = (t, d) => Math.abs(
114
114
  }, l = M(() => n ? x(
115
115
  n.checkinDate,
116
116
  n.checkoutDate
117
- ) : 0, []), O = async () => {
117
+ ) : 0, []), E = async () => {
118
118
  const o = await C.getTransferPartners(
119
- h.toProgram(t.hotelGroup)
119
+ p.toProgram(t.hotelGroup)
120
120
  );
121
121
  v(o);
122
122
  };
123
123
  return {
124
124
  transferPartners: B,
125
- bestCheckout: R,
126
- isAvailable: L,
127
- cashRooms: S,
125
+ bestCheckout: S,
126
+ isAvailable: V,
127
+ cashRooms: R,
128
128
  pointsRooms: A,
129
- hotelDetails: k,
129
+ hotelDetails: y,
130
130
  loadingBestCheckout: g.bestCheckoutLoading,
131
131
  loadingPointsCheck: g.pointsCheckLoading,
132
132
  loadingAccommodation: g.accommodationLoading
@@ -1,4 +1,5 @@
1
1
  import { ICoordinates } from '@type-op/shared';
2
+ import { IRoom } from '../../services/booking/BookingService.types';
2
3
  export interface IHotelDetails {
3
4
  hotelId: string;
4
5
  address: string;
@@ -25,9 +26,7 @@ export interface IHotelDetails {
25
26
  freeNight?: boolean;
26
27
  hotelGroup: string;
27
28
  hotelStatus: string;
28
- images: string[] | {
29
- url: string;
30
- }[];
29
+ images: string[];
31
30
  legacyCoordinates: number[];
32
31
  name: string;
33
32
  nthNightFree?: number;
@@ -87,18 +86,6 @@ export interface IPointsAsCash {
87
86
  totalPointsUsed: number;
88
87
  awardProgram: string | number;
89
88
  }
90
- export interface IRoom {
91
- roomId: string;
92
- roomTitle: string;
93
- roomType: string;
94
- roomCategory: string;
95
- roomDescription: string;
96
- roomImage: string;
97
- lowestPointsRate: number;
98
- lowestAwardPointsRate: number;
99
- photos?: IPhoto[];
100
- name?: string;
101
- }
102
89
  export interface IPhoto {
103
90
  url: string;
104
91
  }
@@ -1,5 +1,6 @@
1
- import { IHotelDetails, IRoom } from '../../components/HotelResult/HotelResult.types';
1
+ import { IHotelDetails } from '../../components/HotelResult/HotelResult.types';
2
2
  import { IBestCheckout } from './useHotelDetails.types';
3
+ import { IRoom } from '../../services/booking/BookingService.types';
3
4
  /**
4
5
  * The `useHotelDetails` is responsible for all logic related to the hotel details. Including the following:
5
6
  * - Getting the best checkout for the user
@@ -1,3 +1,5 @@
1
+ import { IRoom, IRate } from './services/booking/BookingService.types';
1
2
  export { ESearchType } from './services/hotel/HotelService.types';
2
3
  export * from './components';
3
4
  export * from './hooks';
5
+ export type { IRoom, IRate };
@@ -1,5 +1,4 @@
1
- import { IGetAvailableRoomsProps } from './BookingService.types';
2
- import { IRoom } from '../../components/HotelResult/HotelResult.types';
1
+ import { IGetAvailableRoomsProps, IRoom } from './BookingService.types';
3
2
  export declare enum EBookingType {
4
3
  Hotel = "awayz_hotel_booking_id",
5
4
  Flight = "awayz_flight_booking_id",
@@ -1,6 +1,7 @@
1
1
  import { ICoordinates } from '@type-op/shared';
2
2
  import { EGuestType, ERoomBoardType, ERoomPaymentType } from './BookingService.enums';
3
3
  import { Moment } from 'moment';
4
+ import { IPhoto } from '../../components/HotelResult/HotelResult.types';
4
5
  export interface IGetAvailableRoomsProps {
5
6
  checkinDate: Moment;
6
7
  checkoutDate: Moment;
@@ -115,43 +116,65 @@ interface IRating {
115
116
  source: string;
116
117
  value: number;
117
118
  }
118
- interface IPhoto {
119
- url: string;
120
- }
121
- interface IRoom {
122
- beds: IBed[];
123
- photos: IPhoto[];
124
- rates: IRate[];
125
- name: string;
126
- }
127
119
  interface IBed {
128
120
  type: string;
129
121
  count: number;
130
122
  }
131
- interface IRate {
123
+ export interface IRoom {
124
+ roomId: string;
125
+ rates: IRate[];
126
+ roomTitle: string;
127
+ roomType: string;
128
+ roomCategory: string;
129
+ roomDescription: string;
130
+ roomImage: string;
131
+ lowestPointsRate: number;
132
+ lowestAwardPointsRate: number;
133
+ lowestCashRate: ILowestCashRate;
134
+ roomRatePlans: IPointsRate[];
135
+ photos?: IPhoto[];
136
+ name?: string;
137
+ beds?: IBed[];
138
+ }
139
+ interface ILowestCashRate {
140
+ currency: string;
141
+ cashAmount: number;
142
+ }
143
+ export interface IRate {
132
144
  publicCurrency: string;
133
145
  dueAtAccommodationCurrency: string;
134
- dueAtAccommodationAmount: number | null;
146
+ dueAtAccommodationAmount?: number;
135
147
  quantityAvailable: number;
136
- publicAmount: number | null;
137
- dealTypes: string | null;
148
+ publicAmount?: number;
149
+ dealTypes?: string;
138
150
  cancellationTimeline: string[];
139
151
  boardType: string;
140
- supportedLoyaltyProgramme: string | null;
152
+ supportedLoyaltyProgramme?: string;
141
153
  availablePaymentMethods: string[];
142
- feeAmount: string;
154
+ feeAmount: number;
143
155
  taxCurrency: string;
144
156
  baseCurrency: string;
145
- baseAmount: string;
146
- taxAmount: string;
157
+ baseAmount: number;
158
+ taxAmount: number;
147
159
  feeCurrency: string;
148
160
  totalCurrency: string;
149
161
  paymentType: string;
150
- totalAmount: string;
162
+ totalAmount: number;
151
163
  conditions: ICondition[];
152
164
  source: string;
153
165
  id: string;
154
166
  }
167
+ interface IPointsRate {
168
+ ratePlanId: string;
169
+ ratePlanName: string;
170
+ ratePlanType: string;
171
+ ratePlanCategory: string;
172
+ ratePlanPoints: number;
173
+ ratePlanCash: {
174
+ cash: number;
175
+ currency: string;
176
+ };
177
+ }
155
178
  interface ICondition {
156
179
  title: string;
157
180
  description: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@odynn/awayz-hotels",
3
3
  "private": false,
4
- "version": "0.1.7",
4
+ "version": "0.1.9",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"