@voyantjs/bookings-react 0.2.0 → 0.3.1

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.
Files changed (52) hide show
  1. package/LICENSE +109 -0
  2. package/README.md +11 -0
  3. package/dist/hooks/index.d.ts +8 -0
  4. package/dist/hooks/index.d.ts.map +1 -1
  5. package/dist/hooks/index.js +8 -0
  6. package/dist/hooks/use-booking-activity.d.ts +15 -0
  7. package/dist/hooks/use-booking-activity.d.ts.map +1 -0
  8. package/dist/hooks/use-booking-activity.js +12 -0
  9. package/dist/hooks/use-booking-note-mutation.d.ts +11 -0
  10. package/dist/hooks/use-booking-note-mutation.d.ts.map +1 -0
  11. package/dist/hooks/use-booking-note-mutation.js +24 -0
  12. package/dist/hooks/use-booking-notes.d.ts +13 -0
  13. package/dist/hooks/use-booking-notes.d.ts.map +1 -0
  14. package/dist/hooks/use-booking-notes.js +12 -0
  15. package/dist/hooks/use-booking.d.ts.map +1 -1
  16. package/dist/hooks/use-booking.js +2 -5
  17. package/dist/hooks/use-bookings.d.ts +1 -1
  18. package/dist/hooks/use-bookings.d.ts.map +1 -1
  19. package/dist/hooks/use-bookings.js +2 -20
  20. package/dist/hooks/use-passengers.d.ts.map +1 -1
  21. package/dist/hooks/use-passengers.js +2 -8
  22. package/dist/hooks/use-public-booking-session-flow-mutation.d.ts +145 -0
  23. package/dist/hooks/use-public-booking-session-flow-mutation.d.ts.map +1 -0
  24. package/dist/hooks/use-public-booking-session-flow-mutation.js +35 -0
  25. package/dist/hooks/use-public-booking-session-state.d.ts +16 -0
  26. package/dist/hooks/use-public-booking-session-state.d.ts.map +1 -0
  27. package/dist/hooks/use-public-booking-session-state.js +12 -0
  28. package/dist/hooks/use-public-booking-session.d.ts +98 -0
  29. package/dist/hooks/use-public-booking-session.d.ts.map +1 -0
  30. package/dist/hooks/use-public-booking-session.js +12 -0
  31. package/dist/hooks/use-supplier-status-mutation.d.ts +46 -0
  32. package/dist/hooks/use-supplier-status-mutation.d.ts.map +1 -0
  33. package/dist/hooks/use-supplier-status-mutation.js +39 -0
  34. package/dist/hooks/use-supplier-statuses.d.ts +20 -0
  35. package/dist/hooks/use-supplier-statuses.d.ts.map +1 -0
  36. package/dist/hooks/use-supplier-statuses.js +12 -0
  37. package/dist/index.d.ts +1 -0
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +1 -0
  40. package/dist/provider.d.ts +1 -13
  41. package/dist/provider.d.ts.map +1 -1
  42. package/dist/provider.js +1 -16
  43. package/dist/query-keys.d.ts +3 -0
  44. package/dist/query-keys.d.ts.map +1 -1
  45. package/dist/query-keys.js +3 -0
  46. package/dist/query-options.d.ts +828 -0
  47. package/dist/query-options.d.ts.map +1 -0
  48. package/dist/query-options.js +71 -0
  49. package/dist/schemas.d.ts +342 -3
  50. package/dist/schemas.d.ts.map +1 -1
  51. package/dist/schemas.js +4 -0
  52. package/package.json +42 -46
