@voyant-travel/bookings-react 0.201.1 → 0.203.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/README.md +8 -8
- package/dist/admin/bookings-host.d.ts +1 -2
- package/dist/admin/bookings-host.js +2 -3
- package/dist/admin/index.d.ts +6 -44
- package/dist/admin/index.js +2 -65
- package/dist/components/booking-create-utils.d.ts +1 -1
- package/dist/components/booking-create-utils.js +5 -17
- package/dist/components/booking-dialog.d.ts +4 -19
- package/dist/components/booking-dialog.js +3 -12
- package/dist/components/booking-list.d.ts +1 -2
- package/dist/components/booking-list.js +5 -13
- package/dist/components/bookings-page.d.ts +1 -2
- package/dist/components/bookings-page.js +2 -2
- package/dist/hooks/booking-create-types.d.ts +34 -0
- package/dist/hooks/booking-create-types.js +1 -0
- package/dist/hooks/index.d.ts +2 -4
- package/dist/hooks/index.js +1 -4
- package/dist/hooks/use-booking-mutation.d.ts +3 -65
- package/dist/hooks/use-booking-mutation.js +1 -10
- package/dist/i18n/en-create-list.d.ts +0 -1
- package/dist/i18n/en-create-list.js +0 -1
- package/dist/i18n/en.d.ts +0 -1
- package/dist/i18n/messages-create-list.d.ts +0 -1
- package/dist/i18n/provider.d.ts +0 -2
- package/dist/i18n/ro-create-list.d.ts +0 -1
- package/dist/i18n/ro-create-list.js +0 -1
- package/dist/i18n/ro.d.ts +0 -1
- package/dist/journey/components/booking-journey-rules.d.ts +0 -22
- package/dist/journey/components/booking-journey-rules.js +0 -54
- package/dist/journey/components/journey-steps/payment-step.js +1 -1
- package/dist/journey/components/journey-steps/shared.d.ts +3 -3
- package/dist/journey/components/journey-steps.d.ts +1 -1
- package/dist/journey/components/journey-steps.js +1 -1
- package/dist/journey/index.d.ts +2 -12
- package/dist/journey/index.js +1 -11
- package/dist/journey/types.d.ts +3 -208
- package/dist/journey/types.js +2 -6
- package/dist/storefront/index.d.ts +0 -2
- package/dist/storefront/index.js +0 -2
- package/dist/ui.d.ts +0 -2
- package/dist/ui.js +0 -2
- package/package.json +33 -33
- package/dist/admin/booking-journey-host.d.ts +0 -23
- package/dist/admin/booking-journey-host.js +0 -280
- package/dist/admin/journey-billing-duplicate-warning.d.ts +0 -2
- package/dist/admin/journey-billing-duplicate-warning.js +0 -26
- package/dist/admin/journey-departure-picker.d.ts +0 -6
- package/dist/admin/journey-departure-picker.js +0 -91
- package/dist/admin/journey-travel-credit-picker.d.ts +0 -2
- package/dist/admin/journey-travel-credit-picker.js +0 -72
- package/dist/admin/journey-units-picker.d.ts +0 -10
- package/dist/admin/journey-units-picker.js +0 -60
- package/dist/admin/pages/booking-journey-page.d.ts +0 -11
- package/dist/admin/pages/booking-journey-page.js +0 -26
- package/dist/admin/pages/booking-new-page.d.ts +0 -15
- package/dist/admin/pages/booking-new-page.js +0 -50
- package/dist/components/booking-create-page.d.ts +0 -13
- package/dist/components/booking-create-page.js +0 -11
- package/dist/components/booking-create-sheet.d.ts +0 -34
- package/dist/components/booking-create-sheet.js +0 -815
- package/dist/hooks/use-booking-convert-mutation.d.ts +0 -80
- package/dist/hooks/use-booking-convert-mutation.js +0 -24
- package/dist/hooks/use-booking-create-mutation.d.ts +0 -336
- package/dist/hooks/use-booking-create-mutation.js +0 -43
- package/dist/hooks/use-booking-dual-create-mutation.d.ts +0 -337
- package/dist/hooks/use-booking-dual-create-mutation.js +0 -45
- package/dist/journey/components/booking-journey.d.ts +0 -2
- package/dist/journey/components/booking-journey.js +0 -485
- package/dist/storefront/storefront-booking-errors.d.ts +0 -12
- package/dist/storefront/storefront-booking-errors.js +0 -50
- package/dist/storefront/storefront-booking-journey.d.ts +0 -71
- package/dist/storefront/storefront-booking-journey.js +0 -327
- package/dist/storefront/storefront-booking-page.d.ts +0 -35
- package/dist/storefront/storefront-booking-page.js +0 -215
- package/dist/storefront/storefront-checkout-bodies.d.ts +0 -36
- package/dist/storefront/storefront-checkout-bodies.js +0 -69
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
export interface ConvertProductToBookingInput {
|
|
2
|
-
productId: string;
|
|
3
|
-
bookingNumber: string;
|
|
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;
|
|
11
|
-
personId?: string | null;
|
|
12
|
-
organizationId?: string | null;
|
|
13
|
-
internalNotes?: string | null;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Creates a draft booking from a product via POST /v1/admin/bookings/from-product.
|
|
17
|
-
* Purpose-built for the operator booking-create flow — the backend seeds items,
|
|
18
|
-
* dates, and pricing from the product definition.
|
|
19
|
-
*/
|
|
20
|
-
export declare function useBookingConvertMutation(): import("@tanstack/react-query").UseMutationResult<{
|
|
21
|
-
id: string;
|
|
22
|
-
bookingNumber: string;
|
|
23
|
-
status: "draft" | "expired" | "cancelled" | "on_hold" | "awaiting_payment" | "confirmed" | "in_progress" | "completed";
|
|
24
|
-
personId: string | null;
|
|
25
|
-
organizationId: string | null;
|
|
26
|
-
sellCurrency: string;
|
|
27
|
-
sellAmountCents: number | null;
|
|
28
|
-
costAmountCents: number | null;
|
|
29
|
-
marginPercent: number | null;
|
|
30
|
-
startDate: string | null;
|
|
31
|
-
endDate: string | null;
|
|
32
|
-
pax: number | null;
|
|
33
|
-
internalNotes: string | null;
|
|
34
|
-
createdAt: string;
|
|
35
|
-
updatedAt: string;
|
|
36
|
-
startsAt?: string | null | undefined;
|
|
37
|
-
endsAt?: string | null | undefined;
|
|
38
|
-
items?: {
|
|
39
|
-
id: string;
|
|
40
|
-
title: string;
|
|
41
|
-
itemType: string;
|
|
42
|
-
productId: string | null;
|
|
43
|
-
productName?: string | null | undefined;
|
|
44
|
-
startsAt?: string | null | undefined;
|
|
45
|
-
endsAt?: string | null | undefined;
|
|
46
|
-
}[] | undefined;
|
|
47
|
-
communicationLanguage?: string | null | undefined;
|
|
48
|
-
contactFirstName?: string | null | undefined;
|
|
49
|
-
contactLastName?: string | null | undefined;
|
|
50
|
-
contactPartyType?: "individual" | "company" | null | undefined;
|
|
51
|
-
contactTaxId?: string | null | undefined;
|
|
52
|
-
contactEmail?: string | null | undefined;
|
|
53
|
-
contactPhone?: string | null | undefined;
|
|
54
|
-
contactPreferredLanguage?: string | null | undefined;
|
|
55
|
-
contactCountry?: string | null | undefined;
|
|
56
|
-
contactRegion?: string | null | undefined;
|
|
57
|
-
contactCity?: string | null | undefined;
|
|
58
|
-
contactAddressLine1?: string | null | undefined;
|
|
59
|
-
contactAddressLine2?: string | null | undefined;
|
|
60
|
-
contactPostalCode?: string | null | undefined;
|
|
61
|
-
customerPaymentPolicy?: {
|
|
62
|
-
deposit: {
|
|
63
|
-
kind: "none" | "percent" | "fixed_cents";
|
|
64
|
-
percent?: number | undefined;
|
|
65
|
-
amountCents?: number | undefined;
|
|
66
|
-
};
|
|
67
|
-
minDaysBeforeDepartureForDeposit: number;
|
|
68
|
-
balanceDueDaysBeforeDeparture: number;
|
|
69
|
-
balanceDueMinDaysFromNow: number;
|
|
70
|
-
} | null | undefined;
|
|
71
|
-
priceOverride?: {
|
|
72
|
-
isManual: true;
|
|
73
|
-
originalAmountCents: number | null;
|
|
74
|
-
overriddenAmountCents: number;
|
|
75
|
-
currency: string;
|
|
76
|
-
reason: string;
|
|
77
|
-
overriddenBy: string;
|
|
78
|
-
overriddenAt: string;
|
|
79
|
-
} | null | undefined;
|
|
80
|
-
}, Error, ConvertProductToBookingInput, unknown>;
|
|
@@ -1,24 +0,0 @@
|
|
|
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 } from "../schemas.js";
|
|
7
|
-
/**
|
|
8
|
-
* Creates a draft booking from a product via POST /v1/admin/bookings/from-product.
|
|
9
|
-
* Purpose-built for the operator booking-create flow — the backend seeds items,
|
|
10
|
-
* dates, and pricing from the product definition.
|
|
11
|
-
*/
|
|
12
|
-
export function useBookingConvertMutation() {
|
|
13
|
-
const { baseUrl, fetcher } = useVoyantBookingsContext();
|
|
14
|
-
const queryClient = useQueryClient();
|
|
15
|
-
return useMutation({
|
|
16
|
-
mutationFn: async (input) => {
|
|
17
|
-
const { data } = await fetchWithValidation("/v1/admin/bookings/from-product", bookingSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
18
|
-
return data;
|
|
19
|
-
},
|
|
20
|
-
onSuccess: () => {
|
|
21
|
-
void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.bookings() });
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
}
|
|
@@ -1,336 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { type BookingStatus } from "../schemas.js";
|
|
3
|
-
export interface BookingCreateTravelerInput {
|
|
4
|
-
/**
|
|
5
|
-
* Stable client-side traveler identity used by itemLines/extraLines
|
|
6
|
-
* `travelerKeys` to link created booking items to travelers without
|
|
7
|
-
* relying on request-array position.
|
|
8
|
-
*/
|
|
9
|
-
clientTravelerKey?: string | null;
|
|
10
|
-
firstName: string;
|
|
11
|
-
lastName: string;
|
|
12
|
-
email?: string | null;
|
|
13
|
-
phone?: string | null;
|
|
14
|
-
personId?: string | null;
|
|
15
|
-
participantType?: "traveler" | "occupant" | "other";
|
|
16
|
-
travelerCategory?: "adult" | "child" | "infant" | "senior" | "other" | null;
|
|
17
|
-
preferredLanguage?: string | null;
|
|
18
|
-
specialRequests?: string | null;
|
|
19
|
-
/**
|
|
20
|
-
* Deprecated compatibility alias for the traveler's pricing-tier option
|
|
21
|
-
* unit. The server accepts this field but does not persist it; item-line
|
|
22
|
-
* `travelerKeys` carry the supported traveler-to-item linkage.
|
|
23
|
-
*
|
|
24
|
-
* @deprecated Use itemLines[].travelerKeys to express traveler-priced
|
|
25
|
-
* lines and inventory placement.
|
|
26
|
-
*/
|
|
27
|
-
roomUnitId?: string | null;
|
|
28
|
-
isPrimary?: boolean | null;
|
|
29
|
-
notes?: string | null;
|
|
30
|
-
}
|
|
31
|
-
export interface BookingCreatePaymentScheduleInput {
|
|
32
|
-
scheduleType?: "deposit" | "installment" | "balance" | "hold" | "other";
|
|
33
|
-
status?: "pending" | "due" | "paid" | "waived" | "cancelled" | "expired";
|
|
34
|
-
dueDate: string;
|
|
35
|
-
currency: string;
|
|
36
|
-
amountCents: number;
|
|
37
|
-
notes?: string | null;
|
|
38
|
-
}
|
|
39
|
-
export interface BookingCreateDocumentGenerationInput {
|
|
40
|
-
contractDocument?: boolean;
|
|
41
|
-
invoiceDocument?: boolean;
|
|
42
|
-
/** `"proforma"` issues a placeholder doc; defaults to `"invoice"`. */
|
|
43
|
-
invoiceType?: "invoice" | "proforma";
|
|
44
|
-
}
|
|
45
|
-
export interface BookingCreateItemLineInput {
|
|
46
|
-
/**
|
|
47
|
-
* Stable client-side key (e.g. `unit:optu_adult`) the server uses
|
|
48
|
-
* to look up this item after insert and link it to the travelers
|
|
49
|
-
* referenced in `travelerKeys`. Server writes
|
|
50
|
-
* `metadata.bookingCreateLineKey` so the lookup survives the
|
|
51
|
-
* round-trip. See voyant-travel/voyant#1267.
|
|
52
|
-
*/
|
|
53
|
-
clientLineKey?: string | null;
|
|
54
|
-
optionId?: string | null;
|
|
55
|
-
optionUnitId: string;
|
|
56
|
-
pricingCategoryId?: string | null;
|
|
57
|
-
quantity: number;
|
|
58
|
-
title?: string | null;
|
|
59
|
-
description?: string | null;
|
|
60
|
-
unitSellAmountCents?: number | null;
|
|
61
|
-
totalSellAmountCents?: number | null;
|
|
62
|
-
/**
|
|
63
|
-
* Stable `clientTravelerKey` values of travelers mapped to this item. The server inserts one
|
|
64
|
-
* `booking_item_travelers` row per traveler, linking the created
|
|
65
|
-
* `booking_item` to the corresponding `booking_traveler`. Null or
|
|
66
|
-
* empty = unlinked (no per-traveler ledger entry).
|
|
67
|
-
*/
|
|
68
|
-
travelerKeys?: string[] | null;
|
|
69
|
-
/**
|
|
70
|
-
* Indexes (into the request's `travelers` array) of travelers
|
|
71
|
-
* mapped to this item.
|
|
72
|
-
*
|
|
73
|
-
* @deprecated Use travelerKeys. Removal target: next booking-create wire-format major.
|
|
74
|
-
*/
|
|
75
|
-
travelerIndexes?: number[] | null;
|
|
76
|
-
}
|
|
77
|
-
export interface BookingCreateExtraLineInput {
|
|
78
|
-
/** See `BookingCreateItemLineInput.clientLineKey`. */
|
|
79
|
-
clientLineKey?: string | null;
|
|
80
|
-
productExtraId: string;
|
|
81
|
-
optionExtraConfigId?: string | null;
|
|
82
|
-
name: string;
|
|
83
|
-
description?: string | null;
|
|
84
|
-
pricingMode?: string | null;
|
|
85
|
-
pricedPerPerson?: boolean | null;
|
|
86
|
-
quantity: number;
|
|
87
|
-
sellCurrency: string;
|
|
88
|
-
unitSellAmountCents?: number | null;
|
|
89
|
-
totalSellAmountCents?: number | null;
|
|
90
|
-
/** See `BookingCreateItemLineInput.travelerKeys`. */
|
|
91
|
-
travelerKeys?: string[] | null;
|
|
92
|
-
/**
|
|
93
|
-
* See `BookingCreateItemLineInput.travelerIndexes`.
|
|
94
|
-
*
|
|
95
|
-
* @deprecated Use travelerKeys. Removal target: next booking-create wire-format major.
|
|
96
|
-
*/
|
|
97
|
-
travelerIndexes?: number[] | null;
|
|
98
|
-
}
|
|
99
|
-
export interface BookingCreateTravelCreditRedemptionInput {
|
|
100
|
-
travelCreditId: string;
|
|
101
|
-
amountCents: number;
|
|
102
|
-
}
|
|
103
|
-
export type BookingCreateGroupMembershipInput = {
|
|
104
|
-
action: "join";
|
|
105
|
-
groupId: string;
|
|
106
|
-
role?: "primary" | "shared";
|
|
107
|
-
} | {
|
|
108
|
-
action: "create";
|
|
109
|
-
kind?: "shared_room" | "other";
|
|
110
|
-
label?: string | null;
|
|
111
|
-
optionUnitId?: string | null;
|
|
112
|
-
makeBookingPrimary?: boolean;
|
|
113
|
-
};
|
|
114
|
-
export interface BookingCreateInput {
|
|
115
|
-
productId: string;
|
|
116
|
-
optionId?: string | null;
|
|
117
|
-
slotId?: string | null;
|
|
118
|
-
bookingNumber: string;
|
|
119
|
-
personId?: string | null;
|
|
120
|
-
organizationId?: string | null;
|
|
121
|
-
internalNotes?: string | null;
|
|
122
|
-
catalogSellAmountCents?: number | null;
|
|
123
|
-
confirmedSellAmountCents?: number | null;
|
|
124
|
-
priceOverrideReason?: string | null;
|
|
125
|
-
itemLines?: BookingCreateItemLineInput[];
|
|
126
|
-
extraLines?: BookingCreateExtraLineInput[];
|
|
127
|
-
travelers?: BookingCreateTravelerInput[];
|
|
128
|
-
paymentSchedules?: BookingCreatePaymentScheduleInput[];
|
|
129
|
-
travelCreditRedemption?: BookingCreateTravelCreditRedemptionInput;
|
|
130
|
-
groupMembership?: BookingCreateGroupMembershipInput;
|
|
131
|
-
documentGeneration?: BookingCreateDocumentGenerationInput;
|
|
132
|
-
/**
|
|
133
|
-
* Initial booking status — defaults to `draft` on the server. Set
|
|
134
|
-
* this to skip the legacy create-then-flip dance: the server commits
|
|
135
|
-
* the booking already in `confirmed` / `awaiting_payment` in the
|
|
136
|
-
* same transaction and fires `booking.confirmed` post-commit when
|
|
137
|
-
* applicable.
|
|
138
|
-
*/
|
|
139
|
-
initialStatus?: BookingStatus;
|
|
140
|
-
/**
|
|
141
|
-
* Only honored when `initialStatus === "confirmed"`. When true, the
|
|
142
|
-
* post-commit `booking.confirmed` event carries
|
|
143
|
-
* `suppressNotifications: true` so downstream subscribers skip
|
|
144
|
-
* customer-facing emails / document bundles.
|
|
145
|
-
*/
|
|
146
|
-
suppressNotifications?: boolean;
|
|
147
|
-
/**
|
|
148
|
-
* Allows a second active booking for the same billing party and departure.
|
|
149
|
-
* Leave unset for retry/double-submit protection.
|
|
150
|
-
*/
|
|
151
|
-
allowDuplicate?: boolean;
|
|
152
|
-
/**
|
|
153
|
-
* Billing-contact snapshot. Caller (typically the create dialog)
|
|
154
|
-
* reads the linked CRM person/org and supplies what it knows so the
|
|
155
|
-
* booking detail page renders the right payer even if those CRM
|
|
156
|
-
* records change later.
|
|
157
|
-
*/
|
|
158
|
-
contactFirstName?: string | null;
|
|
159
|
-
contactLastName?: string | null;
|
|
160
|
-
contactPartyType?: "individual" | "company" | null;
|
|
161
|
-
contactTaxId?: string | null;
|
|
162
|
-
contactEmail?: string | null;
|
|
163
|
-
contactPhone?: string | null;
|
|
164
|
-
contactPreferredLanguage?: string | null;
|
|
165
|
-
contactCountry?: string | null;
|
|
166
|
-
contactRegion?: string | null;
|
|
167
|
-
contactCity?: string | null;
|
|
168
|
-
contactAddressLine1?: string | null;
|
|
169
|
-
contactAddressLine2?: string | null;
|
|
170
|
-
contactPostalCode?: string | null;
|
|
171
|
-
}
|
|
172
|
-
declare const bookingCreateResultSchema: z.ZodObject<{
|
|
173
|
-
booking: z.ZodObject<{
|
|
174
|
-
id: z.ZodString;
|
|
175
|
-
bookingNumber: z.ZodString;
|
|
176
|
-
status: z.ZodEnum<{
|
|
177
|
-
draft: "draft";
|
|
178
|
-
expired: "expired";
|
|
179
|
-
cancelled: "cancelled";
|
|
180
|
-
on_hold: "on_hold";
|
|
181
|
-
awaiting_payment: "awaiting_payment";
|
|
182
|
-
confirmed: "confirmed";
|
|
183
|
-
in_progress: "in_progress";
|
|
184
|
-
completed: "completed";
|
|
185
|
-
}>;
|
|
186
|
-
personId: z.ZodNullable<z.ZodString>;
|
|
187
|
-
organizationId: z.ZodNullable<z.ZodString>;
|
|
188
|
-
sellCurrency: z.ZodString;
|
|
189
|
-
sellAmountCents: z.ZodNullable<z.ZodNumber>;
|
|
190
|
-
costAmountCents: z.ZodNullable<z.ZodNumber>;
|
|
191
|
-
marginPercent: z.ZodNullable<z.ZodNumber>;
|
|
192
|
-
startDate: z.ZodNullable<z.ZodString>;
|
|
193
|
-
endDate: z.ZodNullable<z.ZodString>;
|
|
194
|
-
startsAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
195
|
-
endsAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
196
|
-
pax: z.ZodNullable<z.ZodNumber>;
|
|
197
|
-
items: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
198
|
-
id: z.ZodString;
|
|
199
|
-
title: z.ZodString;
|
|
200
|
-
itemType: z.ZodString;
|
|
201
|
-
productId: z.ZodNullable<z.ZodString>;
|
|
202
|
-
productName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
203
|
-
startsAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
204
|
-
endsAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
205
|
-
}, z.core.$strip>>>;
|
|
206
|
-
internalNotes: z.ZodNullable<z.ZodString>;
|
|
207
|
-
communicationLanguage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
208
|
-
contactFirstName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
209
|
-
contactLastName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
210
|
-
contactPartyType: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
211
|
-
individual: "individual";
|
|
212
|
-
company: "company";
|
|
213
|
-
}>>>;
|
|
214
|
-
contactTaxId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
215
|
-
contactEmail: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
216
|
-
contactPhone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
217
|
-
contactPreferredLanguage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
218
|
-
contactCountry: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
219
|
-
contactRegion: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
220
|
-
contactCity: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
221
|
-
contactAddressLine1: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
222
|
-
contactAddressLine2: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
223
|
-
contactPostalCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
224
|
-
customerPaymentPolicy: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
225
|
-
deposit: z.ZodObject<{
|
|
226
|
-
kind: z.ZodEnum<{
|
|
227
|
-
none: "none";
|
|
228
|
-
percent: "percent";
|
|
229
|
-
fixed_cents: "fixed_cents";
|
|
230
|
-
}>;
|
|
231
|
-
percent: z.ZodOptional<z.ZodNumber>;
|
|
232
|
-
amountCents: z.ZodOptional<z.ZodNumber>;
|
|
233
|
-
}, z.core.$strip>;
|
|
234
|
-
minDaysBeforeDepartureForDeposit: z.ZodNumber;
|
|
235
|
-
balanceDueDaysBeforeDeparture: z.ZodNumber;
|
|
236
|
-
balanceDueMinDaysFromNow: z.ZodNumber;
|
|
237
|
-
}, z.core.$strip>>>;
|
|
238
|
-
priceOverride: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
239
|
-
isManual: z.ZodLiteral<true>;
|
|
240
|
-
originalAmountCents: z.ZodNullable<z.ZodNumber>;
|
|
241
|
-
overriddenAmountCents: z.ZodNumber;
|
|
242
|
-
currency: z.ZodString;
|
|
243
|
-
reason: z.ZodString;
|
|
244
|
-
overriddenBy: z.ZodString;
|
|
245
|
-
overriddenAt: z.ZodString;
|
|
246
|
-
}, z.core.$strip>>>;
|
|
247
|
-
createdAt: z.ZodString;
|
|
248
|
-
updatedAt: z.ZodString;
|
|
249
|
-
}, z.core.$strip>;
|
|
250
|
-
travelers: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
251
|
-
paymentSchedules: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
252
|
-
travelCreditRedemption: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
|
|
253
|
-
groupMembership: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
|
|
254
|
-
invoice: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
|
|
255
|
-
invoiceDocument: z.ZodOptional<z.ZodUnknown>;
|
|
256
|
-
payments: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
257
|
-
}, z.core.$strip>;
|
|
258
|
-
export type BookingCreateResult = z.infer<typeof bookingCreateResultSchema>;
|
|
259
|
-
/**
|
|
260
|
-
* Atomic booking-create: calls `POST /v1/admin/bookings/create` which wraps
|
|
261
|
-
* convert-from-product + travelers + payment schedules + Travel Credit redemption
|
|
262
|
-
* + group membership in one transaction. Prefer this over chaining the
|
|
263
|
-
* separate create mutations (convert, group, traveler) from a single submit
|
|
264
|
-
* handler — a mid-chain failure there leaves orphan state.
|
|
265
|
-
*/
|
|
266
|
-
export declare function useBookingCreateMutation(): import("@tanstack/react-query").UseMutationResult<{
|
|
267
|
-
booking: {
|
|
268
|
-
id: string;
|
|
269
|
-
bookingNumber: string;
|
|
270
|
-
status: "draft" | "expired" | "cancelled" | "on_hold" | "awaiting_payment" | "confirmed" | "in_progress" | "completed";
|
|
271
|
-
personId: string | null;
|
|
272
|
-
organizationId: string | null;
|
|
273
|
-
sellCurrency: string;
|
|
274
|
-
sellAmountCents: number | null;
|
|
275
|
-
costAmountCents: number | null;
|
|
276
|
-
marginPercent: number | null;
|
|
277
|
-
startDate: string | null;
|
|
278
|
-
endDate: string | null;
|
|
279
|
-
pax: number | null;
|
|
280
|
-
internalNotes: string | null;
|
|
281
|
-
createdAt: string;
|
|
282
|
-
updatedAt: string;
|
|
283
|
-
startsAt?: string | null | undefined;
|
|
284
|
-
endsAt?: string | null | undefined;
|
|
285
|
-
items?: {
|
|
286
|
-
id: string;
|
|
287
|
-
title: string;
|
|
288
|
-
itemType: string;
|
|
289
|
-
productId: string | null;
|
|
290
|
-
productName?: string | null | undefined;
|
|
291
|
-
startsAt?: string | null | undefined;
|
|
292
|
-
endsAt?: string | null | undefined;
|
|
293
|
-
}[] | undefined;
|
|
294
|
-
communicationLanguage?: string | null | undefined;
|
|
295
|
-
contactFirstName?: string | null | undefined;
|
|
296
|
-
contactLastName?: string | null | undefined;
|
|
297
|
-
contactPartyType?: "individual" | "company" | null | undefined;
|
|
298
|
-
contactTaxId?: string | null | undefined;
|
|
299
|
-
contactEmail?: string | null | undefined;
|
|
300
|
-
contactPhone?: string | null | undefined;
|
|
301
|
-
contactPreferredLanguage?: string | null | undefined;
|
|
302
|
-
contactCountry?: string | null | undefined;
|
|
303
|
-
contactRegion?: string | null | undefined;
|
|
304
|
-
contactCity?: string | null | undefined;
|
|
305
|
-
contactAddressLine1?: string | null | undefined;
|
|
306
|
-
contactAddressLine2?: string | null | undefined;
|
|
307
|
-
contactPostalCode?: string | null | undefined;
|
|
308
|
-
customerPaymentPolicy?: {
|
|
309
|
-
deposit: {
|
|
310
|
-
kind: "none" | "percent" | "fixed_cents";
|
|
311
|
-
percent?: number | undefined;
|
|
312
|
-
amountCents?: number | undefined;
|
|
313
|
-
};
|
|
314
|
-
minDaysBeforeDepartureForDeposit: number;
|
|
315
|
-
balanceDueDaysBeforeDeparture: number;
|
|
316
|
-
balanceDueMinDaysFromNow: number;
|
|
317
|
-
} | null | undefined;
|
|
318
|
-
priceOverride?: {
|
|
319
|
-
isManual: true;
|
|
320
|
-
originalAmountCents: number | null;
|
|
321
|
-
overriddenAmountCents: number;
|
|
322
|
-
currency: string;
|
|
323
|
-
reason: string;
|
|
324
|
-
overriddenBy: string;
|
|
325
|
-
overriddenAt: string;
|
|
326
|
-
} | null | undefined;
|
|
327
|
-
};
|
|
328
|
-
travelers?: unknown[] | undefined;
|
|
329
|
-
paymentSchedules?: unknown[] | undefined;
|
|
330
|
-
travelCreditRedemption?: unknown;
|
|
331
|
-
groupMembership?: unknown;
|
|
332
|
-
invoice?: unknown;
|
|
333
|
-
invoiceDocument?: unknown;
|
|
334
|
-
payments?: unknown[] | undefined;
|
|
335
|
-
}, Error, BookingCreateInput, unknown>;
|
|
336
|
-
export {};
|
|
@@ -1,43 +0,0 @@
|
|
|
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, travelCreditRedemption, 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 bookingCreateResultSchema = z.object({
|
|
14
|
-
booking: bookingRecordSchema,
|
|
15
|
-
travelers: z.array(z.unknown()).optional(),
|
|
16
|
-
paymentSchedules: z.array(z.unknown()).optional(),
|
|
17
|
-
travelCreditRedemption: z.unknown().nullable().optional(),
|
|
18
|
-
groupMembership: z.unknown().nullable().optional(),
|
|
19
|
-
invoice: z.unknown().nullable().optional(),
|
|
20
|
-
invoiceDocument: z.unknown().optional(),
|
|
21
|
-
payments: z.array(z.unknown()).optional(),
|
|
22
|
-
});
|
|
23
|
-
const bookingCreateResponseSchema = z.object({ data: bookingCreateResultSchema });
|
|
24
|
-
/**
|
|
25
|
-
* Atomic booking-create: calls `POST /v1/admin/bookings/create` which wraps
|
|
26
|
-
* convert-from-product + travelers + payment schedules + Travel Credit redemption
|
|
27
|
-
* + group membership in one transaction. Prefer this over chaining the
|
|
28
|
-
* separate create mutations (convert, group, traveler) from a single submit
|
|
29
|
-
* handler — a mid-chain failure there leaves orphan state.
|
|
30
|
-
*/
|
|
31
|
-
export function useBookingCreateMutation() {
|
|
32
|
-
const { baseUrl, fetcher } = useVoyantBookingsContext();
|
|
33
|
-
const queryClient = useQueryClient();
|
|
34
|
-
return useMutation({
|
|
35
|
-
mutationFn: async (input) => {
|
|
36
|
-
const { data } = await fetchWithValidation("/v1/admin/bookings/create", bookingCreateResponseSchema, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
37
|
-
return data;
|
|
38
|
-
},
|
|
39
|
-
onSuccess: () => {
|
|
40
|
-
void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.bookings() });
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
}
|