@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.
- package/dist/hooks/useAvailabilityAlerts/useAvailabilityAlerts.js +76 -74
- package/dist/lib/hooks/useAvailabilityAlerts/useAvailabilityAlerts.d.ts +1 -1
- package/dist/lib/hooks/useAvailabilityAlerts/useAvailabilityAlerts.types.d.ts +63 -0
- package/dist/lib/services/availabilityAlerts/AvailabilityAlertsService.types.d.ts +1 -0
- package/dist/services/availabilityAlerts/AvailabilityAlertsService.js +7 -6
- package/package.json +1 -1
|
@@ -1,135 +1,137 @@
|
|
|
1
|
-
import { awayzClient as
|
|
2
|
-
import { useQuery as
|
|
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
|
|
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
|
|
10
|
-
checkin:
|
|
11
|
-
checkout:
|
|
12
|
-
hotelGroup:
|
|
13
|
-
hotelId:
|
|
14
|
-
name:
|
|
15
|
-
hotelImage:
|
|
16
|
-
hotelAddress:
|
|
17
|
-
hotelDescription:
|
|
18
|
-
hotelProgramName:
|
|
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 (!
|
|
20
|
+
if (!o)
|
|
21
21
|
throw new Error("Hotel ID is required");
|
|
22
|
-
if (!
|
|
22
|
+
if (!r)
|
|
23
23
|
throw new Error("Check-in date is required");
|
|
24
|
-
if (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 (!
|
|
26
|
+
if (!t)
|
|
27
27
|
throw new Error("Check-out date is required");
|
|
28
|
-
if (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(
|
|
30
|
+
if (new Date(t) <= new Date(r))
|
|
31
31
|
throw new Error("Check-out date must be after check-in date");
|
|
32
|
-
if (!
|
|
32
|
+
if (!n)
|
|
33
33
|
throw new Error("Hotel name is required");
|
|
34
|
-
if (!
|
|
34
|
+
if (!a)
|
|
35
35
|
throw new Error("Hotel group is required");
|
|
36
|
-
if (!
|
|
36
|
+
if (!l)
|
|
37
37
|
throw new Error("Hotel image is required");
|
|
38
|
-
if (!
|
|
38
|
+
if (!i)
|
|
39
39
|
throw new Error("Hotel address is required");
|
|
40
|
-
if (!
|
|
40
|
+
if (!s)
|
|
41
41
|
throw new Error("Hotel description is required");
|
|
42
|
-
if (!
|
|
42
|
+
if (!A)
|
|
43
43
|
throw new Error("Hotel program name is required");
|
|
44
|
-
},
|
|
45
|
-
alertId:
|
|
46
|
-
checkin:
|
|
47
|
-
checkout:
|
|
48
|
-
hotelGroup:
|
|
49
|
-
hotelId:
|
|
50
|
-
name:
|
|
51
|
-
hotelImage:
|
|
52
|
-
hotelAddress:
|
|
53
|
-
hotelDescription:
|
|
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 (!
|
|
58
|
+
if (!r)
|
|
58
59
|
throw new Error("Alert ID is required");
|
|
59
60
|
if (![
|
|
60
|
-
|
|
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
|
-
(
|
|
73
|
+
(m) => m != null && m !== ""
|
|
72
74
|
))
|
|
73
75
|
throw new Error("At least one field must be provided for update");
|
|
74
|
-
},
|
|
75
|
-
const { data:
|
|
76
|
+
}, K = () => {
|
|
77
|
+
const { data: r = [] } = f({
|
|
76
78
|
queryKey: [u.AVAILABILITY_ALERTS],
|
|
77
79
|
queryFn: () => w.getMyActiveAlerts()
|
|
78
|
-
}), { data:
|
|
80
|
+
}), { data: t = [] } = f({
|
|
79
81
|
queryKey: [u.ALERT_NOTIFICATIONS],
|
|
80
82
|
queryFn: () => w.getAlertNotifications()
|
|
81
83
|
}), {
|
|
82
|
-
mutate:
|
|
83
|
-
isPending:
|
|
84
|
-
isError:
|
|
85
|
-
error:
|
|
86
|
-
} =
|
|
87
|
-
mutationFn: async (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
|
-
|
|
91
|
+
v.invalidateQueries({
|
|
90
92
|
queryKey: [u.AVAILABILITY_ALERTS]
|
|
91
93
|
});
|
|
92
94
|
}
|
|
93
95
|
}), {
|
|
94
|
-
mutate:
|
|
95
|
-
isPending:
|
|
96
|
-
isError:
|
|
96
|
+
mutate: i,
|
|
97
|
+
isPending: s,
|
|
98
|
+
isError: A,
|
|
97
99
|
error: y,
|
|
98
100
|
data: c
|
|
99
|
-
} =
|
|
101
|
+
} = p({
|
|
100
102
|
mutationFn: async (e) => {
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
return
|
|
103
|
+
q(e);
|
|
104
|
+
const d = await w.updateAvailabilityAlert(e);
|
|
105
|
+
return b(d);
|
|
104
106
|
},
|
|
105
107
|
onSuccess: () => {
|
|
106
|
-
|
|
108
|
+
v.invalidateQueries({
|
|
107
109
|
queryKey: [u.AVAILABILITY_ALERTS]
|
|
108
|
-
}),
|
|
110
|
+
}), v.invalidateQueries({
|
|
109
111
|
queryKey: [u.ALERT_NOTIFICATIONS]
|
|
110
112
|
});
|
|
111
113
|
}
|
|
112
114
|
});
|
|
113
115
|
return {
|
|
114
|
-
activeAlerts:
|
|
115
|
-
alertNotifications:
|
|
116
|
+
activeAlerts: r,
|
|
117
|
+
alertNotifications: t,
|
|
116
118
|
// Mutation for creating a new availability alert
|
|
117
|
-
createAvailabilityAlert:
|
|
118
|
-
isCreateAvailabilityAlertPending:
|
|
119
|
-
isCreateAvailabilityAlertError:
|
|
120
|
-
createAvailabilityAlertError:
|
|
119
|
+
createAvailabilityAlert: a,
|
|
120
|
+
isCreateAvailabilityAlertPending: o,
|
|
121
|
+
isCreateAvailabilityAlertError: n,
|
|
122
|
+
createAvailabilityAlertError: l,
|
|
121
123
|
// Mutation for updating/removing an existing alert
|
|
122
|
-
updateAvailabilityAlert:
|
|
123
|
-
isUpdateAvailabilityAlertPending:
|
|
124
|
-
isUpdateAvailabilityAlertError:
|
|
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,
|
|
130
|
+
updateAcknowledgement: (e, d = !0) => i({ alertId: e, acknowledged: d })
|
|
129
131
|
};
|
|
130
132
|
};
|
|
131
133
|
export {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var l = (r, 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
|
|
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
|
|
98
|
+
const b = new d();
|
|
98
99
|
export {
|
|
99
|
-
|
|
100
|
+
b as AvailabilityAlertsService
|
|
100
101
|
};
|