@odynn/awayz-hotels 0.1.2 → 0.1.3

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,32 +1,57 @@
1
- import { useState as r } from "react";
2
- import { HotelService as n } from "../../services/hotel/HotelService.js";
3
- import { ESearchType as u } from "../../services/hotel/HotelService.types.js";
4
- const _ = () => {
5
- const [h, s] = r([]), [a, t] = r(!1);
1
+ import { useState as n } from "react";
2
+ import { HotelService as i } from "../../services/hotel/HotelService.js";
3
+ import { ESearchType as p } from "../../services/hotel/HotelService.types.js";
4
+ import { HotelChains as r } from "../../definitions/HotelChains.js";
5
+ const m = () => {
6
+ const [h, s] = n([]), [u, c] = n(!1), l = (e) => {
7
+ if (!e.checkinDate || !e.checkoutDate)
8
+ throw new Error("Checkin and checkout dates are required");
9
+ if (!e.coordinates)
10
+ throw new Error("Coordinates are required");
11
+ e.hotelGroups && e.hotelGroups.forEach((o) => {
12
+ if (!r.toList().includes(o))
13
+ throw new Error(
14
+ `Invalid hotel group: ${o}. Please use one of the following: ${r.toList().join(
15
+ ", "
16
+ )}`
17
+ );
18
+ });
19
+ }, a = async (e) => {
20
+ l(e), c(!0);
21
+ const o = {
22
+ check_in_date: e.checkinDate,
23
+ check_out_date: e.checkoutDate,
24
+ guests: e.guests || 2,
25
+ rooms: e.rooms || 1,
26
+ cash_or_points: e.cashOrPoints || ["cash", "points"],
27
+ currency: e.currency || "USD",
28
+ lat: e.coordinates.latitude,
29
+ lon: e.coordinates.longitude,
30
+ search_range: e.searchRange || 10,
31
+ range_type: e.rangeType || "mi",
32
+ hotel_groups: e.hotelGroups || r.toList(),
33
+ type: e.searchType || p.CITY
34
+ }, t = await i.searchByCoords(o);
35
+ t.success && s(t.data), c(!1);
36
+ }, d = (e) => {
37
+ if (!e.checkinDate || !e.checkoutDate)
38
+ throw new Error("Checkin and checkout dates are required");
39
+ if (!e.hotelId)
40
+ throw new Error("Hotel ID is required");
41
+ if (!e.hotelGroup)
42
+ throw new Error("Hotel group is required");
43
+ if (!r.toList().includes(e.hotelGroup))
44
+ throw new Error(
45
+ `Invalid hotel group: ${e.hotelGroup}. Please use one of the following: ${r.toList().join(", ")}`
46
+ );
47
+ };
6
48
  return {
7
49
  results: h,
8
- loading: a,
9
- searchByCoords: async (e) => {
10
- t(!0);
11
- const c = {
12
- check_in_date: e.checkinDate,
13
- check_out_date: e.checkoutDate,
14
- guests: e.guests || 2,
15
- rooms: e.rooms || 1,
16
- cash_or_points: e.cashOrPoints || ["cash", "points"],
17
- currency: e.currency || "USD",
18
- lat: e.coords.latitude,
19
- lon: e.coords.longitude,
20
- search_range: e.searchRange || 10,
21
- range_type: e.rangeType || "mi",
22
- hotel_groups: e.hotelGroups || ["accor"],
23
- type: e.searchType || u.CITY
24
- }, o = await n.searchByCoords(c);
25
- o.success && s(o.data), t(!1);
26
- },
50
+ loading: u,
51
+ searchByCoords: a,
27
52
  searchByHotelId: async (e) => {
28
- t(!0);
29
- const c = {
53
+ d(e), c(!0);
54
+ const o = {
30
55
  check_in_date: e.checkinDate,
31
56
  check_out_date: e.checkoutDate,
32
57
  hotel_id: e.hotelId,
@@ -35,11 +60,11 @@ const _ = () => {
35
60
  currency: e.currency || "USD",
36
61
  cash_or_points: e.cashOrPoints || ["cash", "points"],
37
62
  hotel_group: e.hotelGroup
38
- }, o = await n.searchByHotelId(c);
39
- o.success && s(o.data), t(!1);
63
+ }, t = await i.searchByHotelId(o);
64
+ t.success && s(t.data), c(!1);
40
65
  }
41
66
  };
42
67
  };
43
68
  export {
44
- _ as useHotelSearch
69
+ m as useHotelSearch
45
70
  };
@@ -6,7 +6,7 @@ export interface ISearchByCoordsParams extends ISearchByParams {
6
6
  * @type ICoordinates
7
7
  * @example { latitude: 123.456, longitude: 123.456 }
8
8
  */
9
- coords: ICoordinates;
9
+ coordinates: ICoordinates;
10
10
  /**
11
11
  * Optional search range in miles
12
12
  * @default 10
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@odynn/awayz-hotels",
3
3
  "private": false,
4
- "version": "0.1.2",
4
+ "version": "0.1.3",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"