package/LICENSE ADDED
@@ -0,0 +1,109 @@
1
+ # Functional Source License, Version 1.1, Apache 2.0 Future License
2
+
3
+ ## Abbreviation
4
+
5
+ FSL-1.1-Apache-2.0
6
+
7
+ ## Notice
8
+
9
+ Copyright 2026 PixelMakers Studio SRL
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly
28
+ display and redistribute the Software for any Permitted Purpose identified
29
+ below.
30
+
31
+ ### Permitted Purpose
32
+
33
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing
34
+ Use means making the Software available to others in a commercial product or
35
+ service that:
36
+
37
+ 1. substitutes for the Software;
38
+
39
+ 2. substitutes for any other product or service we offer using the Software
40
+ that exists as of the date we make the Software available; or
41
+
42
+ 3. offers the same or substantially similar functionality as the Software.
43
+
44
+ Permitted Purposes specifically include using the Software:
45
+
46
+ 1. for your internal use and access;
47
+
48
+ 2. for non-commercial education;
49
+
50
+ 3. for non-commercial research; and
51
+
52
+ 4. in connection with professional services that you provide to a licensee
53
+ using the Software in accordance with these Terms and Conditions.
54
+
55
+ ### Patents
56
+
57
+ To the extent your use for a Permitted Purpose would necessarily infringe
58
+ our patents, the license grant above includes a license under our patents.
59
+ If you make a claim against any party that the Software infringes or
60
+ contributes to the infringement of any patent, then your patent license to
61
+ the Software ends immediately.
62
+
63
+ ### Redistribution
64
+
65
+ The Terms and Conditions apply to all copies, modifications and derivatives
66
+ of the Software.
67
+
68
+ If you redistribute any copies, modifications or derivatives of the
69
+ Software, you must include a copy of or a link to these Terms and Conditions
70
+ and not remove any copyright notices provided in or with the Software.
71
+
72
+ ### Disclaimer
73
+
74
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS
75
+ OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A
76
+ PARTICULAR PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
77
+
78
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO
79
+ THE SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
80
+ DAMAGES, EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
81
+
82
+ ### Trademarks
83
+
84
+ Except for displaying the License Details and identifying us as the origin
85
+ of the Software, you have no right under these Terms and Conditions to use
86
+ our trademarks, trade names, service marks or product names.
87
+
88
+ ---
89
+
90
+ ## Grant of Future License
91
+
92
+ We hereby irrevocably grant you an additional license to use the Software
93
+ under the Apache License, Version 2.0 that is effective on the second
94
+ anniversary of the date we make the Software available. On or after that
95
+ date, you may use the Software under the Apache License, Version 2.0, in
96
+ which case the following will apply:
97
+
98
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
99
+ use this file except in compliance with the License.
100
+
101
+ You may obtain a copy of the License at
102
+
103
+ http://www.apache.org/licenses/LICENSE-2.0
104
+
105
+ Unless required by applicable law or agreed to in writing, software
106
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
107
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
108
+ License for the specific language governing permissions and limitations
109
+ under the License.
package/README.md CHANGED
@@ -1 +1,12 @@
1
1
  `@voyantjs/bookings-react` provides React Query hooks and provider utilities for Voyant bookings.
2
+
3
+ It now includes public storefront flow helpers alongside the admin hooks:
4
+
5
+ - `usePublicBookingSession`
6
+ - `usePublicBookingSessionState`
7
+ - `usePublicBookingSessionFlowMutation`
8
+ - `getPublicBookingSessionQueryOptions`
9
+ - `getPublicBookingSessionStateQueryOptions`
10
+
11
+ Those helpers target the public booking session contract for wizard-state
12
+ storage and room-selection repricing.
@@ -1,7 +1,15 @@
1
1
  export { type UseBookingOptions, useBooking } from "./use-booking.js";
2
+ export { type UseBookingActivityOptions, useBookingActivity } from "./use-booking-activity.js";
2
3
  export { type CreateBookingInput, type UpdateBookingInput, useBookingMutation, } from "./use-booking-mutation.js";
4
+ export { type CreateBookingNoteInput, useBookingNoteMutation, } from "./use-booking-note-mutation.js";
5
+ export { type UseBookingNotesOptions, useBookingNotes } from "./use-booking-notes.js";
3
6
  export { type UpdateBookingStatusInput, useBookingStatusMutation, } from "./use-booking-status-mutation.js";
4
7
  export { type UseBookingsOptions, useBookings } from "./use-bookings.js";
