@mccaskie-labs/workbench-bookings 0.0.0-stage → 0.2.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/CHANGELOG.md +11 -0
- package/README.md +71 -2
- package/dist/bookings.d.ts +160 -0
- package/dist/bookings.js +446 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.js +125 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.js +165 -0
- package/dist/errors.d.ts +25 -0
- package/dist/errors.js +10 -0
- package/dist/format.d.ts +12 -0
- package/dist/format.js +24 -0
- package/dist/ical.d.ts +13 -0
- package/dist/ical.js +67 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +20 -0
- package/dist/migration.d.ts +4 -0
- package/dist/migration.js +441 -0
- package/dist/slots.d.ts +24 -0
- package/dist/slots.js +87 -0
- package/dist/starters.d.ts +31 -0
- package/dist/starters.js +29 -0
- package/dist/styles.d.ts +34 -0
- package/dist/styles.js +97 -0
- package/dist/time.d.ts +15 -0
- package/dist/time.js +82 -0
- package/dist/types.d.ts +130 -0
- package/dist/types.js +4 -0
- package/dist/ui.d.ts +131 -0
- package/dist/ui.js +208 -0
- package/dist/words.d.ts +4 -0
- package/dist/words.js +160 -0
- package/package.json +48 -4
package/dist/ui.js
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// The booking pages (docs/capabilities/13-bookings.md): plain HTML strings,
|
|
2
|
+
// no script of their own, mobile first. The customer's side is public: the
|
|
3
|
+
// free times (a GET form per day, so choosing a time changes nothing), the
|
|
4
|
+
// details form (a POST to the project's endpoint, which hands the fields to
|
|
5
|
+
// bookingAction), the done page and the customer's own booking page from
|
|
6
|
+
// their manage link. The owner's list sits behind the app's sign-in and posts
|
|
7
|
+
// to ownerBookingAction. Every element carries a wb-booking-* class
|
|
8
|
+
// (BOOKING_STYLES), and every button is at least 44 px tall.
|
|
9
|
+
import { BookingsError } from "./errors.js";
|
|
10
|
+
import { dayText, DEFAULT_LOCALE, timeText, whenText, words } from "./format.js";
|
|
11
|
+
const esc = (s) => s.replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
12
|
+
const hidden = (name, value) => `<input type="hidden" name="${esc(name)}" value="${esc(value)}">`;
|
|
13
|
+
/** The free times, a day at a time. Days with none are left out. */
|
|
14
|
+
export function renderSlotPicker(days, o) {
|
|
15
|
+
const say = words(o.t);
|
|
16
|
+
const locale = o.locale ?? DEFAULT_LOCALE;
|
|
17
|
+
const open = days.filter((d) => d.slots.length);
|
|
18
|
+
const form = (d) => {
|
|
19
|
+
const buttons = d.slots
|
|
20
|
+
.map((s) => `<button class="wb-booking-slot" type="submit" name="start" value="${esc(s.start)}">${esc(timeText(s.start, o.timeZone, locale))}${s.left > 1 ? `<span class="wb-booking-left">${esc(say("picker.left", { left: s.left }))}</span>` : ""}</button>`)
|
|
21
|
+
.join("");
|
|
22
|
+
const fields = o.move ? `${hidden("action", "move")}${hidden("token", o.move.token)}` : hidden("service", o.service);
|
|
23
|
+
return `<form class="wb-booking-slots" method="${o.move ? "post" : "get"}" action="${esc(o.endpoint)}">${fields}${buttons}</form>`;
|
|
24
|
+
};
|
|
25
|
+
const list = open.length
|
|
26
|
+
? `<ol class="wb-booking-days">${open.map((d) => `<li class="wb-booking-day"><h3 class="wb-booking-date">${esc(dayText(d.date, locale))}</h3>${form(d)}</li>`).join("")}</ol>`
|
|
27
|
+
: `<p class="wb-booking-empty">${esc(say("picker.empty"))}</p>`;
|
|
28
|
+
const more = o.more ? `<a class="wb-booking-more" href="${esc(o.more)}">${esc(say("picker.more"))}</a>` : "";
|
|
29
|
+
return `<section class="wb-booking-picker"><h2 class="wb-booking-heading">${esc(say("picker.title"))}</h2><p class="wb-booking-service">${esc(o.title)}</p>${list}${more}</section>`;
|
|
30
|
+
}
|
|
31
|
+
/** The booking form for a chosen time. */
|
|
32
|
+
export function renderBookingForm(o) {
|
|
33
|
+
const say = words(o.t);
|
|
34
|
+
const v = o.values ?? {};
|
|
35
|
+
const phone = o.ask?.phone ?? "no";
|
|
36
|
+
const err = (f) => (o.field === f ? `<span class="wb-booking-error" id="wb-booking-error-${f}">${esc(say(`form.error.${f}`))}</span>` : "");
|
|
37
|
+
const aria = (f) => (o.field === f ? ` aria-invalid="true" aria-describedby="wb-booking-error-${f}"` : "");
|
|
38
|
+
const input = (f, label, type, auto, required) => `<label class="wb-booking-field"><span class="wb-booking-label">${esc(label)}</span><input class="wb-booking-input" type="${type}" name="${f}" autocomplete="${auto}" maxlength="${f === "email" ? 254 : f === "phone" ? 40 : 100}"${required ? " required" : ""} value="${esc(v[f] ?? "")}"${aria(f)}>${err(f)}</label>`;
|
|
39
|
+
return [
|
|
40
|
+
`<form class="wb-booking-details" method="post" action="${esc(o.endpoint)}">`,
|
|
41
|
+
`<h2 class="wb-booking-heading">${esc(say("form.title"))}</h2>`,
|
|
42
|
+
`<p class="wb-booking-when">${esc(o.title)}, ${esc(whenText(o.start, o.timeZone, o.locale ?? DEFAULT_LOCALE))}</p>`,
|
|
43
|
+
o.message ? `<p class="wb-booking-message" role="alert">${esc(o.message)}</p>` : "",
|
|
44
|
+
hidden("action", "book"),
|
|
45
|
+
hidden("service", o.service),
|
|
46
|
+
hidden("start", o.start),
|
|
47
|
+
input("name", say("form.name"), "text", "name", true),
|
|
48
|
+
input("email", say("form.email"), "email", "email", true),
|
|
49
|
+
phone === "no" ? "" : input("phone", say(phone === "required" ? "form.phone" : "form.phone_optional"), "tel", "tel", phone === "required"),
|
|
50
|
+
(o.places ?? 1) > 1
|
|
51
|
+
? `<label class="wb-booking-field"><span class="wb-booking-label">${esc(say("form.places"))}</span><select class="wb-booking-select" name="places"${aria("places")}>${Array.from({ length: Math.min(o.places, 100) }, (_, i) => `<option value="${i + 1}"${String(i + 1) === (v.places ?? "1") ? " selected" : ""}>${i + 1}</option>`).join("")}</select>${err("places")}</label>`
|
|
52
|
+
: "",
|
|
53
|
+
o.ask?.note
|
|
54
|
+
? `<label class="wb-booking-field"><span class="wb-booking-label">${esc(say("form.note"))}</span><textarea class="wb-booking-textarea" name="note" rows="4" maxlength="1000"${aria("note")}>${esc(v.note ?? "")}</textarea>${err("note")}</label>`
|
|
55
|
+
: "",
|
|
56
|
+
`<div class="wb-booking-actions"><button class="wb-booking-submit" type="submit">${esc(say(o.confirm === "owner_approves" ? "form.submit_request" : "form.submit"))}</button>`,
|
|
57
|
+
o.back ? `<a class="wb-booking-back" href="${esc(o.back)}">${esc(say("form.back"))}</a>` : "",
|
|
58
|
+
"</div></form>",
|
|
59
|
+
].join("");
|
|
60
|
+
}
|
|
61
|
+
/** You're booked, or Request sent. */
|
|
62
|
+
export function renderBookingDone(b, o) {
|
|
63
|
+
const say = words(o.t);
|
|
64
|
+
const pending = b.status === "pending";
|
|
65
|
+
const links = [
|
|
66
|
+
!pending && o.ics ? `<a class="wb-booking-ics" href="${esc(o.ics)}" download="booking.ics">${esc(say("done.ics"))}</a>` : "",
|
|
67
|
+
o.manage ? `<a class="wb-booking-manage" href="${esc(o.manage)}">${esc(say("done.manage"))}</a>` : "",
|
|
68
|
+
].join("");
|
|
69
|
+
return `<section class="wb-booking-done" role="status"><h2 class="wb-booking-heading">${esc(say(pending ? "done.pending.title" : "done.confirmed.title"))}</h2><p class="wb-booking-when">${esc(o.title)}, ${esc(whenText(b.starts_at, o.timeZone, o.locale ?? DEFAULT_LOCALE))}</p><p class="wb-booking-text">${esc(say(pending ? "done.pending.body" : "done.confirmed.body"))}</p>${links ? `<div class="wb-booking-actions">${links}</div>` : ""}</section>`;
|
|
70
|
+
}
|
|
71
|
+
/** The customer's own booking page, from their manage link: when, its status, and cancel or move while they still can. */
|
|
72
|
+
export function renderBookingManage(b, o) {
|
|
73
|
+
const say = words(o.t);
|
|
74
|
+
const live = b.status === "pending" || b.status === "confirmed";
|
|
75
|
+
const actions = !live
|
|
76
|
+
? ""
|
|
77
|
+
: o.changeable
|
|
78
|
+
? `<div class="wb-booking-actions">${o.move ? `<a class="wb-booking-move" href="${esc(o.move)}">${esc(say("manage.move"))}</a>` : ""}${b.status === "confirmed" && o.ics ? `<a class="wb-booking-ics" href="${esc(o.ics)}" download="booking.ics">${esc(say("done.ics"))}</a>` : ""}<form class="wb-booking-cancel-form" method="post" action="${esc(o.endpoint)}">${hidden("action", "cancel")}${hidden("token", o.token)}<button class="wb-booking-cancel" type="submit">${esc(say("manage.cancel"))}</button></form></div>`
|
|
79
|
+
: `<p class="wb-booking-locked">${esc(say("manage.locked"))}</p>`;
|
|
80
|
+
return `<section class="wb-booking-page"><h2 class="wb-booking-heading">${esc(say("manage.title"))}</h2><p class="wb-booking-when">${esc(o.title)}, ${esc(whenText(b.starts_at, o.timeZone, o.locale ?? DEFAULT_LOCALE))}</p><p class="wb-booking-status">${esc(say(`status.${b.status}`))}</p>${actions}</section>`;
|
|
81
|
+
}
|
|
82
|
+
/** The owner's bookings, earliest first, with Accept and Decline for requests and Cancel for the rest. */
|
|
83
|
+
export function renderBookingList(bookings, o) {
|
|
84
|
+
const say = words(o.t);
|
|
85
|
+
const locale = o.locale ?? DEFAULT_LOCALE;
|
|
86
|
+
const head = `<h2 class="wb-booking-heading">${esc(say("list.title"))}</h2>`;
|
|
87
|
+
if (bookings.length === 0)
|
|
88
|
+
return `<section class="wb-booking-list">${head}<p class="wb-booking-empty">${esc(say("list.empty"))}</p></section>`;
|
|
89
|
+
const form = (b, action, cls, label) => `<form class="wb-booking-form" method="post" action="${esc(o.endpoint)}">${hidden("booking", b.id)}${hidden("action", action)}<button class="${cls}" type="submit">${esc(label)}</button></form>`;
|
|
90
|
+
const item = (b) => {
|
|
91
|
+
const ended = b.status === "cancelled" || b.status === "declined";
|
|
92
|
+
const cls = ["wb-booking", b.status === "pending" ? "wb-booking-pending" : "", ended ? "wb-booking-ended" : ""].filter(Boolean).join(" ");
|
|
93
|
+
const who = [b.customer.name, b.customer.email, b.customer.phone].filter(Boolean).join(" · ");
|
|
94
|
+
const buttons = b.status === "pending"
|
|
95
|
+
? `${form(b, "approve", "wb-booking-approve", say("list.approve"))}${form(b, "decline", "wb-booking-decline", say("list.decline"))}`
|
|
96
|
+
: b.status === "confirmed"
|
|
97
|
+
? form(b, "cancel", "wb-booking-owner-cancel", say("list.cancel"))
|
|
98
|
+
: "";
|
|
99
|
+
return `<li class="wb-booking-item"><article class="${cls}" id="wb-booking-${esc(b.id)}"><h3 class="wb-booking-title">${esc(whenText(b.starts_at, o.timeZone, locale))} · ${esc(o.titleOf(b.service))}</h3><p class="wb-booking-who">${esc(who)}</p>${b.places > 1 ? `<p class="wb-booking-places">${esc(say("list.places", { places: b.places }))}</p>` : ""}${b.customer.note ? `<p class="wb-booking-note">${esc(b.customer.note)}</p>` : ""}<p class="wb-booking-status">${esc(say(`status.${b.status}`))}</p>${buttons ? `<div class="wb-booking-actions">${buttons}</div>` : ""}</article></li>`;
|
|
100
|
+
};
|
|
101
|
+
return `<section class="wb-booking-list">${head}<ul class="wb-booking-items">${bookings.map(item).join("")}</ul></section>`;
|
|
102
|
+
}
|
|
103
|
+
/** A signed-in member's own bookings (bookings.mine), with Cancel while they still can. */
|
|
104
|
+
export function renderMyBookings(bookings, o) {
|
|
105
|
+
const say = words(o.t);
|
|
106
|
+
const locale = o.locale ?? DEFAULT_LOCALE;
|
|
107
|
+
const head = `<h2 class="wb-booking-heading">${esc(say("mine.title"))}</h2>`;
|
|
108
|
+
const book = o.book ? `<a class="wb-booking-more" href="${esc(o.book)}">${esc(say("mine.book"))}</a>` : "";
|
|
109
|
+
if (bookings.length === 0)
|
|
110
|
+
return `<section class="wb-booking-mine">${head}<p class="wb-booking-empty">${esc(say("mine.empty"))}</p>${book}</section>`;
|
|
111
|
+
const item = (b) => {
|
|
112
|
+
const live = b.status === "pending" || b.status === "confirmed";
|
|
113
|
+
const cls = ["wb-booking", b.status === "pending" ? "wb-booking-pending" : "", live ? "" : "wb-booking-ended"].filter(Boolean).join(" ");
|
|
114
|
+
const action = !live
|
|
115
|
+
? ""
|
|
116
|
+
: o.changeable(b)
|
|
117
|
+
? `<div class="wb-booking-actions"><form class="wb-booking-cancel-form" method="post" action="${esc(o.endpoint)}">${hidden("action", "cancel")}${hidden("booking", b.id)}<button class="wb-booking-cancel" type="submit">${esc(say("mine.cancel"))}</button></form></div>`
|
|
118
|
+
: `<p class="wb-booking-locked">${esc(say("manage.locked"))}</p>`;
|
|
119
|
+
return `<li class="wb-booking-item"><article class="${cls}" id="wb-booking-${esc(b.id)}"><h3 class="wb-booking-title">${esc(whenText(b.starts_at, o.timeZone, locale))} · ${esc(o.titleOf(b.service))}</h3>${b.places > 1 ? `<p class="wb-booking-places">${esc(say("list.places", { places: b.places }))}</p>` : ""}<p class="wb-booking-status">${esc(say(`status.${b.status}`))}</p>${action}</article></li>`;
|
|
120
|
+
};
|
|
121
|
+
return `<section class="wb-booking-mine">${head}<ul class="wb-booking-items">${bookings.map(item).join("")}</ul>${book}</section>`;
|
|
122
|
+
}
|
|
123
|
+
const STATUS = {
|
|
124
|
+
bad_config: 500,
|
|
125
|
+
bad_input: 400,
|
|
126
|
+
unknown_service: 404,
|
|
127
|
+
not_open: 409,
|
|
128
|
+
taken: 409,
|
|
129
|
+
too_many: 409,
|
|
130
|
+
too_late: 409,
|
|
131
|
+
unknown_booking: 404,
|
|
132
|
+
not_allowed: 403,
|
|
133
|
+
store_failed: 502,
|
|
134
|
+
};
|
|
135
|
+
function failed(e, o) {
|
|
136
|
+
if (!(e instanceof BookingsError))
|
|
137
|
+
throw e;
|
|
138
|
+
const say = words(o.t);
|
|
139
|
+
const field = e.code === "bad_input" ? /^(name|email|phone|note|places):/.exec(e.message)?.[1] : undefined;
|
|
140
|
+
const text = field !== undefined
|
|
141
|
+
? say(`form.error.${field}`)
|
|
142
|
+
: e.code === "taken" || e.code === "not_open" || e.code === "too_late" || e.code === "not_allowed" || e.code === "unknown_booking"
|
|
143
|
+
? say(`error.${e.code}`)
|
|
144
|
+
: e.code === "too_many"
|
|
145
|
+
? say("error.too_many", { max: o.max ?? 3 })
|
|
146
|
+
: say("error.failed");
|
|
147
|
+
return { status: STATUS[e.code], body: { ok: false, error: e.code, message: e.message, text, ...(field ? { field } : {}) } };
|
|
148
|
+
}
|
|
149
|
+
const str = (v) => (typeof v === "string" ? v : "");
|
|
150
|
+
/**
|
|
151
|
+
* The customer's posts, on the booking page: `book` (service, start, name,
|
|
152
|
+
* email, places when the service allows more than one, and phone or note when
|
|
153
|
+
* asked; answers the booking and its manage secret), `cancel` (token, or with
|
|
154
|
+
* a signed-in member the booking's id) and `move` (token, start). Put
|
|
155
|
+
* Turnstile or the app's rate limit in front of it. `member` is the signed-in
|
|
156
|
+
* member's id from the app's own sign-in, never from the form. `text` is the
|
|
157
|
+
* line to show the customer when it didn't go through, and `field` the field
|
|
158
|
+
* to mark.
|
|
159
|
+
*/
|
|
160
|
+
export async function bookingAction(bookings, body, ctx) {
|
|
161
|
+
const max = bookings.config.max_per_customer ?? 3;
|
|
162
|
+
try {
|
|
163
|
+
const action = str(body.action);
|
|
164
|
+
if (action === "book") {
|
|
165
|
+
const { booking, token } = await bookings.book({
|
|
166
|
+
account: ctx.account,
|
|
167
|
+
service: str(body.service),
|
|
168
|
+
start: str(body.start),
|
|
169
|
+
customer: { name: str(body.name), email: str(body.email), phone: str(body.phone), note: str(body.note) },
|
|
170
|
+
...(body.places !== undefined && body.places !== "" ? { places: /^[0-9]{1,3}$/.test(str(body.places)) ? Number(body.places) : NaN } : {}),
|
|
171
|
+
...(ctx.member ? { member: ctx.member } : {}),
|
|
172
|
+
});
|
|
173
|
+
return { status: 201, body: { ok: true, action, booking, token } };
|
|
174
|
+
}
|
|
175
|
+
if (action === "cancel" && ctx.member && str(body.booking))
|
|
176
|
+
return { status: 200, body: { ok: true, action, booking: await bookings.cancelAsMember(str(body.booking), ctx.account, ctx.member) } };
|
|
177
|
+
if (action === "cancel")
|
|
178
|
+
return { status: 200, body: { ok: true, action, booking: await bookings.cancel(str(body.token)) } };
|
|
179
|
+
if (action === "move")
|
|
180
|
+
return { status: 200, body: { ok: true, action, booking: await bookings.move(str(body.token), str(body.start)) } };
|
|
181
|
+
throw new BookingsError("bad_input", "action must be book, cancel or move");
|
|
182
|
+
}
|
|
183
|
+
catch (e) {
|
|
184
|
+
return failed(e, { ...(ctx.t ? { t: ctx.t } : {}), max });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* The owner's posts, behind the app's sign-in, with the signed-in owner's
|
|
189
|
+
* account: `approve`, `decline` or `cancel` a booking. A booking of another
|
|
190
|
+
* account is answered as unknown.
|
|
191
|
+
*/
|
|
192
|
+
export async function ownerBookingAction(bookings, body, account) {
|
|
193
|
+
try {
|
|
194
|
+
const action = str(body.action);
|
|
195
|
+
const id = str(body.booking);
|
|
196
|
+
const reason = str(body.reason).trim().slice(0, 200) || undefined;
|
|
197
|
+
if (action === "approve")
|
|
198
|
+
return { status: 200, body: { ok: true, action, booking: await bookings.approve(id, account) } };
|
|
199
|
+
if (action === "decline")
|
|
200
|
+
return { status: 200, body: { ok: true, action, booking: await bookings.decline(id, account, reason) } };
|
|
201
|
+
if (action === "cancel")
|
|
202
|
+
return { status: 200, body: { ok: true, action, booking: await bookings.cancelByOwner(id, account, reason) } };
|
|
203
|
+
throw new BookingsError("bad_input", "action must be approve, decline or cancel");
|
|
204
|
+
}
|
|
205
|
+
catch (e) {
|
|
206
|
+
return failed(e, {});
|
|
207
|
+
}
|
|
208
|
+
}
|
package/dist/words.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const BOOKING_WORD_KEYS: readonly ["picker.title", "picker.empty", "picker.more", "picker.left", "form.title", "form.name", "form.email", "form.phone", "form.phone_optional", "form.note", "form.places", "form.error.places", "form.submit", "form.submit_request", "form.back", "form.error.name", "form.error.email", "form.error.phone", "form.error.note", "error.taken", "error.not_open", "error.too_many", "error.too_late", "error.not_allowed", "error.unknown_booking", "error.failed", "done.confirmed.title", "done.confirmed.body", "done.pending.title", "done.pending.body", "done.ics", "done.manage", "manage.title", "manage.cancel", "manage.move", "manage.locked", "status.pending", "status.confirmed", "status.cancelled", "status.declined", "list.title", "list.empty", "list.approve", "list.decline", "list.cancel", "list.places", "mine.title", "mine.empty", "mine.cancel", "mine.book", "email.hello", "email.booked.subject", "email.booked.body", "email.requested.subject", "email.requested.body", "email.confirmed.subject", "email.confirmed.body", "email.declined.subject", "email.declined.body", "email.cancelled.subject", "email.cancelled.body", "email.moved.subject", "email.moved.body", "email.reminder.subject", "email.reminder.body", "email.places", "email.manage", "email.calendar", "email.owner.new.subject", "email.owner.request.subject", "email.owner.cancelled.subject", "email.owner.moved.subject", "email.owner.body", "email.owner.open", "email.owner.footer"];
|
|
2
|
+
export type BookingWordKey = (typeof BOOKING_WORD_KEYS)[number];
|
|
3
|
+
/** The words in Australian English, as `ui.wbbooking.<key>` would hold them. */
|
|
4
|
+
export declare const BOOKING_WORDS: Readonly<Record<BookingWordKey, string>>;
|
package/dist/words.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// The booking pages' and emails' words, keyed as the project's strings
|
|
2
|
+
// catalogue keys them (`ui.wbbooking.*`), in Australian English. A project
|
|
3
|
+
// copies them into its catalogue (or keeps its own) and passes its `t`; a
|
|
4
|
+
// word the catalogue lacks falls back to the English here. Other languages
|
|
5
|
+
// come from the project's catalogue. No email quotes the customer's note.
|
|
6
|
+
export const BOOKING_WORD_KEYS = [
|
|
7
|
+
"picker.title",
|
|
8
|
+
"picker.empty",
|
|
9
|
+
"picker.more",
|
|
10
|
+
"picker.left",
|
|
11
|
+
"form.title",
|
|
12
|
+
"form.name",
|
|
13
|
+
"form.email",
|
|
14
|
+
"form.phone",
|
|
15
|
+
"form.phone_optional",
|
|
16
|
+
"form.note",
|
|
17
|
+
"form.places",
|
|
18
|
+
"form.error.places",
|
|
19
|
+
"form.submit",
|
|
20
|
+
"form.submit_request",
|
|
21
|
+
"form.back",
|
|
22
|
+
"form.error.name",
|
|
23
|
+
"form.error.email",
|
|
24
|
+
"form.error.phone",
|
|
25
|
+
"form.error.note",
|
|
26
|
+
"error.taken",
|
|
27
|
+
"error.not_open",
|
|
28
|
+
"error.too_many",
|
|
29
|
+
"error.too_late",
|
|
30
|
+
"error.not_allowed",
|
|
31
|
+
"error.unknown_booking",
|
|
32
|
+
"error.failed",
|
|
33
|
+
"done.confirmed.title",
|
|
34
|
+
"done.confirmed.body",
|
|
35
|
+
"done.pending.title",
|
|
36
|
+
"done.pending.body",
|
|
37
|
+
"done.ics",
|
|
38
|
+
"done.manage",
|
|
39
|
+
"manage.title",
|
|
40
|
+
"manage.cancel",
|
|
41
|
+
"manage.move",
|
|
42
|
+
"manage.locked",
|
|
43
|
+
"status.pending",
|
|
44
|
+
"status.confirmed",
|
|
45
|
+
"status.cancelled",
|
|
46
|
+
"status.declined",
|
|
47
|
+
"list.title",
|
|
48
|
+
"list.empty",
|
|
49
|
+
"list.approve",
|
|
50
|
+
"list.decline",
|
|
51
|
+
"list.cancel",
|
|
52
|
+
"list.places",
|
|
53
|
+
"mine.title",
|
|
54
|
+
"mine.empty",
|
|
55
|
+
"mine.cancel",
|
|
56
|
+
"mine.book",
|
|
57
|
+
"email.hello",
|
|
58
|
+
"email.booked.subject",
|
|
59
|
+
"email.booked.body",
|
|
60
|
+
"email.requested.subject",
|
|
61
|
+
"email.requested.body",
|
|
62
|
+
"email.confirmed.subject",
|
|
63
|
+
"email.confirmed.body",
|
|
64
|
+
"email.declined.subject",
|
|
65
|
+
"email.declined.body",
|
|
66
|
+
"email.cancelled.subject",
|
|
67
|
+
"email.cancelled.body",
|
|
68
|
+
"email.moved.subject",
|
|
69
|
+
"email.moved.body",
|
|
70
|
+
"email.reminder.subject",
|
|
71
|
+
"email.reminder.body",
|
|
72
|
+
"email.places",
|
|
73
|
+
"email.manage",
|
|
74
|
+
"email.calendar",
|
|
75
|
+
"email.owner.new.subject",
|
|
76
|
+
"email.owner.request.subject",
|
|
77
|
+
"email.owner.cancelled.subject",
|
|
78
|
+
"email.owner.moved.subject",
|
|
79
|
+
"email.owner.body",
|
|
80
|
+
"email.owner.open",
|
|
81
|
+
"email.owner.footer",
|
|
82
|
+
];
|
|
83
|
+
/** The words in Australian English, as `ui.wbbooking.<key>` would hold them. */
|
|
84
|
+
export const BOOKING_WORDS = {
|
|
85
|
+
"picker.title": "Choose a time",
|
|
86
|
+
"picker.empty": "No free times on these days.",
|
|
87
|
+
"picker.more": "Later dates",
|
|
88
|
+
"picker.left": "{left} places left",
|
|
89
|
+
"form.title": "Your details",
|
|
90
|
+
"form.name": "Your name",
|
|
91
|
+
"form.email": "Email",
|
|
92
|
+
"form.phone": "Phone",
|
|
93
|
+
"form.phone_optional": "Phone (optional)",
|
|
94
|
+
"form.note": "Anything we should know? (optional)",
|
|
95
|
+
"form.places": "How many places",
|
|
96
|
+
"form.submit": "Book",
|
|
97
|
+
"form.submit_request": "Send request",
|
|
98
|
+
"form.back": "Choose another time",
|
|
99
|
+
"form.error.name": "Please enter your name.",
|
|
100
|
+
"form.error.email": "Please enter an email address we can send the confirmation to.",
|
|
101
|
+
"form.error.phone": "Please enter a phone number.",
|
|
102
|
+
"form.error.note": "Please keep the note under 1,000 characters.",
|
|
103
|
+
"form.error.places": "Please choose how many places.",
|
|
104
|
+
"error.taken": "Sorry, someone has just booked that time. Please choose another.",
|
|
105
|
+
"error.not_open": "That time isn't available. Please choose another.",
|
|
106
|
+
"error.too_many": "You already have {max} upcoming bookings with us. Change or cancel one first.",
|
|
107
|
+
"error.too_late": "It's too close to the start to change this online. Please contact us.",
|
|
108
|
+
"error.not_allowed": "Online booking isn't available right now.",
|
|
109
|
+
"error.unknown_booking": "We couldn't find that booking. It may have been cancelled.",
|
|
110
|
+
"error.failed": "Something went wrong on our side. Please try again.",
|
|
111
|
+
"done.confirmed.title": "You're booked",
|
|
112
|
+
"done.confirmed.body": "We've emailed you the details.",
|
|
113
|
+
"done.pending.title": "Request sent",
|
|
114
|
+
"done.pending.body": "We'll email you as soon as it's confirmed.",
|
|
115
|
+
"done.ics": "Add to my calendar",
|
|
116
|
+
"done.manage": "Change or cancel",
|
|
117
|
+
"manage.title": "Your booking",
|
|
118
|
+
"manage.cancel": "Cancel booking",
|
|
119
|
+
"manage.move": "Choose another time",
|
|
120
|
+
"manage.locked": "It's too close to the start to change this online. Please contact us.",
|
|
121
|
+
"status.pending": "Waiting for confirmation",
|
|
122
|
+
"status.confirmed": "Confirmed",
|
|
123
|
+
"status.cancelled": "Cancelled",
|
|
124
|
+
"status.declined": "Not accepted",
|
|
125
|
+
"list.title": "Bookings",
|
|
126
|
+
"list.empty": "No bookings on these days.",
|
|
127
|
+
"list.approve": "Accept",
|
|
128
|
+
"list.decline": "Decline",
|
|
129
|
+
"list.cancel": "Cancel",
|
|
130
|
+
"list.places": "{places} places",
|
|
131
|
+
"mine.title": "My bookings",
|
|
132
|
+
"mine.empty": "You have no upcoming bookings.",
|
|
133
|
+
"mine.cancel": "Cancel booking",
|
|
134
|
+
"mine.book": "Make a booking",
|
|
135
|
+
"email.hello": "Hi {name},",
|
|
136
|
+
"email.booked.subject": "Booked: {service}, {when}",
|
|
137
|
+
"email.booked.body": "You're booked for {service} with {business} on {when}.",
|
|
138
|
+
"email.requested.subject": "Request received: {service}, {when}",
|
|
139
|
+
"email.requested.body": "{business} has your request for {service} on {when}. We'll email you when it's confirmed.",
|
|
140
|
+
"email.confirmed.subject": "Confirmed: {service}, {when}",
|
|
141
|
+
"email.confirmed.body": "{business} has confirmed {service} on {when}.",
|
|
142
|
+
"email.declined.subject": "Not accepted: {service}, {when}",
|
|
143
|
+
"email.declined.body": "Sorry, {business} can't take your booking for {service} on {when}. Please choose another time.",
|
|
144
|
+
"email.cancelled.subject": "Cancelled: {service}, {when}",
|
|
145
|
+
"email.cancelled.body": "Your booking for {service} with {business} on {when} is cancelled.",
|
|
146
|
+
"email.moved.subject": "Moved: {service}, now {when}",
|
|
147
|
+
"email.moved.body": "Your booking for {service} with {business} is now on {when}.",
|
|
148
|
+
"email.reminder.subject": "Reminder: {service}, {when}",
|
|
149
|
+
"email.reminder.body": "A reminder of your booking for {service} with {business} on {when}.",
|
|
150
|
+
"email.places": "Places: {places}",
|
|
151
|
+
"email.manage": "To change or cancel it: {url}",
|
|
152
|
+
"email.calendar": "Open the attached calendar file to add it to your calendar.",
|
|
153
|
+
"email.owner.new.subject": "New booking: {service}, {when}",
|
|
154
|
+
"email.owner.request.subject": "To accept: {service}, {when}",
|
|
155
|
+
"email.owner.cancelled.subject": "Cancelled by the customer: {service}, {when}",
|
|
156
|
+
"email.owner.moved.subject": "Moved by the customer: {service}, now {when}",
|
|
157
|
+
"email.owner.body": "{name} ({email}) booked {service} on {when}.",
|
|
158
|
+
"email.owner.open": "Open your bookings: {url}",
|
|
159
|
+
"email.owner.footer": "Sent by your booking page.",
|
|
160
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mccaskie-labs/workbench-bookings",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "A bookings calendar for Workbench apps: customers pick a free time, book it with their name and email, and get a confirmation email with a calendar file, reminders before it starts and a private link to change or cancel. The owner gets an email for each booking, a list in the app and a calendar feed. Stored in the app's own database, with tick() from the app's cron for reminders. No AI.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/mccaskie-labs/workbench.git",
|
|
10
|
+
"directory": "packages/bookings"
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=24"
|
|
14
|
+
},
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./styles": {
|
|
22
|
+
"types": "./dist/styles.d.ts",
|
|
23
|
+
"default": "./dist/styles.js"
|
|
24
|
+
},
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"bin": {
|
|
28
|
+
"workbench-bookings": "./dist/cli.js"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md",
|
|
33
|
+
"CHANGELOG.md"
|
|
34
|
+
],
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"typecheck": "tsc -p tsconfig.check.json && tsc -p test/tsconfig.json",
|
|
40
|
+
"test": "vitest run",
|
|
41
|
+
"test:store": "vitest run --config vitest.db.config.ts",
|
|
42
|
+
"build": "node scripts/build.mjs",
|
|
43
|
+
"prepack": "node scripts/build.mjs"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "24.19.2",
|
|
47
|
+
"postgres": "4.1.0",
|
|
48
|
+
"vitest": "^5.1.0"
|
|
49
|
+
}
|
|
50
|
+
}
|