@composable-os/pack-bookings 0.1.0-beta.10 → 0.1.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocks/bookings-class-list/class-list.d.ts +7 -0
- package/dist/blocks/bookings-class-list/class-list.js +37 -0
- package/dist/blocks/bookings-desk/desk.js +4 -0
- package/dist/blocks/bookings-drop-in/drop-in.d.ts +22 -0
- package/dist/blocks/bookings-drop-in/drop-in.js +54 -0
- package/dist/blocks/bookings-native-timetable/timetable-screen.d.ts +1 -1
- package/dist/blocks/bookings-native-timetable/timetable-screen.js +18 -6
- package/dist/blocks/bookings-timetable/timetable.d.ts +4 -2
- package/dist/blocks/bookings-timetable/timetable.js +39 -8
- package/dist/client/index.d.ts +1210 -162
- package/dist/client/index.js +74 -2
- package/dist/index.d.ts +555 -12
- package/dist/index.js +338 -34
- package/dist/tools.d.ts +338 -0
- package/dist/tools.js +887 -62
- package/package.json +3 -3
package/dist/client/index.js
CHANGED
|
@@ -53,6 +53,21 @@ export function refusalMessage(result, zone, locale = "en-AU") {
|
|
|
53
53
|
}
|
|
54
54
|
return result.message;
|
|
55
55
|
}
|
|
56
|
+
/** The digits of a currency's minor unit (2 for AUD, 0 for JPY). */
|
|
57
|
+
function currencyDigits(currency) {
|
|
58
|
+
try {
|
|
59
|
+
return (new Intl.NumberFormat("en", { style: "currency", currency }).resolvedOptions()
|
|
60
|
+
.maximumFractionDigits ?? 2);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return 2;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** An amount the host gave in the minor unit, as a buyer reads it: `25.00 AUD`. Display only. */
|
|
67
|
+
export function formatAmount(minor, currency) {
|
|
68
|
+
const digits = currencyDigits(currency);
|
|
69
|
+
return `${(minor / 10 ** digits).toFixed(digits)} ${currency}`;
|
|
70
|
+
}
|
|
56
71
|
/** The member's live booking of a class, if any (to show Cancel instead of Book). */
|
|
57
72
|
export function bookingFor(classId, bookings) {
|
|
58
73
|
return bookings?.find((b) => b.classId === classId && b.state === "booked");
|
|
@@ -66,14 +81,25 @@ export const BOOKINGS_HOOKS_CALL = {
|
|
|
66
81
|
useTimetable: ["x.bookings.timetable"],
|
|
67
82
|
useClass: ["x.bookings.classGet"],
|
|
68
83
|
useMyBookings: ["x.bookings.mine"],
|
|
84
|
+
useFamily: ["x.bookings.family"],
|
|
69
85
|
useBook: ["x.bookings.book"],
|
|
70
86
|
useCancel: ["x.bookings.cancel"],
|
|
87
|
+
useLeaveWaitlist: ["x.bookings.leaveWaitlist"],
|
|
71
88
|
useDay: ["x.bookings.day"],
|
|
72
89
|
useClassList: ["x.bookings.classList"],
|
|
73
90
|
useBookFor: ["x.bookings.bookFor"],
|
|
74
91
|
useCancelFor: ["x.bookings.cancelFor"],
|
|
75
92
|
useReturnUse: ["x.bookings.returnUse"],
|
|
76
93
|
useFindPeople: ["x.bookings.findPeople"],
|
|
94
|
+
// Paying for one class (a drop-in): a purchase, so web only (native blocks are noPurchase).
|
|
95
|
+
useBuy: ["x.bookings.buy", "order.checkout"],
|
|
96
|
+
useRoster: ["x.bookings.roster"],
|
|
97
|
+
useMarkAttended: ["x.bookings.markAttended"],
|
|
98
|
+
useUndoAttended: ["x.bookings.undoAttended"],
|
|
99
|
+
useMarkNoShow: ["x.bookings.markNoShow"],
|
|
100
|
+
useMarkAll: ["x.bookings.markAll"],
|
|
101
|
+
useMove: ["x.bookings.move"],
|
|
102
|
+
useCancelClass: ["x.bookings.cancelClass"],
|
|
77
103
|
};
|
|
78
104
|
/**
|
|
79
105
|
* Hooks for a React or React Native app:
|
|
@@ -94,11 +120,15 @@ function allBookingsHooks(react, api) {
|
|
|
94
120
|
useClass(input) {
|
|
95
121
|
return useQuery(api.query("x.bookings.classGet", input));
|
|
96
122
|
},
|
|
97
|
-
/** The signed-in member's own bookings. */
|
|
123
|
+
/** The signed-in member's own bookings, or (with personId) a child's linked to them. */
|
|
98
124
|
useMyBookings(input = {}) {
|
|
99
125
|
return useQuery(api.query("x.bookings.mine", input));
|
|
100
126
|
},
|
|
101
|
-
/**
|
|
127
|
+
/** Who the member may book for: themselves and the children staff linked to them. */
|
|
128
|
+
useFamily() {
|
|
129
|
+
return useQuery(api.query("x.bookings.family", {}));
|
|
130
|
+
},
|
|
131
|
+
/** Books the member into a class; the host answers booked, waiting (full) or why not. */
|
|
102
132
|
useBook() {
|
|
103
133
|
return useMutation(api.mutation("x.bookings.book"));
|
|
104
134
|
},
|
|
@@ -106,6 +136,10 @@ function allBookingsHooks(react, api) {
|
|
|
106
136
|
useCancel() {
|
|
107
137
|
return useMutation(api.mutation("x.bookings.cancel"));
|
|
108
138
|
},
|
|
139
|
+
/** Takes the member off a class's waitlist (a booking that is waiting). */
|
|
140
|
+
useLeaveWaitlist() {
|
|
141
|
+
return useMutation(api.mutation("x.bookings.leaveWaitlist"));
|
|
142
|
+
},
|
|
109
143
|
/** Staff: one local date's classes. */
|
|
110
144
|
useDay(input) {
|
|
111
145
|
return useQuery(api.query("x.bookings.day", input));
|
|
@@ -126,6 +160,16 @@ function allBookingsHooks(react, api) {
|
|
|
126
160
|
useReturnUse() {
|
|
127
161
|
return useMutation(api.mutation("x.bookings.returnUse"));
|
|
128
162
|
},
|
|
163
|
+
/**
|
|
164
|
+
* Pay for one class (a drop-in, web only): `start` has the host hold the place and start the
|
|
165
|
+
* order; `checkout` opens the provider's page for it.
|
|
166
|
+
*/
|
|
167
|
+
useBuy() {
|
|
168
|
+
return {
|
|
169
|
+
start: useMutation(api.mutation("x.bookings.buy")),
|
|
170
|
+
checkout: useMutation(api.mutation("order.checkout")),
|
|
171
|
+
};
|
|
172
|
+
},
|
|
129
173
|
/** Staff: People on file matching a name or email (at least two letters). */
|
|
130
174
|
useFindPeople(input) {
|
|
131
175
|
return useQuery({
|
|
@@ -133,5 +177,33 @@ function allBookingsHooks(react, api) {
|
|
|
133
177
|
enabled: input.query.trim().length >= 2,
|
|
134
178
|
});
|
|
135
179
|
},
|
|
180
|
+
/** A coach or staff: a class's list with names and marks (nothing of what anyone paid). */
|
|
181
|
+
useRoster(input) {
|
|
182
|
+
return useQuery(api.query("x.bookings.roster", input));
|
|
183
|
+
},
|
|
184
|
+
/** A coach or staff: tick a name; the host says if someone ticked it first, and who. */
|
|
185
|
+
useMarkAttended() {
|
|
186
|
+
return useMutation(api.mutation("x.bookings.markAttended"));
|
|
187
|
+
},
|
|
188
|
+
/** A coach or staff: untick a name ticked by mistake. */
|
|
189
|
+
useUndoAttended() {
|
|
190
|
+
return useMutation(api.mutation("x.bookings.undoAttended"));
|
|
191
|
+
},
|
|
192
|
+
/** A coach or staff: mark a name as not come, once the class has started. */
|
|
193
|
+
useMarkNoShow() {
|
|
194
|
+
return useMutation(api.mutation("x.bookings.markNoShow"));
|
|
195
|
+
},
|
|
196
|
+
/** A coach or staff: tick everyone still booked on a class. */
|
|
197
|
+
useMarkAll() {
|
|
198
|
+
return useMutation(api.mutation("x.bookings.markAll"));
|
|
199
|
+
},
|
|
200
|
+
/** Staff: move a booking to another class with its use (refused whole when it cannot). */
|
|
201
|
+
useMove() {
|
|
202
|
+
return useMutation(api.mutation("x.bookings.move"));
|
|
203
|
+
},
|
|
204
|
+
/** A person on the staff: cancel a class and its bookings (an AI's call waits for one). */
|
|
205
|
+
useCancelClass() {
|
|
206
|
+
return useMutation(api.mutation("x.bookings.cancelClass"));
|
|
207
|
+
},
|
|
136
208
|
};
|
|
137
209
|
}
|