@odynn/awayz-core 0.2.33 → 0.3.0
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/AccountService-Ct4hShV-.js +2037 -0
- package/dist/DateFormats-DZD30Nea.js +4 -0
- package/dist/{_commonjsHelpers-B52_cu2H.js → _commonjsHelpers-MdHo5S7N.js} +2 -2
- package/dist/{AccountService-8OR0UkZ6.js → arrayExtensions-DlcBOj5a.js} +1338 -3360
- package/dist/assets/FlightBooking.css +1 -0
- package/dist/assets/HotelBooking.css +1 -0
- package/dist/assets/Menu.css +1 -0
- package/dist/components/Bookings/FlightBooking/FlightBooking.js +88 -0
- package/dist/components/Bookings/HotelBooking/HotelBooking.js +75 -0
- package/dist/components/CashValue/CashValue.js +519 -2173
- package/dist/components/CashValue/CashValue.stories.js +18 -17
- package/dist/components/Menu/Menu.js +2491 -0
- package/dist/configs/endpoints.js +4 -2
- package/dist/hooks/useAwayzAuth/useAwayzAuth.js +12 -11
- package/dist/hooks/useBookingManagement/useBookingManagement.js +79 -0
- package/dist/hooks/useBookingManagement/useBookingManagement.test.js +79 -0
- package/dist/hooks/useBookingManagement/useBookingManagement.types.js +1 -0
- package/dist/hooks/useSearchLimit.js +2 -1
- package/dist/hooks/useTripManagement/mocks/index.js +19 -0
- package/dist/hooks/useTripManagement/useTripManagement.js +190 -0
- package/dist/hooks/useTripManagement/useTripManagement.test.js +205 -0
- package/dist/hooks/useTripManagement/useTripManagement.types.js +1 -0
- package/dist/hooks/useWallet/useWallet.js +7 -6
- package/dist/hooks/useWallet/useWallet.test.js +17 -12851
- package/dist/index-COgXcb6p.js +1696 -0
- package/dist/{index-B7QVGqcx.js → index-Cv-wvFlM.js} +1 -1
- package/dist/lib/components/Bookings/FlightBooking/FlightBooking.d.ts +59 -0
- package/dist/lib/components/Bookings/HotelBooking/HotelBooking.d.ts +52 -0
- package/dist/lib/components/Menu/Menu.d.ts +13 -0
- package/dist/lib/configs/endpoints.d.ts +12 -0
- package/dist/lib/hooks/useBookingManagement/mocks/FlightBooking200.json.d.ts +312 -0
- package/dist/lib/hooks/useBookingManagement/mocks/HotelBooking200.json.d.ts +92 -0
- package/dist/lib/hooks/useBookingManagement/useBookingManagement.d.ts +11 -0
- package/dist/lib/hooks/useBookingManagement/useBookingManagement.test.d.ts +1 -0
- package/dist/lib/hooks/useBookingManagement/useBookingManagement.types.d.ts +49 -0
- package/dist/lib/hooks/useTripManagement/mocks/PastTrip200.json.d.ts +20 -0
- package/dist/lib/hooks/useTripManagement/mocks/UncategorisedBookings200.json.d.ts +123 -0
- package/dist/lib/hooks/useTripManagement/mocks/UpcomingTrip200.json.d.ts +20 -0
- package/dist/lib/hooks/useTripManagement/mocks/UpdatedTrip200.json.d.ts +18 -0
- package/dist/lib/hooks/useTripManagement/mocks/index.d.ts +5 -0
- package/dist/lib/hooks/useTripManagement/useTripManagement.d.ts +9 -0
- package/dist/lib/hooks/useTripManagement/useTripManagement.test.d.ts +1 -0
- package/dist/lib/hooks/useTripManagement/useTripManagement.types.d.ts +109 -0
- package/dist/lib/main.d.ts +1 -0
- package/dist/lib/services/bookings/BookingService.d.ts +10 -0
- package/dist/lib/services/bookings/BookingService.types.d.ts +110 -0
- package/dist/lib/services/trips/TripService.types.d.ts +124 -0
- package/dist/lib/services/trips/TripsService.d.ts +19 -0
- package/dist/main.js +23 -20
- package/dist/providers/AwayzProvider.js +8 -7
- package/dist/services/account/AccountService.js +3 -2
- package/dist/services/bookings/BookingService.js +51 -0
- package/dist/services/bookings/BookingService.types.js +1 -0
- package/dist/services/currency/CurrencyService.js +11 -10
- package/dist/services/index.js +1 -1
- package/dist/services/instance.js +4 -3
- package/dist/services/instanceConfig.js +7 -6
- package/dist/services/noRetryInstance.js +1 -1
- package/dist/services/trips/TripService.types.js +9 -0
- package/dist/services/trips/TripsService.js +81 -0
- package/dist/services/wallet/WalletService.js +18 -23
- package/dist/tests/TestWrapper.js +2 -2
- package/dist/vi.ClIskdbk-k6t29WRA.js +12860 -0
- package/package.json +2 -1
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { h as c } from "../../arrayExtensions-DlcBOj5a.js";
|
|
2
|
+
import { renderHook as o, waitFor as i } from "../../tests/TestWrapper.js";
|
|
3
|
+
import { useTripManagement as n } from "./useTripManagement.js";
|
|
4
|
+
import "react/jsx-runtime";
|
|
5
|
+
import "react";
|
|
6
|
+
import "../../context/AwayzContext.js";
|
|
7
|
+
import { c as d } from "../../AccountService-Ct4hShV-.js";
|
|
8
|
+
import { EMyTripsEndpoints as p } from "../../configs/endpoints.js";
|
|
9
|
+
import "../../configs/awayzClient.js";
|
|
10
|
+
import "@tanstack/react-query";
|
|
11
|
+
import "../../services/noRetryInstance.js";
|
|
12
|
+
import '../../assets/_styles.css';/* empty css */
|
|
13
|
+
import { UncategorisedBookings200 as D, PastTrip200 as B, UpcomingTrip200 as I, UpdatedTrip200 as T } from "./mocks/index.js";
|
|
14
|
+
import { EBookingType as k } from "../../services/trips/TripService.types.js";
|
|
15
|
+
import { d as u, v as l, b, t as s, g as e } from "../../vi.ClIskdbk-k6t29WRA.js";
|
|
16
|
+
let m = {
|
|
17
|
+
past: [...B.data],
|
|
18
|
+
upcoming: [...I.data].concat(T.data)
|
|
19
|
+
};
|
|
20
|
+
u("useTripManagement", () => {
|
|
21
|
+
l.mocked(d.get).mockImplementation((r, t) => {
|
|
22
|
+
var a, g;
|
|
23
|
+
return r === p.UNCATEGORISED_BOOKINGS ? Promise.resolve({
|
|
24
|
+
data: D
|
|
25
|
+
}) : ((a = t == null ? void 0 : t.params) == null ? void 0 : a.status) === "past" ? Promise.resolve({
|
|
26
|
+
data: { ...B, data: m.past }
|
|
27
|
+
}) : ((g = t == null ? void 0 : t.params) == null ? void 0 : g.status) === "upcoming" ? Promise.resolve({
|
|
28
|
+
data: { ...I, data: m.upcoming }
|
|
29
|
+
}) : Promise.resolve({ data: {} });
|
|
30
|
+
}), l.mocked(d.put).mockImplementation((r) => {
|
|
31
|
+
if (r === `${p.TRIPS}/67fd23bc3a7cbcd0a8757cdc`) {
|
|
32
|
+
const t = {
|
|
33
|
+
...T.data,
|
|
34
|
+
name: "Updated Trip"
|
|
35
|
+
};
|
|
36
|
+
return m.past = m.past.map(
|
|
37
|
+
(a) => a._id === "67fd23bc3a7cbcd0a8757cdc" ? t : a
|
|
38
|
+
), m.upcoming = m.upcoming.map(
|
|
39
|
+
(a) => a._id === "67fd23bc3a7cbcd0a8757cdc" ? t : a
|
|
40
|
+
), Promise.resolve({
|
|
41
|
+
data: T
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return r === p.ADD_BOOKING ? Promise.resolve({
|
|
45
|
+
data: { success: !0, message: "Booking added to trip successfully" }
|
|
46
|
+
}) : Promise.resolve({ data: {} });
|
|
47
|
+
}), b(() => {
|
|
48
|
+
l.clearAllMocks();
|
|
49
|
+
}), u("Get User Trips", () => {
|
|
50
|
+
s("Has past trips", async () => {
|
|
51
|
+
const { result: r } = o(() => n());
|
|
52
|
+
await i(() => {
|
|
53
|
+
e(r.current.pastTrips.length).greaterThan(0), e(
|
|
54
|
+
c(r.current.pastTrips[0].endDate).isBefore(c())
|
|
55
|
+
).toBe(!0);
|
|
56
|
+
});
|
|
57
|
+
}), s("Has upcoming trips", async () => {
|
|
58
|
+
const { result: r } = o(() => n());
|
|
59
|
+
await i(() => {
|
|
60
|
+
e(r.current.upcomingTrips.length).greaterThan(0), e(
|
|
61
|
+
c(r.current.upcomingTrips[0].startDate).isAfter(c())
|
|
62
|
+
).toBe(!0);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}), u("Create Trip", () => {
|
|
66
|
+
s("Invalid Requests", async () => {
|
|
67
|
+
const { result: r } = o(() => n());
|
|
68
|
+
r.current.createTrip(), await i(() => {
|
|
69
|
+
var t;
|
|
70
|
+
e(r.current.isCreateTripError).toBe(!0), e((t = r.current.createTripError) == null ? void 0 : t.message).toContain(
|
|
71
|
+
"Trip details are required to create a trip"
|
|
72
|
+
);
|
|
73
|
+
}), r.current.createTrip({
|
|
74
|
+
name: "",
|
|
75
|
+
startDate: "",
|
|
76
|
+
endDate: ""
|
|
77
|
+
}), await i(() => {
|
|
78
|
+
var t;
|
|
79
|
+
e(r.current.isCreateTripError).toBe(!0), e((t = r.current.createTripError) == null ? void 0 : t.message).toContain(
|
|
80
|
+
"Trip name, start date, and end date are required"
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
}), s("Can successfully create a trip", async () => {
|
|
84
|
+
const r = {
|
|
85
|
+
name: "New Trip",
|
|
86
|
+
startDate: c().add(1, "days").format("YYYY-MM-DD"),
|
|
87
|
+
endDate: c().add(2, "days").format("YYYY-MM-DD")
|
|
88
|
+
}, { result: t } = o(() => n());
|
|
89
|
+
t.current.createTrip(r), await i(() => {
|
|
90
|
+
e(d.post).toHaveBeenCalledWith(
|
|
91
|
+
p.TRIPS,
|
|
92
|
+
e.objectContaining({
|
|
93
|
+
name: r.name,
|
|
94
|
+
start_date: r.startDate,
|
|
95
|
+
end_date: r.endDate
|
|
96
|
+
})
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
}), u("Delete Trip", () => {
|
|
101
|
+
s("Can successfully delete a trip", async () => {
|
|
102
|
+
const r = "12345", { result: t } = o(() => n());
|
|
103
|
+
t.current.deleteTrip(r), await i(() => {
|
|
104
|
+
e(d.delete).toHaveBeenCalledWith(
|
|
105
|
+
`${p.TRIPS}/${r}`
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
}), u("Update Trip", () => {
|
|
110
|
+
s("Invalid tripId arg", async () => {
|
|
111
|
+
const { result: r } = o(() => n());
|
|
112
|
+
r.current.updateTrip({
|
|
113
|
+
tripId: "",
|
|
114
|
+
tripDetails: {
|
|
115
|
+
name: "Updated Trip"
|
|
116
|
+
}
|
|
117
|
+
}), await i(() => {
|
|
118
|
+
var t;
|
|
119
|
+
e(r.current.isUpdateTripError).toBe(!0), e((t = r.current.updateTripError) == null ? void 0 : t.message).toContain(
|
|
120
|
+
"Trip ID is required"
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
}), s("Invalid tripDetails arg", async () => {
|
|
124
|
+
const { result: r } = o(() => n());
|
|
125
|
+
r.current.updateTrip({
|
|
126
|
+
tripId: "123",
|
|
127
|
+
tripDetails: {}
|
|
128
|
+
}), await i(() => {
|
|
129
|
+
var t;
|
|
130
|
+
e(r.current.isUpdateTripError).toBe(!0), e((t = r.current.updateTripError) == null ? void 0 : t.message).toContain(
|
|
131
|
+
"Trip details must be provided for update"
|
|
132
|
+
);
|
|
133
|
+
});
|
|
134
|
+
}), s("Successful update", async () => {
|
|
135
|
+
const { result: r } = o(() => n()), t = "682ffebaa6cc24f39d99fdc7";
|
|
136
|
+
r.current.updateTrip({
|
|
137
|
+
tripId: t,
|
|
138
|
+
tripDetails: {
|
|
139
|
+
name: "Updated Trip"
|
|
140
|
+
}
|
|
141
|
+
}), await i(() => {
|
|
142
|
+
e(d.put).toHaveBeenCalledWith(
|
|
143
|
+
`${p.TRIPS}/${t}`,
|
|
144
|
+
e.objectContaining({
|
|
145
|
+
name: "Updated Trip"
|
|
146
|
+
})
|
|
147
|
+
);
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
}), u("Add Booking to Trip", () => {
|
|
151
|
+
s("Invalid tripId arg", async () => {
|
|
152
|
+
const { result: r } = o(() => n());
|
|
153
|
+
r.current.addBookingToTrip({
|
|
154
|
+
booking: r.current.uncategorisedHotelBookings[0]
|
|
155
|
+
}), await i(() => {
|
|
156
|
+
var t;
|
|
157
|
+
e(r.current.isAddBookingToTripError).toBe(!0), e((t = r.current.addBookingToTripError) == null ? void 0 : t.message).toContain(
|
|
158
|
+
"Trip ID is required"
|
|
159
|
+
);
|
|
160
|
+
});
|
|
161
|
+
}), s("Invalid bookingId arg", async () => {
|
|
162
|
+
const { result: r } = o(() => n());
|
|
163
|
+
r.current.addBookingToTrip({
|
|
164
|
+
tripId: "12345"
|
|
165
|
+
}), await i(() => {
|
|
166
|
+
var t;
|
|
167
|
+
e(r.current.isAddBookingToTripError).toBe(!0), e((t = r.current.addBookingToTripError) == null ? void 0 : t.message).toContain(
|
|
168
|
+
"Booking is required"
|
|
169
|
+
);
|
|
170
|
+
});
|
|
171
|
+
}), s("Successfully add hotel booking to trip", async () => {
|
|
172
|
+
const { result: r } = o(() => n()), t = r.current.uncategorisedHotelBookings[0], a = r.current.upcomingTrips[0];
|
|
173
|
+
r.current.addBookingToTrip({
|
|
174
|
+
tripId: a.id,
|
|
175
|
+
booking: t
|
|
176
|
+
}), await i(() => {
|
|
177
|
+
e(d.put).toHaveBeenCalledWith(
|
|
178
|
+
p.ADD_BOOKING,
|
|
179
|
+
e.objectContaining({
|
|
180
|
+
trip_id: a.id,
|
|
181
|
+
booking_id: t.id,
|
|
182
|
+
booking_type: k.HOTEL
|
|
183
|
+
})
|
|
184
|
+
);
|
|
185
|
+
});
|
|
186
|
+
}), s("Successfully add flight booking to trip", async () => {
|
|
187
|
+
const { result: r } = o(() => n());
|
|
188
|
+
console.log(r.current);
|
|
189
|
+
const t = r.current.uncategorisedFlightBookings[0], a = r.current.upcomingTrips[0];
|
|
190
|
+
console.log({ booking: t }), r.current.addBookingToTrip({
|
|
191
|
+
tripId: a.id,
|
|
192
|
+
booking: t
|
|
193
|
+
}), await i(() => {
|
|
194
|
+
e(d.put).toHaveBeenCalledWith(
|
|
195
|
+
p.ADD_BOOKING,
|
|
196
|
+
e.objectContaining({
|
|
197
|
+
trip_id: a.id,
|
|
198
|
+
booking_id: t.id,
|
|
199
|
+
booking_type: k.FLIGHT
|
|
200
|
+
})
|
|
201
|
+
);
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { useQuery as a, useMutation as
|
|
2
|
-
import
|
|
1
|
+
import { useQuery as a, useMutation as d } from "@tanstack/react-query";
|
|
2
|
+
import "../../arrayExtensions-DlcBOj5a.js";
|
|
3
|
+
import { E as o, a as s } from "../../AccountService-Ct4hShV-.js";
|
|
3
4
|
import "react";
|
|
4
5
|
import { WalletService as t } from "../../services/wallet/WalletService.js";
|
|
5
6
|
import "react/jsx-runtime";
|
|
@@ -7,7 +8,7 @@ import "../../context/AwayzContext.js";
|
|
|
7
8
|
import { awayzClient as f } from "../../configs/awayzClient.js";
|
|
8
9
|
import "../../services/noRetryInstance.js";
|
|
9
10
|
import '../../assets/_styles.css';/* empty css */
|
|
10
|
-
const
|
|
11
|
+
const k = () => {
|
|
11
12
|
const { data: r } = a({
|
|
12
13
|
queryKey: [o.PROGRAMS],
|
|
13
14
|
queryFn: t.getAwards,
|
|
@@ -24,9 +25,9 @@ const F = () => {
|
|
|
24
25
|
queryKey: [o.USER_CARDS],
|
|
25
26
|
queryFn: t.getUserCards,
|
|
26
27
|
placeholderData: []
|
|
27
|
-
}), { mutate: c } =
|
|
28
|
+
}), { mutate: c } = d({
|
|
28
29
|
mutationFn: async (e) => {
|
|
29
|
-
const { programId: n, awardsAmount: i } = e, m = r == null ? void 0 : r.find((
|
|
30
|
+
const { programId: n, awardsAmount: i } = e, m = r == null ? void 0 : r.find((p) => p.id === n);
|
|
30
31
|
if (!m)
|
|
31
32
|
throw new Error("Program not found");
|
|
32
33
|
await t.setAwardPoints(m.mainProgram, i);
|
|
@@ -59,5 +60,5 @@ const F = () => {
|
|
|
59
60
|
};
|
|
60
61
|
};
|
|
61
62
|
export {
|
|
62
|
-
|
|
63
|
+
k as useWallet
|
|
63
64
|
};
|