@voyantjs/flights-react 0.21.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/client.d.ts +16 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +75 -0
- package/dist/hooks/index.d.ts +13 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +12 -0
- package/dist/hooks/use-aircraft.d.ts +17 -0
- package/dist/hooks/use-aircraft.d.ts.map +1 -0
- package/dist/hooks/use-aircraft.js +18 -0
- package/dist/hooks/use-airlines.d.ts +18 -0
- package/dist/hooks/use-airlines.d.ts.map +1 -0
- package/dist/hooks/use-airlines.js +18 -0
- package/dist/hooks/use-airport-search.d.ts +28 -0
- package/dist/hooks/use-airport-search.d.ts.map +1 -0
- package/dist/hooks/use-airport-search.js +23 -0
- package/dist/hooks/use-airports.d.ts +21 -0
- package/dist/hooks/use-airports.d.ts.map +1 -0
- package/dist/hooks/use-airports.js +17 -0
- package/dist/hooks/use-flight-ancillaries.d.ts +63 -0
- package/dist/hooks/use-flight-ancillaries.d.ts.map +1 -0
- package/dist/hooks/use-flight-ancillaries.js +24 -0
- package/dist/hooks/use-flight-book.d.ts +139 -0
- package/dist/hooks/use-flight-book.d.ts.map +1 -0
- package/dist/hooks/use-flight-book.js +24 -0
- package/dist/hooks/use-flight-offer.d.ts +106 -0
- package/dist/hooks/use-flight-offer.d.ts.map +1 -0
- package/dist/hooks/use-flight-offer.js +20 -0
- package/dist/hooks/use-flight-order.d.ts +286 -0
- package/dist/hooks/use-flight-order.d.ts.map +1 -0
- package/dist/hooks/use-flight-order.js +38 -0
- package/dist/hooks/use-flight-orders.d.ts +147 -0
- package/dist/hooks/use-flight-orders.d.ts.map +1 -0
- package/dist/hooks/use-flight-orders.js +31 -0
- package/dist/hooks/use-flight-search.d.ts +110 -0
- package/dist/hooks/use-flight-search.d.ts.map +1 -0
- package/dist/hooks/use-flight-search.js +18 -0
- package/dist/hooks/use-flight-seat-map.d.ts +49 -0
- package/dist/hooks/use-flight-seat-map.d.ts.map +1 -0
- package/dist/hooks/use-flight-seat-map.js +23 -0
- package/dist/hooks/use-saved-payment-methods.d.ts +23 -0
- package/dist/hooks/use-saved-payment-methods.d.ts.map +1 -0
- package/dist/hooks/use-saved-payment-methods.js +20 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/provider.d.ts +2 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +1 -0
- package/dist/query-keys.d.ts +42 -0
- package/dist/query-keys.d.ts.map +1 -0
- package/dist/query-keys.js +22 -0
- package/dist/query-options.d.ts +827 -0
- package/dist/query-options.d.ts.map +1 -0
- package/dist/query-options.js +58 -0
- package/dist/schemas.d.ts +1658 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +295 -0
- package/package.json +85 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { FlightOffer } from "@voyantjs/flights/contract/types";
|
|
2
|
+
export interface PriceOfferInput {
|
|
3
|
+
offerId: string;
|
|
4
|
+
/** Some adapters require the offer payload echoed back. */
|
|
5
|
+
offer?: FlightOffer;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* POST `/v1/admin/flights/price` — re-prices an offer immediately before
|
|
9
|
+
* booking. Returns `{ offer, valid, invalidReason? }`. The mutation shape
|
|
10
|
+
* fits the typical "user clicks Continue → re-price → if invalid, show
|
|
11
|
+
* banner; if valid, proceed to booking" flow.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useFlightOfferPrice(): import("@tanstack/react-query").UseMutationResult<{
|
|
14
|
+
offer: {
|
|
15
|
+
offerId: string;
|
|
16
|
+
source: string;
|
|
17
|
+
itineraries: {
|
|
18
|
+
segments: {
|
|
19
|
+
segmentId: string;
|
|
20
|
+
carrierCode: string;
|
|
21
|
+
flightNumber: string;
|
|
22
|
+
departure: {
|
|
23
|
+
iataCode: string;
|
|
24
|
+
at: string;
|
|
25
|
+
terminal?: string | undefined;
|
|
26
|
+
};
|
|
27
|
+
arrival: {
|
|
28
|
+
iataCode: string;
|
|
29
|
+
at: string;
|
|
30
|
+
terminal?: string | undefined;
|
|
31
|
+
};
|
|
32
|
+
cabin: "economy" | "premium_economy" | "business" | "first";
|
|
33
|
+
operatingCarrierCode?: string | undefined;
|
|
34
|
+
operatingFlightNumber?: string | undefined;
|
|
35
|
+
duration?: string | undefined;
|
|
36
|
+
aircraft?: string | undefined;
|
|
37
|
+
fareClass?: string | undefined;
|
|
38
|
+
fareBasis?: string | undefined;
|
|
39
|
+
status?: string | undefined;
|
|
40
|
+
providerData?: Record<string, unknown> | undefined;
|
|
41
|
+
}[];
|
|
42
|
+
duration?: string | undefined;
|
|
43
|
+
}[];
|
|
44
|
+
fareBreakdowns: {
|
|
45
|
+
passengerType: "adult" | "child" | "infant" | "senior" | "youth";
|
|
46
|
+
passengerCount: number;
|
|
47
|
+
baseFare: {
|
|
48
|
+
amount: string;
|
|
49
|
+
currency: string;
|
|
50
|
+
};
|
|
51
|
+
taxes: {
|
|
52
|
+
amount: string;
|
|
53
|
+
currency: string;
|
|
54
|
+
};
|
|
55
|
+
total: {
|
|
56
|
+
amount: string;
|
|
57
|
+
currency: string;
|
|
58
|
+
};
|
|
59
|
+
fees?: {
|
|
60
|
+
amount: string;
|
|
61
|
+
currency: string;
|
|
62
|
+
} | undefined;
|
|
63
|
+
fareFamily?: string | undefined;
|
|
64
|
+
}[];
|
|
65
|
+
totalPrice: {
|
|
66
|
+
amount: string;
|
|
67
|
+
currency: string;
|
|
68
|
+
};
|
|
69
|
+
validatingCarrier?: string | undefined;
|
|
70
|
+
expiresAt?: string | undefined;
|
|
71
|
+
lastTicketingDate?: string | undefined;
|
|
72
|
+
instantTicketing?: boolean | undefined;
|
|
73
|
+
fareBundles?: {
|
|
74
|
+
id: string;
|
|
75
|
+
label: string;
|
|
76
|
+
tier: "basic" | "standard" | "plus" | "premium";
|
|
77
|
+
priceDelta: {
|
|
78
|
+
amount: string;
|
|
79
|
+
currency: string;
|
|
80
|
+
};
|
|
81
|
+
inclusions: {
|
|
82
|
+
cabinBag?: {
|
|
83
|
+
included: boolean;
|
|
84
|
+
weightKg?: number | undefined;
|
|
85
|
+
} | undefined;
|
|
86
|
+
checkedBag?: {
|
|
87
|
+
included: boolean;
|
|
88
|
+
pieces?: number | undefined;
|
|
89
|
+
weightKg?: number | undefined;
|
|
90
|
+
} | undefined;
|
|
91
|
+
seatSelection?: "standard" | "none" | "free" | undefined;
|
|
92
|
+
priorityBoarding?: boolean | undefined;
|
|
93
|
+
loungeAccess?: boolean | undefined;
|
|
94
|
+
refundable?: boolean | undefined;
|
|
95
|
+
changeable?: boolean | undefined;
|
|
96
|
+
notes?: string[] | undefined;
|
|
97
|
+
};
|
|
98
|
+
recommended?: boolean | undefined;
|
|
99
|
+
providerData?: Record<string, unknown> | undefined;
|
|
100
|
+
}[] | undefined;
|
|
101
|
+
providerData?: Record<string, unknown> | undefined;
|
|
102
|
+
};
|
|
103
|
+
valid: boolean;
|
|
104
|
+
invalidReason?: string | undefined;
|
|
105
|
+
}, Error, PriceOfferInput, unknown>;
|
|
106
|
+
//# sourceMappingURL=use-flight-offer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-flight-offer.d.ts","sourceRoot":"","sources":["../../src/hooks/use-flight-offer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAMnE,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,2DAA2D;IAC3D,KAAK,CAAC,EAAE,WAAW,CAAA;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCASlC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantFlightsContext } from "../provider.js";
|
|
5
|
+
import { flightPriceResponseSchema } from "../schemas.js";
|
|
6
|
+
/**
|
|
7
|
+
* POST `/v1/admin/flights/price` — re-prices an offer immediately before
|
|
8
|
+
* booking. Returns `{ offer, valid, invalidReason? }`. The mutation shape
|
|
9
|
+
* fits the typical "user clicks Continue → re-price → if invalid, show
|
|
10
|
+
* banner; if valid, proceed to booking" flow.
|
|
11
|
+
*/
|
|
12
|
+
export function useFlightOfferPrice() {
|
|
13
|
+
const client = useVoyantFlightsContext();
|
|
14
|
+
return useMutation({
|
|
15
|
+
mutationFn: (input) => fetchWithValidation("/v1/admin/flights/price", flightPriceResponseSchema, client, {
|
|
16
|
+
method: "POST",
|
|
17
|
+
body: JSON.stringify(input),
|
|
18
|
+
}),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
export interface UseFlightOrderOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* GET `/v1/admin/flights/orders/:orderId` — fetch a previously-booked order.
|
|
6
|
+
* 404 surfaces as a query error; the consumer renders an "order not found"
|
|
7
|
+
* fallback in that case.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useFlightOrder(orderId: string | null, options?: UseFlightOrderOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
10
|
+
order: {
|
|
11
|
+
orderId: string;
|
|
12
|
+
status: "pending" | "confirmed" | "ticketed" | "cancelled" | "failed";
|
|
13
|
+
offer: {
|
|
14
|
+
offerId: string;
|
|
15
|
+
source: string;
|
|
16
|
+
itineraries: {
|
|
17
|
+
segments: {
|
|
18
|
+
segmentId: string;
|
|
19
|
+
carrierCode: string;
|
|
20
|
+
flightNumber: string;
|
|
21
|
+
departure: {
|
|
22
|
+
iataCode: string;
|
|
23
|
+
at: string;
|
|
24
|
+
terminal?: string | undefined;
|
|
25
|
+
};
|
|
26
|
+
arrival: {
|
|
27
|
+
iataCode: string;
|
|
28
|
+
at: string;
|
|
29
|
+
terminal?: string | undefined;
|
|
30
|
+
};
|
|
31
|
+
cabin: "economy" | "premium_economy" | "business" | "first";
|
|
32
|
+
operatingCarrierCode?: string | undefined;
|
|
33
|
+
operatingFlightNumber?: string | undefined;
|
|
34
|
+
duration?: string | undefined;
|
|
35
|
+
aircraft?: string | undefined;
|
|
36
|
+
fareClass?: string | undefined;
|
|
37
|
+
fareBasis?: string | undefined;
|
|
38
|
+
status?: string | undefined;
|
|
39
|
+
providerData?: Record<string, unknown> | undefined;
|
|
40
|
+
}[];
|
|
41
|
+
duration?: string | undefined;
|
|
42
|
+
}[];
|
|
43
|
+
fareBreakdowns: {
|
|
44
|
+
passengerType: "adult" | "child" | "infant" | "senior" | "youth";
|
|
45
|
+
passengerCount: number;
|
|
46
|
+
baseFare: {
|
|
47
|
+
amount: string;
|
|
48
|
+
currency: string;
|
|
49
|
+
};
|
|
50
|
+
taxes: {
|
|
51
|
+
amount: string;
|
|
52
|
+
currency: string;
|
|
53
|
+
};
|
|
54
|
+
total: {
|
|
55
|
+
amount: string;
|
|
56
|
+
currency: string;
|
|
57
|
+
};
|
|
58
|
+
fees?: {
|
|
59
|
+
amount: string;
|
|
60
|
+
currency: string;
|
|
61
|
+
} | undefined;
|
|
62
|
+
fareFamily?: string | undefined;
|
|
63
|
+
}[];
|
|
64
|
+
totalPrice: {
|
|
65
|
+
amount: string;
|
|
66
|
+
currency: string;
|
|
67
|
+
};
|
|
68
|
+
validatingCarrier?: string | undefined;
|
|
69
|
+
expiresAt?: string | undefined;
|
|
70
|
+
lastTicketingDate?: string | undefined;
|
|
71
|
+
instantTicketing?: boolean | undefined;
|
|
72
|
+
fareBundles?: {
|
|
73
|
+
id: string;
|
|
74
|
+
label: string;
|
|
75
|
+
tier: "basic" | "standard" | "plus" | "premium";
|
|
76
|
+
priceDelta: {
|
|
77
|
+
amount: string;
|
|
78
|
+
currency: string;
|
|
79
|
+
};
|
|
80
|
+
inclusions: {
|
|
81
|
+
cabinBag?: {
|
|
82
|
+
included: boolean;
|
|
83
|
+
weightKg?: number | undefined;
|
|
84
|
+
} | undefined;
|
|
85
|
+
checkedBag?: {
|
|
86
|
+
included: boolean;
|
|
87
|
+
pieces?: number | undefined;
|
|
88
|
+
weightKg?: number | undefined;
|
|
89
|
+
} | undefined;
|
|
90
|
+
seatSelection?: "standard" | "none" | "free" | undefined;
|
|
91
|
+
priorityBoarding?: boolean | undefined;
|
|
92
|
+
loungeAccess?: boolean | undefined;
|
|
93
|
+
refundable?: boolean | undefined;
|
|
94
|
+
changeable?: boolean | undefined;
|
|
95
|
+
notes?: string[] | undefined;
|
|
96
|
+
};
|
|
97
|
+
recommended?: boolean | undefined;
|
|
98
|
+
providerData?: Record<string, unknown> | undefined;
|
|
99
|
+
}[] | undefined;
|
|
100
|
+
providerData?: Record<string, unknown> | undefined;
|
|
101
|
+
};
|
|
102
|
+
passengers: {
|
|
103
|
+
passengerId: string;
|
|
104
|
+
type: "adult" | "child" | "infant" | "senior" | "youth";
|
|
105
|
+
firstName: string;
|
|
106
|
+
lastName: string;
|
|
107
|
+
dateOfBirth: string;
|
|
108
|
+
middleName?: string | undefined;
|
|
109
|
+
gender?: "M" | "F" | "X" | undefined;
|
|
110
|
+
email?: string | undefined;
|
|
111
|
+
phone?: string | undefined;
|
|
112
|
+
documents?: {
|
|
113
|
+
type: "passport" | "national_id" | "visa";
|
|
114
|
+
number: string;
|
|
115
|
+
countryOfIssue: string;
|
|
116
|
+
countryOfNationality?: string | undefined;
|
|
117
|
+
expiryDate?: string | undefined;
|
|
118
|
+
}[] | undefined;
|
|
119
|
+
}[];
|
|
120
|
+
totalPrice: {
|
|
121
|
+
amount: string;
|
|
122
|
+
currency: string;
|
|
123
|
+
};
|
|
124
|
+
createdAt: string;
|
|
125
|
+
pnr?: string | undefined;
|
|
126
|
+
contact?: {
|
|
127
|
+
email?: string | undefined;
|
|
128
|
+
phone?: string | undefined;
|
|
129
|
+
} | undefined;
|
|
130
|
+
tickets?: {
|
|
131
|
+
ticketNumber: string;
|
|
132
|
+
passengerId: string;
|
|
133
|
+
segmentIds: string[];
|
|
134
|
+
status?: string | undefined;
|
|
135
|
+
}[] | undefined;
|
|
136
|
+
paymentDeadline?: string | undefined;
|
|
137
|
+
updatedAt?: string | undefined;
|
|
138
|
+
providerData?: Record<string, unknown> | undefined;
|
|
139
|
+
};
|
|
140
|
+
}, Error>;
|
|
141
|
+
export interface CancelOrderInput {
|
|
142
|
+
orderId: string;
|
|
143
|
+
reason?: "customer_request" | "schedule_change" | "operational" | "fraud";
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* POST `/v1/admin/flights/orders/:orderId/cancel`. Updates the cached
|
|
147
|
+
* order on success so the confirmation page reflects the new "cancelled"
|
|
148
|
+
* status without a refetch.
|
|
149
|
+
*/
|
|
150
|
+
export declare function useFlightOrderCancel(): import("@tanstack/react-query").UseMutationResult<{
|
|
151
|
+
order: {
|
|
152
|
+
orderId: string;
|
|
153
|
+
status: "pending" | "confirmed" | "ticketed" | "cancelled" | "failed";
|
|
154
|
+
offer: {
|
|
155
|
+
offerId: string;
|
|
156
|
+
source: string;
|
|
157
|
+
itineraries: {
|
|
158
|
+
segments: {
|
|
159
|
+
segmentId: string;
|
|
160
|
+
carrierCode: string;
|
|
161
|
+
flightNumber: string;
|
|
162
|
+
departure: {
|
|
163
|
+
iataCode: string;
|
|
164
|
+
at: string;
|
|
165
|
+
terminal?: string | undefined;
|
|
166
|
+
};
|
|
167
|
+
arrival: {
|
|
168
|
+
iataCode: string;
|
|
169
|
+
at: string;
|
|
170
|
+
terminal?: string | undefined;
|
|
171
|
+
};
|
|
172
|
+
cabin: "economy" | "premium_economy" | "business" | "first";
|
|
173
|
+
operatingCarrierCode?: string | undefined;
|
|
174
|
+
operatingFlightNumber?: string | undefined;
|
|
175
|
+
duration?: string | undefined;
|
|
176
|
+
aircraft?: string | undefined;
|
|
177
|
+
fareClass?: string | undefined;
|
|
178
|
+
fareBasis?: string | undefined;
|
|
179
|
+
status?: string | undefined;
|
|
180
|
+
providerData?: Record<string, unknown> | undefined;
|
|
181
|
+
}[];
|
|
182
|
+
duration?: string | undefined;
|
|
183
|
+
}[];
|
|
184
|
+
fareBreakdowns: {
|
|
185
|
+
passengerType: "adult" | "child" | "infant" | "senior" | "youth";
|
|
186
|
+
passengerCount: number;
|
|
187
|
+
baseFare: {
|
|
188
|
+
amount: string;
|
|
189
|
+
currency: string;
|
|
190
|
+
};
|
|
191
|
+
taxes: {
|
|
192
|
+
amount: string;
|
|
193
|
+
currency: string;
|
|
194
|
+
};
|
|
195
|
+
total: {
|
|
196
|
+
amount: string;
|
|
197
|
+
currency: string;
|
|
198
|
+
};
|
|
199
|
+
fees?: {
|
|
200
|
+
amount: string;
|
|
201
|
+
currency: string;
|
|
202
|
+
} | undefined;
|
|
203
|
+
fareFamily?: string | undefined;
|
|
204
|
+
}[];
|
|
205
|
+
totalPrice: {
|
|
206
|
+
amount: string;
|
|
207
|
+
currency: string;
|
|
208
|
+
};
|
|
209
|
+
validatingCarrier?: string | undefined;
|
|
210
|
+
expiresAt?: string | undefined;
|
|
211
|
+
lastTicketingDate?: string | undefined;
|
|
212
|
+
instantTicketing?: boolean | undefined;
|
|
213
|
+
fareBundles?: {
|
|
214
|
+
id: string;
|
|
215
|
+
label: string;
|
|
216
|
+
tier: "basic" | "standard" | "plus" | "premium";
|
|
217
|
+
priceDelta: {
|
|
218
|
+
amount: string;
|
|
219
|
+
currency: string;
|
|
220
|
+
};
|
|
221
|
+
inclusions: {
|
|
222
|
+
cabinBag?: {
|
|
223
|
+
included: boolean;
|
|
224
|
+
weightKg?: number | undefined;
|
|
225
|
+
} | undefined;
|
|
226
|
+
checkedBag?: {
|
|
227
|
+
included: boolean;
|
|
228
|
+
pieces?: number | undefined;
|
|
229
|
+
weightKg?: number | undefined;
|
|
230
|
+
} | undefined;
|
|
231
|
+
seatSelection?: "standard" | "none" | "free" | undefined;
|
|
232
|
+
priorityBoarding?: boolean | undefined;
|
|
233
|
+
loungeAccess?: boolean | undefined;
|
|
234
|
+
refundable?: boolean | undefined;
|
|
235
|
+
changeable?: boolean | undefined;
|
|
236
|
+
notes?: string[] | undefined;
|
|
237
|
+
};
|
|
238
|
+
recommended?: boolean | undefined;
|
|
239
|
+
providerData?: Record<string, unknown> | undefined;
|
|
240
|
+
}[] | undefined;
|
|
241
|
+
providerData?: Record<string, unknown> | undefined;
|
|
242
|
+
};
|
|
243
|
+
passengers: {
|
|
244
|
+
passengerId: string;
|
|
245
|
+
type: "adult" | "child" | "infant" | "senior" | "youth";
|
|
246
|
+
firstName: string;
|
|
247
|
+
lastName: string;
|
|
248
|
+
dateOfBirth: string;
|
|
249
|
+
middleName?: string | undefined;
|
|
250
|
+
gender?: "M" | "F" | "X" | undefined;
|
|
251
|
+
email?: string | undefined;
|
|
252
|
+
phone?: string | undefined;
|
|
253
|
+
documents?: {
|
|
254
|
+
type: "passport" | "national_id" | "visa";
|
|
255
|
+
number: string;
|
|
256
|
+
countryOfIssue: string;
|
|
257
|
+
countryOfNationality?: string | undefined;
|
|
258
|
+
expiryDate?: string | undefined;
|
|
259
|
+
}[] | undefined;
|
|
260
|
+
}[];
|
|
261
|
+
totalPrice: {
|
|
262
|
+
amount: string;
|
|
263
|
+
currency: string;
|
|
264
|
+
};
|
|
265
|
+
createdAt: string;
|
|
266
|
+
pnr?: string | undefined;
|
|
267
|
+
contact?: {
|
|
268
|
+
email?: string | undefined;
|
|
269
|
+
phone?: string | undefined;
|
|
270
|
+
} | undefined;
|
|
271
|
+
tickets?: {
|
|
272
|
+
ticketNumber: string;
|
|
273
|
+
passengerId: string;
|
|
274
|
+
segmentIds: string[];
|
|
275
|
+
status?: string | undefined;
|
|
276
|
+
}[] | undefined;
|
|
277
|
+
paymentDeadline?: string | undefined;
|
|
278
|
+
updatedAt?: string | undefined;
|
|
279
|
+
providerData?: Record<string, unknown> | undefined;
|
|
280
|
+
};
|
|
281
|
+
refundedAmount?: {
|
|
282
|
+
amount: string;
|
|
283
|
+
currency: string;
|
|
284
|
+
} | undefined;
|
|
285
|
+
}, Error, CancelOrderInput, unknown>;
|
|
286
|
+
//# sourceMappingURL=use-flight-order.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-flight-order.d.ts","sourceRoot":"","sources":["../../src/hooks/use-flight-order.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,GAAE,qBAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAazF;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,kBAAkB,GAAG,iBAAiB,GAAG,aAAa,GAAG,OAAO,CAAA;CAC1E;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCAkBnC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantFlightsContext } from "../provider.js";
|
|
5
|
+
import { flightsQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { flightCancelResponseSchema, flightGetOrderResponseSchema, } from "../schemas.js";
|
|
7
|
+
/**
|
|
8
|
+
* GET `/v1/admin/flights/orders/:orderId` — fetch a previously-booked order.
|
|
9
|
+
* 404 surfaces as a query error; the consumer renders an "order not found"
|
|
10
|
+
* fallback in that case.
|
|
11
|
+
*/
|
|
12
|
+
export function useFlightOrder(orderId, options = {}) {
|
|
13
|
+
const client = useVoyantFlightsContext();
|
|
14
|
+
const { enabled = true } = options;
|
|
15
|
+
return useQuery({
|
|
16
|
+
queryKey: flightsQueryKeys.orderDetail(orderId ?? ""),
|
|
17
|
+
queryFn: () => fetchWithValidation(`/v1/admin/flights/orders/${encodeURIComponent(orderId ?? "")}`, flightGetOrderResponseSchema, client),
|
|
18
|
+
enabled: enabled && !!orderId,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* POST `/v1/admin/flights/orders/:orderId/cancel`. Updates the cached
|
|
23
|
+
* order on success so the confirmation page reflects the new "cancelled"
|
|
24
|
+
* status without a refetch.
|
|
25
|
+
*/
|
|
26
|
+
export function useFlightOrderCancel() {
|
|
27
|
+
const client = useVoyantFlightsContext();
|
|
28
|
+
const qc = useQueryClient();
|
|
29
|
+
return useMutation({
|
|
30
|
+
mutationFn: (input) => fetchWithValidation(`/v1/admin/flights/orders/${encodeURIComponent(input.orderId)}/cancel`, flightCancelResponseSchema, client, {
|
|
31
|
+
method: "POST",
|
|
32
|
+
body: JSON.stringify(input.reason ? { reason: input.reason } : {}),
|
|
33
|
+
}),
|
|
34
|
+
onSuccess: (data) => {
|
|
35
|
+
qc.setQueryData(flightsQueryKeys.orderDetail(data.order.orderId), { order: data.order });
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { type FlightOrdersListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseFlightOrdersOptions {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* GET `/v1/admin/flights/orders` — paginated list of flight orders the
|
|
7
|
+
* adapter has visibility on. Capability-gated: adapters that don't declare
|
|
8
|
+
* `flight/list-orders` will 501.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useFlightOrders(filters?: FlightOrdersListFilters, options?: UseFlightOrdersOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
11
|
+
orders: {
|
|
12
|
+
orderId: string;
|
|
13
|
+
status: "pending" | "confirmed" | "ticketed" | "cancelled" | "failed";
|
|
14
|
+
offer: {
|
|
15
|
+
offerId: string;
|
|
16
|
+
source: string;
|
|
17
|
+
itineraries: {
|
|
18
|
+
segments: {
|
|
19
|
+
segmentId: string;
|
|
20
|
+
carrierCode: string;
|
|
21
|
+
flightNumber: string;
|
|
22
|
+
departure: {
|
|
23
|
+
iataCode: string;
|
|
24
|
+
at: string;
|
|
25
|
+
terminal?: string | undefined;
|
|
26
|
+
};
|
|
27
|
+
arrival: {
|
|
28
|
+
iataCode: string;
|
|
29
|
+
at: string;
|
|
30
|
+
terminal?: string | undefined;
|
|
31
|
+
};
|
|
32
|
+
cabin: "economy" | "premium_economy" | "business" | "first";
|
|
33
|
+
operatingCarrierCode?: string | undefined;
|
|
34
|
+
operatingFlightNumber?: string | undefined;
|
|
35
|
+
duration?: string | undefined;
|
|
36
|
+
aircraft?: string | undefined;
|
|
37
|
+
fareClass?: string | undefined;
|
|
38
|
+
fareBasis?: string | undefined;
|
|
39
|
+
status?: string | undefined;
|
|
40
|
+
providerData?: Record<string, unknown> | undefined;
|
|
41
|
+
}[];
|
|
42
|
+
duration?: string | undefined;
|
|
43
|
+
}[];
|
|
44
|
+
fareBreakdowns: {
|
|
45
|
+
passengerType: "adult" | "child" | "infant" | "senior" | "youth";
|
|
46
|
+
passengerCount: number;
|
|
47
|
+
baseFare: {
|
|
48
|
+
amount: string;
|
|
49
|
+
currency: string;
|
|
50
|
+
};
|
|
51
|
+
taxes: {
|
|
52
|
+
amount: string;
|
|
53
|
+
currency: string;
|
|
54
|
+
};
|
|
55
|
+
total: {
|
|
56
|
+
amount: string;
|
|
57
|
+
currency: string;
|
|
58
|
+
};
|
|
59
|
+
fees?: {
|
|
60
|
+
amount: string;
|
|
61
|
+
currency: string;
|
|
62
|
+
} | undefined;
|
|
63
|
+
fareFamily?: string | undefined;
|
|
64
|
+
}[];
|
|
65
|
+
totalPrice: {
|
|
66
|
+
amount: string;
|
|
67
|
+
currency: string;
|
|
68
|
+
};
|
|
69
|
+
validatingCarrier?: string | undefined;
|
|
70
|
+
expiresAt?: string | undefined;
|
|
71
|
+
lastTicketingDate?: string | undefined;
|
|
72
|
+
instantTicketing?: boolean | undefined;
|
|
73
|
+
fareBundles?: {
|
|
74
|
+
id: string;
|
|
75
|
+
label: string;
|
|
76
|
+
tier: "basic" | "standard" | "plus" | "premium";
|
|
77
|
+
priceDelta: {
|
|
78
|
+
amount: string;
|
|
79
|
+
currency: string;
|
|
80
|
+
};
|
|
81
|
+
inclusions: {
|
|
82
|
+
cabinBag?: {
|
|
83
|
+
included: boolean;
|
|
84
|
+
weightKg?: number | undefined;
|
|
85
|
+
} | undefined;
|
|
86
|
+
checkedBag?: {
|
|
87
|
+
included: boolean;
|
|
88
|
+
pieces?: number | undefined;
|
|
89
|
+
weightKg?: number | undefined;
|
|
90
|
+
} | undefined;
|
|
91
|
+
seatSelection?: "standard" | "none" | "free" | undefined;
|
|
92
|
+
priorityBoarding?: boolean | undefined;
|
|
93
|
+
loungeAccess?: boolean | undefined;
|
|
94
|
+
refundable?: boolean | undefined;
|
|
95
|
+
changeable?: boolean | undefined;
|
|
96
|
+
notes?: string[] | undefined;
|
|
97
|
+
};
|
|
98
|
+
recommended?: boolean | undefined;
|
|
99
|
+
providerData?: Record<string, unknown> | undefined;
|
|
100
|
+
}[] | undefined;
|
|
101
|
+
providerData?: Record<string, unknown> | undefined;
|
|
102
|
+
};
|
|
103
|
+
passengers: {
|
|
104
|
+
passengerId: string;
|
|
105
|
+
type: "adult" | "child" | "infant" | "senior" | "youth";
|
|
106
|
+
firstName: string;
|
|
107
|
+
lastName: string;
|
|
108
|
+
dateOfBirth: string;
|
|
109
|
+
middleName?: string | undefined;
|
|
110
|
+
gender?: "M" | "F" | "X" | undefined;
|
|
111
|
+
email?: string | undefined;
|
|
112
|
+
phone?: string | undefined;
|
|
113
|
+
documents?: {
|
|
114
|
+
type: "passport" | "national_id" | "visa";
|
|
115
|
+
number: string;
|
|
116
|
+
countryOfIssue: string;
|
|
117
|
+
countryOfNationality?: string | undefined;
|
|
118
|
+
expiryDate?: string | undefined;
|
|
119
|
+
}[] | undefined;
|
|
120
|
+
}[];
|
|
121
|
+
totalPrice: {
|
|
122
|
+
amount: string;
|
|
123
|
+
currency: string;
|
|
124
|
+
};
|
|
125
|
+
createdAt: string;
|
|
126
|
+
pnr?: string | undefined;
|
|
127
|
+
contact?: {
|
|
128
|
+
email?: string | undefined;
|
|
129
|
+
phone?: string | undefined;
|
|
130
|
+
} | undefined;
|
|
131
|
+
tickets?: {
|
|
132
|
+
ticketNumber: string;
|
|
133
|
+
passengerId: string;
|
|
134
|
+
segmentIds: string[];
|
|
135
|
+
status?: string | undefined;
|
|
136
|
+
}[] | undefined;
|
|
137
|
+
paymentDeadline?: string | undefined;
|
|
138
|
+
updatedAt?: string | undefined;
|
|
139
|
+
providerData?: Record<string, unknown> | undefined;
|
|
140
|
+
}[];
|
|
141
|
+
pagination: {
|
|
142
|
+
total: number;
|
|
143
|
+
hasMore: boolean;
|
|
144
|
+
cursor?: string | undefined;
|
|
145
|
+
};
|
|
146
|
+
}, Error>;
|
|
147
|
+
//# sourceMappingURL=use-flight-orders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-flight-orders.d.ts","sourceRoot":"","sources":["../../src/hooks/use-flight-orders.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,uBAAuB,EAAoB,MAAM,kBAAkB,CAAA;AAGjF,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,OAAO,GAAE,uBAA4B,EACrC,OAAO,GAAE,sBAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAqBrC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation, withQueryParams } from "../client.js";
|
|
4
|
+
import { useVoyantFlightsContext } from "../provider.js";
|
|
5
|
+
import { flightsQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { flightOrdersListResponseSchema } from "../schemas.js";
|
|
7
|
+
/**
|
|
8
|
+
* GET `/v1/admin/flights/orders` — paginated list of flight orders the
|
|
9
|
+
* adapter has visibility on. Capability-gated: adapters that don't declare
|
|
10
|
+
* `flight/list-orders` will 501.
|
|
11
|
+
*/
|
|
12
|
+
export function useFlightOrders(filters = {}, options = {}) {
|
|
13
|
+
const client = useVoyantFlightsContext();
|
|
14
|
+
const { enabled = true } = options;
|
|
15
|
+
const params = {};
|
|
16
|
+
if (filters.cursor)
|
|
17
|
+
params.cursor = filters.cursor;
|
|
18
|
+
if (filters.limit !== undefined)
|
|
19
|
+
params.limit = filters.limit;
|
|
20
|
+
if (filters.search)
|
|
21
|
+
params.q = filters.search;
|
|
22
|
+
if (filters.status?.length)
|
|
23
|
+
params.status = filters.status;
|
|
24
|
+
if (filters.paymentStatus?.length)
|
|
25
|
+
params.paymentStatus = filters.paymentStatus;
|
|
26
|
+
return useQuery({
|
|
27
|
+
queryKey: flightsQueryKeys.orderList(filters),
|
|
28
|
+
queryFn: () => fetchWithValidation(withQueryParams("/v1/admin/flights/orders", params), flightOrdersListResponseSchema, client),
|
|
29
|
+
enabled,
|
|
30
|
+
});
|
|
31
|
+
}
|