@odynn/awayz-hotels 0.2.0 → 0.2.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,27 +1,30 @@
1
- import { jsxs as s, jsx as l } from "react/jsx-runtime";
1
+ import { jsxs as a, jsx as s } from "react/jsx-runtime";
2
2
  import { a as d, b as i } from "../../../index-D8bHwbxH.js";
3
3
  import '../../../assets/Ratings.css';var p = /* @__PURE__ */ ((r) => (r.INHERIT = "inherit", r.PRIMARY = "primary", r.LIGHT = "light", r.DARK = "dark", r))(p || {});
4
- const f = ({
4
+ const o = ({
5
5
  starRating: r,
6
- userRating: a,
7
- color: m = "dark",
6
+ userRating: e,
7
+ color: n = "dark",
8
8
  fill: c = !1,
9
- starColor: e = "primary"
9
+ starColor: l = "primary"
10
10
  /* PRIMARY */
11
11
  }) => {
12
- if (!r && !a) return null;
13
- const n = r ? c ? /* @__PURE__ */ l(d, { className: e }) : /* @__PURE__ */ l(i, { className: e }) : null;
14
- return /* @__PURE__ */ s("div", { className: `rating ${m}`, children: [
15
- n,
16
- /* @__PURE__ */ l("p", { children: r ? r + "-star" : null }),
17
- a ? /* @__PURE__ */ s("p", { children: [
12
+ if (!r && !e) return null;
13
+ const m = !e || e === 0 || e.toString().toLowerCase() === "none", t = r ? c ? /* @__PURE__ */ s(d, { className: l }) : /* @__PURE__ */ s(i, { className: l }) : null;
14
+ return /* @__PURE__ */ a("div", { className: `rating ${n}`, children: [
15
+ t,
16
+ r ? /* @__PURE__ */ a("p", { children: [
17
+ r,
18
+ "-star"
19
+ ] }) : null,
20
+ m ? null : /* @__PURE__ */ a("p", { children: [
18
21
  "(",
19
- a,
22
+ e,
20
23
  " rating)"
21
- ] }) : null
24
+ ] })
22
25
  ] });
23
26
  };
24
27
  export {
25
28
  p as ERatingColor,
26
- f as default
29
+ o as default
27
30
  };
@@ -1,67 +1,61 @@
1
1
  import { jsxs as o, jsx as t } from "react/jsx-runtime";
2
- import { useState as v, useRef as k, useEffect as u } from "react";
2
+ import { useState as N, useRef as H, useEffect as m } from "react";
3
3
  import '../../assets/_styles.css';/* empty css */
4
- import { o as x } from "../../stringUtils-CvWpky85.js";
4
+ import { o as S } from "../../stringUtils-CvWpky85.js";
5
5
  import "../../moment-BGjjqtLQ.js";
6
6
  import "../../arrayExtensions-cyilNkdJ.js";
7
- import { UnavailableDate as H } from "../Banners/UnavailableDate/UnavailableDate.js";
8
- import { c as w, d as B, e as j, f as T, g as D } from "../../index-D8bHwbxH.js";
9
- import { HotelChains as y } from "../../definitions/HotelChains.js";
10
- import G, { ERatingColor as M } from "../Banners/Ratings/Ratings.js";
11
- import { getBookingOptions as U } from "../../utilities/hotelUtils/hotelUtils.js";
12
- const E = (...e) => e.join(" ");
13
- function z(e) {
7
+ import { UnavailableDate as B } from "../Banners/UnavailableDate/UnavailableDate.js";
8
+ import { c as j, d as w, e as T, f as G, g as E } from "../../index-D8bHwbxH.js";
9
+ import { HotelChains as v } from "../../definitions/HotelChains.js";
10
+ import z, { ERatingColor as D } from "../Banners/Ratings/Ratings.js";
11
+ import { getBookingOptions as L } from "../../utilities/hotelUtils/hotelUtils.js";
12
+ import { CashValue as M } from "@odynn/awayz-core";
13
+ const O = (...e) => e.join(" ");
14
+ function P(e) {
14
15
  if (!e || isNaN(e) || e < 0) return "N/A";
15
16
  let n = e == null ? void 0 : e.toString().split(".")[0];
16
17
  return n == null ? void 0 : n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
17
18
  }
18
- const L = (e, n) => {
19
- if (e <= 0) return "N/A";
20
- var a = new Intl.NumberFormat("en-US", {
21
- style: "currency",
22
- currency: "USD"
23
- });
24
- return e ? a.format(Math.round(e)).toString().split(".")[0] : a.format(0);
25
- }, _ = ({
19
+ const te = ({
26
20
  details: e,
27
21
  onHotelSelect: n,
28
- onViewDetails: a,
29
- customStyling: F = !1,
30
- isSelected: i,
22
+ onViewDetails: C,
23
+ customStyling: y = !1,
24
+ isSelected: c,
31
25
  showBookableTag: R = !1,
32
- customBookableTag: S = "Bookable"
26
+ customBookableTag: F = "Bookable"
33
27
  }) => {
34
- var N;
35
- const [c, d] = v(i), p = k(null), {
36
- transferPartners: r,
37
- bestBookingOption: s,
38
- alternateBookingOption: h,
39
- hasPoints: I
40
- } = U(e), [l, b] = v(0), m = r == null ? void 0 : r[l], f = typeof e.cashValue.amount == "number" ? e.cashValue.amount : parseFloat(e.cashValue.amount), g = (m == null ? void 0 : m.value) > 0 || (s == null ? void 0 : s.value) > 0 || (h == null ? void 0 : h.value) > 0 || f > 0;
41
- u(() => {
42
- i !== void 0 && d(i);
43
- }, [i]), u(() => {
44
- const C = setTimeout(() => {
45
- const V = l >= (r == null ? void 0 : r.length) - 1 ? 0 : l + 1;
46
- return b(V), () => {
47
- clearTimeout(C);
28
+ var g;
29
+ const [i, u] = N(c), d = H(null), {
30
+ transferPartners: a,
31
+ bestBookingOption: l,
32
+ alternateBookingOption: s,
33
+ hasPoints: V
34
+ } = L(e), [r, I] = N(0), h = a == null ? void 0 : a[r], p = typeof e.cashValue.amount == "number" ? e.cashValue.amount : parseFloat(e.cashValue.amount), { currency: b } = e.cashValue, f = (h == null ? void 0 : h.value) > 0 || (l == null ? void 0 : l.value) > 0 || (s == null ? void 0 : s.value) > 0 || p > 0;
35
+ m(() => {
36
+ c !== void 0 && u(c);
37
+ }, [c]), m(() => {
38
+ const k = setTimeout(() => {
39
+ const x = r >= (a == null ? void 0 : a.length) - 1 ? 0 : r + 1;
40
+ return I(x), () => {
41
+ clearTimeout(k);
48
42
  };
49
43
  }, 2e3);
50
- }, [l, r == null ? void 0 : r.length]);
51
- const A = y.isHotelChain(e.hotelGroup);
52
- return u(() => {
53
- c && p.current.scrollIntoView({
44
+ }, [r, a == null ? void 0 : a.length]);
45
+ const A = v.isHotelChain(e.hotelGroup);
46
+ return m(() => {
47
+ i && d.current.scrollIntoView({
54
48
  behavior: "smooth",
55
49
  block: "center"
56
50
  });
57
- }, [c]), /* @__PURE__ */ o(
51
+ }, [i]), /* @__PURE__ */ o(
58
52
  "div",
59
53
  {
60
- ref: p,
61
- className: E(
62
- F ? "hotel-result" : "awayz-hotel-result",
54
+ ref: d,
55
+ className: O(
56
+ y ? "hotel-result" : "awayz-hotel-result",
63
57
  // insufficient_points ? 'insufficient-points' : '',
64
- c ? "go-to-journey-button" : ""
58
+ i ? "go-to-journey-button" : ""
65
59
  ),
66
60
  "data-testid": "search-result",
67
61
  children: [
@@ -70,7 +64,7 @@ const L = (e, n) => {
70
64
  {
71
65
  className: "content",
72
66
  onClick: () => {
73
- d(!c), n(e);
67
+ u(!i), n(e);
74
68
  },
75
69
  children: [
76
70
  /* @__PURE__ */ o("div", { className: "details", children: [
@@ -82,35 +76,35 @@ const L = (e, n) => {
82
76
  backgroundImage: `url(${e.images[0]})`
83
77
  },
84
78
  children: /* @__PURE__ */ o("div", { className: "hotel-chain", children: [
85
- /* @__PURE__ */ t(w, {}),
86
- /* @__PURE__ */ t("p", { children: y.toString(e.hotelGroup) })
79
+ /* @__PURE__ */ t(j, {}),
80
+ /* @__PURE__ */ t("p", { children: v.toString(e.hotelGroup) })
87
81
  ] })
88
82
  }
89
83
  ),
90
84
  /* @__PURE__ */ o("div", { className: "info", children: [
91
85
  /* @__PURE__ */ o("div", { className: "hotel-data", children: [
92
86
  /* @__PURE__ */ o("div", { className: "hotel-information", children: [
93
- !!((N = e.cashBookingOffers) != null && N.accommodationId) && R && /* @__PURE__ */ o("div", { children: [
94
- /* @__PURE__ */ t(B, {}),
95
- /* @__PURE__ */ t("p", { children: S })
87
+ !!((g = e.cashBookingOffers) != null && g.accommodationId) && R && /* @__PURE__ */ o("div", { children: [
88
+ /* @__PURE__ */ t(w, {}),
89
+ /* @__PURE__ */ t("p", { children: F })
96
90
  ] }),
97
91
  /* @__PURE__ */ t(
98
- G,
92
+ z,
99
93
  {
100
94
  starRating: e.chainRating ?? 0,
101
- starColor: M.PRIMARY,
95
+ starColor: D.PRIMARY,
102
96
  userRating: e.reviewRating ?? "",
103
97
  fill: !0
104
98
  }
105
99
  ),
106
100
  e.freeNight && /* @__PURE__ */ o("div", { children: [
107
- /* @__PURE__ */ t(j, {}),
101
+ /* @__PURE__ */ t(T, {}),
108
102
  /* @__PURE__ */ t("p", { children: "Free Night" })
109
103
  ] }),
110
104
  typeof e.nthNightFree == "number" && e.nthNightFree > 0 && /* @__PURE__ */ o("div", { children: [
111
- /* @__PURE__ */ t(T, {}),
105
+ /* @__PURE__ */ t(G, {}),
112
106
  /* @__PURE__ */ o("p", { children: [
113
- x(e.nthNightFree),
107
+ S(e.nthNightFree),
114
108
  " Night Free"
115
109
  ] })
116
110
  ] })
@@ -119,10 +113,10 @@ const L = (e, n) => {
119
113
  /* @__PURE__ */ t("p", { className: "hotel-address", children: e.address })
120
114
  ] }),
121
115
  /* @__PURE__ */ t(
122
- H,
116
+ B,
123
117
  {
124
- hasPoints: I,
125
- isAvailable: g,
118
+ hasPoints: V,
119
+ isAvailable: f,
126
120
  selectedHotel: () => {
127
121
  },
128
122
  chainName: e.hotelGroup
@@ -130,15 +124,15 @@ const L = (e, n) => {
130
124
  )
131
125
  ] })
132
126
  ] }),
133
- g && /* @__PURE__ */ o("div", { className: "payments", children: [
127
+ f && /* @__PURE__ */ o("div", { className: "payments", children: [
134
128
  A && /* @__PURE__ */ o("div", { className: "payment-details", children: [
135
129
  /* @__PURE__ */ t("p", { children: "POINTS" }),
136
- /* @__PURE__ */ t("p", { children: z(e.awardPoints) }),
130
+ /* @__PURE__ */ t("p", { children: P(e.awardPoints) }),
137
131
  e.bestValue === "points" && /* @__PURE__ */ t("p", { className: "best-value", children: "Best Value" })
138
132
  ] }),
139
133
  /* @__PURE__ */ o("div", { className: "payment-details", children: [
140
134
  /* @__PURE__ */ t("p", { children: "CASH" }),
141
- /* @__PURE__ */ t("p", { children: L(f) }),
135
+ /* @__PURE__ */ t(M, { amount: p, currency: b }),
142
136
  e.bestValue === "cash" && /* @__PURE__ */ t("p", { className: "best-value", children: "Best Value" })
143
137
  ] })
144
138
  ] })
@@ -150,9 +144,9 @@ const L = (e, n) => {
150
144
  {
151
145
  "data-testid": "go-to-journey-button",
152
146
  onClick: () => {
153
- a(e);
147
+ C(e);
154
148
  },
155
- children: /* @__PURE__ */ t(D, {})
149
+ children: /* @__PURE__ */ t(E, {})
156
150
  }
157
151
  )
158
152
  ]
@@ -160,5 +154,5 @@ const L = (e, n) => {
160
154
  );
161
155
  };
162
156
  export {
163
- _ as HotelResult
157
+ te as HotelResult
164
158
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@odynn/awayz-hotels",
3
3
  "private": false,
4
- "version": "0.2.0",
4
+ "version": "0.2.2",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -65,7 +65,7 @@
65
65
  ]
66
66
  },
67
67
  "dependencies": {
68
- "@odynn/awayz-core": "^0.2.0",
68
+ "@odynn/awayz-core": "^0.2.1",
69
69
  "@tanstack/react-query": "^5.66.9"
70
70
  }
71
71
  }