5
8
  export { type CreatePassengerInput, type UpdatePassengerInput, usePassengerMutation, } from "./use-passenger-mutation.js";
6
9
  export { type UsePassengersOptions, usePassengers } from "./use-passengers.js";
10
+ export { type UsePublicBookingSessionOptions, usePublicBookingSession, } from "./use-public-booking-session.js";
11
+ export { usePublicBookingSessionFlowMutation } from "./use-public-booking-session-flow-mutation.js";
12
+ export { type UsePublicBookingSessionStateOptions, usePublicBookingSessionState, } from "./use-public-booking-session-state.js";
13
+ export { type CreateSupplierStatusInput, type UpdateSupplierStatusInput, useSupplierStatusMutation, } from "./use-supplier-status-mutation.js";
14
+ export { type UseSupplierStatusesOptions, useSupplierStatuses } from "./use-supplier-statuses.js";
7
15
  //# 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,EACL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,kBAAkB,GACnB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,KAAK,wBAAwB,EAC7B,wBAAwB,GACzB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,KAAK,kBAAkB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,oBAAoB,GACrB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,KAAK,oBAAoB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA"}
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,KAAK,kBAAkB,EACvB,kBAAkB,GACnB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,KAAK,sBAAsB,EAC3B,sBAAsB,GACvB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,KAAK,sBAAsB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACrF,OAAO,EACL,KAAK,wBAAwB,EAC7B,wBAAwB,GACzB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,KAAK,kBAAkB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,oBAAoB,GACrB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,KAAK,oBAAoB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAC9E,OAAO,EACL,KAAK,8BAA8B,EACnC,uBAAuB,GACxB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAAE,mCAAmC,EAAE,MAAM,+CAA+C,CAAA;AACnG,OAAO,EACL,KAAK,mCAAmC,EACxC,4BAA4B,GAC7B,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,yBAAyB,GAC1B,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAAE,KAAK,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA"}
@@ -1,6 +1,14 @@
1
1
  export { useBooking } from "./use-booking.js";
2
+ export { useBookingActivity } from "./use-booking-activity.js";
2
3
  export { useBookingMutation, } from "./use-booking-mutation.js";
4
+ export { useBookingNoteMutation, } from "./use-booking-note-mutation.js";
5
+ export { useBookingNotes } from "./use-booking-notes.js";
3
6
  export { useBookingStatusMutation, } from "./use-booking-status-mutation.js";
4
7
  export { useBookings } from "./use-bookings.js";
5
8
  export { usePassengerMutation, } from "./use-passenger-mutation.js";
6
9
  export { usePassengers } from "./use-passengers.js";
