@voyantjs/availability-react 0.33.0 → 0.34.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.
@@ -9,6 +9,7 @@ export type { UseProductsOptions } from "./use-products.js";
9
9
  export { useProducts } from "./use-products.js";
10
10
  export type { UseRulesOptions } from "./use-rules.js";
11
11
  export { useRules } from "./use-rules.js";
12
+ export { type UseSlotAllocationOptions, useAllocationAutomationMutation, useAllocationResourceMutation, useAssignTravelerAllocationMutation, useProductResourceTemplates, useResourceTemplateMutation, useSharingGroupLabelMutation, useSlotAllocation, useSlotAllocationAuditLog, useTravelerSharingGroupMutation, } from "./use-slot-allocation.js";
12
13
  export type { UseSlotUnitAvailabilityOptions } from "./use-slot-unit-availability.js";
13
14
  export { useSlotUnitAvailability } from "./use-slot-unit-availability.js";
14
15
  export type { UseSlotsOptions } from "./use-slots.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAA;AACjF,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAA;AACjF,OAAO,EAAE,gCAAgC,EAAE,MAAM,2CAA2C,CAAA;AAC5F,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,YAAY,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AM,iCAAiC,CAAA;AACzE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA"}
@@ -5,6 +5,7 @@ export { useCloseouts } from "./use-closeouts.js";
5
5
  export { usePickupPoints } from "./use-pickup-points.js";
6
6
  export { useProducts } from "./use-products.js";
7
7
  export { useRules } from "./use-rules.js";
8
+ export { useAllocationAutomationMutation, useAllocationResourceMutation, useAssignTravelerAllocationMutation, useProductResourceTemplates, useResourceTemplateMutation, useSharingGroupLabelMutation, useSlotAllocation, useSlotAllocationAuditLog, useTravelerSharingGroupMutation, } from "./use-slot-allocation.js";
8
9
  export { useSlotUnitAvailability } from "./use-slot-unit-availability.js";
9
10
  export { useSlots } from "./use-slots.js";
10
11
  export { useStartTimes } from "./use-start-times.js";
