@odynn/awayz-hotels 0.6.7 → 0.6.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,135 +1,137 @@
1
- import { awayzClient as m } from "@odynn/awayz-core";
2
- import { useQuery as v, useMutation as E } from "@tanstack/react-query";
1
+ import { awayzClient as v } from "@odynn/awayz-core";
2
+ import { useQuery as f, useMutation as p } from "@tanstack/react-query";
3
3
  import "../../moment-BGjjqtLQ.js";
4
4
  import "../../arrayExtensions-CFEBYUok.js";
5
- import { c as p } from "../../objectUtils-DOsrxUF7.js";
5
+ import { c as b } from "../../objectUtils-DOsrxUF7.js";
6
6
  import { E as u } from "../../enums-DxmoBOKL.js";
7
7
  import "react";
8
8
  import { AvailabilityAlertsService as w } from "../../services/availabilityAlerts/AvailabilityAlertsService.js";
9
- const b = ({
10
- checkin: t,
11
- checkout: i,
12
- hotelGroup: o,
13
- hotelId: n,
14
- name: l,
15
- hotelImage: s,
16
- hotelAddress: a,
17
- hotelDescription: A,
18
- hotelProgramName: d
9
+ const h = ({
10
+ checkin: r,
11
+ checkout: t,
12
+ hotelGroup: a,
13
+ hotelId: o,
14
+ name: n,
15
+ hotelImage: l,
16
+ hotelAddress: i,
17
+ hotelDescription: s,
18
+ hotelProgramName: A
19
19
  }) => {
20
- if (!n)
20
+ if (!o)
21
21
  throw new Error("Hotel ID is required");
22
- if (!t)
22
+ if (!r)
23
23
  throw new Error("Check-in date is required");
24
- if (new Date(t) <= /* @__PURE__ */ new Date())
24
+ if (new Date(r) <= /* @__PURE__ */ new Date())
25
25
  throw new Error("Check-in date must be in the future");
26
- if (!i)
26
+ if (!t)
27
27
  throw new Error("Check-out date is required");
28
- if (new Date(i) <= /* @__PURE__ */ new Date())
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(i) <= new Date(t))
30
+ if (new Date(t) <= new Date(r))
31
31
  throw new Error("Check-out date must be after check-in date");
32
- if (!l)
32
+ if (!n)
33
33
  throw new Error("Hotel name is required");
34
- if (!o)
34
+ if (!a)
35
35
  throw new Error("Hotel group is required");
36
- if (!s)
36
+ if (!l)
37
37
  throw new Error("Hotel image is required");
38
- if (!a)
38
+ if (!i)
39
39
  throw new Error("Hotel address is required");
40
- if (!A)
40
+ if (!s)
41
41
  throw new Error("Hotel description is required");
42
- if (!d)
42
+ if (!A)
43
43
  throw new Error("Hotel program name is required");
44
- }, h = ({
45
- alertId: t,
46
- checkin: i,
47
- checkout: o,
48
- hotelGroup: n,
49
- hotelId: l,
50
- name: s,
51
- hotelImage: a,
52
- hotelAddress: A,
53
- hotelDescription: d,
44
+ }, q = ({
45
+ alertId: r,
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
54
  hotelProgramName: y,
55
- archived: c
55
+ archived: c,
56
+ acknowledged: E
56
57
  }) => {
57
- if (!t)
58
+ if (!r)
58
59
  throw new Error("Alert ID is required");
59
60
  if (![
60
- i,
61
+ t,
62
+ a,
61
63
  o,
62
64
  n,
63
65
  l,
66
+ i,
64
67
  s,
65
- a,
66
68
  A,
67
- d,
68
69
  y,
69
- c
70
+ c,
71
+ E
70
72
  ].some(
71
- (r) => r != null && r !== ""
73
+ (m) => m != null && m !== ""
72
74
  ))
73
75
  throw new Error("At least one field must be provided for update");
74
- }, H = () => {
75
- const { data: t = [] } = v({
76
+ }, K = () => {
77
+ const { data: r = [] } = f({
76
78
  queryKey: [u.AVAILABILITY_ALERTS],
77
79
  queryFn: () => w.getMyActiveAlerts()
78
- }), { data: i = [] } = v({
80
+ }), { data: t = [] } = f({
79
81
  queryKey: [u.ALERT_NOTIFICATIONS],
80
82
  queryFn: () => w.getAlertNotifications()
81
83
  }), {
82
- mutate: o,
83
- isPending: n,
84
- isError: l,
85
- error: s
86
- } = E({
87
- mutationFn: async (e) => (b(e), await w.createAvailabilityAlert(e)),
84
+ mutate: a,
85
+ isPending: o,
86
+ isError: n,
87
+ error: l
88
+ } = p({
89
+ mutationFn: async (e) => (h(e), await w.createAvailabilityAlert(e)),
88
90
  onSuccess: () => {
89
- m.invalidateQueries({
91
+ v.invalidateQueries({
90
92
  queryKey: [u.AVAILABILITY_ALERTS]
91
93
  });
92
94
  }
93
95
  }), {
94
- mutate: a,
95
- isPending: A,
96
- isError: d,
96
+ mutate: i,
97
+ isPending: s,
98
+ isError: A,
97
99
  error: y,
98
100
  data: c
99
- } = E({
101
+ } = p({
100
102
  mutationFn: async (e) => {
101
- h(e);
102
- const r = await w.updateAvailabilityAlert(e);
103
- return p(r);
103
+ q(e);
104
+ const d = await w.updateAvailabilityAlert(e);
105
+ return b(d);
104
106
  },
105
107
  onSuccess: () => {
106
- m.invalidateQueries({
108
+ v.invalidateQueries({
107
109
  queryKey: [u.AVAILABILITY_ALERTS]
108
- }), m.invalidateQueries({
110
+ }), v.invalidateQueries({
109
111
  queryKey: [u.ALERT_NOTIFICATIONS]
110
112
  });
111
113
  }
112
114
  });
113
115
  return {
114
- activeAlerts: t,
115
- alertNotifications: i,
116
+ activeAlerts: r,
117
+ alertNotifications: t,
116
118
  // Mutation for creating a new availability alert
117
- createAvailabilityAlert: o,
118
- isCreateAvailabilityAlertPending: n,
119
- isCreateAvailabilityAlertError: l,
120
- createAvailabilityAlertError: s,
119
+ createAvailabilityAlert: a,
120
+ isCreateAvailabilityAlertPending: o,
121
+ isCreateAvailabilityAlertError: n,
122
+ createAvailabilityAlertError: l,
121
123
  // Mutation for updating/removing an existing alert
122
- updateAvailabilityAlert: a,
123
- isUpdateAvailabilityAlertPending: A,
124
- isUpdateAvailabilityAlertError: d,
124
+ updateAvailabilityAlert: i,
125
+ isUpdateAvailabilityAlertPending: s,
126
+ isUpdateAvailabilityAlertError: A,
125
127
  updateAvailabilityAlertError: y,
126
128
  updatedAvailabilityAlert: c,
127
129
  // convenience function to update acknowledgment
128
- updateAcknowledgement: (e, r = !0) => a({ alertId: e, acknowledged: r })
130
+ updateAcknowledgement: (e, d = !0) => i({ alertId: e, acknowledged: d })
129
131
  };
130
132
  };
131
133
  export {
132
- H as useAvailabilityAlerts,
133
- b as validateCreateAvailabilityAlert,
134
- h as validateUpdateAvailabilityAlert
134
+ K as useAvailabilityAlerts,
135
+ h as validateCreateAvailabilityAlert,
136
+ q as validateUpdateAvailabilityAlert
135
137
  };
@@ -1,6 +1,6 @@
1
1
  import { ICreateAvailabilityAlertRequest, IUpdateAvailabilityAlertRequest, IUpdateAvailabilityAlertResponse } from './useAvailabilityAlerts.types';
2
2
  export declare const validateCreateAvailabilityAlert: ({ checkin, checkout, hotelGroup, hotelId, name, hotelImage, hotelAddress, hotelDescription, hotelProgramName }: ICreateAvailabilityAlertRequest) => void;
3
- export declare const validateUpdateAvailabilityAlert: ({ alertId, checkin, checkout, hotelGroup, hotelId, name, hotelImage, hotelAddress, hotelDescription, hotelProgramName, archived }: IUpdateAvailabilityAlertRequest) => void;
3
+ export declare const validateUpdateAvailabilityAlert: ({ alertId, checkin, checkout, hotelGroup, hotelId, name, hotelImage, hotelAddress, hotelDescription, hotelProgramName, archived, acknowledged }: IUpdateAvailabilityAlertRequest) => void;
4
4
  /**
5
5
  * Custom hook to manage availability alerts for hotels.
6
6
  * Provides functionality to create, update, and fetch availability alerts, as well as
@@ -1,4 +1,21 @@
1
1
  import { EAvailabilityAlertStatus } from '../../enums/EAvailabilityAlert';
2
+ /**
3
+ * Represents an availability alert for a hotel.
4
+ * @property id - Unique identifier for the alert.
5
+ * @property hotelName - Name of the hotel.
6
+ * @property hotelId - Unique identifier for the hotel.
7
+ * @property hotelAddress - Address of the hotel.
8
+ * @property hotelImage - Image URL of the hotel.
9
+ * @property checkin - Check-in date (ISO string).
10
+ * @property checkout - Check-out date (ISO string).
11
+ * @property hotelStatus - Current status of the hotel alert.
12
+ * @property hotelGroup - Group or brand of the hotel.
13
+ * @property hotelDescription - Description of the hotel.
14
+ * @property numberOfGuests - Number of guests for the booking.
15
+ * @property numberOfRooms - Number of rooms for the booking.
16
+ * @property archived - Whether the alert is archived.
17
+ * @property acknowledged - Whether the alert has been acknowledged by the user.
18
+ */
2
19
  export interface IAvailabilityAlert {
3
20
  id: string;
4
21
  hotelName: string;
@@ -13,7 +30,22 @@ export interface IAvailabilityAlert {
13
30
  numberOfGuests: number;
14
31
  numberOfRooms: number;
15
32
  archived: boolean;
33
+ acknowledged: boolean;
16
34
  }
35
+ /**
36
+ * Request payload for creating a new availability alert.
37
+ * @property checkin - Check-in date (ISO string).
38
+ * @property checkout - Check-out date (ISO string).
39
+ * @property hotelGroup - Group or brand of the hotel.
40
+ * @property hotelId - Unique identifier for the hotel.
41
+ * @property name - Name of the hotel.
42
+ * @property hotelImage - Image URL of the hotel.
43
+ * @property hotelAddress - Address of the hotel.
44
+ * @property hotelDescription - Description of the hotel.
45
+ * @property hotelProgramName - Loyalty program name for the hotel.
46
+ * @property numberOfGuests - Number of guests for the booking (optional).
47
+ * @property numberOfRooms - Number of rooms for the booking (optional).
48
+ */
17
49
  export interface ICreateAvailabilityAlertRequest {
18
50
  checkin: string;
19
51
  checkout: string;
@@ -27,11 +59,27 @@ export interface ICreateAvailabilityAlertRequest {
27
59
  numberOfGuests?: number;
28
60
  numberOfRooms?: number;
29
61
  }
62
+ /**
63
+ * Request payload for updating an existing availability alert.
64
+ * Extends partial properties from ICreateAvailabilityAlertRequest.
65
+ * @property alertId - Unique identifier for the alert to update.
66
+ * @property archived - Whether the alert should be archived (optional).
67
+ * @property acknowledged - Whether the alert should be acknowledged (optional).
68
+ */
30
69
  export interface IUpdateAvailabilityAlertRequest extends Partial<ICreateAvailabilityAlertRequest> {
31
70
  alertId: string;
32
71
  archived?: boolean;
33
72
  acknowledged?: boolean;
34
73
  }
74
+ /**
75
+ * Response payload after updating an availability alert.
76
+ * @property alertId - Unique identifier for the alert.
77
+ * @property userId - Unique identifier for the user.
78
+ * @property alertParams - Parameters of the updated alert.
79
+ * @property archived - Whether the alert is archived.
80
+ * @property active - Whether the alert is active.
81
+ * @property batch - Batch number for processing.
82
+ */
35
83
  export interface IUpdateAvailabilityAlertResponse {
36
84
  alertId: string;
37
85
  userId: string;
@@ -55,6 +103,21 @@ export interface IUpdateAvailabilityAlertResponse {
55
103
  active: boolean;
56
104
  batch: number;
57
105
  }
106
+ /**
107
+ * Represents a notification for an availability alert.
108
+ * @property id - Unique identifier for the notification.
109
+ * @property hotelName - Name of the hotel.
110
+ * @property hotelId - Unique identifier for the hotel.
111
+ * @property hotelAddress - Address of the hotel.
112
+ * @property hotelImage - Image URL of the hotel.
113
+ * @property checkInDate - Check-in date (ISO string).
114
+ * @property checkOutDate - Check-out date (ISO string).
115
+ * @property hotelGroup - Group or brand of the hotel.
116
+ * @property acknowledged - Whether the notification has been acknowledged.
117
+ * @property hasSentMail - Whether a notification email has been sent.
118
+ * @property numberOfGuests - Number of guests for the booking.
119
+ * @property numberOfRooms - Number of rooms for the booking.
120
+ */
58
121
  export interface IAvailabilityAlertNotification {
59
122
  id: string;
60
123
  hotelName: string;
@@ -18,6 +18,7 @@ export interface ICreateAlertParams {
18
18
  export interface IUpdateAlertParams extends Partial<ICreateAlertParams> {
19
19
  alert_id: string;
20
20
  archived?: boolean;
21
+ acknowledged?: boolean;
21
22
  }
22
23
  export interface ICreateAlertResponse {
23
24
  success: true;
@@ -1,13 +1,13 @@
1
- var h = Object.defineProperty;
2
- var c = (r, a, t) => a in r ? h(r, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[a] = t;
3
- var l = (r, a, t) => c(r, typeof a != "symbol" ? a + "" : a, t);
1
+ var c = Object.defineProperty;
2
+ var h = (r, a, t) => a in r ? c(r, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[a] = t;
3
+ var l = (r, a, t) => h(r, typeof a != "symbol" ? a + "" : a, t);
4
4
  import { clientInstance as m } from "@odynn/awayz-core";
5
5
  import "../../moment-BGjjqtLQ.js";
6
6
  import "../../arrayExtensions-CFEBYUok.js";
7
7
  import { a as p } from "../../objectUtils-DOsrxUF7.js";
8
8
  import "react";
9
9
  import { EHotelEndpoints as _ } from "../../configs/endpoints.js";
10
- class n {
10
+ class d {
11
11
  constructor() {
12
12
  l(this, "getMyActiveAlerts", async () => {
13
13
  const { data: a } = await m.get(_.AVAILABILITY_ALERTS);
@@ -27,6 +27,7 @@ class n {
27
27
  hotelStatus: e.alert_params.hotel_status.toLowerCase(),
28
28
  numberOfGuests: (s = e.alert_params) == null ? void 0 : s.number_of_guests,
29
29
  numberOfRooms: (o = e.alert_params) == null ? void 0 : o.number_of_rooms,
30
+ acknowledged: e.alert_params.acknowledged,
30
31
  archived: e.archived
31
32
  };
32
33
  }
@@ -94,7 +95,7 @@ class n {
94
95
  });
95
96
  }
96
97
  }
97
- const k = new n();
98
+ const b = new d();
98
99
  export {
99
- k as AvailabilityAlertsService
100
+ b as AvailabilityAlertsService
100
101
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@odynn/awayz-hotels",
3
3
  "private": false,
4
- "version": "0.6.7",
4
+ "version": "0.6.9",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"