10
+ export { usePublicBookingSession, } from "./use-public-booking-session.js";
11
+ export { usePublicBookingSessionFlowMutation } from "./use-public-booking-session-flow-mutation.js";
12
+ export { usePublicBookingSessionState, } from "./use-public-booking-session-state.js";
13
+ export { useSupplierStatusMutation, } from "./use-supplier-status-mutation.js";
14
+ export { useSupplierStatuses } from "./use-supplier-statuses.js";
@@ -0,0 +1,15 @@
1
+ export interface UseBookingActivityOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function useBookingActivity(bookingId: string | null | undefined, options?: UseBookingActivityOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ data: {
6
+ id: string;
7
+ bookingId: string;
8
+ actorId: string | null;
9
+ activityType: string;
10
+ description: string;
11
+ metadata: Record<string, unknown> | null;
12
+ createdAt: string;
13
+ }[];
14
+ }, Error>;
15
+ //# sourceMappingURL=use-booking-activity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-booking-activity.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking-activity.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,yBAAyB;IACxC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,OAAO,GAAE,yBAA8B;;;;;;;;;;UASxC"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantBookingsContext } from "../provider.js";
4
+ import { getBookingActivityQueryOptions } from "../query-options.js";
5
+ export function useBookingActivity(bookingId, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantBookingsContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getBookingActivityQueryOptions({ baseUrl, fetcher }, bookingId),
10
+ enabled: enabled && Boolean(bookingId),
11
+ });
12
+ }
@@ -0,0 +1,11 @@
1
+ export interface CreateBookingNoteInput {
2
+ content: string;
3
+ }
4
+ export declare function useBookingNoteMutation(bookingId: string): import("@tanstack/react-query").UseMutationResult<{
5
+ id: string;
6
+ bookingId: string;
7
+ authorId: string;
8
+ content: string;
9
+ createdAt: string;
10
+ }, Error, CreateBookingNoteInput, unknown>;
11
+ //# sourceMappingURL=use-booking-note-mutation.d.ts.map
@@ -0,0 +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;AAMD,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM;;;;;;2CAmBvD"}
@@ -0,0 +1,24 @@
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 { bookingNoteRecordSchema } from "../schemas.js";
8
+ const bookingNoteSingleResponse = z.object({
9
+ data: bookingNoteRecordSchema,
10
+ });
11
+ export function useBookingNoteMutation(bookingId) {
12
+ const { baseUrl, fetcher } = useVoyantBookingsContext();
13
+ const queryClient = useQueryClient();
14
+ return useMutation({
15
+ mutationFn: async (input) => {
16
+ const { data } = await fetchWithValidation(`/v1/bookings/${bookingId}/notes`, bookingNoteSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
17
+ return data;
18
+ },
19
+ onSuccess: () => {
20
+ void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.notes(bookingId) });
21
+ void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.activity(bookingId) });
22
+ },
23
+ });
24
+ }
@@ -0,0 +1,13 @@
1
+ export interface UseBookingNotesOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function useBookingNotes(bookingId: string | null | undefined, options?: UseBookingNotesOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ data: {
6
+ id: string;
7
+ bookingId: string;
8
+ authorId: string;
9
+ content: string;
10
+ createdAt: string;
11
+ }[];
12
+ }, Error>;
13
+ //# sourceMappingURL=use-booking-notes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-booking-notes.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking-notes.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,OAAO,GAAE,sBAA2B;;;;;;;;UASrC"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantBookingsContext } from "../provider.js";
4
+ import { getBookingNotesQueryOptions } from "../query-options.js";
5
+ export function useBookingNotes(bookingId, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantBookingsContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getBookingNotesQueryOptions({ baseUrl, fetcher }, bookingId),
10
+ enabled: enabled && Boolean(bookingId),
11
+ });
12
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"use-booking.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,GAAE,iBAAsB;;;;;;;;;;;;;;;;;;UAUxF"}
1
+ {"version":3,"file":"use-booking.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,GAAE,iBAAsB;;;;;;;;;;;;;;;;;;UAQxF"}
@@ -1,15 +1,12 @@
1
1
  "use client";
2
2
  import { useQuery } from "@tanstack/react-query";
3
- import { fetchWithValidation } from "../client.js";
4
3
  import { useVoyantBookingsContext } from "../provider.js";
5
- import { bookingsQueryKeys } from "../query-keys.js";
6
- import { bookingSingleResponse } from "../schemas.js";
4
+ import { getBookingQueryOptions } from "../query-options.js";
7
5
  export function useBooking(id, options = {}) {
8
6
  const { baseUrl, fetcher } = useVoyantBookingsContext();
9
7
  const { enabled = true } = options;
10
8
  return useQuery({
11
- queryKey: bookingsQueryKeys.booking(id ?? ""),
12
- queryFn: () => fetchWithValidation(`/v1/bookings/${id}`, bookingSingleResponse, { baseUrl, fetcher }),
9
+ ...getBookingQueryOptions({ baseUrl, fetcher }, id),
13
10
  enabled: enabled && Boolean(id),
14
11
  });
15
12
  }