@@ -0,0 +1,282 @@
1
+ import { type UpdateAllocationResourceInput, type UpsertResourceTemplateInput } from "../schemas.js";
2
+ export interface UseSlotAllocationOptions {
3
+ slotId: string | null | undefined;
4
+ enabled?: boolean;
5
+ }
6
+ export declare function useSlotAllocation({ slotId, enabled }: UseSlotAllocationOptions): import("@tanstack/react-query").UseQueryResult<{
7
+ data: {
8
+ slot: {
9
+ id: string;
10
+ productId: string | null;
11
+ startsAt: string | null;
12
+ endsAt: string | null;
13
+ };
14
+ bookings: {
15
+ id: string;
16
+ bookingNumber: string;
17
+ status: string;
18
+ contactFirstName: string | null;
19
+ contactLastName: string | null;
20
+ contactEmail: string | null;
21
+ contactPhone: string | null;
22
+ sellCurrency: string | null;
23
+ pax: number | null;
24
+ travelers: {
25
+ id: string;
26
+ bookingId: string;
27
+ bookingNumber: string;
28
+ bookingStatus: string;
29
+ firstName: string;
30
+ lastName: string;
31
+ fullName: string;
32
+ email: string | null;
33
+ phone: string | null;
34
+ isLeadTraveler: boolean;
35
+ isPrimary: boolean;
36
+ sharingGroupId: string | null;
37
+ roomTypeId: string | null;
38
+ bedPreference: string | null;
39
+ allocations: Record<string, string>;
40
+ travelerCategory: string | null;
41
+ participantType: string;
42
+ hasAccessibilityNeeds: boolean;
43
+ hasDietaryRequirements: boolean;
44
+ }[];
45
+ }[];
46
+ resources: {
47
+ id: string;
48
+ slotId: string;
49
+ kind: string;
50
+ refType: string | null;
51
+ refId: string | null;
52
+ label: string | null;
53
+ capacity: number;
54
+ flags: Record<string, unknown>;
55
+ parentId: string | null;
56
+ sortOrder: number;
57
+ createdAt: string | Date;
58
+ updatedAt: string | Date;
59
+ }[];
60
+ sharingGroupLabels: Record<string, string>;
61
+ summary: {
62
+ bookingCount: number;
63
+ travelerCount: number;
64
+ leadTravelerCount: number;
65
+ bookingsByStatus: Record<string, number>;
66
+ };
67
+ };
68
+ }, Error>;
69
+ export declare function useSlotAllocationAuditLog({ slotId, enabled }: UseSlotAllocationOptions): import("@tanstack/react-query").UseQueryResult<{
70
+ data: {
71
+ id: string;
72
+ slotId: string;
73
+ action: string;
74
+ actorId: string | null;
75
+ travelerId: string | null;
76
+ resourceId: string | null;
77
+ before: Record<string, unknown> | null;
78
+ after: Record<string, unknown> | null;
79
+ createdAt: string;
80
+ }[];
81
+ }, Error>;
82
+ export declare function useProductResourceTemplates({ productId, enabled, }: {
83
+ productId: string | null | undefined;
84
+ enabled?: boolean;
85
+ }): import("@tanstack/react-query").UseQueryResult<{
86
+ data: {
87
+ id: string;
88
+ name: string;
89
+ code: string | null;
90
+ description: string | null;
91
+ status: string;
92
+ isDefault: boolean;
93
+ sortOrder: number;
94
+ templates: {
95
+ id: string;
96
+ productOptionId: string;
97
+ kind: string;
98
+ refType: string | null;
99
+ refId: string | null;
100
+ capacity: number;
101
+ namePattern: string;
102
+ layout: string | null;
103
+ flags: Record<string, unknown>;
104
+ createdAt: string;
105
+ updatedAt: string;
106
+ }[];
107
+ }[];
108
+ }, Error>;
109
+ export declare function useAllocationResourceMutation(slotId: string): {
110
+ create: import("@tanstack/react-query").UseMutationResult<{
111
+ id: string;
112
+ slotId: string;
113
+ kind: string;
114
+ refType: string | null;
115
+ refId: string | null;
116
+ label: string | null;
117
+ capacity: number;
118
+ flags: Record<string, unknown>;
119
+ parentId: string | null;
120
+ sortOrder: number;
121
+ createdAt: string | Date;
122
+ updatedAt: string | Date;
123
+ }, Error, {
124
+ kind: string;
125
+ capacity: number;
126
+ refType?: string | null | undefined;
127
+ refId?: string | null | undefined;
128
+ label?: string | null | undefined;
129
+ flags?: Record<string, unknown> | undefined;
130
+ parentId?: string | null | undefined;
131
+ sortOrder?: number | undefined;
132
+ }, unknown>;
133
+ update: import("@tanstack/react-query").UseMutationResult<{
134
+ id: string;
135
+ slotId: string;
136
+ kind: string;
137
+ refType: string | null;
138
+ refId: string | null;
139
+ label: string | null;
140
+ capacity: number;
141
+ flags: Record<string, unknown>;
142
+ parentId: string | null;
143
+ sortOrder: number;
144
+ createdAt: string | Date;
145
+ updatedAt: string | Date;
146
+ }, Error, {
147
+ resourceId: string;
148
+ input: UpdateAllocationResourceInput;
149
+ }, unknown>;
150
+ remove: import("@tanstack/react-query").UseMutationResult<{
151
+ data: {
152
+ id: string;
153
+ };
154
+ }, Error, string, unknown>;
155
+ };
156
+ export declare function useResourceTemplateMutation(productId: string): {
157
+ upsert: import("@tanstack/react-query").UseMutationResult<{
158
+ id: string;
159
+ productOptionId: string;
160
+ kind: string;
161
+ refType: string | null;
162
+ refId: string | null;
163
+ capacity: number;
164
+ namePattern: string;
165
+ layout: string | null;
166
+ flags: Record<string, unknown>;
167
+ createdAt: string;
168
+ updatedAt: string;
169
+ }, Error, {
170
+ optionId: string;
171
+ kind: string;
172
+ input: UpsertResourceTemplateInput;
173
+ }, unknown>;
174
+ remove: import("@tanstack/react-query").UseMutationResult<{
175
+ data: {
176
+ productOptionId: string;
177
+ kind: string;
178
+ };
179
+ }, Error, {
180
+ optionId: string;
181
+ kind: string;
182
+ }, unknown>;
183
+ };
184
+ export declare function useAllocationAutomationMutation(slotId: string): {
185
+ autoMaterialize: import("@tanstack/react-query").UseMutationResult<{
186
+ kind: string;
187
+ assigned?: number | undefined;
188
+ skipped?: number | undefined;
189
+ created?: number | undefined;
190
+ resources?: {
191
+ id: string;
192
+ slotId: string;
193
+ kind: string;
194
+ refType: string | null;
195
+ refId: string | null;
196
+ label: string | null;
197
+ capacity: number;
198
+ flags: Record<string, unknown>;
199
+ parentId: string | null;
200
+ sortOrder: number;
201
+ createdAt: string | Date;
202
+ updatedAt: string | Date;
203
+ }[] | undefined;
204
+ }, Error, {
205
+ kind?: string;
206
+ }, unknown>;
207
+ autoAllocate: import("@tanstack/react-query").UseMutationResult<{
208
+ kind: string;
209
+ assigned?: number | undefined;
210
+ skipped?: number | undefined;
211
+ created?: number | undefined;
212
+ resources?: {
213
+ id: string;
214
+ slotId: string;
215
+ kind: string;
216
+ refType: string | null;
217
+ refId: string | null;
218
+ label: string | null;
219
+ capacity: number;
220
+ flags: Record<string, unknown>;
221
+ parentId: string | null;
222
+ sortOrder: number;
223
+ createdAt: string | Date;
224
+ updatedAt: string | Date;
225
+ }[] | undefined;
226
+ }, Error, {
227
+ kind?: string;
228
+ }, unknown>;
229
+ };
230
+ export declare function useAssignTravelerAllocationMutation(slotId: string): import("@tanstack/react-query").UseMutationResult<{
231
+ data: {
232
+ travelerId: string;
233
+ kind: string;
234
+ resourceId: string | null;
235
+ };
236
+ }, Error, {
237
+ travelerId: string;
238
+ kind: string;
239
+ resourceId: string | null;
240
+ }, unknown>;
241
+ export declare function useSharingGroupLabelMutation(slotId: string): {
242
+ update: import("@tanstack/react-query").UseMutationResult<{
243
+ data: {
244
+ groupId: string;
245
+ label: string;
246
+ createdAt: string | Date;
247
+ updatedAt: string | Date;
248
+ };
249
+ }, Error, {
250
+ groupId: string;
251
+ label: string;
252
+ }, unknown>;
253
+ remove: import("@tanstack/react-query").UseMutationResult<{
254
+ data: {
255
+ groupId: string;
256
+ label: string;
257
+ createdAt: string | Date;
258
+ updatedAt: string | Date;
259
+ };
260
+ }, Error, string, unknown>;
261
+ };
262
+ export declare function useTravelerSharingGroupMutation(slotId: string): {
263
+ update: import("@tanstack/react-query").UseMutationResult<{
264
+ data: {
265
+ travelerId: string;
266
+ sharingGroupId: string | null;
267
+ };
268
+ }, Error, {
269
+ travelerId: string;
270
+ sharingGroupId: string | null;
271
+ }, unknown>;
272
+ pair: import("@tanstack/react-query").UseMutationResult<{
273
+ data: {
274
+ sharingGroupId: string;
275
+ travelerIds: string[];
276
+ };
277
+ }, Error, {
278
+ travelerIds: string[];
279
+ sharingGroupId?: string;
280
+ }, unknown>;
281
+ };
282
+ //# sourceMappingURL=use-slot-allocation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-slot-allocation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-slot-allocation.ts"],"names":[],"mappings":"AAaA,OAAO,EAOL,KAAK,6BAA6B,EAClC,KAAK,2BAA2B,EACjC,MAAM,eAAe,CAAA;AAwBtB,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACjC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,MAAM,EAAE,OAAc,EAAE,EAAE,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAMrF;AAED,wBAAgB,yBAAyB,CAAC,EAAE,MAAM,EAAE,OAAc,EAAE,EAAE,wBAAwB;;;;;;;;;;;;UAM7F;AAED,wBAAgB,2BAA2B,CAAC,EAC1C,SAAS,EACT,OAAc,GACf,EAAE;IACD,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACpC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;;;;;;;;;;;;;;;;;;;;;;;UAMA;AAED,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBA4B1C,MAAM;eACX,6BAA6B;;;;;;;EAyBzC;AAED,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM;;;;;;;;;;;;;;kBAe7C,MAAM;cACV,MAAM;eACL,2BAA2B;;;;;;;;kBAce,MAAM;cAAQ,MAAM;;EAW1E;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;eAWvB,MAAM;;;;;;;;;;;;;;;;;;;;;;eAaN,MAAM;;EAa5C;AAED,wBAAgB,mCAAmC,CAAC,MAAM,EAAE,MAAM;;;;;;;gBAK5B,MAAM;UAAQ,MAAM;gBAAc,MAAM,GAAG,IAAI;YAmBpF;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM;;;;;;;;;iBAWxB,MAAM;eAAS,MAAM;;;;;;;;;;EAsBvD;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,MAAM;;;;;;;oBAIxB,MAAM;wBAAkB,MAAM,GAAG,IAAI;;;;;;;;qBAkBpC,MAAM,EAAE;yBAAmB,MAAM;;EAkBvE"}
@@ -0,0 +1,181 @@
1
+ "use client";
2
+ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
3
+ import { z } from "zod";
4
+ import { fetchWithValidation } from "../client.js";
5
+ import { useVoyantAvailabilityContext } from "../provider.js";
6
+ import { availabilityQueryKeys } from "../query-keys.js";
7
+ import { getProductResourceTemplatesQueryOptions, getSlotAllocationAuditLogQueryOptions, getSlotAllocationQueryOptions, } from "../query-options.js";
8
+ import { allocationAutomationResponse, allocationResourceSchema, resourceTemplateSchema, sharingGroupLabelSchema, singleEnvelope, } from "../schemas.js";
9
+ const assignTravelerAllocationResponse = singleEnvelope(z.object({
10
+ travelerId: z.string(),
11
+ kind: z.string(),
12
+ resourceId: z.string().nullable(),
13
+ }));
14
+ const updateTravelerSharingGroupResponse = singleEnvelope(z.object({
15
+ travelerId: z.string(),
16
+ sharingGroupId: z.string().nullable(),
17
+ }));
18
+ const pairSharingGroupResponse = singleEnvelope(z.object({
19
+ sharingGroupId: z.string(),
20
+ travelerIds: z.array(z.string()),
21
+ }));
22
+ export function useSlotAllocation({ slotId, enabled = true }) {
23
+ const client = useVoyantAvailabilityContext();
24
+ return useQuery({
25
+ ...getSlotAllocationQueryOptions(client, slotId),
26
+ enabled: enabled && Boolean(slotId),
27
+ });
28
+ }
29
+ export function useSlotAllocationAuditLog({ slotId, enabled = true }) {
30
+ const client = useVoyantAvailabilityContext();
31
+ return useQuery({
32
+ ...getSlotAllocationAuditLogQueryOptions(client, slotId),
33
+ enabled: enabled && Boolean(slotId),
34
+ });
35
+ }
36
+ export function useProductResourceTemplates({ productId, enabled = true, }) {
37
+ const client = useVoyantAvailabilityContext();
38
+ return useQuery({
39
+ ...getProductResourceTemplatesQueryOptions(client, productId),
40
+ enabled: enabled && Boolean(productId),
41
+ });
42
+ }
43
+ export function useAllocationResourceMutation(slotId) {
44
+ const { baseUrl, fetcher } = useVoyantAvailabilityContext();
45
+ const queryClient = useQueryClient();
46
+ const invalidate = async () => {
47
+ await queryClient.invalidateQueries({ queryKey: availabilityQueryKeys.slotAllocation(slotId) });
48
+ await queryClient.invalidateQueries({
49
+ queryKey: availabilityQueryKeys.slotAllocationAuditLog(slotId),
50
+ });
51
+ };
52
+ const create = useMutation({
53
+ mutationFn: async (input) => {
54
+ const { data } = await fetchWithValidation(`/v1/admin/availability/slots/${slotId}/allocation/resources`, singleEnvelope(allocationResourceSchema), { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
55
+ return data;
56
+ },
57
+ onSuccess: invalidate,
58
+ });
59
+ const update = useMutation({
60
+ mutationFn: async ({ resourceId, input, }) => {
61
+ const { data } = await fetchWithValidation(`/v1/admin/availability/slots/${slotId}/allocation/resources/${resourceId}`, singleEnvelope(allocationResourceSchema), { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
62
+ return data;
63
+ },
64
+ onSuccess: invalidate,
65
+ });
66
+ const remove = useMutation({
67
+ mutationFn: async (resourceId) => fetchWithValidation(`/v1/admin/availability/slots/${slotId}/allocation/resources/${resourceId}`, singleEnvelope(allocationResourceSchema.pick({ id: true })), { baseUrl, fetcher }, { method: "DELETE" }),
68
+ onSuccess: invalidate,
69
+ });
70
+ return { create, update, remove };
71
+ }
72
+ export function useResourceTemplateMutation(productId) {
73
+ const { baseUrl, fetcher } = useVoyantAvailabilityContext();
74
+ const queryClient = useQueryClient();
75
+ const invalidate = async () => {
76
+ await queryClient.invalidateQueries({
77
+ queryKey: availabilityQueryKeys.productResourceTemplates(productId),
78
+ });
79
+ };
80
+ const upsert = useMutation({
81
+ mutationFn: async ({ optionId, kind, input, }) => {
82
+ const { data } = await fetchWithValidation(`/v1/admin/availability/products/${productId}/options/${optionId}/allocation/resource-templates/${kind}`, singleEnvelope(resourceTemplateSchema), { baseUrl, fetcher }, { method: "PUT", body: JSON.stringify(input) });
83
+ return data;
84
+ },
85
+ onSuccess: invalidate,
86
+ });
87
+ const remove = useMutation({
88
+ mutationFn: async ({ optionId, kind }) => fetchWithValidation(`/v1/admin/availability/products/${productId}/options/${optionId}/allocation/resource-templates/${kind}`, singleEnvelope(z.object({ productOptionId: z.string(), kind: z.string() })), { baseUrl, fetcher }, { method: "DELETE" }),
89
+ onSuccess: invalidate,
90
+ });
91
+ return { upsert, remove };
92
+ }
93
+ export function useAllocationAutomationMutation(slotId) {
94
+ const { baseUrl, fetcher } = useVoyantAvailabilityContext();
95
+ const queryClient = useQueryClient();
96
+ const invalidate = async () => {
97
+ await queryClient.invalidateQueries({ queryKey: availabilityQueryKeys.slotAllocation(slotId) });
98
+ await queryClient.invalidateQueries({
99
+ queryKey: availabilityQueryKeys.slotAllocationAuditLog(slotId),
100
+ });
101
+ };
102
+ const autoMaterialize = useMutation({
103
+ mutationFn: async (input) => {
104
+ const result = await fetchWithValidation(`/v1/admin/availability/slots/${slotId}/allocation/auto-materialize`, allocationAutomationResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
105
+ return result.data;
106
+ },
107
+ onSuccess: invalidate,
108
+ });
109
+ const autoAllocate = useMutation({
110
+ mutationFn: async (input) => {
111
+ const result = await fetchWithValidation(`/v1/admin/availability/slots/${slotId}/allocation/auto-allocate`, allocationAutomationResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
112
+ return result.data;
113
+ },
114
+ onSuccess: invalidate,
115
+ });
116
+ return { autoMaterialize, autoAllocate };
117
+ }
118
+ export function useAssignTravelerAllocationMutation(slotId) {
119
+ const { baseUrl, fetcher } = useVoyantAvailabilityContext();
120
+ const queryClient = useQueryClient();
121
+ return useMutation({
122
+ mutationFn: (input) => fetchWithValidation(`/v1/admin/availability/slots/${slotId}/allocation/travelers/${input.travelerId}`, assignTravelerAllocationResponse, { baseUrl, fetcher }, {
123
+ method: "PATCH",
124
+ body: JSON.stringify({ kind: input.kind, resourceId: input.resourceId }),
125
+ }),
126
+ onSuccess: async () => {
127
+ await queryClient.invalidateQueries({
128
+ queryKey: availabilityQueryKeys.slotAllocation(slotId),
129
+ });
130
+ await queryClient.invalidateQueries({
131
+ queryKey: availabilityQueryKeys.slotAllocationAuditLog(slotId),
132
+ });
133
+ },
134
+ });
135
+ }
136
+ export function useSharingGroupLabelMutation(slotId) {
137
+ const { baseUrl, fetcher } = useVoyantAvailabilityContext();
138
+ const queryClient = useQueryClient();
139
+ const invalidate = async () => {
140
+ await queryClient.invalidateQueries({ queryKey: availabilityQueryKeys.slotAllocation(slotId) });
141
+ await queryClient.invalidateQueries({
142
+ queryKey: availabilityQueryKeys.slotAllocationAuditLog(slotId),
143
+ });
144
+ };
145
+ const update = useMutation({
146
+ mutationFn: (input) => fetchWithValidation(`/v1/admin/availability/slots/${slotId}/allocation/sharing-groups/${input.groupId}/label`, singleEnvelope(sharingGroupLabelSchema), { baseUrl, fetcher }, { method: "PUT", body: JSON.stringify({ label: input.label }) }),
147
+ onSuccess: invalidate,
148
+ });
149
+ const remove = useMutation({
150
+ mutationFn: (groupId) => fetchWithValidation(`/v1/admin/availability/slots/${slotId}/allocation/sharing-groups/${groupId}/label`, singleEnvelope(sharingGroupLabelSchema), { baseUrl, fetcher }, { method: "DELETE" }),
151
+ onSuccess: invalidate,
152
+ });
153
+ return { update, remove };
154
+ }
155
+ export function useTravelerSharingGroupMutation(slotId) {
156
+ const { baseUrl, fetcher } = useVoyantAvailabilityContext();
157
+ const queryClient = useQueryClient();
158
+ const update = useMutation({
159
+ mutationFn: (input) => fetchWithValidation(`/v1/admin/availability/slots/${slotId}/allocation/travelers/${input.travelerId}/sharing-group`, updateTravelerSharingGroupResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify({ sharingGroupId: input.sharingGroupId }) }),
160
+ onSuccess: async () => {
161
+ await queryClient.invalidateQueries({
162
+ queryKey: availabilityQueryKeys.slotAllocation(slotId),
163
+ });
164
+ await queryClient.invalidateQueries({
165
+ queryKey: availabilityQueryKeys.slotAllocationAuditLog(slotId),
166
+ });
167
+ },
168
+ });
169
+ const pair = useMutation({
170
+ mutationFn: (input) => fetchWithValidation(`/v1/admin/availability/slots/${slotId}/allocation/sharing-groups/pair`, pairSharingGroupResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) }),
171
+ onSuccess: async () => {
172
+ await queryClient.invalidateQueries({
173
+ queryKey: availabilityQueryKeys.slotAllocation(slotId),
174
+ });
175
+ await queryClient.invalidateQueries({
176
+ queryKey: availabilityQueryKeys.slotAllocationAuditLog(slotId),
177
+ });
178
+ },
179
+ });
180
+ return { update, pair };
181
+ }
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export * from "./constants.js";
3
3
  export * from "./hooks/index.js";
4
4
  export { useVoyantAvailabilityContext, type VoyantAvailabilityContextValue, VoyantAvailabilityProvider, type VoyantAvailabilityProviderProps, } from "./provider.js";
5
5
  export { availabilityQueryKeys } from "./query-keys.js";
6
- export { getCloseoutsQueryOptions, getPickupPointsQueryOptions, getProductQueryOptions, getProductsQueryOptions, getRulesQueryOptions, getSlotAssignmentsQueryOptions, getSlotBookingsQueryOptions, getSlotCloseoutsQueryOptions, getSlotPickupsQueryOptions, getSlotQueryOptions, getSlotResourcesQueryOptions, getSlotsQueryOptions, getSlotUnitAvailabilityQueryOptions, getStartTimesQueryOptions, } from "./query-options.js";
6
+ export { getCloseoutsQueryOptions, getPickupPointsQueryOptions, getProductQueryOptions, getProductResourceTemplatesQueryOptions, getProductsQueryOptions, getRulesQueryOptions, getSlotAllocationAuditLogQueryOptions, getSlotAllocationQueryOptions, getSlotAssignmentsQueryOptions, getSlotBookingsQueryOptions, getSlotCloseoutsQueryOptions, getSlotPickupsQueryOptions, getSlotQueryOptions, getSlotResourcesQueryOptions, getSlotsQueryOptions, getSlotUnitAvailabilityQueryOptions, getStartTimesQueryOptions, } from "./query-options.js";
7
7
  export * from "./schemas.js";
8
8
  export * from "./utils.js";
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,KAAK,aAAa,GACnB,MAAM,aAAa,CAAA;AACpB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,OAAO,EACL,4BAA4B,EAC5B,KAAK,8BAA8B,EACnC,0BAA0B,EAC1B,KAAK,+BAA+B,GACrC,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,8BAA8B,EAC9B,2BAA2B,EAC3B,4BAA4B,EAC5B,0BAA0B,EAC1B,mBAAmB,EACnB,4BAA4B,EAC5B,oBAAoB,EACpB,mCAAmC,EACnC,yBAAyB,GAC1B,MAAM,oBAAoB,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,KAAK,aAAa,GACnB,MAAM,aAAa,CAAA;AACpB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,OAAO,EACL,4BAA4B,EAC5B,KAAK,8BAA8B,EACnC,0BAA0B,EAC1B,KAAK,+BAA+B,GACrC,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,sBAAsB,EACtB,uCAAuC,EACvC,uBAAuB,EACvB,oBAAoB,EACpB,qCAAqC,EACrC,6BAA6B,EAC7B,8BAA8B,EAC9B,2BAA2B,EAC3B,4BAA4B,EAC5B,0BAA0B,EAC1B,mBAAmB,EACnB,4BAA4B,EAC5B,oBAAoB,EACpB,mCAAmC,EACnC,yBAAyB,GAC1B,MAAM,oBAAoB,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
package/dist/index.js CHANGED
@@ -3,6 +3,6 @@ export * from "./constants.js";
3
3
  export * from "./hooks/index.js";
4
4
  export { useVoyantAvailabilityContext, VoyantAvailabilityProvider, } from "./provider.js";
5
5
  export { availabilityQueryKeys } from "./query-keys.js";
6
- export { getCloseoutsQueryOptions, getPickupPointsQueryOptions, getProductQueryOptions, getProductsQueryOptions, getRulesQueryOptions, getSlotAssignmentsQueryOptions, getSlotBookingsQueryOptions, getSlotCloseoutsQueryOptions, getSlotPickupsQueryOptions, getSlotQueryOptions, getSlotResourcesQueryOptions, getSlotsQueryOptions, getSlotUnitAvailabilityQueryOptions, getStartTimesQueryOptions, } from "./query-options.js";
6
+ export { getCloseoutsQueryOptions, getPickupPointsQueryOptions, getProductQueryOptions, getProductResourceTemplatesQueryOptions, getProductsQueryOptions, getRulesQueryOptions, getSlotAllocationAuditLogQueryOptions, getSlotAllocationQueryOptions, getSlotAssignmentsQueryOptions, getSlotBookingsQueryOptions, getSlotCloseoutsQueryOptions, getSlotPickupsQueryOptions, getSlotQueryOptions, getSlotResourcesQueryOptions, getSlotsQueryOptions, getSlotUnitAvailabilityQueryOptions, getStartTimesQueryOptions, } from "./query-options.js";
7
7
  export * from "./schemas.js";
8
8
  export * from "./utils.js";
@@ -51,6 +51,9 @@ export declare const availabilityQueryKeys: {
51
51
  readonly slotAssignmentsList: (filters: AvailabilitySlotDetailFilters) => readonly ["voyant", "availability", "slots", "assignments", "list", AvailabilitySlotDetailFilters];
52
52
  readonly slotResourcesList: (filters: PaginationFilters) => readonly ["voyant", "availability", "slots", "resources", "list", PaginationFilters];
53
53
  readonly slotBookingsList: (filters: PaginationFilters) => readonly ["voyant", "availability", "slots", "bookings", "list", PaginationFilters];
54
+ readonly slotAllocation: (slotId: string) => readonly ["voyant", "availability", "slots", "allocation", string];
55
+ readonly slotAllocationAuditLog: (slotId: string) => readonly ["voyant", "availability", "slots", "allocation", string, "audit-log"];
54
56
  readonly product: (id: string) => readonly ["voyant", "availability", "products", "detail", string];
57
+ readonly productResourceTemplates: (productId: string) => readonly ["voyant", "availability", "products", "resource-templates", string];
55
58
  };
56
59
  //# sourceMappingURL=query-keys.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query-keys.d.ts","sourceRoot":"","sources":["../src/query-keys.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED,MA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E3B,6BAA6B;0CAE/B,iBAAiB;yCAElB,iBAAiB;sCAEpB,MAAM;8CAEE,MAAM;2BAEzB,MAAM;mDACkB,MAAM;CAEpC,CAAA"}
@@ -21,5 +21,8 @@ export const availabilityQueryKeys = {
21
21
  slotAssignmentsList: (filters) => [...availabilityQueryKeys.slots(), "assignments", "list", filters],
22
22
  slotResourcesList: (filters) => [...availabilityQueryKeys.slots(), "resources", "list", filters],
23
23
  slotBookingsList: (filters) => [...availabilityQueryKeys.slots(), "bookings", "list", filters],
24
+ slotAllocation: (slotId) => [...availabilityQueryKeys.slots(), "allocation", slotId],
25
+ slotAllocationAuditLog: (slotId) => [...availabilityQueryKeys.slots(), "allocation", slotId, "audit-log"],
24
26
  product: (id) => [...availabilityQueryKeys.products(), "detail", id],
27
+ productResourceTemplates: (productId) => [...availabilityQueryKeys.products(), "resource-templates", productId],
25
28
  };