@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
package/dist/hooks/index.d.ts
CHANGED
|
@@ -2,26 +2,29 @@ export { type UseBookingOptions, useBooking } from "./use-booking.js";
|
|
|
2
2
|
export { type UseBookingActivityOptions, useBookingActivity } from "./use-booking-activity.js";
|
|
3
3
|
export { type CancelBookingInput, useBookingCancelMutation, } from "./use-booking-cancel-mutation.js";
|
|
4
4
|
export { type ConvertProductToBookingInput, useBookingConvertMutation, } from "./use-booking-convert-mutation.js";
|
|
5
|
-
export { type
|
|
5
|
+
export { type CreateBookingTravelerDocumentInput, type UseBookingTravelerDocumentsOptions, useBookingTravelerDocumentMutation, useBookingTravelerDocuments, } from "./use-booking-documents.js";
|
|
6
|
+
export { type DualCreateBookingInput, type DualCreateBookingResult, type DualCreateGroupInput, type DualCreateSubBookingInput, useBookingDualCreateMutation, } from "./use-booking-dual-create-mutation.js";
|
|
6
7
|
export { type UseBookingGroupOptions, useBookingGroup } from "./use-booking-group.js";
|
|
7
8
|
export { type UseBookingGroupForBookingOptions, useBookingGroupForBooking, } from "./use-booking-group-for-booking.js";
|
|
8
9
|
export { type AddBookingGroupMemberInput, useBookingGroupMemberMutation, } from "./use-booking-group-member-mutation.js";
|
|
9
10
|
export { type CreateBookingGroupInput, type UpdateBookingGroupInput, useBookingGroupMutation, } from "./use-booking-group-mutation.js";
|
|
10
11
|
export { type UseBookingGroupsOptions, useBookingGroups } from "./use-booking-groups.js";
|
|
11
12
|
export { type CreateBookingItemInput, type UpdateBookingItemInput, useBookingItemMutation, } from "./use-booking-item-mutation.js";
|
|
12
|
-
export { type
|
|
13
|
+
export { type AddItemTravelerInput, type UseBookingItemTravelersOptions, useBookingItemTravelerMutation, useBookingItemTravelers, } from "./use-booking-item-travelers.js";
|
|
13
14
|
export { type UseBookingItemsOptions, useBookingItems } from "./use-booking-items.js";
|
|
14
15
|
export { type CreateBookingInput, type UpdateBookingInput, useBookingMutation, } from "./use-booking-mutation.js";
|
|
15
16
|
export { type CreateBookingNoteInput, useBookingNoteMutation, } from "./use-booking-note-mutation.js";
|
|
16
17
|
export { type UseBookingNotesOptions, useBookingNotes } from "./use-booking-notes.js";
|
|
17
18
|
export { type UseBookingPrimaryProductOptions, type UseBookingPrimaryProductResult, useBookingPrimaryProduct, } from "./use-booking-primary-product.js";
|
|
18
|
-
export { type
|
|
19
|
+
export { type QuickCreateBookingInput, type QuickCreateBookingResult, type QuickCreateGroupMembershipInput, type QuickCreatePaymentScheduleInput, type QuickCreateTravelerInput, type QuickCreateVoucherRedemptionInput, useBookingQuickCreateMutation, } from "./use-booking-quick-create-mutation.js";
|
|
20
|
+
export { type UpdateBookingStatusByIdInput, type UpdateBookingStatusInput, useBookingStatusByIdMutation, useBookingStatusMutation, } from "./use-booking-status-mutation.js";
|
|
19
21
|
export { type UseBookingsOptions, useBookings } from "./use-bookings.js";
|
|
20
|
-
export { type
|
|
21
|
-
export { type UsePassengersOptions, usePassengers } from "./use-passengers.js";
|
|
22
|
+
export { type UsePricingPreviewOptions, usePricingPreview } from "./use-pricing-preview.js";
|
|
22
23
|
export { type UsePublicBookingSessionOptions, usePublicBookingSession, } from "./use-public-booking-session.js";
|
|
23
24
|
export { usePublicBookingSessionFlowMutation } from "./use-public-booking-session-flow-mutation.js";
|
|
24
25
|
export { type UsePublicBookingSessionStateOptions, usePublicBookingSessionState, } from "./use-public-booking-session-state.js";
|
|
25
26
|
export { type CreateSupplierStatusInput, type UpdateSupplierStatusInput, useSupplierStatusMutation, } from "./use-supplier-status-mutation.js";
|
|
26
27
|
export { type UseSupplierStatusesOptions, useSupplierStatuses } from "./use-supplier-statuses.js";
|
|
28
|
+
export { type CreateTravelerInput, type UpdateTravelerInput, useTravelerMutation, } from "./use-traveler-mutation.js";
|
|
29
|
+
export { type UseTravelersOptions, useTravelers } from "./use-travelers.js";
|
|
27
30
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,EAAE,KAAK,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9F,OAAO,EACL,KAAK,kBAAkB,EACvB,wBAAwB,GACzB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EACL,KAAK,4BAA4B,EACjC,yBAAyB,GAC1B,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"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"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -2,25 +2,28 @@ export { useBooking } from "./use-booking.js";
|
|
|
2
2
|
export { useBookingActivity } from "./use-booking-activity.js";
|
|
3
3
|
export { useBookingCancelMutation, } from "./use-booking-cancel-mutation.js";
|
|
4
4
|
export { useBookingConvertMutation, } from "./use-booking-convert-mutation.js";
|
|
5
|
-
export {
|
|
5
|
+
export { useBookingTravelerDocumentMutation, useBookingTravelerDocuments, } from "./use-booking-documents.js";
|
|
6
|
+
export { useBookingDualCreateMutation, } from "./use-booking-dual-create-mutation.js";
|
|
6
7
|
export { useBookingGroup } from "./use-booking-group.js";
|
|
7
8
|
export { useBookingGroupForBooking, } from "./use-booking-group-for-booking.js";
|
|
8
9
|
export { useBookingGroupMemberMutation, } from "./use-booking-group-member-mutation.js";
|
|
9
10
|
export { useBookingGroupMutation, } from "./use-booking-group-mutation.js";
|
|
10
11
|
export { useBookingGroups } from "./use-booking-groups.js";
|
|
11
12
|
export { useBookingItemMutation, } from "./use-booking-item-mutation.js";
|
|
12
|
-
export {
|
|
13
|
+
export { useBookingItemTravelerMutation, useBookingItemTravelers, } from "./use-booking-item-travelers.js";
|
|
13
14
|
export { useBookingItems } from "./use-booking-items.js";
|
|
14
15
|
export { useBookingMutation, } from "./use-booking-mutation.js";
|
|
15
16
|
export { useBookingNoteMutation, } from "./use-booking-note-mutation.js";
|
|
16
17
|
export { useBookingNotes } from "./use-booking-notes.js";
|
|
17
18
|
export { useBookingPrimaryProduct, } from "./use-booking-primary-product.js";
|
|
18
|
-
export {
|
|
19
|
+
export { useBookingQuickCreateMutation, } from "./use-booking-quick-create-mutation.js";
|
|
20
|
+
export { useBookingStatusByIdMutation, useBookingStatusMutation, } from "./use-booking-status-mutation.js";
|
|
19
21
|
export { useBookings } from "./use-bookings.js";
|
|
20
|
-
export {
|
|
21
|
-
export { usePassengers } from "./use-passengers.js";
|
|
22
|
+
export { usePricingPreview } from "./use-pricing-preview.js";
|
|
22
23
|
export { usePublicBookingSession, } from "./use-public-booking-session.js";
|
|
23
24
|
export { usePublicBookingSessionFlowMutation } from "./use-public-booking-session-flow-mutation.js";
|
|
24
25
|
export { usePublicBookingSessionState, } from "./use-public-booking-session-state.js";
|
|
25
26
|
export { useSupplierStatusMutation, } from "./use-supplier-status-mutation.js";
|
|
26
27
|
export { useSupplierStatuses } from "./use-supplier-statuses.js";
|
|
28
|
+
export { useTravelerMutation, } from "./use-traveler-mutation.js";
|
|
29
|
+
export { useTravelers } from "./use-travelers.js";
|
|
@@ -2,6 +2,12 @@ export interface ConvertProductToBookingInput {
|
|
|
2
2
|
productId: string;
|
|
3
3
|
bookingNumber: string;
|
|
4
4
|
optionId?: string | null;
|
|
5
|
+
/**
|
|
6
|
+
* Availability slot the operator picked. When set, the booking's start/end
|
|
7
|
+
* dates are pinned to the slot instead of defaulting to the (typically null)
|
|
8
|
+
* product dates. Server-side validation rejects mismatched product/option.
|
|
9
|
+
*/
|
|
10
|
+
slotId?: string | null;
|
|
5
11
|
personId?: string | null;
|
|
6
12
|
organizationId?: string | null;
|
|
7
13
|
internalNotes?: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-booking-convert-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking-convert-mutation.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,4BAA4B;IAC3C,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB;;;;;;;;;;;;;;;;iDAkBxC"}
|
|
1
|
+
{"version":3,"file":"use-booking-convert-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking-convert-mutation.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,4BAA4B;IAC3C,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB;;;;;;;;;;;;;;;;iDAkBxC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface UseBookingTravelerDocumentsOptions {
|
|
2
2
|
enabled?: boolean;
|
|
3
3
|
}
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function useBookingTravelerDocuments(bookingId: string | null | undefined, options?: UseBookingTravelerDocumentsOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
5
|
data: {
|
|
6
6
|
id: string;
|
|
7
7
|
bookingId: string;
|
|
8
|
-
|
|
8
|
+
travelerId: string | null;
|
|
9
9
|
type: "other" | "visa" | "insurance" | "health" | "passport_copy";
|
|
10
10
|
fileName: string;
|
|
11
11
|
fileUrl: string;
|
|
@@ -14,26 +14,26 @@ export declare function useBookingDocuments(bookingId: string | null | undefined
|
|
|
14
14
|
createdAt: string;
|
|
15
15
|
}[];
|
|
16
16
|
}, Error>;
|
|
17
|
-
export interface
|
|
17
|
+
export interface CreateBookingTravelerDocumentInput {
|
|
18
18
|
type: string;
|
|
19
19
|
fileName: string;
|
|
20
20
|
fileUrl: string;
|
|
21
|
-
|
|
21
|
+
travelerId?: string | null;
|
|
22
22
|
expiresAt?: string | null;
|
|
23
23
|
notes?: string | null;
|
|
24
24
|
}
|
|
25
|
-
export declare function
|
|
25
|
+
export declare function useBookingTravelerDocumentMutation(bookingId: string): {
|
|
26
26
|
create: import("@tanstack/react-query").UseMutationResult<{
|
|
27
27
|
id: string;
|
|
28
28
|
bookingId: string;
|
|
29
|
-
|
|
29
|
+
travelerId: string | null;
|
|
30
30
|
type: "other" | "visa" | "insurance" | "health" | "passport_copy";
|
|
31
31
|
fileName: string;
|
|
32
32
|
fileUrl: string;
|
|
33
33
|
expiresAt: string | null;
|
|
34
34
|
notes: string | null;
|
|
35
35
|
createdAt: string;
|
|
36
|
-
}, Error,
|
|
36
|
+
}, Error, CreateBookingTravelerDocumentInput, unknown>;
|
|
37
37
|
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
38
38
|
success: boolean;
|
|
39
39
|
}, Error, string, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-booking-documents.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking-documents.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-booking-documents.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking-documents.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,kCAAkC;IACjD,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,OAAO,GAAE,kCAAuC;;;;;;;;;;;;UASjD;AAED,MAAM,WAAW,kCAAkC;IACjD,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACtB;AAED,wBAAgB,kCAAkC,CAAC,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;EA6CnE"}
|
|
@@ -3,17 +3,17 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
|
3
3
|
import { fetchWithValidation } from "../client.js";
|
|
4
4
|
import { useVoyantBookingsContext } from "../provider.js";
|
|
5
5
|
import { bookingsQueryKeys } from "../query-keys.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
export function
|
|
6
|
+
import { getBookingTravelerDocumentsQueryOptions } from "../query-options.js";
|
|
7
|
+
import { bookingSingleResponse, bookingTravelerDocumentsResponse, successEnvelope, } from "../schemas.js";
|
|
8
|
+
export function useBookingTravelerDocuments(bookingId, options = {}) {
|
|
9
9
|
const { baseUrl, fetcher } = useVoyantBookingsContext();
|
|
10
10
|
const { enabled = true } = options;
|
|
11
11
|
return useQuery({
|
|
12
|
-
...
|
|
12
|
+
...getBookingTravelerDocumentsQueryOptions({ baseUrl, fetcher }, bookingId),
|
|
13
13
|
enabled: enabled && Boolean(bookingId),
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
export function
|
|
16
|
+
export function useBookingTravelerDocumentMutation(bookingId) {
|
|
17
17
|
const { baseUrl, fetcher } = useVoyantBookingsContext();
|
|
18
18
|
const queryClient = useQueryClient();
|
|
19
19
|
const invalidate = () => {
|
|
@@ -22,8 +22,18 @@ export function useBookingDocumentMutation(bookingId) {
|
|
|
22
22
|
const create = useMutation({
|
|
23
23
|
mutationFn: async (input) => {
|
|
24
24
|
const { data } = await fetchWithValidation(`/v1/bookings/${bookingId}/documents`, bookingSingleResponse.extend({
|
|
25
|
-
data:
|
|
26
|
-
}), { baseUrl, fetcher }, {
|
|
25
|
+
data: bookingTravelerDocumentsResponse.shape.data.element,
|
|
26
|
+
}), { baseUrl, fetcher }, {
|
|
27
|
+
method: "POST",
|
|
28
|
+
body: JSON.stringify({
|
|
29
|
+
type: input.type,
|
|
30
|
+
fileName: input.fileName,
|
|
31
|
+
fileUrl: input.fileUrl,
|
|
32
|
+
travelerId: input.travelerId,
|
|
33
|
+
expiresAt: input.expiresAt,
|
|
34
|
+
notes: input.notes,
|
|
35
|
+
}),
|
|
36
|
+
});
|
|
27
37
|
return data;
|
|
28
38
|
},
|
|
29
39
|
onSuccess: invalidate,
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { QuickCreateBookingInput } from "./use-booking-quick-create-mutation.js";
|
|
3
|
+
/**
|
|
4
|
+
* Sub-booking payload for dual-create. Same shape as quickCreate input
|
|
5
|
+
* minus `groupMembership` — the dual endpoint manages the group itself.
|
|
6
|
+
*/
|
|
7
|
+
export type DualCreateSubBookingInput = Omit<QuickCreateBookingInput, "groupMembership">;
|
|
8
|
+
export interface DualCreateGroupInput {
|
|
9
|
+
kind?: "shared_room" | "other";
|
|
10
|
+
label?: string | null;
|
|
11
|
+
/**
|
|
12
|
+
* option_unit the shared group occupies. The dual flow lives-or-dies on
|
|
13
|
+
* matching this across both bookings — when set, both sub-bookings should
|
|
14
|
+
* target the same optionUnitId in their passengers/allocations.
|
|
15
|
+
*/
|
|
16
|
+
optionUnitId?: string | null;
|
|
17
|
+
}
|
|
18
|
+
export interface DualCreateBookingInput {
|
|
19
|
+
primary: DualCreateSubBookingInput;
|
|
20
|
+
secondary: DualCreateSubBookingInput;
|
|
21
|
+
group?: DualCreateGroupInput;
|
|
22
|
+
}
|
|
23
|
+
declare const dualCreateResultSchema: z.ZodObject<{
|
|
24
|
+
primary: z.ZodObject<{
|
|
25
|
+
booking: z.ZodObject<{
|
|
26
|
+
id: z.ZodString;
|
|
27
|
+
bookingNumber: z.ZodString;
|
|
28
|
+
status: z.ZodEnum<{
|
|
29
|
+
draft: "draft";
|
|
30
|
+
on_hold: "on_hold";
|
|
31
|
+
confirmed: "confirmed";
|
|
32
|
+
in_progress: "in_progress";
|
|
33
|
+
completed: "completed";
|
|
34
|
+
expired: "expired";
|
|
35
|
+
cancelled: "cancelled";
|
|
36
|
+
}>;
|
|
37
|
+
personId: z.ZodNullable<z.ZodString>;
|
|
38
|
+
organizationId: z.ZodNullable<z.ZodString>;
|
|
39
|
+
sellCurrency: z.ZodString;
|
|
40
|
+
sellAmountCents: z.ZodNullable<z.ZodNumber>;
|
|
41
|
+
costAmountCents: z.ZodNullable<z.ZodNumber>;
|
|
42
|
+
marginPercent: z.ZodNullable<z.ZodNumber>;
|
|
43
|
+
startDate: z.ZodNullable<z.ZodString>;
|
|
44
|
+
endDate: z.ZodNullable<z.ZodString>;
|
|
45
|
+
pax: z.ZodNullable<z.ZodNumber>;
|
|
46
|
+
internalNotes: z.ZodNullable<z.ZodString>;
|
|
47
|
+
createdAt: z.ZodString;
|
|
48
|
+
updatedAt: z.ZodString;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
travelers: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
51
|
+
paymentSchedules: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
52
|
+
voucherRedemption: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
secondary: z.ZodObject<{
|
|
55
|
+
booking: z.ZodObject<{
|
|
56
|
+
id: z.ZodString;
|
|
57
|
+
bookingNumber: z.ZodString;
|
|
58
|
+
status: z.ZodEnum<{
|
|
59
|
+
draft: "draft";
|
|
60
|
+
on_hold: "on_hold";
|
|
61
|
+
confirmed: "confirmed";
|
|
62
|
+
in_progress: "in_progress";
|
|
63
|
+
completed: "completed";
|
|
64
|
+
expired: "expired";
|
|
65
|
+
cancelled: "cancelled";
|
|
66
|
+
}>;
|
|
67
|
+
personId: z.ZodNullable<z.ZodString>;
|
|
68
|
+
organizationId: z.ZodNullable<z.ZodString>;
|
|
69
|
+
sellCurrency: z.ZodString;
|
|
70
|
+
sellAmountCents: z.ZodNullable<z.ZodNumber>;
|
|
71
|
+
costAmountCents: z.ZodNullable<z.ZodNumber>;
|
|
72
|
+
marginPercent: z.ZodNullable<z.ZodNumber>;
|
|
73
|
+
startDate: z.ZodNullable<z.ZodString>;
|
|
74
|
+
endDate: z.ZodNullable<z.ZodString>;
|
|
75
|
+
pax: z.ZodNullable<z.ZodNumber>;
|
|
76
|
+
internalNotes: z.ZodNullable<z.ZodString>;
|
|
77
|
+
createdAt: z.ZodString;
|
|
78
|
+
updatedAt: z.ZodString;
|
|
79
|
+
}, z.core.$strip>;
|
|
80
|
+
travelers: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
81
|
+
paymentSchedules: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
82
|
+
voucherRedemption: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
|
|
83
|
+
}, z.core.$strip>;
|
|
84
|
+
group: z.ZodUnknown;
|
|
85
|
+
primaryMember: z.ZodUnknown;
|
|
86
|
+
secondaryMember: z.ZodUnknown;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
export type DualCreateBookingResult = z.infer<typeof dualCreateResultSchema>;
|
|
89
|
+
/**
|
|
90
|
+
* Atomic dual-booking (partaj) create: calls `POST /v1/bookings/dual-create`
|
|
91
|
+
* which wraps two quickCreate calls + one booking_group in a single
|
|
92
|
+
* transaction. Use this over calling useBookingQuickCreateMutation twice
|
|
93
|
+
* from a submit handler — a failure on the second call there would leave
|
|
94
|
+
* the first booking orphaned.
|
|
95
|
+
*/
|
|
96
|
+
export declare function useBookingDualCreateMutation(): import("@tanstack/react-query").UseMutationResult<{
|
|
97
|
+
primary: {
|
|
98
|
+
booking: {
|
|
99
|
+
id: string;
|
|
100
|
+
bookingNumber: string;
|
|
101
|
+
status: "draft" | "on_hold" | "confirmed" | "in_progress" | "completed" | "expired" | "cancelled";
|
|
102
|
+
personId: string | null;
|
|
103
|
+
organizationId: string | null;
|
|
104
|
+
sellCurrency: string;
|
|
105
|
+
sellAmountCents: number | null;
|
|
106
|
+
costAmountCents: number | null;
|
|
107
|
+
marginPercent: number | null;
|
|
108
|
+
startDate: string | null;
|
|
109
|
+
endDate: string | null;
|
|
110
|
+
pax: number | null;
|
|
111
|
+
internalNotes: string | null;
|
|
112
|
+
createdAt: string;
|
|
113
|
+
updatedAt: string;
|
|
114
|
+
};
|
|
115
|
+
travelers?: unknown[] | undefined;
|
|
116
|
+
paymentSchedules?: unknown[] | undefined;
|
|
117
|
+
voucherRedemption?: unknown;
|
|
118
|
+
};
|
|
119
|
+
secondary: {
|
|
120
|
+
booking: {
|
|
121
|
+
id: string;
|
|
122
|
+
bookingNumber: string;
|
|
123
|
+
status: "draft" | "on_hold" | "confirmed" | "in_progress" | "completed" | "expired" | "cancelled";
|
|
124
|
+
personId: string | null;
|
|
125
|
+
organizationId: string | null;
|
|
126
|
+
sellCurrency: string;
|
|
127
|
+
sellAmountCents: number | null;
|
|
128
|
+
costAmountCents: number | null;
|
|
129
|
+
marginPercent: number | null;
|
|
130
|
+
startDate: string | null;
|
|
131
|
+
endDate: string | null;
|
|
132
|
+
pax: number | null;
|
|
133
|
+
internalNotes: string | null;
|
|
134
|
+
createdAt: string;
|
|
135
|
+
updatedAt: string;
|
|
136
|
+
};
|
|
137
|
+
travelers?: unknown[] | undefined;
|
|
138
|
+
paymentSchedules?: unknown[] | undefined;
|
|
139
|
+
voucherRedemption?: unknown;
|
|
140
|
+
};
|
|
141
|
+
group: unknown;
|
|
142
|
+
primaryMember: unknown;
|
|
143
|
+
secondaryMember: unknown;
|
|
144
|
+
}, Error, DualCreateBookingInput, unknown>;
|
|
145
|
+
export {};
|
|
146
|
+
//# sourceMappingURL=use-booking-dual-create-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-booking-dual-create-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking-dual-create-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAA;AAErF;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,uBAAuB,EAAE,iBAAiB,CAAC,CAAA;AAExF,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,aAAa,GAAG,OAAO,CAAA;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,yBAAyB,CAAA;IAClC,SAAS,EAAE,yBAAyB,CAAA;IACpC,KAAK,CAAC,EAAE,oBAAoB,CAAA;CAC7B;AAED,QAAA,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgB1B,CAAA;AAIF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAE5E;;;;;;GAMG;AACH,wBAAgB,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAkB3C"}
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
const dualCreateResultSchema = z.object({
|
|
9
|
+
primary: z.object({
|
|
10
|
+
booking: bookingRecordSchema,
|
|
11
|
+
travelers: z.array(z.unknown()).optional(),
|
|
12
|
+
paymentSchedules: z.array(z.unknown()).optional(),
|
|
13
|
+
voucherRedemption: z.unknown().nullable().optional(),
|
|
14
|
+
}),
|
|
15
|
+
secondary: z.object({
|
|
16
|
+
booking: bookingRecordSchema,
|
|
17
|
+
travelers: z.array(z.unknown()).optional(),
|
|
18
|
+
paymentSchedules: z.array(z.unknown()).optional(),
|
|
19
|
+
voucherRedemption: z.unknown().nullable().optional(),
|
|
20
|
+
}),
|
|
21
|
+
group: z.unknown(),
|
|
22
|
+
primaryMember: z.unknown(),
|
|
23
|
+
secondaryMember: z.unknown(),
|
|
24
|
+
});
|
|
25
|
+
const dualCreateResponseSchema = z.object({ data: dualCreateResultSchema });
|
|
26
|
+
/**
|
|
27
|
+
* Atomic dual-booking (partaj) create: calls `POST /v1/bookings/dual-create`
|
|
28
|
+
* which wraps two quickCreate calls + one booking_group in a single
|
|
29
|
+
* transaction. Use this over calling useBookingQuickCreateMutation twice
|
|
30
|
+
* from a submit handler — a failure on the second call there would leave
|
|
31
|
+
* the first booking orphaned.
|
|
32
|
+
*/
|
|
33
|
+
export function useBookingDualCreateMutation() {
|
|
34
|
+
const { baseUrl, fetcher } = useVoyantBookingsContext();
|
|
35
|
+
const queryClient = useQueryClient();
|
|
36
|
+
return useMutation({
|
|
37
|
+
mutationFn: async (input) => {
|
|
38
|
+
const { data } = await fetchWithValidation("/v1/bookings/dual-create", dualCreateResponseSchema, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
39
|
+
return data;
|
|
40
|
+
},
|
|
41
|
+
onSuccess: () => {
|
|
42
|
+
void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.bookings() });
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
enabled?: boolean;
|
|
3
|
-
}
|
|
4
|
-
export declare function useBookingItemParticipants(bookingId: string | null | undefined, itemId: string | null | undefined, options?: UseBookingItemParticipantsOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
-
data: {
|
|
6
|
-
id: string;
|
|
7
|
-
bookingItemId: string;
|
|
8
|
-
participantId: string;
|
|
9
|
-
role: "traveler" | "occupant" | "other" | "primary_contact" | "service_assignee" | "beneficiary";
|
|
10
|
-
isPrimary: boolean;
|
|
11
|
-
createdAt: string;
|
|
12
|
-
}[];
|
|
13
|
-
}, Error>;
|
|
1
|
+
export { type UseBookingItemTravelersOptions as UseBookingItemParticipantsOptions, useBookingItemTravelers as useBookingItemParticipants, } from "./use-booking-item-travelers.js";
|
|
14
2
|
export interface AddItemParticipantInput {
|
|
15
|
-
|
|
3
|
+
travelerId?: string;
|
|
4
|
+
participantId?: string;
|
|
5
|
+
passengerId?: string;
|
|
16
6
|
role?: string;
|
|
17
7
|
isPrimary?: boolean;
|
|
18
8
|
}
|
|
@@ -20,8 +10,8 @@ export declare function useBookingItemParticipantMutation(bookingId: string, ite
|
|
|
20
10
|
add: import("@tanstack/react-query").UseMutationResult<{
|
|
21
11
|
id: string;
|
|
22
12
|
bookingItemId: string;
|
|
23
|
-
|
|
24
|
-
role: "traveler" | "occupant" | "other" | "
|
|
13
|
+
travelerId: string;
|
|
14
|
+
role: "traveler" | "occupant" | "other" | "beneficiary" | "service_assignee" | "primary_contact";
|
|
25
15
|
isPrimary: boolean;
|
|
26
16
|
createdAt: string;
|
|
27
17
|
}, Error, AddItemParticipantInput, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-booking-item-participants.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking-item-participants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-booking-item-participants.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking-item-participants.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,8BAA8B,IAAI,iCAAiC,EACxE,uBAAuB,IAAI,0BAA0B,GACtD,MAAM,iCAAiC,CAAA;AAExC,MAAM,WAAW,uBAAuB;IACtC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,wBAAgB,iCAAiC,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;;;;;;;;;;EAiDlF"}
|
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useMutation,
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
3
|
import { fetchWithValidation } from "../client.js";
|
|
4
4
|
import { useVoyantBookingsContext } from "../provider.js";
|
|
5
5
|
import { bookingsQueryKeys } from "../query-keys.js";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
export function useBookingItemParticipants(bookingId, itemId, options = {}) {
|
|
9
|
-
const { baseUrl, fetcher } = useVoyantBookingsContext();
|
|
10
|
-
const { enabled = true } = options;
|
|
11
|
-
return useQuery({
|
|
12
|
-
...getBookingItemParticipantsQueryOptions({ baseUrl, fetcher }, bookingId, itemId),
|
|
13
|
-
enabled: enabled && Boolean(bookingId) && Boolean(itemId),
|
|
14
|
-
});
|
|
15
|
-
}
|
|
6
|
+
import { bookingItemTravelersResponse, bookingSingleResponse, successEnvelope } from "../schemas.js";
|
|
7
|
+
export { useBookingItemTravelers as useBookingItemParticipants, } from "./use-booking-item-travelers.js";
|
|
16
8
|
export function useBookingItemParticipantMutation(bookingId, itemId) {
|
|
17
9
|
const { baseUrl, fetcher } = useVoyantBookingsContext();
|
|
18
10
|
const queryClient = useQueryClient();
|
|
19
11
|
const add = useMutation({
|
|
20
12
|
mutationFn: async (input) => {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
const travelerId = input.travelerId ?? input.participantId ?? input.passengerId;
|
|
14
|
+
if (!travelerId)
|
|
15
|
+
throw new Error("travelerId is required");
|
|
16
|
+
const { data } = await fetchWithValidation(`/v1/bookings/${bookingId}/items/${itemId}/travelers`, bookingSingleResponse.extend({
|
|
17
|
+
data: bookingItemTravelersResponse.shape.data.element,
|
|
18
|
+
}), { baseUrl, fetcher }, {
|
|
19
|
+
method: "POST",
|
|
20
|
+
body: JSON.stringify({
|
|
21
|
+
travelerId,
|
|
22
|
+
role: input.role,
|
|
23
|
+
isPrimary: input.isPrimary,
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
24
26
|
return data;
|
|
25
27
|
},
|
|
26
28
|
onSuccess: () => {
|
|
27
29
|
void queryClient.invalidateQueries({
|
|
28
|
-
queryKey: bookingsQueryKeys.
|
|
30
|
+
queryKey: bookingsQueryKeys.itemTravelers(bookingId, itemId),
|
|
29
31
|
});
|
|
30
32
|
},
|
|
31
33
|
});
|
|
32
34
|
const remove = useMutation({
|
|
33
|
-
mutationFn: async (linkId) => fetchWithValidation(`/v1/bookings/${bookingId}/items/${itemId}/
|
|
35
|
+
mutationFn: async (linkId) => fetchWithValidation(`/v1/bookings/${bookingId}/items/${itemId}/travelers/${linkId}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
|
|
34
36
|
onSuccess: () => {
|
|
35
37
|
void queryClient.invalidateQueries({
|
|
36
|
-
queryKey: bookingsQueryKeys.
|
|
38
|
+
queryKey: bookingsQueryKeys.itemTravelers(bookingId, itemId),
|
|
37
39
|
});
|
|
38
40
|
},
|
|
39
41
|
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface UseBookingItemTravelersOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useBookingItemTravelers(bookingId: string | null | undefined, itemId: string | null | undefined, options?: UseBookingItemTravelersOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
data: {
|
|
6
|
+
id: string;
|
|
7
|
+
bookingItemId: string;
|
|
8
|
+
travelerId: string;
|
|
9
|
+
role: "traveler" | "occupant" | "other" | "beneficiary" | "service_assignee" | "primary_contact";
|
|
10
|
+
isPrimary: boolean;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
}[];
|
|
13
|
+
}, Error>;
|
|
14
|
+
export interface AddItemTravelerInput {
|
|
15
|
+
travelerId: string;
|
|
16
|
+
role?: string;
|
|
17
|
+
isPrimary?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function useBookingItemTravelerMutation(bookingId: string, itemId: string): {
|
|
20
|
+
add: import("@tanstack/react-query").UseMutationResult<{
|
|
21
|
+
id: string;
|
|
22
|
+
bookingItemId: string;
|
|
23
|
+
travelerId: string;
|
|
24
|
+
role: "traveler" | "occupant" | "other" | "beneficiary" | "service_assignee" | "primary_contact";
|
|
25
|
+
isPrimary: boolean;
|
|
26
|
+
createdAt: string;
|
|
27
|
+
}, Error, AddItemTravelerInput, unknown>;
|
|
28
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
29
|
+
success: boolean;
|
|
30
|
+
}, Error, string, unknown>;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=use-booking-item-travelers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-booking-item-travelers.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking-item-travelers.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,8BAA8B;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACjC,OAAO,GAAE,8BAAmC;;;;;;;;;UAS7C;AAED,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;;;;;;;;;;EA8C/E"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQuery, 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 { getBookingItemTravelersQueryOptions } from "../query-options.js";
|
|
7
|
+
import { bookingItemTravelersResponse, bookingSingleResponse, successEnvelope } from "../schemas.js";
|
|
8
|
+
export function useBookingItemTravelers(bookingId, itemId, options = {}) {
|
|
9
|
+
const { baseUrl, fetcher } = useVoyantBookingsContext();
|
|
10
|
+
const { enabled = true } = options;
|
|
11
|
+
return useQuery({
|
|
12
|
+
...getBookingItemTravelersQueryOptions({ baseUrl, fetcher }, bookingId, itemId),
|
|
13
|
+
enabled: enabled && Boolean(bookingId) && Boolean(itemId),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export function useBookingItemTravelerMutation(bookingId, itemId) {
|
|
17
|
+
const { baseUrl, fetcher } = useVoyantBookingsContext();
|
|
18
|
+
const queryClient = useQueryClient();
|
|
19
|
+
const add = useMutation({
|
|
20
|
+
mutationFn: async (input) => {
|
|
21
|
+
const { data } = await fetchWithValidation(`/v1/bookings/${bookingId}/items/${itemId}/travelers`, bookingSingleResponse.extend({
|
|
22
|
+
data: bookingItemTravelersResponse.shape.data.element,
|
|
23
|
+
}), { baseUrl, fetcher }, {
|
|
24
|
+
method: "POST",
|
|
25
|
+
body: JSON.stringify({
|
|
26
|
+
travelerId: input.travelerId,
|
|
27
|
+
role: input.role,
|
|
28
|
+
isPrimary: input.isPrimary,
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
return data;
|
|
32
|
+
},
|
|
33
|
+
onSuccess: () => {
|
|
34
|
+
void queryClient.invalidateQueries({
|
|
35
|
+
queryKey: bookingsQueryKeys.itemTravelers(bookingId, itemId),
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
const remove = useMutation({
|
|
40
|
+
mutationFn: async (linkId) => fetchWithValidation(`/v1/bookings/${bookingId}/items/${itemId}/travelers/${linkId}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
|
|
41
|
+
onSuccess: () => {
|
|
42
|
+
void queryClient.invalidateQueries({
|
|
43
|
+
queryKey: bookingsQueryKeys.itemTravelers(bookingId, itemId),
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
return { add, remove };
|
|
48
|
+
}
|
|
@@ -7,5 +7,16 @@ export declare function useBookingNoteMutation(bookingId: string): import("@tans
|
|
|
7
7
|
authorId: string;
|
|
8
8
|
content: string;
|
|
9
9
|
createdAt: string;
|
|
10
|
-
}, Error, CreateBookingNoteInput, unknown
|
|
10
|
+
}, Error, CreateBookingNoteInput, unknown> & {
|
|
11
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
12
|
+
id: string;
|
|
13
|
+
bookingId: string;
|
|
14
|
+
authorId: string;
|
|
15
|
+
content: string;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
}, Error, CreateBookingNoteInput, unknown>;
|
|
18
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
19
|
+
success: boolean;
|
|
20
|
+
}, Error, string, unknown>;
|
|
21
|
+
};
|
|
11
22
|
//# sourceMappingURL=use-booking-note-mutation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-booking-note-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking-note-mutation.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAA;CAChB;
|
|
1
|
+
{"version":3,"file":"use-booking-note-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking-note-mutation.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAA;CAChB;AAQD,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;EAuCvD"}
|