@odla-ai/chapter 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -18
- package/dist/chunk-YO6DY5DL.js +281 -0
- package/dist/chunk-YO6DY5DL.js.map +1 -0
- package/dist/chunk-ZCZK6QLC.js +537 -0
- package/dist/chunk-ZCZK6QLC.js.map +1 -0
- package/dist/index.cjs +35 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -9
- package/dist/index.d.ts +46 -9
- package/dist/index.js +35 -5
- package/dist/index.js.map +1 -1
- package/dist/ui/admin/index.d.ts +71 -0
- package/dist/ui/admin/index.js +9 -0
- package/dist/ui/admin/index.js.map +1 -0
- package/dist/ui/index.d.ts +4 -219
- package/dist/ui/index.js +20 -795
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/member/index.d.ts +152 -0
- package/dist/ui/member/index.js +33 -0
- package/dist/ui/member/index.js.map +1 -0
- package/dist/worker/index.cjs +34 -6
- package/dist/worker/index.cjs.map +1 -1
- package/dist/worker/index.d.cts +9 -0
- package/dist/worker/index.d.ts +9 -0
- package/dist/worker/index.js +34 -6
- package/dist/worker/index.js.map +1 -1
- package/package.json +11 -3
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
// src/ui/slot-picker.tsx
|
|
2
|
+
import { useMemo, useState } from "react";
|
|
3
|
+
|
|
4
|
+
// src/ui/datetime.ts
|
|
5
|
+
function tzShort(tz) {
|
|
6
|
+
try {
|
|
7
|
+
const parts = new Intl.DateTimeFormat(void 0, { timeZone: tz, timeZoneName: "short" }).formatToParts(
|
|
8
|
+
/* @__PURE__ */ new Date()
|
|
9
|
+
);
|
|
10
|
+
return parts.find((p) => p.type === "timeZoneName")?.value ?? tz;
|
|
11
|
+
} catch {
|
|
12
|
+
return tz;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function dayKey(ms, tz) {
|
|
16
|
+
return new Date(ms).toLocaleDateString("en-CA", { timeZone: tz });
|
|
17
|
+
}
|
|
18
|
+
function dayLabel(ms, tz) {
|
|
19
|
+
return new Date(ms).toLocaleDateString(void 0, { timeZone: tz, weekday: "short", month: "short", day: "numeric" });
|
|
20
|
+
}
|
|
21
|
+
function timeLabel(ms, tz) {
|
|
22
|
+
return new Date(ms).toLocaleTimeString(void 0, { timeZone: tz, hour: "numeric", minute: "2-digit" });
|
|
23
|
+
}
|
|
24
|
+
function fullLabel(ms, tz) {
|
|
25
|
+
return new Date(ms).toLocaleString(void 0, {
|
|
26
|
+
timeZone: tz,
|
|
27
|
+
weekday: "long",
|
|
28
|
+
month: "long",
|
|
29
|
+
day: "numeric",
|
|
30
|
+
hour: "numeric",
|
|
31
|
+
minute: "2-digit",
|
|
32
|
+
timeZoneName: "short"
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function fmtMoney(cents) {
|
|
36
|
+
return "$" + Math.round(cents / 100).toLocaleString();
|
|
37
|
+
}
|
|
38
|
+
function fmtDate(ms) {
|
|
39
|
+
return new Date(ms).toLocaleDateString(void 0, { month: "short", day: "numeric", year: "numeric" });
|
|
40
|
+
}
|
|
41
|
+
function groupSlotsByDay(slots, tz) {
|
|
42
|
+
const byDay = /* @__PURE__ */ new Map();
|
|
43
|
+
for (const s of slots) {
|
|
44
|
+
const k = dayKey(s.startAt, tz);
|
|
45
|
+
const bucket = byDay.get(k);
|
|
46
|
+
if (bucket) bucket.push(s);
|
|
47
|
+
else byDay.set(k, [s]);
|
|
48
|
+
}
|
|
49
|
+
return byDay;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// src/ui/slot-picker.tsx
|
|
53
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
54
|
+
var DEFAULT_CLASSES = {
|
|
55
|
+
days: "slot-days",
|
|
56
|
+
day: "slot-day",
|
|
57
|
+
times: "slot-grid",
|
|
58
|
+
time: "slot-time"
|
|
59
|
+
};
|
|
60
|
+
function SlotPicker(props) {
|
|
61
|
+
const { slots, timezone, selectedStartAt, onPick, onDayChange, classes = DEFAULT_CLASSES } = props;
|
|
62
|
+
const byDay = useMemo(() => groupSlotsByDay(slots, timezone), [slots, timezone]);
|
|
63
|
+
const dayKeys = [...byDay.keys()];
|
|
64
|
+
const [activeDay, setActiveDay] = useState(dayKeys[0]);
|
|
65
|
+
const day = activeDay !== void 0 && byDay.has(activeDay) ? activeDay : dayKeys[0];
|
|
66
|
+
const times = (day !== void 0 ? byDay.get(day) : void 0) ?? [];
|
|
67
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
68
|
+
/* @__PURE__ */ jsx("div", { className: classes.days, children: dayKeys.map((key) => {
|
|
69
|
+
const first = byDay.get(key)?.[0];
|
|
70
|
+
return /* @__PURE__ */ jsx(
|
|
71
|
+
"button",
|
|
72
|
+
{
|
|
73
|
+
type: "button",
|
|
74
|
+
className: classes.day,
|
|
75
|
+
"aria-pressed": key === day,
|
|
76
|
+
onClick: () => {
|
|
77
|
+
setActiveDay(key);
|
|
78
|
+
onDayChange?.();
|
|
79
|
+
},
|
|
80
|
+
children: first ? dayLabel(first.startAt, timezone) : key
|
|
81
|
+
},
|
|
82
|
+
key
|
|
83
|
+
);
|
|
84
|
+
}) }),
|
|
85
|
+
/* @__PURE__ */ jsx("div", { className: classes.times, children: times.map((s) => /* @__PURE__ */ jsx(
|
|
86
|
+
"button",
|
|
87
|
+
{
|
|
88
|
+
type: "button",
|
|
89
|
+
className: classes.time,
|
|
90
|
+
"aria-pressed": selectedStartAt === s.startAt,
|
|
91
|
+
onClick: () => onPick(s),
|
|
92
|
+
children: timeLabel(s.startAt, timezone)
|
|
93
|
+
},
|
|
94
|
+
s.startAt
|
|
95
|
+
)) })
|
|
96
|
+
] });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// src/ui/members.tsx
|
|
100
|
+
import { useEffect, useState as useState3 } from "react";
|
|
101
|
+
|
|
102
|
+
// src/ui/reschedule.tsx
|
|
103
|
+
import { useState as useState2 } from "react";
|
|
104
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
105
|
+
function Rescheduler(props) {
|
|
106
|
+
const { api, applicationId, timezone, onRescheduled, label = "Change your time" } = props;
|
|
107
|
+
const [open, setOpen] = useState2(false);
|
|
108
|
+
const [slots, setSlots] = useState2(null);
|
|
109
|
+
const [tz, setTz] = useState2(timezone);
|
|
110
|
+
const [busy, setBusy] = useState2(false);
|
|
111
|
+
const [msg, setMsg] = useState2(null);
|
|
112
|
+
const start = async () => {
|
|
113
|
+
setOpen(true);
|
|
114
|
+
setSlots(null);
|
|
115
|
+
setMsg(null);
|
|
116
|
+
try {
|
|
117
|
+
const r = await api("/api/schedule/slots");
|
|
118
|
+
if (r.schedulingReady === false) {
|
|
119
|
+
setSlots([]);
|
|
120
|
+
setMsg("Scheduling is briefly unavailable. We'll reach out by email to arrange your call.");
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
setSlots(r.slots ?? []);
|
|
124
|
+
if (r.timezone) setTz(r.timezone);
|
|
125
|
+
} catch {
|
|
126
|
+
setSlots([]);
|
|
127
|
+
setMsg("Times are briefly unavailable. Please try again.");
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
const pick = async (slot) => {
|
|
131
|
+
setBusy(true);
|
|
132
|
+
setMsg(null);
|
|
133
|
+
try {
|
|
134
|
+
await api("/api/schedule/book", { method: "POST", body: JSON.stringify({ applicationId, startAt: slot.startAt }) });
|
|
135
|
+
setOpen(false);
|
|
136
|
+
await onRescheduled();
|
|
137
|
+
} catch (e) {
|
|
138
|
+
setMsg(e instanceof Error ? e.message : "That time is no longer available. Please pick another.");
|
|
139
|
+
} finally {
|
|
140
|
+
setBusy(false);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
if (!open) {
|
|
144
|
+
return /* @__PURE__ */ jsx2("p", { className: "meeting-note", children: /* @__PURE__ */ jsx2(
|
|
145
|
+
"a",
|
|
146
|
+
{
|
|
147
|
+
href: "#",
|
|
148
|
+
onClick: (e) => {
|
|
149
|
+
e.preventDefault();
|
|
150
|
+
void start();
|
|
151
|
+
},
|
|
152
|
+
children: label
|
|
153
|
+
}
|
|
154
|
+
) });
|
|
155
|
+
}
|
|
156
|
+
return /* @__PURE__ */ jsxs2("div", { className: "msched", children: [
|
|
157
|
+
slots === null ? /* @__PURE__ */ jsx2("p", { className: "meeting-note", children: "Loading available times\u2026" }) : slots.length === 0 ? /* @__PURE__ */ jsx2("p", { className: "meeting-note", children: msg ?? "No open times right now. Please check back soon." }) : /* @__PURE__ */ jsx2(
|
|
158
|
+
SlotPicker,
|
|
159
|
+
{
|
|
160
|
+
slots,
|
|
161
|
+
timezone: tz,
|
|
162
|
+
classes: { days: "msched-days", day: "msched-day", times: "msched-times", time: "msched-time" },
|
|
163
|
+
onPick: (s) => void pick(s)
|
|
164
|
+
}
|
|
165
|
+
),
|
|
166
|
+
busy ? /* @__PURE__ */ jsx2("p", { className: "meeting-note", children: "Rescheduling\u2026" }) : null,
|
|
167
|
+
msg && slots && slots.length > 0 ? /* @__PURE__ */ jsx2("p", { className: "meeting-note error", children: msg }) : null,
|
|
168
|
+
/* @__PURE__ */ jsx2("p", { className: "meeting-note", children: /* @__PURE__ */ jsx2(
|
|
169
|
+
"a",
|
|
170
|
+
{
|
|
171
|
+
href: "#",
|
|
172
|
+
onClick: (e) => {
|
|
173
|
+
e.preventDefault();
|
|
174
|
+
setOpen(false);
|
|
175
|
+
},
|
|
176
|
+
children: "Keep my current time"
|
|
177
|
+
}
|
|
178
|
+
) })
|
|
179
|
+
] });
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// src/ui/members.tsx
|
|
183
|
+
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
184
|
+
function card(kicker, body) {
|
|
185
|
+
return /* @__PURE__ */ jsxs3("div", { className: "card", children: [
|
|
186
|
+
/* @__PURE__ */ jsx3("div", { className: "card-label", children: "Your Application" }),
|
|
187
|
+
/* @__PURE__ */ jsxs3("div", { className: "meeting-block", children: [
|
|
188
|
+
/* @__PURE__ */ jsx3("div", { className: "meeting-kicker", children: kicker }),
|
|
189
|
+
body
|
|
190
|
+
] })
|
|
191
|
+
] });
|
|
192
|
+
}
|
|
193
|
+
function ProvisionalCard(props) {
|
|
194
|
+
const { api, application, applyHref, onReschedule } = props;
|
|
195
|
+
if (!application) {
|
|
196
|
+
return card(
|
|
197
|
+
"One step remains",
|
|
198
|
+
/* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
199
|
+
/* @__PURE__ */ jsx3("div", { className: "meeting-note", children: "Your account is ready, and the application that completes it takes a few minutes." }),
|
|
200
|
+
/* @__PURE__ */ jsx3("a", { className: "apply-link", href: applyHref, children: "Apply for membership" })
|
|
201
|
+
] })
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
if (application.status === "refunded") {
|
|
205
|
+
return card("Membership refunded", /* @__PURE__ */ jsx3("div", { className: "meeting-note", children: "Your fee has been refunded in full and your membership is canceled." }));
|
|
206
|
+
}
|
|
207
|
+
const membership = application.paid ? /* @__PURE__ */ jsxs3("div", { className: "meeting-note", children: [
|
|
208
|
+
"Your membership is active",
|
|
209
|
+
application.renewalAt ? ` and renews ${fmtDate(application.renewalAt)}` : "",
|
|
210
|
+
"."
|
|
211
|
+
] }) : null;
|
|
212
|
+
if (application.meetingAt) {
|
|
213
|
+
return card(
|
|
214
|
+
"Your introduction call",
|
|
215
|
+
/* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
216
|
+
/* @__PURE__ */ jsx3("div", { className: "meeting-date", children: fullLabel(application.meetingAt, application.timezone) }),
|
|
217
|
+
/* @__PURE__ */ jsx3("div", { className: "meeting-note", children: "A calendar invitation with the video call link is in your email." }),
|
|
218
|
+
application.meetUrl ? /* @__PURE__ */ jsx3("div", { className: "meeting-note", children: /* @__PURE__ */ jsx3("a", { href: application.meetUrl, target: "_blank", rel: "noopener", children: "Join the video call" }) }) : null,
|
|
219
|
+
/* @__PURE__ */ jsx3(Rescheduler, { api, applicationId: application.id, timezone: application.timezone, onRescheduled: onReschedule }),
|
|
220
|
+
membership
|
|
221
|
+
] })
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
return card(
|
|
225
|
+
"Book your introduction call",
|
|
226
|
+
/* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
227
|
+
/* @__PURE__ */ jsx3("div", { className: "meeting-note", children: "Your application is in. Choose a time below, and a calendar invitation will reach your email." }),
|
|
228
|
+
/* @__PURE__ */ jsx3(Rescheduler, { api, applicationId: application.id, timezone: application.timezone, onRescheduled: onReschedule, label: "Choose a time" }),
|
|
229
|
+
membership
|
|
230
|
+
] })
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
function MembersArea(props) {
|
|
234
|
+
const { api, signOut, adminHref = "/admin/", applyHref = "/join.html", memberContent } = props;
|
|
235
|
+
const [me, setMe] = useState3(null);
|
|
236
|
+
const [error, setError] = useState3(false);
|
|
237
|
+
const reload = async () => {
|
|
238
|
+
try {
|
|
239
|
+
setMe(await api("/api/me"));
|
|
240
|
+
} catch {
|
|
241
|
+
setError(true);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
useEffect(() => {
|
|
245
|
+
void reload();
|
|
246
|
+
}, []);
|
|
247
|
+
if (error) return /* @__PURE__ */ jsx3("p", { className: "meeting-note", children: "Sign in is briefly unavailable. Please refresh." });
|
|
248
|
+
if (!me) return /* @__PURE__ */ jsx3("p", { className: "meeting-note", children: "Loading\u2026" });
|
|
249
|
+
const role = me.role || "provisional";
|
|
250
|
+
return /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
251
|
+
/* @__PURE__ */ jsxs3("div", { className: "card", children: [
|
|
252
|
+
/* @__PURE__ */ jsxs3("div", { className: "member-row", children: [
|
|
253
|
+
/* @__PURE__ */ jsx3("span", { className: "member-email", children: me.email }),
|
|
254
|
+
/* @__PURE__ */ jsx3("span", { className: "role-badge " + role, children: role })
|
|
255
|
+
] }),
|
|
256
|
+
/* @__PURE__ */ jsxs3("div", { className: "account-actions", children: [
|
|
257
|
+
/* @__PURE__ */ jsx3("button", { className: "btn secondary mini", onClick: signOut, children: "Sign out" }),
|
|
258
|
+
role === "admin" ? /* @__PURE__ */ jsx3("a", { className: "admin-console-link", href: adminHref, children: "Admin console" }) : null
|
|
259
|
+
] })
|
|
260
|
+
] }),
|
|
261
|
+
role === "provisional" ? /* @__PURE__ */ jsx3(ProvisionalCard, { api, application: me.application, applyHref, onReschedule: reload }) : memberContent ?? /* @__PURE__ */ jsx3("div", { className: "card", children: /* @__PURE__ */ jsx3("div", { className: "card-label", children: "Welcome back." }) })
|
|
262
|
+
] });
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// src/ui/join.tsx
|
|
266
|
+
import { useEffect as useEffect2, useState as useState5 } from "react";
|
|
267
|
+
|
|
268
|
+
// src/ui/payment-step.tsx
|
|
269
|
+
import { useRef, useState as useState4 } from "react";
|
|
270
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
271
|
+
var loader = null;
|
|
272
|
+
function loadStripe() {
|
|
273
|
+
const existing = globalThis.Stripe;
|
|
274
|
+
if (existing) return Promise.resolve(existing);
|
|
275
|
+
if (!loader) {
|
|
276
|
+
loader = new Promise((resolve, reject) => {
|
|
277
|
+
const s = document.createElement("script");
|
|
278
|
+
s.src = "https://js.stripe.com/v3/";
|
|
279
|
+
s.onload = () => {
|
|
280
|
+
const fn = globalThis.Stripe;
|
|
281
|
+
if (fn) resolve(fn);
|
|
282
|
+
else reject(new Error("stripe.js unavailable"));
|
|
283
|
+
};
|
|
284
|
+
s.onerror = () => reject(new Error("stripe.js failed to load"));
|
|
285
|
+
document.head.appendChild(s);
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
return loader;
|
|
289
|
+
}
|
|
290
|
+
function PaymentStep(props) {
|
|
291
|
+
const { applicationId, refundPolicyText, onPaid } = props;
|
|
292
|
+
const [status, setStatus] = useState4("idle");
|
|
293
|
+
const [error, setError] = useState4(null);
|
|
294
|
+
const mountRef = useRef(null);
|
|
295
|
+
const stripeRef = useRef(null);
|
|
296
|
+
const elementsRef = useRef(null);
|
|
297
|
+
const begin = async () => {
|
|
298
|
+
setStatus("loading");
|
|
299
|
+
setError(null);
|
|
300
|
+
try {
|
|
301
|
+
const res = await fetch("/api/payments/subscription", {
|
|
302
|
+
method: "POST",
|
|
303
|
+
headers: { "content-type": "application/json" },
|
|
304
|
+
body: JSON.stringify({ applicationId, refundPolicyAck: true })
|
|
305
|
+
});
|
|
306
|
+
const data = await res.json();
|
|
307
|
+
if (!res.ok || !data.clientSecret || !data.publishableKey) throw new Error("Payment could not be set up. Please try again.");
|
|
308
|
+
const stripe = (await loadStripe())(data.publishableKey);
|
|
309
|
+
const elements = stripe.elements({ clientSecret: data.clientSecret });
|
|
310
|
+
const element = elements.create("payment");
|
|
311
|
+
if (mountRef.current) element.mount(mountRef.current);
|
|
312
|
+
stripeRef.current = stripe;
|
|
313
|
+
elementsRef.current = elements;
|
|
314
|
+
setStatus("ready");
|
|
315
|
+
} catch (e) {
|
|
316
|
+
setStatus("idle");
|
|
317
|
+
setError(e instanceof Error ? e.message : "Payment could not be set up. Please try again.");
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
const pay = async () => {
|
|
321
|
+
const stripe = stripeRef.current;
|
|
322
|
+
const elements = elementsRef.current;
|
|
323
|
+
if (!stripe || !elements) return;
|
|
324
|
+
setStatus("confirming");
|
|
325
|
+
setError(null);
|
|
326
|
+
const returnUrl = typeof window !== "undefined" ? `${window.location.origin}${window.location.pathname}?redirect_status=succeeded` : void 0;
|
|
327
|
+
const result = await stripe.confirmPayment({ elements, confirmParams: { return_url: returnUrl }, redirect: "if_required" });
|
|
328
|
+
if (result.error) {
|
|
329
|
+
setError(result.error.message ?? "The payment could not be completed.");
|
|
330
|
+
setStatus("ready");
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
const paid = result.paymentIntent?.status;
|
|
334
|
+
if (paid === "succeeded" || paid === "processing") onPaid();
|
|
335
|
+
else {
|
|
336
|
+
setError("The payment did not complete. Please try again.");
|
|
337
|
+
setStatus("ready");
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
return /* @__PURE__ */ jsxs4("div", { className: "join-pay", children: [
|
|
341
|
+
/* @__PURE__ */ jsxs4("label", { className: "compliance-box", children: [
|
|
342
|
+
/* @__PURE__ */ jsx4(
|
|
343
|
+
"input",
|
|
344
|
+
{
|
|
345
|
+
type: "checkbox",
|
|
346
|
+
disabled: status !== "idle",
|
|
347
|
+
onChange: (e) => {
|
|
348
|
+
if (e.currentTarget.checked) void begin();
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
),
|
|
352
|
+
/* @__PURE__ */ jsx4("span", { children: refundPolicyText })
|
|
353
|
+
] }),
|
|
354
|
+
status === "loading" ? /* @__PURE__ */ jsx4("p", { className: "pay-status", children: "Preparing secure payment\u2026" }) : null,
|
|
355
|
+
/* @__PURE__ */ jsx4("div", { ref: mountRef, hidden: status === "idle" || status === "loading" }),
|
|
356
|
+
status === "ready" || status === "confirming" ? /* @__PURE__ */ jsx4("button", { className: "submit-btn", disabled: status === "confirming", onClick: () => void pay(), children: status === "confirming" ? "Processing\u2026" : "Pay and continue" }) : null,
|
|
357
|
+
error ? /* @__PURE__ */ jsx4("p", { className: "pay-error", children: error }) : null
|
|
358
|
+
] });
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// src/ui/join.tsx
|
|
362
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
363
|
+
function JoinBooking(props) {
|
|
364
|
+
const { applicationId, onBooked } = props;
|
|
365
|
+
const [state, setState] = useState5(null);
|
|
366
|
+
const [msg, setMsg] = useState5(null);
|
|
367
|
+
const [busy, setBusy] = useState5(false);
|
|
368
|
+
const [selected, setSelected] = useState5(null);
|
|
369
|
+
const load = async () => {
|
|
370
|
+
setMsg(null);
|
|
371
|
+
try {
|
|
372
|
+
const res = await fetch("/api/schedule/slots");
|
|
373
|
+
const data = await res.json();
|
|
374
|
+
if (data.schedulingReady === false || !data.slots?.length) {
|
|
375
|
+
setState(null);
|
|
376
|
+
setMsg("Scheduling is briefly unavailable \u2014 we'll reach out by email to arrange your call.");
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
setState({ slots: data.slots, timezone: data.timezone ?? "UTC" });
|
|
380
|
+
} catch {
|
|
381
|
+
setMsg("Times are briefly unavailable. Please try again.");
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
useEffect2(() => {
|
|
385
|
+
void load();
|
|
386
|
+
}, []);
|
|
387
|
+
const book = async () => {
|
|
388
|
+
if (!selected) return;
|
|
389
|
+
setBusy(true);
|
|
390
|
+
setMsg(null);
|
|
391
|
+
try {
|
|
392
|
+
const res = await fetch("/api/schedule/book", {
|
|
393
|
+
method: "POST",
|
|
394
|
+
headers: { "content-type": "application/json" },
|
|
395
|
+
body: JSON.stringify({ applicationId, startAt: selected.startAt })
|
|
396
|
+
});
|
|
397
|
+
const data = await res.json();
|
|
398
|
+
if (res.status === 409 && data.code === "calendar_slot_unavailable") {
|
|
399
|
+
setSelected(null);
|
|
400
|
+
setMsg("That time was just taken. Here are the current openings.");
|
|
401
|
+
await load();
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
if (!res.ok) throw new Error(data.error ?? "The booking could not be completed.");
|
|
405
|
+
onBooked({ startAt: data.startAt ?? selected.startAt, timezone: state?.timezone ?? "UTC" });
|
|
406
|
+
} catch (e) {
|
|
407
|
+
setMsg(e instanceof Error ? e.message : "The booking could not be completed.");
|
|
408
|
+
} finally {
|
|
409
|
+
setBusy(false);
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
if (!state) return /* @__PURE__ */ jsx5("p", { className: "slots-status", children: msg ?? "Loading available times\u2026" });
|
|
413
|
+
return /* @__PURE__ */ jsxs5("div", { className: "join-book", children: [
|
|
414
|
+
/* @__PURE__ */ jsx5(
|
|
415
|
+
SlotPicker,
|
|
416
|
+
{
|
|
417
|
+
slots: state.slots,
|
|
418
|
+
timezone: state.timezone,
|
|
419
|
+
selectedStartAt: selected?.startAt,
|
|
420
|
+
onPick: setSelected,
|
|
421
|
+
onDayChange: () => setSelected(null)
|
|
422
|
+
}
|
|
423
|
+
),
|
|
424
|
+
/* @__PURE__ */ jsxs5("div", { className: "slot-confirm", hidden: !selected, children: [
|
|
425
|
+
/* @__PURE__ */ jsx5("button", { className: "submit-btn", disabled: busy, onClick: () => void book(), children: busy ? "Booking\u2026" : "Book this time" }),
|
|
426
|
+
msg ? /* @__PURE__ */ jsx5("p", { className: "step2-note", children: msg }) : null
|
|
427
|
+
] })
|
|
428
|
+
] });
|
|
429
|
+
}
|
|
430
|
+
function JoinIsland(props) {
|
|
431
|
+
const { config, children, membersHref = "/members/" } = props;
|
|
432
|
+
const [step, setStep] = useState5("form");
|
|
433
|
+
const [applicationId, setApplicationId] = useState5(null);
|
|
434
|
+
const [error, setError] = useState5(null);
|
|
435
|
+
const [submitting, setSubmitting] = useState5(false);
|
|
436
|
+
const [booked, setBooked] = useState5(null);
|
|
437
|
+
const submit = async (e) => {
|
|
438
|
+
e.preventDefault();
|
|
439
|
+
setSubmitting(true);
|
|
440
|
+
setError(null);
|
|
441
|
+
try {
|
|
442
|
+
const fields = {};
|
|
443
|
+
for (const [k, v] of new FormData(e.currentTarget).entries()) fields[k] = v;
|
|
444
|
+
fields.submissionId = crypto.randomUUID();
|
|
445
|
+
const res = await fetch("/api/applications", {
|
|
446
|
+
method: "POST",
|
|
447
|
+
headers: { "content-type": "application/json" },
|
|
448
|
+
body: JSON.stringify(fields)
|
|
449
|
+
});
|
|
450
|
+
const data = await res.json();
|
|
451
|
+
if (!res.ok || !data.id) throw new Error(data.error ?? "Your application could not be submitted.");
|
|
452
|
+
setApplicationId(data.id);
|
|
453
|
+
setStep(config.paymentsReady ? "pay" : "book");
|
|
454
|
+
} catch (err) {
|
|
455
|
+
setError(err instanceof Error ? err.message : "Something went wrong. Please try again.");
|
|
456
|
+
} finally {
|
|
457
|
+
setSubmitting(false);
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
if (step === "done" && booked) {
|
|
461
|
+
return /* @__PURE__ */ jsxs5("div", { className: "join-done card", children: [
|
|
462
|
+
/* @__PURE__ */ jsx5("div", { className: "card-label", children: "You're booked" }),
|
|
463
|
+
/* @__PURE__ */ jsx5("p", { className: "meeting-date", children: fullLabel(booked.startAt, booked.timezone) }),
|
|
464
|
+
/* @__PURE__ */ jsx5("p", { className: "meeting-note", children: "A calendar invitation with the video call link is on its way to your email." }),
|
|
465
|
+
/* @__PURE__ */ jsx5("a", { className: "apply-link", href: membersHref, children: "Go to your member area" })
|
|
466
|
+
] });
|
|
467
|
+
}
|
|
468
|
+
if (step === "book" && applicationId) {
|
|
469
|
+
return /* @__PURE__ */ jsx5(
|
|
470
|
+
JoinBooking,
|
|
471
|
+
{
|
|
472
|
+
applicationId,
|
|
473
|
+
onBooked: (b) => {
|
|
474
|
+
setBooked(b);
|
|
475
|
+
setStep("done");
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
if (step === "pay" && applicationId) {
|
|
481
|
+
return /* @__PURE__ */ jsx5(PaymentStep, { applicationId, refundPolicyText: config.refundPolicyText ?? "", onPaid: () => setStep("book") });
|
|
482
|
+
}
|
|
483
|
+
return /* @__PURE__ */ jsxs5("form", { className: "join-form", onSubmit: (e) => void submit(e), children: [
|
|
484
|
+
children,
|
|
485
|
+
error ? /* @__PURE__ */ jsx5("p", { className: "join-error", children: error }) : null,
|
|
486
|
+
/* @__PURE__ */ jsx5("button", { className: "submit-btn", type: "submit", disabled: submitting, children: submitting ? "Submitting\u2026" : "Submit application" })
|
|
487
|
+
] });
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// src/brand.ts
|
|
491
|
+
function paletteVar(key) {
|
|
492
|
+
return key.startsWith("--") ? key : `--${key}`;
|
|
493
|
+
}
|
|
494
|
+
function cleanValue(value) {
|
|
495
|
+
return value.replace(/[<>{};]/g, "").trim();
|
|
496
|
+
}
|
|
497
|
+
function brandTokens(brand) {
|
|
498
|
+
if (!brand) return "";
|
|
499
|
+
const decls = [];
|
|
500
|
+
for (const [key, value] of Object.entries(brand.palette ?? {})) {
|
|
501
|
+
if (typeof value === "string" && value.trim()) decls.push(`${paletteVar(key)}: ${cleanValue(value)};`);
|
|
502
|
+
}
|
|
503
|
+
const fonts = brand.fonts;
|
|
504
|
+
if (fonts?.display) decls.push(`--ui-font-display: ${cleanValue(fonts.display)};`);
|
|
505
|
+
if (fonts?.body) decls.push(`--ui-font-sans: ${cleanValue(fonts.body)};`);
|
|
506
|
+
if (fonts?.numeral) decls.push(`--ui-font-numeral: ${cleanValue(fonts.numeral)};`);
|
|
507
|
+
return decls.length ? `:root {
|
|
508
|
+
${decls.join("\n ")}
|
|
509
|
+
}
|
|
510
|
+
` : "";
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// src/ui/brand-style.tsx
|
|
514
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
515
|
+
function BrandStyle(props) {
|
|
516
|
+
const css = brandTokens(props.brand);
|
|
517
|
+
if (!css) return null;
|
|
518
|
+
return /* @__PURE__ */ jsx6("style", { children: css });
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
export {
|
|
522
|
+
tzShort,
|
|
523
|
+
dayKey,
|
|
524
|
+
dayLabel,
|
|
525
|
+
timeLabel,
|
|
526
|
+
fullLabel,
|
|
527
|
+
fmtMoney,
|
|
528
|
+
fmtDate,
|
|
529
|
+
groupSlotsByDay,
|
|
530
|
+
SlotPicker,
|
|
531
|
+
Rescheduler,
|
|
532
|
+
MembersArea,
|
|
533
|
+
PaymentStep,
|
|
534
|
+
JoinIsland,
|
|
535
|
+
BrandStyle
|
|
536
|
+
};
|
|
537
|
+
//# sourceMappingURL=chunk-ZCZK6QLC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ui/slot-picker.tsx","../src/ui/datetime.ts","../src/ui/members.tsx","../src/ui/reschedule.tsx","../src/ui/join.tsx","../src/ui/payment-step.tsx","../src/brand.ts","../src/ui/brand-style.tsx"],"sourcesContent":["// SlotPicker — a pure presentational day-chips + time-grid picker, shared by the\n// join booking step and the member-area reschedule. Ported from the proven\n// Silver & Salt Preact island to React; behaviour and DOM shape are unchanged.\n//\n// It holds only the active-day UI state; slot data, selection, and booking are\n// the caller's (the picker is `onPick`-driven). `classes` lets the composing\n// island supply its own CSS contract (join styles `slot-*`, reschedule\n// `msched-*`); the defaults work standalone against those class names.\nimport { useMemo, useState } from \"react\";\nimport { dayLabel, groupSlotsByDay, timeLabel } from \"./datetime.js\";\nimport type { Slot } from \"./datetime.js\";\n\n/** CSS class names for the four picker parts — overridable so one component\n * serves several differently-styled surfaces. */\nexport interface SlotPickerClasses {\n days: string;\n day: string;\n times: string;\n time: string;\n}\n\nconst DEFAULT_CLASSES: SlotPickerClasses = {\n days: \"slot-days\",\n day: \"slot-day\",\n times: \"slot-grid\",\n time: \"slot-time\",\n};\n\n/** Props for {@link SlotPicker}. Generic over the slot type so a caller's richer\n * slot object survives through `onPick`. */\nexport interface SlotPickerProps<T extends Slot = Slot> {\n /** Bookable slots, ideally already chronological. */\n slots: readonly T[];\n /** The group's scheduling timezone; all labels render in it. */\n timezone: string;\n /** The currently-selected slot's start, for the pressed state. */\n selectedStartAt?: number;\n /** Called with the full slot object when a time is chosen. */\n onPick: (slot: T) => void;\n /** Called when the active day changes (callers clear their selection). */\n onDayChange?: () => void;\n classes?: SlotPickerClasses;\n}\n\n/** A day-chips + time-grid slot picker. Presentational and `onPick`-driven: it\n * owns only the active-day selection; the caller owns slot data, the chosen\n * slot, and booking. Shared by the join booking step and the member reschedule. */\nexport function SlotPicker<T extends Slot = Slot>(props: SlotPickerProps<T>) {\n const { slots, timezone, selectedStartAt, onPick, onDayChange, classes = DEFAULT_CLASSES } = props;\n const byDay = useMemo(() => groupSlotsByDay(slots, timezone), [slots, timezone]);\n const dayKeys = [...byDay.keys()];\n const [activeDay, setActiveDay] = useState<string | undefined>(dayKeys[0]);\n\n // Keep the active day valid if the slot set changed under us (e.g. a reload\n // after a 409): fall back to the first available day.\n const day = activeDay !== undefined && byDay.has(activeDay) ? activeDay : dayKeys[0];\n const times = (day !== undefined ? byDay.get(day) : undefined) ?? [];\n\n return (\n <>\n <div className={classes.days}>\n {dayKeys.map((key) => {\n const first = byDay.get(key)?.[0];\n return (\n <button\n key={key}\n type=\"button\"\n className={classes.day}\n aria-pressed={key === day}\n onClick={() => {\n setActiveDay(key);\n onDayChange?.();\n }}\n >\n {first ? dayLabel(first.startAt, timezone) : key}\n </button>\n );\n })}\n </div>\n <div className={classes.times}>\n {times.map((s) => (\n <button\n key={s.startAt}\n type=\"button\"\n className={classes.time}\n aria-pressed={selectedStartAt === s.startAt}\n onClick={() => onPick(s)}\n >\n {timeLabel(s.startAt, timezone)}\n </button>\n ))}\n </div>\n </>\n );\n}\n","// Date/timezone formatting for the chapter member islands (join booking, member\n// area). Ported from the proven Silver & Salt helpers. Every time renders in the\n// group's SCHEDULING timezone with an explicit abbreviation — never the viewer's\n// unlabeled local zone — so an applicant always sees the time the chapter meant.\n// Pure and framework-free, so it is unit-testable without a DOM.\n\n/** A bookable slot: a start instant in epoch milliseconds. */\nexport interface Slot {\n startAt: number;\n}\n\n/** The timezone's short abbreviation (e.g. \"PST\"); falls back to the id if the\n * runtime can't resolve it. */\nexport function tzShort(tz: string): string {\n try {\n const parts = new Intl.DateTimeFormat(undefined, { timeZone: tz, timeZoneName: \"short\" }).formatToParts(\n new Date(),\n );\n return parts.find((p) => p.type === \"timeZoneName\")?.value ?? tz;\n } catch {\n return tz;\n }\n}\n\n/** DST-safe day bucket key (ISO date in the target zone). Groups slots by the\n * calendar day a viewer in `tz` would see, not by UTC midnight. */\nexport function dayKey(ms: number, tz: string): string {\n return new Date(ms).toLocaleDateString(\"en-CA\", { timeZone: tz });\n}\n\n/** Short day label for a day chip, e.g. \"Mon, Jun 3\". */\nexport function dayLabel(ms: number, tz: string): string {\n return new Date(ms).toLocaleDateString(undefined, { timeZone: tz, weekday: \"short\", month: \"short\", day: \"numeric\" });\n}\n\n/** Time-of-day label for a slot button, e.g. \"2:30 PM\". */\nexport function timeLabel(ms: number, tz: string): string {\n return new Date(ms).toLocaleTimeString(undefined, { timeZone: tz, hour: \"numeric\", minute: \"2-digit\" });\n}\n\n/** Full, human confirmation label, e.g. \"Monday, June 3, 2:30 PM PST\". */\nexport function fullLabel(ms: number, tz: string): string {\n return new Date(ms).toLocaleString(undefined, {\n timeZone: tz,\n weekday: \"long\",\n month: \"long\",\n day: \"numeric\",\n hour: \"numeric\",\n minute: \"2-digit\",\n timeZoneName: \"short\",\n });\n}\n\n/** Currency label from integer cents, e.g. 100000 → \"$1,000\". */\nexport function fmtMoney(cents: number): string {\n return \"$\" + Math.round(cents / 100).toLocaleString();\n}\n\n/** Short date label, e.g. \"Jun 3, 2026\" (used for renewal/refund copy). */\nexport function fmtDate(ms: number): string {\n return new Date(ms).toLocaleDateString(undefined, { month: \"short\", day: \"numeric\", year: \"numeric\" });\n}\n\n/** Bucket slots into an insertion-ordered `Map<dayKey, Slot[]>` for the picker.\n * Input order is preserved within each day, so a server that returns slots\n * chronologically yields chronological chips + times. */\nexport function groupSlotsByDay<T extends Slot>(slots: readonly T[], tz: string): Map<string, T[]> {\n const byDay = new Map<string, T[]>();\n for (const s of slots) {\n const k = dayKey(s.startAt, tz);\n const bucket = byDay.get(k);\n if (bucket) bucket.push(s);\n else byDay.set(k, [s]);\n }\n return byDay;\n}\n","// The member area island. Reads GET /api/me (role + the member's own\n// application, folded server-side) and renders the account header plus, for a\n// provisional member, their application card with book/reschedule; a full member\n// sees the caller-supplied `memberContent`. Ported from the S&S members island to\n// React, driven by the injected `api` (no Clerk SDK dependency).\nimport { useEffect, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { Rescheduler } from \"./reschedule.js\";\nimport { fmtDate, fullLabel } from \"./datetime.js\";\nimport type { ApiFn } from \"./api.js\";\nimport type { MemberApplication } from \"../session.js\";\n\ninterface Me {\n email: string | null;\n role: string;\n application: MemberApplication | null;\n}\n\n/** Props for {@link MembersArea}. */\nexport interface MembersAreaProps {\n api: ApiFn;\n /** Sign the member out (the host owns Clerk's signOut). */\n signOut: () => void;\n /** Where the \"Admin console\" link points for admins. Default \"/admin/\". */\n adminHref?: string;\n /** Where an accountless member goes to apply. Default \"/join.html\". */\n applyHref?: string;\n /** What a full (non-provisional) member sees below the account header. */\n memberContent?: ReactNode;\n}\n\nfunction card(kicker: string, body: ReactNode): ReactNode {\n return (\n <div className=\"card\">\n <div className=\"card-label\">Your Application</div>\n <div className=\"meeting-block\">\n <div className=\"meeting-kicker\">{kicker}</div>\n {body}\n </div>\n </div>\n );\n}\n\nfunction ProvisionalCard(props: {\n api: ApiFn;\n application: MemberApplication | null;\n applyHref: string;\n onReschedule: () => void | Promise<void>;\n}): ReactNode {\n const { api, application, applyHref, onReschedule } = props;\n if (!application) {\n return card(\n \"One step remains\",\n <>\n <div className=\"meeting-note\">Your account is ready, and the application that completes it takes a few minutes.</div>\n <a className=\"apply-link\" href={applyHref}>\n Apply for membership\n </a>\n </>,\n );\n }\n if (application.status === \"refunded\") {\n return card(\"Membership refunded\", <div className=\"meeting-note\">Your fee has been refunded in full and your membership is canceled.</div>);\n }\n const membership = application.paid ? (\n <div className=\"meeting-note\">Your membership is active{application.renewalAt ? ` and renews ${fmtDate(application.renewalAt)}` : \"\"}.</div>\n ) : null;\n if (application.meetingAt) {\n return card(\n \"Your introduction call\",\n <>\n <div className=\"meeting-date\">{fullLabel(application.meetingAt, application.timezone)}</div>\n <div className=\"meeting-note\">A calendar invitation with the video call link is in your email.</div>\n {application.meetUrl ? (\n <div className=\"meeting-note\">\n <a href={application.meetUrl} target=\"_blank\" rel=\"noopener\">\n Join the video call\n </a>\n </div>\n ) : null}\n <Rescheduler api={api} applicationId={application.id} timezone={application.timezone} onRescheduled={onReschedule} />\n {membership}\n </>,\n );\n }\n return card(\n \"Book your introduction call\",\n <>\n <div className=\"meeting-note\">Your application is in. Choose a time below, and a calendar invitation will reach your email.</div>\n <Rescheduler api={api} applicationId={application.id} timezone={application.timezone} onRescheduled={onReschedule} label=\"Choose a time\" />\n {membership}\n </>,\n );\n}\n\n/** The signed-in member area. Loads /api/me on mount and renders the account\n * header plus the provisional application card or the full-member content. */\nexport function MembersArea(props: MembersAreaProps) {\n const { api, signOut, adminHref = \"/admin/\", applyHref = \"/join.html\", memberContent } = props;\n const [me, setMe] = useState<Me | null>(null);\n const [error, setError] = useState(false);\n\n const reload = async () => {\n try {\n setMe(await api<Me>(\"/api/me\"));\n } catch {\n setError(true);\n }\n };\n useEffect(() => {\n void reload();\n }, []);\n\n if (error) return <p className=\"meeting-note\">Sign in is briefly unavailable. Please refresh.</p>;\n if (!me) return <p className=\"meeting-note\">Loading…</p>;\n const role = me.role || \"provisional\";\n\n return (\n <>\n <div className=\"card\">\n <div className=\"member-row\">\n <span className=\"member-email\">{me.email}</span>\n <span className={\"role-badge \" + role}>{role}</span>\n </div>\n <div className=\"account-actions\">\n <button className=\"btn secondary mini\" onClick={signOut}>\n Sign out\n </button>\n {role === \"admin\" ? (\n <a className=\"admin-console-link\" href={adminHref}>\n Admin console\n </a>\n ) : null}\n </div>\n </div>\n {role === \"provisional\" ? (\n <ProvisionalCard api={api} application={me.application} applyHref={applyHref} onReschedule={reload} />\n ) : (\n (memberContent ?? (\n <div className=\"card\">\n <div className=\"card-label\">Welcome back.</div>\n </div>\n ))\n )}\n </>\n );\n}\n","// In-place reschedule: open a SlotPicker, rebook via /api/schedule/book (the same\n// capability the join flow uses; the application id is the credential). Ported\n// from the S&S member-area Rescheduler to React, driven by the injected `api`.\nimport { useState } from \"react\";\nimport { SlotPicker } from \"./slot-picker.js\";\nimport type { Slot } from \"./datetime.js\";\nimport type { ApiFn } from \"./api.js\";\n\ninterface SlotsResponse {\n schedulingReady?: boolean;\n slots?: Slot[];\n timezone?: string;\n}\n\n/** Props for {@link Rescheduler}. */\nexport interface RescheduleProps {\n api: ApiFn;\n applicationId: string;\n timezone: string;\n /** Called after a successful (re)booking so the caller can refresh /api/me. */\n onRescheduled: () => void | Promise<void>;\n /** Link text to open the picker (e.g. \"Choose a time\" for a first booking). */\n label?: string;\n}\n\n/** A collapsed \"change your time\" link that expands into a {@link SlotPicker} and\n * rebooks on pick. Degrades to a message when scheduling is unavailable. */\nexport function Rescheduler(props: RescheduleProps) {\n const { api, applicationId, timezone, onRescheduled, label = \"Change your time\" } = props;\n const [open, setOpen] = useState(false);\n const [slots, setSlots] = useState<Slot[] | null>(null);\n const [tz, setTz] = useState(timezone);\n const [busy, setBusy] = useState(false);\n const [msg, setMsg] = useState<string | null>(null);\n\n const start = async () => {\n setOpen(true);\n setSlots(null);\n setMsg(null);\n try {\n const r = await api<SlotsResponse>(\"/api/schedule/slots\");\n if (r.schedulingReady === false) {\n setSlots([]);\n setMsg(\"Scheduling is briefly unavailable. We'll reach out by email to arrange your call.\");\n return;\n }\n setSlots(r.slots ?? []);\n if (r.timezone) setTz(r.timezone);\n } catch {\n setSlots([]);\n setMsg(\"Times are briefly unavailable. Please try again.\");\n }\n };\n\n const pick = async (slot: Slot) => {\n setBusy(true);\n setMsg(null);\n try {\n await api(\"/api/schedule/book\", { method: \"POST\", body: JSON.stringify({ applicationId, startAt: slot.startAt }) });\n setOpen(false);\n await onRescheduled();\n } catch (e) {\n setMsg(e instanceof Error ? e.message : \"That time is no longer available. Please pick another.\");\n } finally {\n setBusy(false);\n }\n };\n\n if (!open) {\n return (\n <p className=\"meeting-note\">\n <a\n href=\"#\"\n onClick={(e) => {\n e.preventDefault();\n void start();\n }}\n >\n {label}\n </a>\n </p>\n );\n }\n return (\n <div className=\"msched\">\n {slots === null ? (\n <p className=\"meeting-note\">Loading available times…</p>\n ) : slots.length === 0 ? (\n <p className=\"meeting-note\">{msg ?? \"No open times right now. Please check back soon.\"}</p>\n ) : (\n <SlotPicker\n slots={slots}\n timezone={tz}\n classes={{ days: \"msched-days\", day: \"msched-day\", times: \"msched-times\", time: \"msched-time\" }}\n onPick={(s) => void pick(s)}\n />\n )}\n {busy ? <p className=\"meeting-note\">Rescheduling…</p> : null}\n {msg && slots && slots.length > 0 ? <p className=\"meeting-note error\">{msg}</p> : null}\n <p className=\"meeting-note\">\n <a\n href=\"#\"\n onClick={(e) => {\n e.preventDefault();\n setOpen(false);\n }}\n >\n Keep my current time\n </a>\n </p>\n </div>\n );\n}\n","// The join island — the signup flow orchestrator. The SITE provides the form\n// fields (as children); this owns the flow: submit → /api/applications →\n// (paymentsReady) the Stripe PaymentStep → (schedulingReady) the SlotPicker\n// booking → confirmation. Faithful to how S&S wires join.html, but the flow +\n// payment + booking are packaged instead of hand-rolled per site.\nimport { useEffect, useState } from \"react\";\nimport type { FormEvent, ReactNode } from \"react\";\nimport { SlotPicker } from \"./slot-picker.js\";\nimport { PaymentStep } from \"./payment-step.js\";\nimport { fullLabel } from \"./datetime.js\";\nimport type { Slot } from \"./datetime.js\";\n\n/** The public join config (the shape `GET /api/join-config` returns). */\nexport interface JoinConfig {\n id: string;\n name: string;\n paymentsReady: boolean;\n refundPolicyText?: string;\n}\n\n/** Props for {@link JoinIsland}. */\nexport interface JoinIslandProps {\n config: JoinConfig;\n /** The site's application form fields — inputs with `name` attributes; their\n * values are collected via FormData and posted to /api/applications. */\n children: ReactNode;\n /** Where the confirmation links after booking. Default \"/members/\". */\n membersHref?: string;\n}\n\ntype Step = \"form\" | \"pay\" | \"book\" | \"done\";\n\ninterface SlotsResponse {\n schedulingReady?: boolean;\n slots?: Slot[];\n timezone?: string;\n}\n\nfunction JoinBooking(props: { applicationId: string; onBooked: (b: { startAt: number; timezone: string }) => void }): ReactNode {\n const { applicationId, onBooked } = props;\n const [state, setState] = useState<{ slots: Slot[]; timezone: string } | null>(null);\n const [msg, setMsg] = useState<string | null>(null);\n const [busy, setBusy] = useState(false);\n const [selected, setSelected] = useState<Slot | null>(null);\n\n const load = async () => {\n setMsg(null);\n try {\n const res = await fetch(\"/api/schedule/slots\");\n const data = (await res.json()) as SlotsResponse;\n if (data.schedulingReady === false || !data.slots?.length) {\n setState(null);\n setMsg(\"Scheduling is briefly unavailable — we'll reach out by email to arrange your call.\");\n return;\n }\n setState({ slots: data.slots, timezone: data.timezone ?? \"UTC\" });\n } catch {\n setMsg(\"Times are briefly unavailable. Please try again.\");\n }\n };\n useEffect(() => {\n void load();\n }, []);\n\n const book = async () => {\n if (!selected) return;\n setBusy(true);\n setMsg(null);\n try {\n const res = await fetch(\"/api/schedule/book\", {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ applicationId, startAt: selected.startAt }),\n });\n const data = (await res.json()) as { startAt?: number; error?: string; code?: string };\n if (res.status === 409 && data.code === \"calendar_slot_unavailable\") {\n setSelected(null);\n setMsg(\"That time was just taken. Here are the current openings.\");\n await load();\n return;\n }\n if (!res.ok) throw new Error(data.error ?? \"The booking could not be completed.\");\n onBooked({ startAt: data.startAt ?? selected.startAt, timezone: state?.timezone ?? \"UTC\" });\n } catch (e) {\n setMsg(e instanceof Error ? e.message : \"The booking could not be completed.\");\n } finally {\n setBusy(false);\n }\n };\n\n if (!state) return <p className=\"slots-status\">{msg ?? \"Loading available times…\"}</p>;\n return (\n <div className=\"join-book\">\n <SlotPicker\n slots={state.slots}\n timezone={state.timezone}\n selectedStartAt={selected?.startAt}\n onPick={setSelected}\n onDayChange={() => setSelected(null)}\n />\n <div className=\"slot-confirm\" hidden={!selected}>\n <button className=\"submit-btn\" disabled={busy} onClick={() => void book()}>\n {busy ? \"Booking…\" : \"Book this time\"}\n </button>\n {msg ? <p className=\"step2-note\">{msg}</p> : null}\n </div>\n </div>\n );\n}\n\n/** The signup island. Renders the site's form, then drives payment (when the\n * chapter charges) and booking (when a calendar is connected) to confirmation. */\nexport function JoinIsland(props: JoinIslandProps) {\n const { config, children, membersHref = \"/members/\" } = props;\n const [step, setStep] = useState<Step>(\"form\");\n const [applicationId, setApplicationId] = useState<string | null>(null);\n const [error, setError] = useState<string | null>(null);\n const [submitting, setSubmitting] = useState(false);\n const [booked, setBooked] = useState<{ startAt: number; timezone: string } | null>(null);\n\n const submit = async (e: FormEvent<HTMLFormElement>) => {\n e.preventDefault();\n setSubmitting(true);\n setError(null);\n try {\n const fields: Record<string, unknown> = {};\n for (const [k, v] of new FormData(e.currentTarget).entries()) fields[k] = v;\n fields.submissionId = crypto.randomUUID();\n const res = await fetch(\"/api/applications\", {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(fields),\n });\n const data = (await res.json()) as { id?: string; error?: string };\n if (!res.ok || !data.id) throw new Error(data.error ?? \"Your application could not be submitted.\");\n setApplicationId(data.id);\n setStep(config.paymentsReady ? \"pay\" : \"book\");\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Something went wrong. Please try again.\");\n } finally {\n setSubmitting(false);\n }\n };\n\n if (step === \"done\" && booked) {\n return (\n <div className=\"join-done card\">\n <div className=\"card-label\">You're booked</div>\n <p className=\"meeting-date\">{fullLabel(booked.startAt, booked.timezone)}</p>\n <p className=\"meeting-note\">A calendar invitation with the video call link is on its way to your email.</p>\n <a className=\"apply-link\" href={membersHref}>\n Go to your member area\n </a>\n </div>\n );\n }\n if (step === \"book\" && applicationId) {\n return (\n <JoinBooking\n applicationId={applicationId}\n onBooked={(b) => {\n setBooked(b);\n setStep(\"done\");\n }}\n />\n );\n }\n if (step === \"pay\" && applicationId) {\n return <PaymentStep applicationId={applicationId} refundPolicyText={config.refundPolicyText ?? \"\"} onPaid={() => setStep(\"book\")} />;\n }\n return (\n <form className=\"join-form\" onSubmit={(e) => void submit(e)}>\n {children}\n {error ? <p className=\"join-error\">{error}</p> : null}\n <button className=\"submit-btn\" type=\"submit\" disabled={submitting}>\n {submitting ? \"Submitting…\" : \"Submit application\"}\n </button>\n </form>\n );\n}\n","// The join flow's payment step. Ports the S&S vanilla card entry into the island:\n// dynamically loads js.stripe.com (NO @stripe/react-stripe-js dep), creates a\n// subscription server-side, and mounts a Stripe Payment Element. The refund-policy\n// checkbox is the gate — checking it starts the (money-creating) subscription\n// call, exactly as S&S does. Client success is advisory only; the webhook is the\n// authoritative writer of paid state (see payments.ts).\nimport { useRef, useState } from \"react\";\n\n// Minimal shapes for the dynamically-loaded js.stripe.com global.\ninterface StripeElementsApi {\n create(type: string): { mount(target: HTMLElement): void };\n}\ninterface StripeApi {\n elements(opts: { clientSecret: string }): StripeElementsApi;\n confirmPayment(opts: {\n elements: StripeElementsApi;\n confirmParams?: { return_url?: string };\n redirect?: \"if_required\";\n }): Promise<{ error?: { message?: string }; paymentIntent?: { status?: string } }>;\n}\ntype StripeFactory = (publishableKey: string) => StripeApi;\n\nlet loader: Promise<StripeFactory> | null = null;\n\n/** Load js.stripe.com once and resolve the `Stripe` global (browser only). */\nfunction loadStripe(): Promise<StripeFactory> {\n const existing = (globalThis as { Stripe?: StripeFactory }).Stripe;\n if (existing) return Promise.resolve(existing);\n if (!loader) {\n loader = new Promise<StripeFactory>((resolve, reject) => {\n const s = document.createElement(\"script\");\n s.src = \"https://js.stripe.com/v3/\";\n s.onload = () => {\n const fn = (globalThis as { Stripe?: StripeFactory }).Stripe;\n if (fn) resolve(fn);\n else reject(new Error(\"stripe.js unavailable\"));\n };\n s.onerror = () => reject(new Error(\"stripe.js failed to load\"));\n document.head.appendChild(s);\n });\n }\n return loader;\n}\n\n/** Props for {@link PaymentStep}. */\nexport interface PaymentStepProps {\n /** The application to attach the subscription to (the capability). */\n applicationId: string;\n /** Refund-policy copy the applicant must acknowledge to start payment. */\n refundPolicyText: string;\n /** Called once the payment succeeds (or is processing) — advance to booking. */\n onPaid: () => void;\n}\n\ninterface SubResponse {\n clientSecret?: string;\n publishableKey?: string | null;\n}\n\n/** The card-entry step: acknowledge the refund policy → create the subscription\n * → mount Stripe Elements → confirm. */\nexport function PaymentStep(props: PaymentStepProps) {\n const { applicationId, refundPolicyText, onPaid } = props;\n const [status, setStatus] = useState<\"idle\" | \"loading\" | \"ready\" | \"confirming\">(\"idle\");\n const [error, setError] = useState<string | null>(null);\n const mountRef = useRef<HTMLDivElement | null>(null);\n const stripeRef = useRef<StripeApi | null>(null);\n const elementsRef = useRef<StripeElementsApi | null>(null);\n\n const begin = async () => {\n setStatus(\"loading\");\n setError(null);\n try {\n const res = await fetch(\"/api/payments/subscription\", {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ applicationId, refundPolicyAck: true }),\n });\n const data = (await res.json()) as SubResponse;\n if (!res.ok || !data.clientSecret || !data.publishableKey) throw new Error(\"Payment could not be set up. Please try again.\");\n const stripe = (await loadStripe())(data.publishableKey);\n const elements = stripe.elements({ clientSecret: data.clientSecret });\n const element = elements.create(\"payment\");\n if (mountRef.current) element.mount(mountRef.current);\n stripeRef.current = stripe;\n elementsRef.current = elements;\n setStatus(\"ready\");\n } catch (e) {\n setStatus(\"idle\");\n setError(e instanceof Error ? e.message : \"Payment could not be set up. Please try again.\");\n }\n };\n\n const pay = async () => {\n const stripe = stripeRef.current;\n const elements = elementsRef.current;\n if (!stripe || !elements) return;\n setStatus(\"confirming\");\n setError(null);\n const returnUrl =\n typeof window !== \"undefined\" ? `${window.location.origin}${window.location.pathname}?redirect_status=succeeded` : undefined;\n const result = await stripe.confirmPayment({ elements, confirmParams: { return_url: returnUrl }, redirect: \"if_required\" });\n if (result.error) {\n setError(result.error.message ?? \"The payment could not be completed.\");\n setStatus(\"ready\");\n return;\n }\n const paid = result.paymentIntent?.status;\n if (paid === \"succeeded\" || paid === \"processing\") onPaid();\n else {\n setError(\"The payment did not complete. Please try again.\");\n setStatus(\"ready\");\n }\n };\n\n return (\n <div className=\"join-pay\">\n <label className=\"compliance-box\">\n <input\n type=\"checkbox\"\n disabled={status !== \"idle\"}\n onChange={(e) => {\n if (e.currentTarget.checked) void begin();\n }}\n />\n <span>{refundPolicyText}</span>\n </label>\n {status === \"loading\" ? <p className=\"pay-status\">Preparing secure payment…</p> : null}\n <div ref={mountRef} hidden={status === \"idle\" || status === \"loading\"} />\n {status === \"ready\" || status === \"confirming\" ? (\n <button className=\"submit-btn\" disabled={status === \"confirming\"} onClick={() => void pay()}>\n {status === \"confirming\" ? \"Processing…\" : \"Pay and continue\"}\n </button>\n ) : null}\n {error ? <p className=\"pay-error\">{error}</p> : null}\n </div>\n );\n}\n","// Brand tokens (H4). defineChapter accepts a `brand` block; this turns it into a\n// `:root { --…: … }` CSS block, so a chapter re-skins the WHOLE UI — the\n// @odla-ai/ui components, the admin shell, and the member islands, which all read\n// --ui-* design tokens — from one config instead of hand-writing inline CSS.\n//\n// Pure string generation, so it is unit-testable and can be emitted at\n// build/SSR time into the page <head> (no flash of unstyled content), or via the\n// <BrandStyle> component from @odla-ai/chapter/ui.\nimport type { ChapterBrand } from \"./types\";\n\n// A palette entry is either a direct custom property (already `--…`, e.g.\n// `--ui-accent` to retheme components) or a bare name we expose as `--<name>`\n// (e.g. `moss` → `--moss`, for a site to reference in its own CSS).\nfunction paletteVar(key: string): string {\n return key.startsWith(\"--\") ? key : `--${key}`;\n}\n\n// Strip characters that could break out of a `--var: value;` declaration or the\n// surrounding <style>. Brand config is trusted author input, so this is a\n// belt-and-suspenders guard, not a security boundary.\nfunction cleanValue(value: string): string {\n return value.replace(/[<>{};]/g, \"\").trim();\n}\n\n/**\n * Build the `:root { … }` CSS that maps a chapter's brand onto the design tokens\n * the UI reads: each `palette` entry becomes a custom property, and `fonts`\n * (display/body/numeral) map to `--ui-font-display` / `--ui-font-sans` /\n * `--ui-font-numeral`. Returns \"\" when there is nothing to theme.\n */\nexport function brandTokens(brand: ChapterBrand | undefined): string {\n if (!brand) return \"\";\n const decls: string[] = [];\n for (const [key, value] of Object.entries(brand.palette ?? {})) {\n if (typeof value === \"string\" && value.trim()) decls.push(`${paletteVar(key)}: ${cleanValue(value)};`);\n }\n const fonts = brand.fonts;\n if (fonts?.display) decls.push(`--ui-font-display: ${cleanValue(fonts.display)};`);\n if (fonts?.body) decls.push(`--ui-font-sans: ${cleanValue(fonts.body)};`);\n if (fonts?.numeral) decls.push(`--ui-font-numeral: ${cleanValue(fonts.numeral)};`);\n return decls.length ? `:root {\\n ${decls.join(\"\\n \")}\\n}\\n` : \"\";\n}\n","// Client-side convenience for brand tokens: render the chapter's brand as a\n// <style> tag. Prefer emitting brandTokens() into the page <head> at build/SSR\n// time (no flash); use this when that isn't available (e.g. a pure SPA mount).\nimport { brandTokens } from \"../brand.js\";\nimport type { ChapterBrand } from \"../types\";\n\n/** Props for {@link BrandStyle}. */\nexport interface BrandStyleProps {\n brand: ChapterBrand | undefined;\n}\n\n/** Render a chapter's brand tokens as an inline <style> block (or nothing when\n * there is no brand to theme). */\nexport function BrandStyle(props: BrandStyleProps) {\n const css = brandTokens(props.brand);\n if (!css) return null;\n return <style>{css}</style>;\n}\n"],"mappings":";AAQA,SAAS,SAAS,gBAAgB;;;ACK3B,SAAS,QAAQ,IAAoB;AAC1C,MAAI;AACF,UAAM,QAAQ,IAAI,KAAK,eAAe,QAAW,EAAE,UAAU,IAAI,cAAc,QAAQ,CAAC,EAAE;AAAA,MACxF,oBAAI,KAAK;AAAA,IACX;AACA,WAAO,MAAM,KAAK,CAAC,MAAM,EAAE,SAAS,cAAc,GAAG,SAAS;AAAA,EAChE,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAIO,SAAS,OAAO,IAAY,IAAoB;AACrD,SAAO,IAAI,KAAK,EAAE,EAAE,mBAAmB,SAAS,EAAE,UAAU,GAAG,CAAC;AAClE;AAGO,SAAS,SAAS,IAAY,IAAoB;AACvD,SAAO,IAAI,KAAK,EAAE,EAAE,mBAAmB,QAAW,EAAE,UAAU,IAAI,SAAS,SAAS,OAAO,SAAS,KAAK,UAAU,CAAC;AACtH;AAGO,SAAS,UAAU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SAAS;AAAA,IAAc,MAAM,KAAK,MAAM,CAAC;AAAA;AAAA,IAAU;AAClE;;;ACzBS,gBAAAI,YAAA;AAHF,SAAS,WAAW,OAAwB;AACjD,QAAM,MAAM,YAAY,MAAM,KAAK;AACnC,MAAI,CAAC,IAAK,QAAO;AACjB,SAAO,gBAAAA,KAAC,WAAO,eAAI;AACrB;","names":["useState","useState","jsx","jsxs","useState","Fragment","jsx","jsxs","useState","useEffect","useState","useState","jsx","jsxs","jsx","jsxs","useState","useEffect","jsx"]}
|