@@ -1,4 +1,4 @@
1
- import { type BookingsListFilters } from "../query-keys.js";
1
+ import type { BookingsListFilters } from "../query-keys.js";
2
2
  export interface UseBookingsOptions extends BookingsListFilters {
3
3
  enabled?: boolean;
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"use-bookings.d.ts","sourceRoot":"","sources":["../../src/hooks/use-bookings.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,mBAAmB,EAAqB,MAAM,kBAAkB,CAAA;AAG9E,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB;;;;;;;;;;;;;;;;;;;;;UAoB3D"}
1
+ {"version":3,"file":"use-bookings.d.ts","sourceRoot":"","sources":["../../src/hooks/use-bookings.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAG3D,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB;;;;;;;;;;;;;;;;;;;;;UAQ3D"}
@@ -1,30 +1,12 @@
1
1
  "use client";
2
2
  import { useQuery } from "@tanstack/react-query";
3
- import { fetchWithValidation } from "../client.js";
4
3
  import { useVoyantBookingsContext } from "../provider.js";
5
- import { bookingsQueryKeys } from "../query-keys.js";
6
- import { bookingListResponse } from "../schemas.js";
4
+ import { getBookingsQueryOptions } from "../query-options.js";
7
5
  export function useBookings(options = {}) {
8
6
  const { baseUrl, fetcher } = useVoyantBookingsContext();
9
7
  const { enabled = true, ...filters } = options;
10
8
  return useQuery({
11
- queryKey: bookingsQueryKeys.bookingsList(filters),
12
- queryFn: () => {
13
- const params = new URLSearchParams();
14
- if (filters.status)
15
- params.set("status", filters.status);
16
- if (filters.search)
17
- params.set("search", filters.search);
18
- if (filters.limit !== undefined)
19
- params.set("limit", String(filters.limit));
20
- if (filters.offset !== undefined)
21
- params.set("offset", String(filters.offset));
22
- const qs = params.toString();
23
- return fetchWithValidation(`/v1/bookings${qs ? `?${qs}` : ""}`, bookingListResponse, {
24
- baseUrl,
25
- fetcher,
26
- });
27
- },
9
+ ...getBookingsQueryOptions({ baseUrl, fetcher }, filters),
28
10
  enabled,
29
11
  });
30
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"use-passengers.d.ts","sourceRoot":"","sources":["../../src/hooks/use-passengers.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,OAAO,GAAE,oBAAyB;;;;;;;;;;;;;UAcnC"}
1
+ {"version":3,"file":"use-passengers.d.ts","sourceRoot":"","sources":["../../src/hooks/use-passengers.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,OAAO,GAAE,oBAAyB;;;;;;;;;;;;;UASnC"}
@@ -1,18 +1,12 @@
1
1
  "use client";
2
2
  import { useQuery } from "@tanstack/react-query";
3
- import { fetchWithValidation } from "../client.js";
4
3
  import { useVoyantBookingsContext } from "../provider.js";
5
- import { bookingsQueryKeys } from "../query-keys.js";
6
- import { bookingPassengersResponse } from "../schemas.js";
4
+ import { getPassengersQueryOptions } from "../query-options.js";
7
5
  export function usePassengers(bookingId, options = {}) {
8
6
  const { baseUrl, fetcher } = useVoyantBookingsContext();
9
7
  const { enabled = true } = options;
10
8
  return useQuery({
11
- queryKey: bookingsQueryKeys.passengers(bookingId ?? ""),
12
- queryFn: () => fetchWithValidation(`/v1/bookings/${bookingId}/passengers`, bookingPassengersResponse, {
13
- baseUrl,
14
- fetcher,
15
- }),
9
+ ...getPassengersQueryOptions({ baseUrl, fetcher }, bookingId),
16
10
  enabled: enabled && Boolean(bookingId),
17
11
  });
18
12
  }
@@ -0,0 +1,145 @@
1
+ export declare function usePublicBookingSessionFlowMutation(sessionId: string): {
2
+ updateState: import("@tanstack/react-query").UseMutationResult<{
3
+ sessionId: string;
4
+ stateKey: "wizard";
5
+ currentStep: string | null;
6
+ completedSteps: string[];
7
+ payload: Record<string, unknown>;
8
+ version: number;
9
+ createdAt: string;
10
+ updatedAt: string;
11
+ }, Error, {
12
+ payload: Record<string, unknown>;
13
+ replacePayload: boolean;
14
+ currentStep?: string | null | undefined;
15
+ completedSteps?: string[] | undefined;
16
+ }, unknown>;
17
+ reprice: import("@tanstack/react-query").UseMutationResult<{
18
+ pricing: {
19
+ sessionId: string;
20
+ catalogId: string | null;
21
+ currencyCode: string;
22
+ totalSellAmountCents: number;
23
+ items: {
24
+ itemId: string;
25
+ title: string;
26
+ productId: string | null;
27
+ optionId: string | null;
28
+ optionUnitId: string | null;
29
+ optionUnitName: string | null;
30
+ optionUnitType: string | null;
31
+ pricingCategoryId: string | null;
32
+ quantity: number;
33
+ pricingMode: string;
34
+ unitSellAmountCents: number | null;
35
+ totalSellAmountCents: number | null;
36
+ warnings: string[];
37
+ }[];
38
+ warnings: string[];
39
+ appliedToSession: boolean;
40
+ };
41
+ session: {
42
+ sessionId: string;
43
+ bookingNumber: string;
44
+ status: "draft" | "on_hold" | "confirmed" | "in_progress" | "completed" | "expired" | "cancelled";
45
+ externalBookingRef: string | null;
46
+ communicationLanguage: string | null;
47
+ sellCurrency: string;
48
+ sellAmountCents: number | null;
49
+ startDate: string | null;
50
+ endDate: string | null;
51
+ pax: number | null;
52
+ holdExpiresAt: string | null;
53
+ confirmedAt: string | null;
54
+ expiredAt: string | null;
55
+ cancelledAt: string | null;
56
+ completedAt: string | null;
57
+ participants: {
58
+ id: string;
59
+ participantType: "traveler" | "booker" | "contact" | "occupant" | "staff" | "other";
60
+ travelerCategory: "other" | "adult" | "child" | "infant" | "senior" | null;
61
+ firstName: string;
62
+ lastName: string;
63
+ email: string | null;
64
+ phone: string | null;
65
+ preferredLanguage: string | null;
66
+ accessibilityNeeds: string | null;
67
+ specialRequests: string | null;
68
+ isPrimary: boolean;
69
+ notes: string | null;
70
+ }[];
71
+ items: {
72
+ id: string;
73
+ title: string;
74
+ description: string | null;
75
+ itemType: "other" | "unit" | "extra" | "service" | "fee" | "tax" | "discount" | "adjustment" | "accommodation" | "transport";
76
+ status: "draft" | "on_hold" | "confirmed" | "expired" | "cancelled" | "fulfilled";
77
+ serviceDate: string | null;
78
+ startsAt: string | null;
79
+ endsAt: string | null;
80
+ quantity: number;
81
+ sellCurrency: string;
82
+ unitSellAmountCents: number | null;
83
+ totalSellAmountCents: number | null;
84
+ costCurrency: string | null;
85
+ unitCostAmountCents: number | null;
86
+ totalCostAmountCents: number | null;
87
+ notes: string | null;
88
+ productId: string | null;
89
+ optionId: string | null;
90
+ optionUnitId: string | null;
91
+ pricingCategoryId: string | null;
92
+ participantLinks: {
93
+ id: string;
94
+ participantId: string;
95
+ role: "traveler" | "occupant" | "other" | "primary_contact" | "service_assignee" | "beneficiary";
96
+ isPrimary: boolean;
97
+ }[];
98
+ }[];
99
+ allocations: {
100
+ id: string;
101
+ bookingItemId: string | null;
102
+ productId: string | null;
103
+ optionId: string | null;
104
+ optionUnitId: string | null;
105
+ pricingCategoryId: string | null;
106
+ availabilitySlotId: string | null;
107
+ quantity: number;
108
+ allocationType: "unit" | "pickup" | "resource";
109
+ status: "confirmed" | "expired" | "cancelled" | "fulfilled" | "held" | "released";
110
+ holdExpiresAt: string | null;
111
+ confirmedAt: string | null;
112
+ releasedAt: string | null;
113
+ }[];
114
+ checklist: {
115
+ hasParticipants: boolean;
116
+ hasTraveler: boolean;
117
+ hasPrimaryParticipant: boolean;
118
+ hasItems: boolean;
119
+ hasAllocations: boolean;
120
+ readyForConfirmation: boolean;
121
+ };
122
+ state: {
123
+ sessionId: string;
124
+ stateKey: "wizard";
125
+ currentStep: string | null;
126
+ completedSteps: string[];
127
+ payload: Record<string, unknown>;
128
+ version: number;
129
+ createdAt: string;
130
+ updatedAt: string;
131
+ } | null;
132
+ } | null;
133
+ }, Error, {
134
+ applyToSession: boolean;
135
+ selections: {
136
+ itemId: string;
137
+ optionId?: string | null | undefined;
138
+ optionUnitId?: string | null | undefined;
139
+ pricingCategoryId?: string | null | undefined;
140
+ quantity?: number | undefined;
141
+ }[];
142
+ catalogId?: string | undefined;
143
+ }, unknown>;
144
+ };
145
+ //# sourceMappingURL=use-public-booking-session-flow-mutation.d.ts.map
@@ -0,0 +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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCpE"}
@@ -0,0 +1,35 @@
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 { publicBookingSessionRepriceResponse, publicBookingSessionStateResponse, } from "../schemas.js";
7
+ export function usePublicBookingSessionFlowMutation(sessionId) {
8
+ const { baseUrl, fetcher } = useVoyantBookingsContext();
9
+ const queryClient = useQueryClient();
10
+ const updateState = useMutation({
11
+ mutationFn: async (input) => {
12
+ const { data } = await fetchWithValidation(`/v1/public/bookings/sessions/${sessionId}/state`, publicBookingSessionStateResponse, { baseUrl, fetcher }, { method: "PUT", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: (data) => {
16
+ queryClient.setQueryData(bookingsQueryKeys.publicSessionState(sessionId), { data });
17
+ void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.publicSession(sessionId) });
18
+ },
19
+ });
20
+ const reprice = useMutation({
21
+ mutationFn: async (input) => {
22
+ const { data } = await fetchWithValidation(`/v1/public/bookings/sessions/${sessionId}/reprice`, publicBookingSessionRepriceResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
23
+ return data;
24
+ },
25
+ onSuccess: (data) => {
26
+ if (data.session) {
27
+ queryClient.setQueryData(bookingsQueryKeys.publicSession(sessionId), { data: data.session });
28
+ void queryClient.invalidateQueries({
29
+ queryKey: bookingsQueryKeys.publicSessionState(sessionId),
30
+ });
31
+ }
32
+ },
33
+ });
34
+ return { updateState, reprice };
35
+ }
@@ -0,0 +1,16 @@
1
+ export interface UsePublicBookingSessionStateOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function usePublicBookingSessionState(sessionId: string | null | undefined, options?: UsePublicBookingSessionStateOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ data: {
6
+ sessionId: string;
7
+ stateKey: "wizard";
8
+ currentStep: string | null;
9
+ completedSteps: string[];
10
+ payload: Record<string, unknown>;
11
+ version: number;
12
+ createdAt: string;
13
+ updatedAt: string;
14
+ };
15
+ }, Error>;
16
+ //# sourceMappingURL=use-public-booking-session-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-public-booking-session-state.d.ts","sourceRoot":"","sources":["../../src/hooks/use-public-booking-session-state.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,mCAAmC;IAClD,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,OAAO,GAAE,mCAAwC;;;;;;;;;;;UASlD"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantBookingsContext } from "../provider.js";
4
+ import { getPublicBookingSessionStateQueryOptions } from "../query-options.js";
5
+ export function usePublicBookingSessionState(sessionId, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantBookingsContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getPublicBookingSessionStateQueryOptions({ baseUrl, fetcher }, sessionId),
10
+ enabled: enabled && Boolean(sessionId),
11
+ });
12
+ }