@voyantjs/bookings-react 0.6.8 → 0.7.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/hooks/index.d.ts +8 -5
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +8 -5
- package/dist/hooks/use-booking-convert-mutation.d.ts +6 -0
- package/dist/hooks/use-booking-convert-mutation.d.ts.map +1 -1
- package/dist/hooks/use-booking-documents.d.ts +8 -8
- package/dist/hooks/use-booking-documents.d.ts.map +1 -1
- package/dist/hooks/use-booking-documents.js +17 -7
- package/dist/hooks/use-booking-dual-create-mutation.d.ts +146 -0
- package/dist/hooks/use-booking-dual-create-mutation.d.ts.map +1 -0
- package/dist/hooks/use-booking-dual-create-mutation.js +45 -0
- package/dist/hooks/use-booking-item-participants.d.ts +6 -16
- package/dist/hooks/use-booking-item-participants.d.ts.map +1 -1
- package/dist/hooks/use-booking-item-participants.js +19 -17
- package/dist/hooks/use-booking-item-travelers.d.ts +32 -0
- package/dist/hooks/use-booking-item-travelers.d.ts.map +1 -0
- package/dist/hooks/use-booking-item-travelers.js +48 -0
- package/dist/hooks/use-booking-note-mutation.d.ts +12 -1
- package/dist/hooks/use-booking-note-mutation.d.ts.map +1 -1
- package/dist/hooks/use-booking-note-mutation.js +17 -4
- package/dist/hooks/use-booking-quick-create-mutation.d.ts +122 -0
- package/dist/hooks/use-booking-quick-create-mutation.d.ts.map +1 -0
- package/dist/hooks/use-booking-quick-create-mutation.js +40 -0
- package/dist/hooks/use-booking-status-mutation.d.ts +27 -0
- package/dist/hooks/use-booking-status-mutation.d.ts.map +1 -1
- package/dist/hooks/use-booking-status-mutation.js +24 -0
- package/dist/hooks/use-passenger-mutation.d.ts +12 -2
- package/dist/hooks/use-passenger-mutation.d.ts.map +1 -1
- package/dist/hooks/use-passengers.d.ts +1 -17
- package/dist/hooks/use-passengers.d.ts.map +1 -1
- package/dist/hooks/use-passengers.js +1 -11
- package/dist/hooks/use-pricing-preview.d.ts +49 -0
- package/dist/hooks/use-pricing-preview.d.ts.map +1 -0
- package/dist/hooks/use-pricing-preview.js +18 -0
- package/dist/hooks/use-public-booking-session-flow-mutation.d.ts +7 -8
- package/dist/hooks/use-public-booking-session-flow-mutation.d.ts.map +1 -1
- package/dist/hooks/use-public-booking-session.d.ts +7 -8
- package/dist/hooks/use-public-booking-session.d.ts.map +1 -1
- package/dist/hooks/use-traveler-mutation.d.ts +56 -0
- package/dist/hooks/use-traveler-mutation.d.ts.map +1 -0
- package/dist/hooks/use-traveler-mutation.js +42 -0
- package/dist/hooks/use-travelers.d.ts +23 -0
- package/dist/hooks/use-travelers.d.ts.map +1 -0
- package/dist/hooks/use-travelers.js +12 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/query-keys.d.ts +9 -1
- package/dist/query-keys.d.ts.map +1 -1
- package/dist/query-keys.js +4 -1
- package/dist/query-options.d.ts +237 -60
- package/dist/query-options.d.ts.map +1 -1
- package/dist/query-options.js +30 -9
- package/dist/schemas.d.ts +150 -43
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +62 -11
- package/package.json +5 -5
|
@@ -8,17 +8,30 @@ import { bookingNoteRecordSchema } from "../schemas.js";
|
|
|
8
8
|
const bookingNoteSingleResponse = z.object({
|
|
9
9
|
data: bookingNoteRecordSchema,
|
|
10
10
|
});
|
|
11
|
+
const successResponse = z.object({ success: z.boolean() });
|
|
11
12
|
export function useBookingNoteMutation(bookingId) {
|
|
12
13
|
const { baseUrl, fetcher } = useVoyantBookingsContext();
|
|
13
14
|
const queryClient = useQueryClient();
|
|
14
|
-
|
|
15
|
+
const invalidate = () => {
|
|
16
|
+
void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.notes(bookingId) });
|
|
17
|
+
void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.activity(bookingId) });
|
|
18
|
+
};
|
|
19
|
+
const create = useMutation({
|
|
15
20
|
mutationFn: async (input) => {
|
|
16
21
|
const { data } = await fetchWithValidation(`/v1/bookings/${bookingId}/notes`, bookingNoteSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
17
22
|
return data;
|
|
18
23
|
},
|
|
19
|
-
onSuccess:
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
onSuccess: invalidate,
|
|
25
|
+
});
|
|
26
|
+
const remove = useMutation({
|
|
27
|
+
mutationFn: async (noteId) => {
|
|
28
|
+
return fetchWithValidation(`/v1/bookings/${bookingId}/notes/${noteId}`, successResponse, { baseUrl, fetcher }, { method: "DELETE" });
|
|
22
29
|
},
|
|
30
|
+
onSuccess: invalidate,
|
|
23
31
|
});
|
|
32
|
+
// Back-compat: older callers invoke `mutation.mutateAsync({ content })` directly
|
|
33
|
+
// on the returned object (treating the hook as a single create mutation).
|
|
34
|
+
// Expose the create mutation's surface at the top level, plus named `create`
|
|
35
|
+
// and `remove` for new callers.
|
|
36
|
+
return Object.assign(create, { create, remove });
|
|
24
37
|
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export interface QuickCreateTravelerInput {
|
|
3
|
+
firstName: string;
|
|
4
|
+
lastName: string;
|
|
5
|
+
email?: string | null;
|
|
6
|
+
phone?: string | null;
|
|
7
|
+
personId?: string | null;
|
|
8
|
+
participantType?: "traveler" | "occupant" | "other";
|
|
9
|
+
travelerCategory?: "adult" | "child" | "infant" | "senior" | "other" | null;
|
|
10
|
+
preferredLanguage?: string | null;
|
|
11
|
+
accessibilityNeeds?: string | null;
|
|
12
|
+
specialRequests?: string | null;
|
|
13
|
+
/**
|
|
14
|
+
* option_unit_id of the room the passenger is assigned to. Round-trips
|
|
15
|
+
* from the UI PassengersSection even though the server currently doesn't
|
|
16
|
+
* persist it — the follow-up that adds a traveler→room link will pick it
|
|
17
|
+
* up without the client changing.
|
|
18
|
+
*/
|
|
19
|
+
roomUnitId?: string | null;
|
|
20
|
+
isPrimary?: boolean | null;
|
|
21
|
+
notes?: string | null;
|
|
22
|
+
}
|
|
23
|
+
export interface QuickCreatePaymentScheduleInput {
|
|
24
|
+
scheduleType?: "deposit" | "installment" | "balance" | "hold" | "other";
|
|
25
|
+
status?: "pending" | "due" | "paid" | "waived" | "cancelled" | "expired";
|
|
26
|
+
dueDate: string;
|
|
27
|
+
currency: string;
|
|
28
|
+
amountCents: number;
|
|
29
|
+
notes?: string | null;
|
|
30
|
+
}
|
|
31
|
+
export interface QuickCreateVoucherRedemptionInput {
|
|
32
|
+
voucherId: string;
|
|
33
|
+
amountCents: number;
|
|
34
|
+
}
|
|
35
|
+
export type QuickCreateGroupMembershipInput = {
|
|
36
|
+
action: "join";
|
|
37
|
+
groupId: string;
|
|
38
|
+
role?: "primary" | "shared";
|
|
39
|
+
} | {
|
|
40
|
+
action: "create";
|
|
41
|
+
kind?: "shared_room" | "other";
|
|
42
|
+
label?: string | null;
|
|
43
|
+
optionUnitId?: string | null;
|
|
44
|
+
makeBookingPrimary?: boolean;
|
|
45
|
+
};
|
|
46
|
+
export interface QuickCreateBookingInput {
|
|
47
|
+
productId: string;
|
|
48
|
+
optionId?: string | null;
|
|
49
|
+
slotId?: string | null;
|
|
50
|
+
bookingNumber: string;
|
|
51
|
+
personId?: string | null;
|
|
52
|
+
organizationId?: string | null;
|
|
53
|
+
internalNotes?: string | null;
|
|
54
|
+
travelers?: QuickCreateTravelerInput[];
|
|
55
|
+
paymentSchedules?: QuickCreatePaymentScheduleInput[];
|
|
56
|
+
voucherRedemption?: QuickCreateVoucherRedemptionInput;
|
|
57
|
+
groupMembership?: QuickCreateGroupMembershipInput;
|
|
58
|
+
}
|
|
59
|
+
declare const quickCreateResultSchema: z.ZodObject<{
|
|
60
|
+
booking: z.ZodObject<{
|
|
61
|
+
id: z.ZodString;
|
|
62
|
+
bookingNumber: z.ZodString;
|
|
63
|
+
status: z.ZodEnum<{
|
|
64
|
+
draft: "draft";
|
|
65
|
+
on_hold: "on_hold";
|
|
66
|
+
confirmed: "confirmed";
|
|
67
|
+
in_progress: "in_progress";
|
|
68
|
+
completed: "completed";
|
|
69
|
+
expired: "expired";
|
|
70
|
+
cancelled: "cancelled";
|
|
71
|
+
}>;
|
|
72
|
+
personId: z.ZodNullable<z.ZodString>;
|
|
73
|
+
organizationId: z.ZodNullable<z.ZodString>;
|
|
74
|
+
sellCurrency: z.ZodString;
|
|
75
|
+
sellAmountCents: z.ZodNullable<z.ZodNumber>;
|
|
76
|
+
costAmountCents: z.ZodNullable<z.ZodNumber>;
|
|
77
|
+
marginPercent: z.ZodNullable<z.ZodNumber>;
|
|
78
|
+
startDate: z.ZodNullable<z.ZodString>;
|
|
79
|
+
endDate: z.ZodNullable<z.ZodString>;
|
|
80
|
+
pax: z.ZodNullable<z.ZodNumber>;
|
|
81
|
+
internalNotes: z.ZodNullable<z.ZodString>;
|
|
82
|
+
createdAt: z.ZodString;
|
|
83
|
+
updatedAt: z.ZodString;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
travelers: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
86
|
+
paymentSchedules: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
87
|
+
voucherRedemption: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
|
|
88
|
+
groupMembership: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
|
|
89
|
+
}, z.core.$strip>;
|
|
90
|
+
export type QuickCreateBookingResult = z.infer<typeof quickCreateResultSchema>;
|
|
91
|
+
/**
|
|
92
|
+
* Atomic booking-create: calls `POST /v1/bookings/quick-create` which wraps
|
|
93
|
+
* convert-from-product + travelers + payment schedules + voucher redemption
|
|
94
|
+
* + group membership in one transaction. Prefer this over chaining the
|
|
95
|
+
* separate create mutations (convert, group, traveler) from a single submit
|
|
96
|
+
* handler — a mid-chain failure there leaves orphan state.
|
|
97
|
+
*/
|
|
98
|
+
export declare function useBookingQuickCreateMutation(): import("@tanstack/react-query").UseMutationResult<{
|
|
99
|
+
booking: {
|
|
100
|
+
id: string;
|
|
101
|
+
bookingNumber: string;
|
|
102
|
+
status: "draft" | "on_hold" | "confirmed" | "in_progress" | "completed" | "expired" | "cancelled";
|
|
103
|
+
personId: string | null;
|
|
104
|
+
organizationId: string | null;
|
|
105
|
+
sellCurrency: string;
|
|
106
|
+
sellAmountCents: number | null;
|
|
107
|
+
costAmountCents: number | null;
|
|
108
|
+
marginPercent: number | null;
|
|
109
|
+
startDate: string | null;
|
|
110
|
+
endDate: string | null;
|
|
111
|
+
pax: number | null;
|
|
112
|
+
internalNotes: string | null;
|
|
113
|
+
createdAt: string;
|
|
114
|
+
updatedAt: string;
|
|
115
|
+
};
|
|
116
|
+
travelers?: unknown[] | undefined;
|
|
117
|
+
paymentSchedules?: unknown[] | undefined;
|
|
118
|
+
voucherRedemption?: unknown;
|
|
119
|
+
groupMembership?: unknown;
|
|
120
|
+
}, Error, QuickCreateBookingInput, unknown>;
|
|
121
|
+
export {};
|
|
122
|
+
//# sourceMappingURL=use-booking-quick-create-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-booking-quick-create-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking-quick-create-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAOvB,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,eAAe,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,OAAO,CAAA;IACnD,gBAAgB,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,IAAI,CAAA;IAC3E,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;IAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACtB;AAED,MAAM,WAAW,+BAA+B;IAC9C,YAAY,CAAC,EAAE,SAAS,GAAG,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAA;IACvE,MAAM,CAAC,EAAE,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,CAAA;IACxE,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACtB;AAED,MAAM,WAAW,iCAAiC;IAChD,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,MAAM,+BAA+B,GACvC;IACE,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;CAC5B,GACD;IACE,MAAM,EAAE,QAAQ,CAAA;IAChB,IAAI,CAAC,EAAE,aAAa,GAAG,OAAO,CAAA;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B,CAAA;AAEL,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAE7B,SAAS,CAAC,EAAE,wBAAwB,EAAE,CAAA;IACtC,gBAAgB,CAAC,EAAE,+BAA+B,EAAE,CAAA;IACpD,iBAAiB,CAAC,EAAE,iCAAiC,CAAA;IACrD,eAAe,CAAC,EAAE,+BAA+B,CAAA;CAClD;AAOD,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAM3B,CAAA;AAIF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAE9E;;;;;;GAMG;AACH,wBAAgB,6BAA6B;;;;;;;;;;;;;;;;;;;;;;4CAkB5C"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { fetchWithValidation } from "../client.js";
|
|
5
|
+
import { useVoyantBookingsContext } from "../provider.js";
|
|
6
|
+
import { bookingsQueryKeys } from "../query-keys.js";
|
|
7
|
+
import { bookingRecordSchema } from "../schemas.js";
|
|
8
|
+
// Response envelope: route returns `{ data: { booking, travelers, paymentSchedules, voucherRedemption, groupMembership } }`.
|
|
9
|
+
// We validate only the booking shape (which drives cache invalidation) and
|
|
10
|
+
// pass the rest through as-is so the surface can evolve without breaking
|
|
11
|
+
// clients. Callers who want typed assertions on the extras can narrow on the
|
|
12
|
+
// result.
|
|
13
|
+
const quickCreateResultSchema = z.object({
|
|
14
|
+
booking: bookingRecordSchema,
|
|
15
|
+
travelers: z.array(z.unknown()).optional(),
|
|
16
|
+
paymentSchedules: z.array(z.unknown()).optional(),
|
|
17
|
+
voucherRedemption: z.unknown().nullable().optional(),
|
|
18
|
+
groupMembership: z.unknown().nullable().optional(),
|
|
19
|
+
});
|
|
20
|
+
const quickCreateResponseSchema = z.object({ data: quickCreateResultSchema });
|
|
21
|
+
/**
|
|
22
|
+
* Atomic booking-create: calls `POST /v1/bookings/quick-create` which wraps
|
|
23
|
+
* convert-from-product + travelers + payment schedules + voucher redemption
|
|
24
|
+
* + group membership in one transaction. Prefer this over chaining the
|
|
25
|
+
* separate create mutations (convert, group, traveler) from a single submit
|
|
26
|
+
* handler — a mid-chain failure there leaves orphan state.
|
|
27
|
+
*/
|
|
28
|
+
export function useBookingQuickCreateMutation() {
|
|
29
|
+
const { baseUrl, fetcher } = useVoyantBookingsContext();
|
|
30
|
+
const queryClient = useQueryClient();
|
|
31
|
+
return useMutation({
|
|
32
|
+
mutationFn: async (input) => {
|
|
33
|
+
const { data } = await fetchWithValidation("/v1/bookings/quick-create", quickCreateResponseSchema, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
34
|
+
return data;
|
|
35
|
+
},
|
|
36
|
+
onSuccess: () => {
|
|
37
|
+
void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.bookings() });
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
@@ -20,4 +20,31 @@ export declare function useBookingStatusMutation(bookingId: string): import("@ta
|
|
|
20
20
|
createdAt: string;
|
|
21
21
|
updatedAt: string;
|
|
22
22
|
}, Error, UpdateBookingStatusInput, unknown>;
|
|
23
|
+
export interface UpdateBookingStatusByIdInput extends UpdateBookingStatusInput {
|
|
24
|
+
bookingId: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Variant of `useBookingStatusMutation` that accepts the booking id at call
|
|
28
|
+
* time instead of at hook-setup time. Used by flows that create a booking
|
|
29
|
+
* and immediately transition its status in the same handler — the id only
|
|
30
|
+
* exists after the create returns, so the per-booking hook shape doesn't
|
|
31
|
+
* fit.
|
|
32
|
+
*/
|
|
33
|
+
export declare function useBookingStatusByIdMutation(): import("@tanstack/react-query").UseMutationResult<{
|
|
34
|
+
id: string;
|
|
35
|
+
bookingNumber: string;
|
|
36
|
+
status: "draft" | "on_hold" | "confirmed" | "in_progress" | "completed" | "expired" | "cancelled";
|
|
37
|
+
personId: string | null;
|
|
38
|
+
organizationId: string | null;
|
|
39
|
+
sellCurrency: string;
|
|
40
|
+
sellAmountCents: number | null;
|
|
41
|
+
costAmountCents: number | null;
|
|
42
|
+
marginPercent: number | null;
|
|
43
|
+
startDate: string | null;
|
|
44
|
+
endDate: string | null;
|
|
45
|
+
pax: number | null;
|
|
46
|
+
internalNotes: string | null;
|
|
47
|
+
createdAt: string;
|
|
48
|
+
updatedAt: string;
|
|
49
|
+
}, Error, UpdateBookingStatusByIdInput, unknown>;
|
|
23
50
|
//# sourceMappingURL=use-booking-status-mutation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-booking-status-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking-status-mutation.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,aAAa,EAAyB,MAAM,eAAe,CAAA;AAEzE,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAA;IAC/B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;6CAoBzD"}
|
|
1
|
+
{"version":3,"file":"use-booking-status-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking-status-mutation.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,aAAa,EAAyB,MAAM,eAAe,CAAA;AAEzE,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAA;IAC/B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;6CAoBzD;AAED,MAAM,WAAW,4BAA6B,SAAQ,wBAAwB;IAC5E,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B;;;;;;;;;;;;;;;;iDAsB3C"}
|
|
@@ -19,3 +19,27 @@ export function useBookingStatusMutation(bookingId) {
|
|
|
19
19
|
},
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Variant of `useBookingStatusMutation` that accepts the booking id at call
|
|
24
|
+
* time instead of at hook-setup time. Used by flows that create a booking
|
|
25
|
+
* and immediately transition its status in the same handler — the id only
|
|
26
|
+
* exists after the create returns, so the per-booking hook shape doesn't
|
|
27
|
+
* fit.
|
|
28
|
+
*/
|
|
29
|
+
export function useBookingStatusByIdMutation() {
|
|
30
|
+
const { baseUrl, fetcher } = useVoyantBookingsContext();
|
|
31
|
+
const queryClient = useQueryClient();
|
|
32
|
+
return useMutation({
|
|
33
|
+
mutationFn: async ({ bookingId, ...input }) => {
|
|
34
|
+
const { data } = await fetchWithValidation(`/v1/bookings/${bookingId}/status`, bookingSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
35
|
+
return data;
|
|
36
|
+
},
|
|
37
|
+
onSuccess: (data, variables) => {
|
|
38
|
+
void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.bookings() });
|
|
39
|
+
queryClient.setQueryData(bookingsQueryKeys.booking(variables.bookingId), { data });
|
|
40
|
+
void queryClient.invalidateQueries({
|
|
41
|
+
queryKey: bookingsQueryKeys.activity(variables.bookingId),
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -11,25 +11,35 @@ export declare function usePassengerMutation(bookingId: string): {
|
|
|
11
11
|
create: import("@tanstack/react-query").UseMutationResult<{
|
|
12
12
|
id: string;
|
|
13
13
|
bookingId: string;
|
|
14
|
+
participantType: string;
|
|
14
15
|
firstName: string;
|
|
15
16
|
lastName: string;
|
|
16
17
|
email: string | null;
|
|
17
18
|
phone: string | null;
|
|
18
19
|
specialRequests: string | null;
|
|
20
|
+
isPrimary: boolean;
|
|
19
21
|
createdAt: string;
|
|
20
|
-
|
|
22
|
+
travelerCategory?: string | null | undefined;
|
|
23
|
+
preferredLanguage?: string | null | undefined;
|
|
24
|
+
accessibilityNeeds?: string | null | undefined;
|
|
25
|
+
notes?: string | null | undefined;
|
|
21
26
|
updatedAt?: string | undefined;
|
|
22
27
|
}, Error, CreatePassengerInput, unknown>;
|
|
23
28
|
update: import("@tanstack/react-query").UseMutationResult<{
|
|
24
29
|
id: string;
|
|
25
30
|
bookingId: string;
|
|
31
|
+
participantType: string;
|
|
26
32
|
firstName: string;
|
|
27
33
|
lastName: string;
|
|
28
34
|
email: string | null;
|
|
29
35
|
phone: string | null;
|
|
30
36
|
specialRequests: string | null;
|
|
37
|
+
isPrimary: boolean;
|
|
31
38
|
createdAt: string;
|
|
32
|
-
|
|
39
|
+
travelerCategory?: string | null | undefined;
|
|
40
|
+
preferredLanguage?: string | null | undefined;
|
|
41
|
+
accessibilityNeeds?: string | null | undefined;
|
|
42
|
+
notes?: string | null | undefined;
|
|
33
43
|
updatedAt?: string | undefined;
|
|
34
44
|
}, Error, {
|
|
35
45
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-passenger-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-passenger-mutation.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,eAAe,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;CACjC;AAED,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;AAEhE,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"use-passenger-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-passenger-mutation.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,eAAe,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;CACjC;AAED,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;AAEhE,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAuBV,MAAM;eAAS,oBAAoB;;;;;EAgC9E"}
|
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
enabled?: boolean;
|
|
3
|
-
}
|
|
4
|
-
export declare function usePassengers(bookingId: string | null | undefined, options?: UsePassengersOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
-
data: {
|
|
6
|
-
id: string;
|
|
7
|
-
bookingId: string;
|
|
8
|
-
firstName: string;
|
|
9
|
-
lastName: string;
|
|
10
|
-
email: string | null;
|
|
11
|
-
phone: string | null;
|
|
12
|
-
specialRequests: string | null;
|
|
13
|
-
createdAt: string;
|
|
14
|
-
isLeadPassenger?: boolean | null | undefined;
|
|
15
|
-
updatedAt?: string | undefined;
|
|
16
|
-
}[];
|
|
17
|
-
}, Error>;
|
|
1
|
+
export { type UseTravelersOptions as UsePassengersOptions, useTravelers as usePassengers, } from "./use-travelers.js";
|
|
18
2
|
//# sourceMappingURL=use-passengers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-passengers.d.ts","sourceRoot":"","sources":["../../src/hooks/use-passengers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-passengers.d.ts","sourceRoot":"","sources":["../../src/hooks/use-passengers.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,mBAAmB,IAAI,oBAAoB,EAChD,YAAY,IAAI,aAAa,GAC9B,MAAM,oBAAoB,CAAA"}
|
|
@@ -1,12 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
import { useVoyantBookingsContext } from "../provider.js";
|
|
4
|
-
import { getPassengersQueryOptions } from "../query-options.js";
|
|
5
|
-
export function usePassengers(bookingId, options = {}) {
|
|
6
|
-
const { baseUrl, fetcher } = useVoyantBookingsContext();
|
|
7
|
-
const { enabled = true } = options;
|
|
8
|
-
return useQuery({
|
|
9
|
-
...getPassengersQueryOptions({ baseUrl, fetcher }, bookingId),
|
|
10
|
-
enabled: enabled && Boolean(bookingId),
|
|
11
|
-
});
|
|
12
|
-
}
|
|
2
|
+
export { useTravelers as usePassengers, } from "./use-travelers.js";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { PricingPreviewFilters } from "../query-keys.js";
|
|
2
|
+
export interface UsePricingPreviewOptions extends PricingPreviewFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Catalog-resolved pricing snapshot for a product + option (+ optional
|
|
7
|
+
* catalog). Consumers match the returned `unitPrices` / `tiers` against their
|
|
8
|
+
* passenger/unit selection to render a breakdown. The snapshot is the same
|
|
9
|
+
* data the storefront session uses, so operator-side numbers stay in sync
|
|
10
|
+
* with customer-facing ones.
|
|
11
|
+
*/
|
|
12
|
+
export declare function usePricingPreview({ enabled, ...filters }: UsePricingPreviewOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
13
|
+
data: {
|
|
14
|
+
catalog: {
|
|
15
|
+
id: string;
|
|
16
|
+
currencyCode: string;
|
|
17
|
+
};
|
|
18
|
+
options: {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
isDefault: boolean;
|
|
22
|
+
}[];
|
|
23
|
+
rules: {
|
|
24
|
+
id: string;
|
|
25
|
+
optionId: string;
|
|
26
|
+
pricingMode: string;
|
|
27
|
+
baseSellAmountCents: number | null;
|
|
28
|
+
isDefault: boolean;
|
|
29
|
+
}[];
|
|
30
|
+
unitPrices: {
|
|
31
|
+
id: string;
|
|
32
|
+
optionPriceRuleId: string;
|
|
33
|
+
unitId: string;
|
|
34
|
+
unitName: string;
|
|
35
|
+
unitType: string;
|
|
36
|
+
pricingCategoryId: string | null;
|
|
37
|
+
pricingMode: string;
|
|
38
|
+
sellAmountCents: number | null;
|
|
39
|
+
minQuantity: number | null;
|
|
40
|
+
maxQuantity: number | null;
|
|
41
|
+
tiers: {
|
|
42
|
+
minQuantity: number;
|
|
43
|
+
maxQuantity: number | null;
|
|
44
|
+
sellAmountCents: number | null;
|
|
45
|
+
}[];
|
|
46
|
+
}[];
|
|
47
|
+
};
|
|
48
|
+
}, Error>;
|
|
49
|
+
//# sourceMappingURL=use-pricing-preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-pricing-preview.d.ts","sourceRoot":"","sources":["../../src/hooks/use-pricing-preview.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAG7D,MAAM,WAAW,wBAAyB,SAAQ,qBAAqB;IACrE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,OAAc,EAAE,GAAG,OAAO,EAAE,EAAE,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAMzF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantBookingsContext } from "../provider.js";
|
|
4
|
+
import { getPricingPreviewQueryOptions } from "../query-options.js";
|
|
5
|
+
/**
|
|
6
|
+
* Catalog-resolved pricing snapshot for a product + option (+ optional
|
|
7
|
+
* catalog). Consumers match the returned `unitPrices` / `tiers` against their
|
|
8
|
+
* passenger/unit selection to render a breakdown. The snapshot is the same
|
|
9
|
+
* data the storefront session uses, so operator-side numbers stay in sync
|
|
10
|
+
* with customer-facing ones.
|
|
11
|
+
*/
|
|
12
|
+
export function usePricingPreview({ enabled = true, ...filters }) {
|
|
13
|
+
const client = useVoyantBookingsContext();
|
|
14
|
+
return useQuery({
|
|
15
|
+
...getPricingPreviewQueryOptions(client, filters),
|
|
16
|
+
enabled: enabled && Boolean(filters.productId),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -54,9 +54,9 @@ export declare function usePublicBookingSessionFlowMutation(sessionId: string):
|
|
|
54
54
|
expiredAt: string | null;
|
|
55
55
|
cancelledAt: string | null;
|
|
56
56
|
completedAt: string | null;
|
|
57
|
-
|
|
57
|
+
travelers: {
|
|
58
58
|
id: string;
|
|
59
|
-
participantType: "traveler" | "
|
|
59
|
+
participantType: "traveler" | "occupant" | "other";
|
|
60
60
|
travelerCategory: "other" | "adult" | "child" | "infant" | "senior" | null;
|
|
61
61
|
firstName: string;
|
|
62
62
|
lastName: string;
|
|
@@ -89,10 +89,10 @@ export declare function usePublicBookingSessionFlowMutation(sessionId: string):
|
|
|
89
89
|
optionId: string | null;
|
|
90
90
|
optionUnitId: string | null;
|
|
91
91
|
pricingCategoryId: string | null;
|
|
92
|
-
|
|
92
|
+
travelerLinks: {
|
|
93
93
|
id: string;
|
|
94
|
-
|
|
95
|
-
role: "traveler" | "occupant" | "other" | "
|
|
94
|
+
travelerId: string;
|
|
95
|
+
role: "traveler" | "occupant" | "other" | "beneficiary";
|
|
96
96
|
isPrimary: boolean;
|
|
97
97
|
}[];
|
|
98
98
|
}[];
|
|
@@ -112,9 +112,8 @@ export declare function usePublicBookingSessionFlowMutation(sessionId: string):
|
|
|
112
112
|
releasedAt: string | null;
|
|
113
113
|
}[];
|
|
114
114
|
checklist: {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
hasPrimaryParticipant: boolean;
|
|
115
|
+
hasTravelers: boolean;
|
|
116
|
+
hasPrimaryTraveler: boolean;
|
|
118
117
|
hasItems: boolean;
|
|
119
118
|
hasAllocations: boolean;
|
|
120
119
|
readyForConfirmation: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-public-booking-session-flow-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-public-booking-session-flow-mutation.ts"],"names":[],"mappings":"AAgBA,wBAAgB,mCAAmC,CAAC,SAAS,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"use-public-booking-session-flow-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-public-booking-session-flow-mutation.ts"],"names":[],"mappings":"AAgBA,wBAAgB,mCAAmC,CAAC,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCpE"}
|
|
@@ -18,9 +18,9 @@ export declare function usePublicBookingSession(sessionId: string | null | undef
|
|
|
18
18
|
expiredAt: string | null;
|
|
19
19
|
cancelledAt: string | null;
|
|
20
20
|
completedAt: string | null;
|
|
21
|
-
|
|
21
|
+
travelers: {
|
|
22
22
|
id: string;
|
|
23
|
-
participantType: "traveler" | "
|
|
23
|
+
participantType: "traveler" | "occupant" | "other";
|
|
24
24
|
travelerCategory: "other" | "adult" | "child" | "infant" | "senior" | null;
|
|
25
25
|
firstName: string;
|
|
26
26
|
lastName: string;
|
|
@@ -53,10 +53,10 @@ export declare function usePublicBookingSession(sessionId: string | null | undef
|
|
|
53
53
|
optionId: string | null;
|
|
54
54
|
optionUnitId: string | null;
|
|
55
55
|
pricingCategoryId: string | null;
|
|
56
|
-
|
|
56
|
+
travelerLinks: {
|
|
57
57
|
id: string;
|
|
58
|
-
|
|
59
|
-
role: "traveler" | "occupant" | "other" | "
|
|
58
|
+
travelerId: string;
|
|
59
|
+
role: "traveler" | "occupant" | "other" | "beneficiary";
|
|
60
60
|
isPrimary: boolean;
|
|
61
61
|
}[];
|
|
62
62
|
}[];
|
|
@@ -76,9 +76,8 @@ export declare function usePublicBookingSession(sessionId: string | null | undef
|
|
|
76
76
|
releasedAt: string | null;
|
|
77
77
|
}[];
|
|
78
78
|
checklist: {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
hasPrimaryParticipant: boolean;
|
|
79
|
+
hasTravelers: boolean;
|
|
80
|
+
hasPrimaryTraveler: boolean;
|
|
82
81
|
hasItems: boolean;
|
|
83
82
|
hasAllocations: boolean;
|
|
84
83
|
readyForConfirmation: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-public-booking-session.d.ts","sourceRoot":"","sources":["../../src/hooks/use-public-booking-session.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,8BAA8B;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,OAAO,GAAE,8BAAmC
|
|
1
|
+
{"version":3,"file":"use-public-booking-session.d.ts","sourceRoot":"","sources":["../../src/hooks/use-public-booking-session.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,8BAA8B;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,OAAO,GAAE,8BAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAS7C"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export interface CreateTravelerInput {
|
|
2
|
+
firstName: string;
|
|
3
|
+
lastName: string;
|
|
4
|
+
email?: string | null;
|
|
5
|
+
phone?: string | null;
|
|
6
|
+
preferredLanguage?: string | null;
|
|
7
|
+
accessibilityNeeds?: string | null;
|
|
8
|
+
specialRequests?: string | null;
|
|
9
|
+
travelerCategory?: string | null;
|
|
10
|
+
isPrimary?: boolean | null;
|
|
11
|
+
notes?: string | null;
|
|
12
|
+
}
|
|
13
|
+
export type UpdateTravelerInput = Partial<CreateTravelerInput>;
|
|
14
|
+
export declare function useTravelerMutation(bookingId: string): {
|
|
15
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
16
|
+
id: string;
|
|
17
|
+
bookingId: string;
|
|
18
|
+
participantType: string;
|
|
19
|
+
firstName: string;
|
|
20
|
+
lastName: string;
|
|
21
|
+
email: string | null;
|
|
22
|
+
phone: string | null;
|
|
23
|
+
specialRequests: string | null;
|
|
24
|
+
isPrimary: boolean;
|
|
25
|
+
createdAt: string;
|
|
26
|
+
travelerCategory?: string | null | undefined;
|
|
27
|
+
preferredLanguage?: string | null | undefined;
|
|
28
|
+
accessibilityNeeds?: string | null | undefined;
|
|
29
|
+
notes?: string | null | undefined;
|
|
30
|
+
updatedAt?: string | undefined;
|
|
31
|
+
}, Error, CreateTravelerInput, unknown>;
|
|
32
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
33
|
+
id: string;
|
|
34
|
+
bookingId: string;
|
|
35
|
+
participantType: string;
|
|
36
|
+
firstName: string;
|
|
37
|
+
lastName: string;
|
|
38
|
+
email: string | null;
|
|
39
|
+
phone: string | null;
|
|
40
|
+
specialRequests: string | null;
|
|
41
|
+
isPrimary: boolean;
|
|
42
|
+
createdAt: string;
|
|
43
|
+
travelerCategory?: string | null | undefined;
|
|
44
|
+
preferredLanguage?: string | null | undefined;
|
|
45
|
+
accessibilityNeeds?: string | null | undefined;
|
|
46
|
+
notes?: string | null | undefined;
|
|
47
|
+
updatedAt?: string | undefined;
|
|
48
|
+
}, Error, {
|
|
49
|
+
id: string;
|
|
50
|
+
input: UpdateTravelerInput;
|
|
51
|
+
}, unknown>;
|
|
52
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
53
|
+
success: boolean;
|
|
54
|
+
}, Error, string, unknown>;
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=use-traveler-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-traveler-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-traveler-mutation.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;IAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACtB;AAED,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;AAE9D,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAuBT,MAAM;eAAS,mBAAmB;;;;;EAgC7E"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantBookingsContext } from "../provider.js";
|
|
5
|
+
import { bookingsQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { bookingSingleResponse, bookingTravelersResponse, successEnvelope } from "../schemas.js";
|
|
7
|
+
export function useTravelerMutation(bookingId) {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantBookingsContext();
|
|
9
|
+
const queryClient = useQueryClient();
|
|
10
|
+
const create = useMutation({
|
|
11
|
+
mutationFn: async (input) => {
|
|
12
|
+
const { data } = await fetchWithValidation(`/v1/bookings/${bookingId}/travelers`, bookingSingleResponse.extend({
|
|
13
|
+
data: bookingTravelersResponse.shape.data.element,
|
|
14
|
+
}), { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
15
|
+
return data;
|
|
16
|
+
},
|
|
17
|
+
onSuccess: () => {
|
|
18
|
+
void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.travelers(bookingId) });
|
|
19
|
+
void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.activity(bookingId) });
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
const update = useMutation({
|
|
23
|
+
mutationFn: async ({ id, input }) => {
|
|
24
|
+
const { data } = await fetchWithValidation(`/v1/bookings/${bookingId}/travelers/${id}`, bookingSingleResponse.extend({
|
|
25
|
+
data: bookingTravelersResponse.shape.data.element,
|
|
26
|
+
}), { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
27
|
+
return data;
|
|
28
|
+
},
|
|
29
|
+
onSuccess: () => {
|
|
30
|
+
void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.travelers(bookingId) });
|
|
31
|
+
void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.activity(bookingId) });
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const remove = useMutation({
|
|
35
|
+
mutationFn: async (travelerId) => fetchWithValidation(`/v1/bookings/${bookingId}/travelers/${travelerId}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
|
|
36
|
+
onSuccess: () => {
|
|
37
|
+
void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.travelers(bookingId) });
|
|
38
|
+
void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.activity(bookingId) });
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
return { create, update, remove };
|
|
42
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface UseTravelersOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useTravelers(bookingId: string | null | undefined, options?: UseTravelersOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
data: {
|
|
6
|
+
id: string;
|
|
7
|
+
bookingId: string;
|
|
8
|
+
participantType: string;
|
|
9
|
+
firstName: string;
|
|
10
|
+
lastName: string;
|
|
11
|
+
email: string | null;
|
|
12
|
+
phone: string | null;
|
|
13
|
+
specialRequests: string | null;
|
|
14
|
+
isPrimary: boolean;
|
|
15
|
+
createdAt: string;
|
|
16
|
+
travelerCategory?: string | null | undefined;
|
|
17
|
+
preferredLanguage?: string | null | undefined;
|
|
18
|
+
accessibilityNeeds?: string | null | undefined;
|
|
19
|
+
notes?: string | null | undefined;
|
|
20
|
+
updatedAt?: string | undefined;
|
|
21
|
+
}[];
|
|
22
|
+
}, Error>;
|
|
23
|
+
//# sourceMappingURL=use-travelers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-travelers.d.ts","sourceRoot":"","sources":["../../src/hooks/use-travelers.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,OAAO,GAAE,mBAAwB;;;;;;;;;;;;;;;;;;UASlC"}
|