@composable-os/pack-bookings 0.0.0-stage → 0.1.0-beta.9

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.
@@ -0,0 +1,991 @@
1
+ import { type ClientHolding, type PackClient } from "@composable-os/client";
2
+ import type { z } from "@composable-os/sdk";
3
+ import type { book, bookFor, cancel, cancelFor, classGet, classList, day, findPeople, mine, returnUse, timetable } from "../tools.ts";
4
+ type Io<T extends {
5
+ input: z.ZodType;
6
+ output: z.ZodType;
7
+ }> = {
8
+ input: z.input<T["input"]>;
9
+ output: z.output<T["output"]>;
10
+ };
11
+ /** The operations this entry calls, as the generated client types them. */
12
+ export type BookingsOperations = {
13
+ "x.bookings.timetable": {
14
+ kind: "query";
15
+ } & Io<typeof timetable>;
16
+ "x.bookings.classGet": {
17
+ kind: "query";
18
+ } & Io<typeof classGet>;
19
+ "x.bookings.mine": {
20
+ kind: "query";
21
+ } & Io<typeof mine>;
22
+ "x.bookings.book": {
23
+ kind: "mutation";
24
+ } & Io<typeof book>;
25
+ "x.bookings.cancel": {
26
+ kind: "mutation";
27
+ } & Io<typeof cancel>;
28
+ "x.bookings.day": {
29
+ kind: "query";
30
+ } & Io<typeof day>;
31
+ "x.bookings.classList": {
32
+ kind: "query";
33
+ } & Io<typeof classList>;
34
+ "x.bookings.bookFor": {
35
+ kind: "mutation";
36
+ } & Io<typeof bookFor>;
37
+ "x.bookings.cancelFor": {
38
+ kind: "mutation";
39
+ } & Io<typeof cancelFor>;
40
+ "x.bookings.returnUse": {
41
+ kind: "mutation";
42
+ } & Io<typeof returnUse>;
43
+ "x.bookings.findPeople": {
44
+ kind: "query";
45
+ } & Io<typeof findPeople>;
46
+ };
47
+ type Name = keyof BookingsOperations & string;
48
+ type In<N extends Name> = BookingsOperations[N]["input"];
49
+ type Out<N extends Name> = BookingsOperations[N]["output"];
50
+ export type Timetable = Out<"x.bookings.timetable">;
51
+ export type TimetableClass = Timetable["classes"][number];
52
+ export type MyBookings = Out<"x.bookings.mine">;
53
+ export type MyBooking = MyBookings["bookings"][number];
54
+ export type BookResult = Out<"x.bookings.book">;
55
+ export type CancelResult = Out<"x.bookings.cancel">;
56
+ export type DayView = Out<"x.bookings.day">;
57
+ export type ClassListView = Out<"x.bookings.classList">;
58
+ export type BookForResult = Out<"x.bookings.bookFor">;
59
+ export type FoundPeople = Out<"x.bookings.findPeople">;
60
+ /** The client of every operation this entry calls (ADR 0453). */
61
+ export type BookingsClient = PackClient<BookingsOperations>;
62
+ /** A class's start and end in its own zone ("Tue 3 Mar, 06:00–07:00"), for display. */
63
+ export declare function classTime(klass: {
64
+ startsAt: string | null;
65
+ endsAt: string | null;
66
+ timeZone: string | null;
67
+ }, locale?: string): string;
68
+ /** What a class's places say ("5 places left", "Full"), from the host's numbers. */
69
+ export declare function placesLabel(places: TimetableClass["places"]): string;
70
+ /** The message to show for a refusal the host gave (with when booking opens, if it said). */
71
+ export declare function refusalMessage(result: {
72
+ message: string;
73
+ opensAt: string | null;
74
+ reason: string;
75
+ }, zone: string | null, locale?: string): string;
76
+ /** The member's live booking of a class, if any (to show Cancel instead of Book). */
77
+ export declare function bookingFor(classId: string, bookings: readonly MyBooking[] | undefined): MyBooking | undefined;
78
+ /** The app's `useQuery`, as far as these hooks use it. */
79
+ export type UseQuery = <T>(options: {
80
+ queryKey: readonly unknown[];
81
+ queryFn: () => Promise<T>;
82
+ enabled?: boolean;
83
+ }) => {
84
+ data: T | undefined;
85
+ isPending: boolean;
86
+ error: unknown;
87
+ refetch?: () => unknown;
88
+ };
89
+ /** The app's `useMutation`, as far as these hooks use it. */
90
+ export type UseMutation = <I, O>(options: {
91
+ mutationKey: readonly unknown[];
92
+ mutationFn: (input: I) => Promise<O>;
93
+ }) => {
94
+ mutate(input: I): void;
95
+ mutateAsync(input: I): Promise<O>;
96
+ data: O | undefined;
97
+ isPending: boolean;
98
+ error: unknown;
99
+ };
100
+ /**
101
+ * The operations each hook calls (ADR 0453). A customer's client gets the member's hooks (the
102
+ * timetable, book, cancel, mine), the public's only the timetable and a class, the staff client
103
+ * all of them.
104
+ */
105
+ export declare const BOOKINGS_HOOKS_CALL: {
106
+ readonly useTimetable: readonly ["x.bookings.timetable"];
107
+ readonly useClass: readonly ["x.bookings.classGet"];
108
+ readonly useMyBookings: readonly ["x.bookings.mine"];
109
+ readonly useBook: readonly ["x.bookings.book"];
110
+ readonly useCancel: readonly ["x.bookings.cancel"];
111
+ readonly useDay: readonly ["x.bookings.day"];
112
+ readonly useClassList: readonly ["x.bookings.classList"];
113
+ readonly useBookFor: readonly ["x.bookings.bookFor"];
114
+ readonly useCancelFor: readonly ["x.bookings.cancelFor"];
115
+ readonly useReturnUse: readonly ["x.bookings.returnUse"];
116
+ readonly useFindPeople: readonly ["x.bookings.findPeople"];
117
+ };
118
+ /**
119
+ * Hooks for a React or React Native app:
120
+ * `const bookings = createBookingsHooks({ useQuery, useMutation }, api)`. `api` is any generated
121
+ * client: the customer's or the staff one. The hooks it cannot back are not there.
122
+ */
123
+ export declare function createBookingsHooks<C extends ClientHolding>(react: {
124
+ useQuery: UseQuery;
125
+ useMutation: UseMutation;
126
+ }, client: C): import("@composable-os/client").HooksFor<{
127
+ /** The timetable between two times (default: the next 7 days). */
128
+ useTimetable(input?: In<"x.bookings.timetable">): {
129
+ data: {
130
+ classes: {
131
+ id: string;
132
+ title: string | null;
133
+ classType: string | null;
134
+ startsAt: string | null;
135
+ endsAt: string | null;
136
+ timeZone: string | null;
137
+ room: {
138
+ id: string;
139
+ name: string | null;
140
+ } | null;
141
+ coach: ({
142
+ id: string;
143
+ name: string | null;
144
+ } & {
145
+ photo?: string | null | undefined;
146
+ }) | null;
147
+ notes: string | null;
148
+ places: {
149
+ status: "available" | "low" | "sold_out";
150
+ available?: number | null | undefined;
151
+ };
152
+ }[];
153
+ } | undefined;
154
+ isPending: boolean;
155
+ error: unknown;
156
+ refetch?: () => unknown;
157
+ };
158
+ /** One scheduled class. */
159
+ useClass(input: In<"x.bookings.classGet">): {
160
+ data: {
161
+ class: {
162
+ id: string;
163
+ title: string | null;
164
+ classType: string | null;
165
+ startsAt: string | null;
166
+ endsAt: string | null;
167
+ timeZone: string | null;
168
+ room: {
169
+ id: string;
170
+ name: string | null;
171
+ } | null;
172
+ coach: ({
173
+ id: string;
174
+ name: string | null;
175
+ } & {
176
+ photo?: string | null | undefined;
177
+ }) | null;
178
+ notes: string | null;
179
+ places: {
180
+ status: "available" | "low" | "sold_out";
181
+ available?: number | null | undefined;
182
+ };
183
+ };
184
+ } | undefined;
185
+ isPending: boolean;
186
+ error: unknown;
187
+ refetch?: () => unknown;
188
+ };
189
+ /** The signed-in member's own bookings. */
190
+ useMyBookings(input?: In<"x.bookings.mine">): {
191
+ data: {
192
+ bookings: {
193
+ id: string;
194
+ state: string | null;
195
+ holderId: string | null;
196
+ classId: string | null;
197
+ title: string | null;
198
+ startsAt: string | null;
199
+ endsAt: string | null;
200
+ timeZone: string | null;
201
+ classState: string | null;
202
+ coach: string | null;
203
+ room: string | null;
204
+ }[];
205
+ } | undefined;
206
+ isPending: boolean;
207
+ error: unknown;
208
+ refetch?: () => unknown;
209
+ };
210
+ /** Books the member into a class; the host answers booked or why not. */
211
+ useBook(): {
212
+ mutate(input: {
213
+ classId: string;
214
+ holderId?: string | undefined;
215
+ }): void;
216
+ mutateAsync(input: {
217
+ classId: string;
218
+ holderId?: string | undefined;
219
+ }): Promise<{
220
+ result: "refused";
221
+ reason: "not_open" | "closed" | "staff_only" | "no_use" | "already_booked" | "full" | "too_late" | "not_found" | "changed" | "not_running" | "person_exists" | "possible_duplicates";
222
+ message: string;
223
+ detail: string | null;
224
+ opensAt: string | null;
225
+ closesAt: string | null;
226
+ people?: {
227
+ id: string;
228
+ name: string;
229
+ reasons: string[];
230
+ }[] | undefined;
231
+ } | {
232
+ result: "booked";
233
+ bookingId: string;
234
+ classId: string;
235
+ holderId: string | null;
236
+ }>;
237
+ data: {
238
+ result: "refused";
239
+ reason: "not_open" | "closed" | "staff_only" | "no_use" | "already_booked" | "full" | "too_late" | "not_found" | "changed" | "not_running" | "person_exists" | "possible_duplicates";
240
+ message: string;
241
+ detail: string | null;
242
+ opensAt: string | null;
243
+ closesAt: string | null;
244
+ people?: {
245
+ id: string;
246
+ name: string;
247
+ reasons: string[];
248
+ }[] | undefined;
249
+ } | {
250
+ result: "booked";
251
+ bookingId: string;
252
+ classId: string;
253
+ holderId: string | null;
254
+ } | undefined;
255
+ isPending: boolean;
256
+ error: unknown;
257
+ };
258
+ /** Cancels a booking: first the host's preview (in time or late), then with confirm. */
259
+ useCancel(): {
260
+ mutate(input: {
261
+ bookingId: string;
262
+ confirm?: boolean | undefined;
263
+ expect?: "cancelled" | "late_cancelled" | undefined;
264
+ }): void;
265
+ mutateAsync(input: {
266
+ bookingId: string;
267
+ confirm?: boolean | undefined;
268
+ expect?: "cancelled" | "late_cancelled" | undefined;
269
+ }): Promise<{
270
+ result: "refused";
271
+ reason: "not_open" | "closed" | "staff_only" | "no_use" | "already_booked" | "full" | "too_late" | "not_found" | "changed" | "not_running" | "person_exists" | "possible_duplicates";
272
+ message: string;
273
+ detail: string | null;
274
+ opensAt: string | null;
275
+ closesAt: string | null;
276
+ people?: {
277
+ id: string;
278
+ name: string;
279
+ reasons: string[];
280
+ }[] | undefined;
281
+ } | {
282
+ result: "cancelled" | "late_cancelled" | "preview";
283
+ state: "cancelled" | "late_cancelled";
284
+ late: boolean;
285
+ message: string;
286
+ }>;
287
+ data: {
288
+ result: "refused";
289
+ reason: "not_open" | "closed" | "staff_only" | "no_use" | "already_booked" | "full" | "too_late" | "not_found" | "changed" | "not_running" | "person_exists" | "possible_duplicates";
290
+ message: string;
291
+ detail: string | null;
292
+ opensAt: string | null;
293
+ closesAt: string | null;
294
+ people?: {
295
+ id: string;
296
+ name: string;
297
+ reasons: string[];
298
+ }[] | undefined;
299
+ } | {
300
+ result: "cancelled" | "late_cancelled" | "preview";
301
+ state: "cancelled" | "late_cancelled";
302
+ late: boolean;
303
+ message: string;
304
+ } | undefined;
305
+ isPending: boolean;
306
+ error: unknown;
307
+ };
308
+ /** Staff: one local date's classes. */
309
+ useDay(input: In<"x.bookings.day">): {
310
+ data: {
311
+ date: string;
312
+ classes: {
313
+ id: string;
314
+ title: string | null;
315
+ classType: {
316
+ id: string;
317
+ name: string | null;
318
+ } | null;
319
+ startsAt: string | null;
320
+ endsAt: string | null;
321
+ timeZone: string | null;
322
+ coach: string | null;
323
+ room: string | null;
324
+ places: number | null;
325
+ booked: number;
326
+ held: number;
327
+ available: number | null;
328
+ state: string | null;
329
+ staffOnly: boolean;
330
+ }[];
331
+ } | undefined;
332
+ isPending: boolean;
333
+ error: unknown;
334
+ refetch?: () => unknown;
335
+ };
336
+ /** Staff: a class's list. */
337
+ useClassList(input: In<"x.bookings.classList">): {
338
+ data: {
339
+ class: {
340
+ id: string;
341
+ title: string | null;
342
+ classType: {
343
+ id: string;
344
+ name: string | null;
345
+ } | null;
346
+ startsAt: string | null;
347
+ endsAt: string | null;
348
+ timeZone: string | null;
349
+ coach: string | null;
350
+ room: string | null;
351
+ places: number | null;
352
+ booked: number;
353
+ held: number;
354
+ available: number | null;
355
+ state: string | null;
356
+ staffOnly: boolean;
357
+ };
358
+ bookings: {
359
+ id: string;
360
+ person: {
361
+ id: string;
362
+ name: string | null;
363
+ } | null;
364
+ state: string | null;
365
+ paidAtDesk: boolean;
366
+ holderId: string | null;
367
+ bookedBy: string | null;
368
+ }[];
369
+ } | undefined;
370
+ isPending: boolean;
371
+ error: unknown;
372
+ refetch?: () => unknown;
373
+ };
374
+ /** Staff: book anyone, a walk-in included. */
375
+ useBookFor(): {
376
+ mutate(input: {
377
+ classId: string;
378
+ personId?: string | undefined;
379
+ newPerson?: {
380
+ givenName: string;
381
+ familyName?: string | undefined;
382
+ email?: string | undefined;
383
+ } | undefined;
384
+ confirmNew?: boolean | undefined;
385
+ holderId?: string | undefined;
386
+ paidAtDesk?: boolean | undefined;
387
+ note?: string | undefined;
388
+ }): void;
389
+ mutateAsync(input: {
390
+ classId: string;
391
+ personId?: string | undefined;
392
+ newPerson?: {
393
+ givenName: string;
394
+ familyName?: string | undefined;
395
+ email?: string | undefined;
396
+ } | undefined;
397
+ confirmNew?: boolean | undefined;
398
+ holderId?: string | undefined;
399
+ paidAtDesk?: boolean | undefined;
400
+ note?: string | undefined;
401
+ }): Promise<{
402
+ result: "refused";
403
+ reason: "not_open" | "closed" | "staff_only" | "no_use" | "already_booked" | "full" | "too_late" | "not_found" | "changed" | "not_running" | "person_exists" | "possible_duplicates";
404
+ message: string;
405
+ detail: string | null;
406
+ opensAt: string | null;
407
+ closesAt: string | null;
408
+ people?: {
409
+ id: string;
410
+ name: string;
411
+ reasons: string[];
412
+ }[] | undefined;
413
+ } | {
414
+ result: "booked";
415
+ bookingId: string;
416
+ classId: string;
417
+ holderId: string | null;
418
+ personId: string;
419
+ }>;
420
+ data: {
421
+ result: "refused";
422
+ reason: "not_open" | "closed" | "staff_only" | "no_use" | "already_booked" | "full" | "too_late" | "not_found" | "changed" | "not_running" | "person_exists" | "possible_duplicates";
423
+ message: string;
424
+ detail: string | null;
425
+ opensAt: string | null;
426
+ closesAt: string | null;
427
+ people?: {
428
+ id: string;
429
+ name: string;
430
+ reasons: string[];
431
+ }[] | undefined;
432
+ } | {
433
+ result: "booked";
434
+ bookingId: string;
435
+ classId: string;
436
+ holderId: string | null;
437
+ personId: string;
438
+ } | undefined;
439
+ isPending: boolean;
440
+ error: unknown;
441
+ };
442
+ /** Staff: cancel a booking, in time or late by the host's clock. */
443
+ useCancelFor(): {
444
+ mutate(input: {
445
+ bookingId: string;
446
+ keepUse?: boolean | undefined;
447
+ note?: string | undefined;
448
+ }): void;
449
+ mutateAsync(input: {
450
+ bookingId: string;
451
+ keepUse?: boolean | undefined;
452
+ note?: string | undefined;
453
+ }): Promise<{
454
+ result: "refused";
455
+ reason: "not_open" | "closed" | "staff_only" | "no_use" | "already_booked" | "full" | "too_late" | "not_found" | "changed" | "not_running" | "person_exists" | "possible_duplicates";
456
+ message: string;
457
+ detail: string | null;
458
+ opensAt: string | null;
459
+ closesAt: string | null;
460
+ people?: {
461
+ id: string;
462
+ name: string;
463
+ reasons: string[];
464
+ }[] | undefined;
465
+ } | {
466
+ result: "cancelled" | "late_cancelled";
467
+ bookingId: string;
468
+ late: boolean;
469
+ }>;
470
+ data: {
471
+ result: "refused";
472
+ reason: "not_open" | "closed" | "staff_only" | "no_use" | "already_booked" | "full" | "too_late" | "not_found" | "changed" | "not_running" | "person_exists" | "possible_duplicates";
473
+ message: string;
474
+ detail: string | null;
475
+ opensAt: string | null;
476
+ closesAt: string | null;
477
+ people?: {
478
+ id: string;
479
+ name: string;
480
+ reasons: string[];
481
+ }[] | undefined;
482
+ } | {
483
+ result: "cancelled" | "late_cancelled";
484
+ bookingId: string;
485
+ late: boolean;
486
+ } | undefined;
487
+ isPending: boolean;
488
+ error: unknown;
489
+ };
490
+ /** A person on the staff: give a booking's use back after the late point (destructive). */
491
+ useReturnUse(): {
492
+ mutate(input: {
493
+ bookingId: string;
494
+ reason: string;
495
+ }): void;
496
+ mutateAsync(input: {
497
+ bookingId: string;
498
+ reason: string;
499
+ }): Promise<{
500
+ result: "refused";
501
+ reason: "not_open" | "closed" | "staff_only" | "no_use" | "already_booked" | "full" | "too_late" | "not_found" | "changed" | "not_running" | "person_exists" | "possible_duplicates";
502
+ message: string;
503
+ detail: string | null;
504
+ opensAt: string | null;
505
+ closesAt: string | null;
506
+ people?: {
507
+ id: string;
508
+ name: string;
509
+ reasons: string[];
510
+ }[] | undefined;
511
+ } | {
512
+ result: "excused";
513
+ bookingId: string;
514
+ late: false;
515
+ }>;
516
+ data: {
517
+ result: "refused";
518
+ reason: "not_open" | "closed" | "staff_only" | "no_use" | "already_booked" | "full" | "too_late" | "not_found" | "changed" | "not_running" | "person_exists" | "possible_duplicates";
519
+ message: string;
520
+ detail: string | null;
521
+ opensAt: string | null;
522
+ closesAt: string | null;
523
+ people?: {
524
+ id: string;
525
+ name: string;
526
+ reasons: string[];
527
+ }[] | undefined;
528
+ } | {
529
+ result: "excused";
530
+ bookingId: string;
531
+ late: false;
532
+ } | undefined;
533
+ isPending: boolean;
534
+ error: unknown;
535
+ };
536
+ /** Staff: People on file matching a name or email (at least two letters). */
537
+ useFindPeople(input: In<"x.bookings.findPeople">): {
538
+ data: {
539
+ people: {
540
+ id: string;
541
+ name: string | null;
542
+ email: string | null;
543
+ }[];
544
+ } | undefined;
545
+ isPending: boolean;
546
+ error: unknown;
547
+ refetch?: () => unknown;
548
+ };
549
+ }, {
550
+ readonly useTimetable: readonly ["x.bookings.timetable"];
551
+ readonly useClass: readonly ["x.bookings.classGet"];
552
+ readonly useMyBookings: readonly ["x.bookings.mine"];
553
+ readonly useBook: readonly ["x.bookings.book"];
554
+ readonly useCancel: readonly ["x.bookings.cancel"];
555
+ readonly useDay: readonly ["x.bookings.day"];
556
+ readonly useClassList: readonly ["x.bookings.classList"];
557
+ readonly useBookFor: readonly ["x.bookings.bookFor"];
558
+ readonly useCancelFor: readonly ["x.bookings.cancelFor"];
559
+ readonly useReturnUse: readonly ["x.bookings.returnUse"];
560
+ readonly useFindPeople: readonly ["x.bookings.findPeople"];
561
+ }, import("@composable-os/client").OperationsOf<C>>;
562
+ declare function allBookingsHooks(react: {
563
+ useQuery: UseQuery;
564
+ useMutation: UseMutation;
565
+ }, api: BookingsClient): {
566
+ /** The timetable between two times (default: the next 7 days). */
567
+ useTimetable(input?: In<"x.bookings.timetable">): {
568
+ data: {
569
+ classes: {
570
+ id: string;
571
+ title: string | null;
572
+ classType: string | null;
573
+ startsAt: string | null;
574
+ endsAt: string | null;
575
+ timeZone: string | null;
576
+ room: {
577
+ id: string;
578
+ name: string | null;
579
+ } | null;
580
+ coach: ({
581
+ id: string;
582
+ name: string | null;
583
+ } & {
584
+ photo?: string | null | undefined;
585
+ }) | null;
586
+ notes: string | null;
587
+ places: {
588
+ status: "available" | "low" | "sold_out";
589
+ available?: number | null | undefined;
590
+ };
591
+ }[];
592
+ } | undefined;
593
+ isPending: boolean;
594
+ error: unknown;
595
+ refetch?: () => unknown;
596
+ };
597
+ /** One scheduled class. */
598
+ useClass(input: In<"x.bookings.classGet">): {
599
+ data: {
600
+ class: {
601
+ id: string;
602
+ title: string | null;
603
+ classType: string | null;
604
+ startsAt: string | null;
605
+ endsAt: string | null;
606
+ timeZone: string | null;
607
+ room: {
608
+ id: string;
609
+ name: string | null;
610
+ } | null;
611
+ coach: ({
612
+ id: string;
613
+ name: string | null;
614
+ } & {
615
+ photo?: string | null | undefined;
616
+ }) | null;
617
+ notes: string | null;
618
+ places: {
619
+ status: "available" | "low" | "sold_out";
620
+ available?: number | null | undefined;
621
+ };
622
+ };
623
+ } | undefined;
624
+ isPending: boolean;
625
+ error: unknown;
626
+ refetch?: () => unknown;
627
+ };
628
+ /** The signed-in member's own bookings. */
629
+ useMyBookings(input?: In<"x.bookings.mine">): {
630
+ data: {
631
+ bookings: {
632
+ id: string;
633
+ state: string | null;
634
+ holderId: string | null;
635
+ classId: string | null;
636
+ title: string | null;
637
+ startsAt: string | null;
638
+ endsAt: string | null;
639
+ timeZone: string | null;
640
+ classState: string | null;
641
+ coach: string | null;
642
+ room: string | null;
643
+ }[];
644
+ } | undefined;
645
+ isPending: boolean;
646
+ error: unknown;
647
+ refetch?: () => unknown;
648
+ };
649
+ /** Books the member into a class; the host answers booked or why not. */
650
+ useBook(): {
651
+ mutate(input: {
652
+ classId: string;
653
+ holderId?: string | undefined;
654
+ }): void;
655
+ mutateAsync(input: {
656
+ classId: string;
657
+ holderId?: string | undefined;
658
+ }): Promise<{
659
+ result: "refused";
660
+ reason: "not_open" | "closed" | "staff_only" | "no_use" | "already_booked" | "full" | "too_late" | "not_found" | "changed" | "not_running" | "person_exists" | "possible_duplicates";
661
+ message: string;
662
+ detail: string | null;
663
+ opensAt: string | null;
664
+ closesAt: string | null;
665
+ people?: {
666
+ id: string;
667
+ name: string;
668
+ reasons: string[];
669
+ }[] | undefined;
670
+ } | {
671
+ result: "booked";
672
+ bookingId: string;
673
+ classId: string;
674
+ holderId: string | null;
675
+ }>;
676
+ data: {
677
+ result: "refused";
678
+ reason: "not_open" | "closed" | "staff_only" | "no_use" | "already_booked" | "full" | "too_late" | "not_found" | "changed" | "not_running" | "person_exists" | "possible_duplicates";
679
+ message: string;
680
+ detail: string | null;
681
+ opensAt: string | null;
682
+ closesAt: string | null;
683
+ people?: {
684
+ id: string;
685
+ name: string;
686
+ reasons: string[];
687
+ }[] | undefined;
688
+ } | {
689
+ result: "booked";
690
+ bookingId: string;
691
+ classId: string;
692
+ holderId: string | null;
693
+ } | undefined;
694
+ isPending: boolean;
695
+ error: unknown;
696
+ };
697
+ /** Cancels a booking: first the host's preview (in time or late), then with confirm. */
698
+ useCancel(): {
699
+ mutate(input: {
700
+ bookingId: string;
701
+ confirm?: boolean | undefined;
702
+ expect?: "cancelled" | "late_cancelled" | undefined;
703
+ }): void;
704
+ mutateAsync(input: {
705
+ bookingId: string;
706
+ confirm?: boolean | undefined;
707
+ expect?: "cancelled" | "late_cancelled" | undefined;
708
+ }): Promise<{
709
+ result: "refused";
710
+ reason: "not_open" | "closed" | "staff_only" | "no_use" | "already_booked" | "full" | "too_late" | "not_found" | "changed" | "not_running" | "person_exists" | "possible_duplicates";
711
+ message: string;
712
+ detail: string | null;
713
+ opensAt: string | null;
714
+ closesAt: string | null;
715
+ people?: {
716
+ id: string;
717
+ name: string;
718
+ reasons: string[];
719
+ }[] | undefined;
720
+ } | {
721
+ result: "cancelled" | "late_cancelled" | "preview";
722
+ state: "cancelled" | "late_cancelled";
723
+ late: boolean;
724
+ message: string;
725
+ }>;
726
+ data: {
727
+ result: "refused";
728
+ reason: "not_open" | "closed" | "staff_only" | "no_use" | "already_booked" | "full" | "too_late" | "not_found" | "changed" | "not_running" | "person_exists" | "possible_duplicates";
729
+ message: string;
730
+ detail: string | null;
731
+ opensAt: string | null;
732
+ closesAt: string | null;
733
+ people?: {
734
+ id: string;
735
+ name: string;
736
+ reasons: string[];
737
+ }[] | undefined;
738
+ } | {
739
+ result: "cancelled" | "late_cancelled" | "preview";
740
+ state: "cancelled" | "late_cancelled";
741
+ late: boolean;
742
+ message: string;
743
+ } | undefined;
744
+ isPending: boolean;
745
+ error: unknown;
746
+ };
747
+ /** Staff: one local date's classes. */
748
+ useDay(input: In<"x.bookings.day">): {
749
+ data: {
750
+ date: string;
751
+ classes: {
752
+ id: string;
753
+ title: string | null;
754
+ classType: {
755
+ id: string;
756
+ name: string | null;
757
+ } | null;
758
+ startsAt: string | null;
759
+ endsAt: string | null;
760
+ timeZone: string | null;
761
+ coach: string | null;
762
+ room: string | null;
763
+ places: number | null;
764
+ booked: number;
765
+ held: number;
766
+ available: number | null;
767
+ state: string | null;
768
+ staffOnly: boolean;
769
+ }[];
770
+ } | undefined;
771
+ isPending: boolean;
772
+ error: unknown;
773
+ refetch?: () => unknown;
774
+ };
775
+ /** Staff: a class's list. */
776
+ useClassList(input: In<"x.bookings.classList">): {
777
+ data: {
778
+ class: {
779
+ id: string;
780
+ title: string | null;
781
+ classType: {
782
+ id: string;
783
+ name: string | null;
784
+ } | null;
785
+ startsAt: string | null;
786
+ endsAt: string | null;
787
+ timeZone: string | null;
788
+ coach: string | null;
789
+ room: string | null;
790
+ places: number | null;
791
+ booked: number;
792
+ held: number;
793
+ available: number | null;
794
+ state: string | null;
795
+ staffOnly: boolean;
796
+ };
797
+ bookings: {
798
+ id: string;
799
+ person: {
800
+ id: string;
801
+ name: string | null;
802
+ } | null;
803
+ state: string | null;
804
+ paidAtDesk: boolean;
805
+ holderId: string | null;
806
+ bookedBy: string | null;
807
+ }[];
808
+ } | undefined;
809
+ isPending: boolean;
810
+ error: unknown;
811
+ refetch?: () => unknown;
812
+ };
813
+ /** Staff: book anyone, a walk-in included. */
814
+ useBookFor(): {
815
+ mutate(input: {
816
+ classId: string;
817
+ personId?: string | undefined;
818
+ newPerson?: {
819
+ givenName: string;
820
+ familyName?: string | undefined;
821
+ email?: string | undefined;
822
+ } | undefined;
823
+ confirmNew?: boolean | undefined;
824
+ holderId?: string | undefined;
825
+ paidAtDesk?: boolean | undefined;
826
+ note?: string | undefined;
827
+ }): void;
828
+ mutateAsync(input: {
829
+ classId: string;
830
+ personId?: string | undefined;
831
+ newPerson?: {
832
+ givenName: string;
833
+ familyName?: string | undefined;
834
+ email?: string | undefined;
835
+ } | undefined;
836
+ confirmNew?: boolean | undefined;
837
+ holderId?: string | undefined;
838
+ paidAtDesk?: boolean | undefined;
839
+ note?: string | undefined;
840
+ }): Promise<{
841
+ result: "refused";
842
+ reason: "not_open" | "closed" | "staff_only" | "no_use" | "already_booked" | "full" | "too_late" | "not_found" | "changed" | "not_running" | "person_exists" | "possible_duplicates";
843
+ message: string;
844
+ detail: string | null;
845
+ opensAt: string | null;
846
+ closesAt: string | null;
847
+ people?: {
848
+ id: string;
849
+ name: string;
850
+ reasons: string[];
851
+ }[] | undefined;
852
+ } | {
853
+ result: "booked";
854
+ bookingId: string;
855
+ classId: string;
856
+ holderId: string | null;
857
+ personId: string;
858
+ }>;
859
+ data: {
860
+ result: "refused";
861
+ reason: "not_open" | "closed" | "staff_only" | "no_use" | "already_booked" | "full" | "too_late" | "not_found" | "changed" | "not_running" | "person_exists" | "possible_duplicates";
862
+ message: string;
863
+ detail: string | null;
864
+ opensAt: string | null;
865
+ closesAt: string | null;
866
+ people?: {
867
+ id: string;
868
+ name: string;
869
+ reasons: string[];
870
+ }[] | undefined;
871
+ } | {
872
+ result: "booked";
873
+ bookingId: string;
874
+ classId: string;
875
+ holderId: string | null;
876
+ personId: string;
877
+ } | undefined;
878
+ isPending: boolean;
879
+ error: unknown;
880
+ };
881
+ /** Staff: cancel a booking, in time or late by the host's clock. */
882
+ useCancelFor(): {
883
+ mutate(input: {
884
+ bookingId: string;
885
+ keepUse?: boolean | undefined;
886
+ note?: string | undefined;
887
+ }): void;
888
+ mutateAsync(input: {
889
+ bookingId: string;
890
+ keepUse?: boolean | undefined;
891
+ note?: string | undefined;
892
+ }): Promise<{
893
+ result: "refused";
894
+ reason: "not_open" | "closed" | "staff_only" | "no_use" | "already_booked" | "full" | "too_late" | "not_found" | "changed" | "not_running" | "person_exists" | "possible_duplicates";
895
+ message: string;
896
+ detail: string | null;
897
+ opensAt: string | null;
898
+ closesAt: string | null;
899
+ people?: {
900
+ id: string;
901
+ name: string;
902
+ reasons: string[];
903
+ }[] | undefined;
904
+ } | {
905
+ result: "cancelled" | "late_cancelled";
906
+ bookingId: string;
907
+ late: boolean;
908
+ }>;
909
+ data: {
910
+ result: "refused";
911
+ reason: "not_open" | "closed" | "staff_only" | "no_use" | "already_booked" | "full" | "too_late" | "not_found" | "changed" | "not_running" | "person_exists" | "possible_duplicates";
912
+ message: string;
913
+ detail: string | null;
914
+ opensAt: string | null;
915
+ closesAt: string | null;
916
+ people?: {
917
+ id: string;
918
+ name: string;
919
+ reasons: string[];
920
+ }[] | undefined;
921
+ } | {
922
+ result: "cancelled" | "late_cancelled";
923
+ bookingId: string;
924
+ late: boolean;
925
+ } | undefined;
926
+ isPending: boolean;
927
+ error: unknown;
928
+ };
929
+ /** A person on the staff: give a booking's use back after the late point (destructive). */
930
+ useReturnUse(): {
931
+ mutate(input: {
932
+ bookingId: string;
933
+ reason: string;
934
+ }): void;
935
+ mutateAsync(input: {
936
+ bookingId: string;
937
+ reason: string;
938
+ }): Promise<{
939
+ result: "refused";
940
+ reason: "not_open" | "closed" | "staff_only" | "no_use" | "already_booked" | "full" | "too_late" | "not_found" | "changed" | "not_running" | "person_exists" | "possible_duplicates";
941
+ message: string;
942
+ detail: string | null;
943
+ opensAt: string | null;
944
+ closesAt: string | null;
945
+ people?: {
946
+ id: string;
947
+ name: string;
948
+ reasons: string[];
949
+ }[] | undefined;
950
+ } | {
951
+ result: "excused";
952
+ bookingId: string;
953
+ late: false;
954
+ }>;
955
+ data: {
956
+ result: "refused";
957
+ reason: "not_open" | "closed" | "staff_only" | "no_use" | "already_booked" | "full" | "too_late" | "not_found" | "changed" | "not_running" | "person_exists" | "possible_duplicates";
958
+ message: string;
959
+ detail: string | null;
960
+ opensAt: string | null;
961
+ closesAt: string | null;
962
+ people?: {
963
+ id: string;
964
+ name: string;
965
+ reasons: string[];
966
+ }[] | undefined;
967
+ } | {
968
+ result: "excused";
969
+ bookingId: string;
970
+ late: false;
971
+ } | undefined;
972
+ isPending: boolean;
973
+ error: unknown;
974
+ };
975
+ /** Staff: People on file matching a name or email (at least two letters). */
976
+ useFindPeople(input: In<"x.bookings.findPeople">): {
977
+ data: {
978
+ people: {
979
+ id: string;
980
+ name: string | null;
981
+ email: string | null;
982
+ }[];
983
+ } | undefined;
984
+ isPending: boolean;
985
+ error: unknown;
986
+ refetch?: () => unknown;
987
+ };
988
+ };
989
+ /** Every hook of this entry. A block takes the ones it calls: `Pick<BookingsHooks, "useBook">`. */
990
+ export type BookingsHooks = ReturnType<typeof allBookingsHooks>;
991
+ export {};