@semics-tech/emdash-events 1.0.0-rc.19 → 1.0.0-rc.20

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  Event bookings and ticketing for [EmDash CMS](https://emdashcms.com): events from your own collection,
4
4
  ticket types, capacity, holds, a booking page, confirmation emails, calendar files, a waitlist, recurring
5
5
  events, slot schedules (several bookable time slots a day from one schedule, with a day view to close, reopen
6
- or re-size slots, booked by picking a day on a month calendar, then a time), optional booking approval with admin notifications, booking requests (a preferred date and time window; staff confirm the time), and check-in. MIT licensed.
6
+ or re-size slots, booked by picking a day on a month calendar, then a time), optional booking approval with admin notifications, booking requests (a preferred date and time window; staff confirm the time, or with Events Pro propose another one the buyer accepts on the booking page), and check-in. MIT licensed.
7
7
 
8
8
  The package holds the sandboxed core `semics-events` (its default export) and the UI kit (`/ui`,
9
9
  `/integration`, and the Astro components under `/astro/*.astro`).
package/dist/index.mjs CHANGED
@@ -7,7 +7,7 @@
7
7
  /** @type {import("emdash").PluginDescriptor} */
8
8
  const descriptor = Object.freeze({
9
9
  "id": "semics-events",
10
- "version": "1.0.0-rc.19",
10
+ "version": "1.0.0-rc.20",
11
11
  "format": "standard",
12
12
  "entrypoint": "@semics-tech/emdash-events/sandbox",
13
13
  "capabilities": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "semics-events",
3
- "version": "1.0.0-rc.19",
3
+ "version": "1.0.0-rc.20",
4
4
  "declaredAccess": {
5
5
  "content": {
6
6
  "read": {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@semics-tech/emdash-events",
3
- "version": "1.0.0-rc.19",
3
+ "version": "1.0.0-rc.20",
4
4
  "type": "module",
5
5
  "main": "dist/index.mjs",
6
6
  "exports": {
@@ -122,6 +122,20 @@ const token = ref && !opening ? (Astro.cookies.get(bookingCookieName(ref))?.valu
122
122
 
123
123
  let cancelled = false;
124
124
  if (ref && token && form) {
125
+ // Another time the organiser proposed (Events Pro, T174c): accepted, or "That doesn't work" (cancelled and refunded).
126
+ const answer = form.get("intent");
127
+ if (answer === "accept-time" || answer === "refuse-time") {
128
+ const accept = answer === "accept-time";
129
+ const result = await callPublicRoute(ctx, {
130
+ method: "POST",
131
+ path: `public/booking/request/${accept ? "accept" : "refuse"}`,
132
+ pluginId,
133
+ body: { bookingRef: ref, accessToken: token },
134
+ });
135
+ notice = result.ok
136
+ ? t(accept ? "booking.proposal.accepted" : "booking.proposal.refused")
137
+ : errorText(result.error.code, "booking.proposal.failed");
138
+ }
125
139
  if (form.get("intent") === "cancel") {
126
140
  const result = await callPublicRoute(ctx, {
127
141
  method: "POST",
@@ -219,7 +233,7 @@ const passes = booking && confirmed ? booking.attendees.filter((a) => a.code) :
219
233
  </form>
220
234
  ) : booking ? (
221
235
  <>
222
- <BookingStatus booking={booking} cancelled={cancelled} ticketNames={names} bookAgain={eventPageHref(booking.event?.slug, page.eventPath)} showAttendees={!signingList} locale={locale} />
236
+ <BookingStatus booking={booking} cancelled={cancelled} proposalAction={`/booking?ref=${ref}`} ticketNames={names} bookAgain={eventPageHref(booking.event?.slug, page.eventPath)} showAttendees={!signingList} locale={locale} />
223
237
  {payment && <PaymentReturn view={payment} bookingRef={ref} action={`/booking?ref=${ref}`} locale={locale} />}
224
238
  {waiverNext && (
225
239
  <section class="semics-events semics-waiver-step" data-testid="waiver-step" aria-labelledby="semics-waiver-step-title">
@@ -2,7 +2,9 @@
2
2
  // <BookingStatus>: a booking's summary card (EU-FR-06). Rendered by the `/booking` page from the
3
3
  // `public/booking` answer. It leads with the event and the booked session, in the event's zone, and the
4
4
  // place (T157), then the state, the order and its total. With `cancelAction` it ends with the quiet cancel
5
- // action (`<CancelBooking>`); the booking page instead puts that at its foot.
5
+ // action (`<CancelBooking>`); the booking page instead puts that at its foot. A request awaiting approval with another
6
+ // time the organiser proposed (Events Pro, T174c) shows it with Accept and "That doesn't work": with `proposalAction`,
7
+ // two plain forms (`intent=accept-time` / `refuse-time`) that post there, so they work without JavaScript.
6
8
  import { around, pickLocale, translator } from "../i18n/index";
7
9
  import CancelBooking from "./CancelBooking.astro";
8
10
  import { zonedAt } from "./lib/list";
@@ -12,6 +14,8 @@ interface Props {
12
14
  booking: BookingView;
13
15
  /** Shown as cancelled (the page just cancelled it). */
14
16
  cancelled?: boolean;
17
+ /** Where the Accept / "That doesn't work" forms of a proposed time post; without it they are not shown. */
18
+ proposalAction?: string;
15
19
  /** Where the cancel form posts; without it the card has no cancel action. */
16
20
  cancelAction?: string;
17
21
  /** Ticket type names by id, when the page knows them. */
@@ -23,12 +27,18 @@ interface Props {
23
27
  locale?: string;
24
28
  }
25
29
 
26
- const { booking, cancelled = false, cancelAction, ticketNames = {}, bookAgain, showAttendees = true } = Astro.props;
30
+ const { booking, cancelled = false, cancelAction, proposalAction, ticketNames = {}, bookAgain, showAttendees = true } =
31
+ Astro.props;
27
32
  const locale = pickLocale(Astro.props.locale, Astro.currentLocale);
28
33
  const { t, plural, lang, dir } = translator(locale);
34
+ // Another time the organiser proposed (Pro, T174c): the buyer's answer is due by the deadline.
35
+ const proposed =
36
+ !cancelled && booking.status === "awaiting_approval" && booking.proposed && Number.isFinite(Date.parse(booking.proposed.startsAt))
37
+ ? booking.proposed
38
+ : undefined;
29
39
  // A request awaiting approval (T131) holds its places until the organiser's deadline.
30
40
  const [heldBefore, heldAfter] = around(
31
- t(booking.status === "awaiting_approval" ? "booking.decideBy" : "booking.heldUntil"),
41
+ t(proposed ? "booking.proposal.answerBy" : booking.status === "awaiting_approval" ? "booking.decideBy" : "booking.heldUntil"),
32
42
  "time",
33
43
  );
34
44
  const tickets = booking.lines.reduce((n, line) => n + line.qty, 0);
@@ -64,7 +74,27 @@ const names = showAttendees && new Set(named).size > 1 ? named : [];
64
74
  </p>
65
75
  </div>
66
76
  {/* A booking request (T174a) waiting for the organiser to agree a time. */}
67
- {status === "awaiting_approval" && booking.requested && <p class="semics-booking-note" data-testid="booking-request">{t("booking.requestSent")}</p>}
77
+ {status === "awaiting_approval" && booking.requested && !proposed && <p class="semics-booking-note" data-testid="booking-request">{t("booking.requestSent")}</p>}
78
+ {proposed && (
79
+ <section class="semics-booking-proposal" data-testid="booking-proposal" aria-labelledby="semics-booking-proposal-title">
80
+ <h3 id="semics-booking-proposal-title">{t("booking.proposal.title")}</h3>
81
+ <p>{t("booking.proposal.lead")}</p>
82
+ <p class="semics-booking-when"><time datetime={proposed.startsAt} data-testid="booking-proposed">{at(proposed.startsAt)}</time></p>
83
+ {proposalAction && (
84
+ <div class="semics-booking-proposal-actions">
85
+ <form method="post" action={proposalAction}>
86
+ <input type="hidden" name="intent" value="accept-time" />
87
+ <button type="submit" data-testid="booking-proposal-accept">{t("booking.proposal.accept")}</button>
88
+ </form>
89
+ <form method="post" action={proposalAction}>
90
+ <input type="hidden" name="intent" value="refuse-time" />
91
+ <button type="submit" class="semics-booking-refuse" data-testid="booking-proposal-refuse">{t("booking.proposal.refuse")}</button>
92
+ </form>
93
+ </div>
94
+ )}
95
+ {proposalAction && <p class="semics-booking-note">{t("booking.proposal.refuseNote")}</p>}
96
+ </section>
97
+ )}
68
98
  {
69
99
  !cancelled && booking.holdExpiresAt && (
70
100
  <p class="semics-booking-note" data-testid="booking-hold">
@@ -163,6 +193,29 @@ const names = showAttendees && new Set(named).size > 1 ? named : [];
163
193
  .semics-booking-note {
164
194
  color: var(--events-muted, #4a4a4a);
165
195
  }
196
+ .semics-booking-proposal {
197
+ margin-block: 1rem;
198
+ padding: 0.75rem 1rem;
199
+ border: 1px solid color-mix(in srgb, var(--events-border, #6b6b6b) 40%, transparent);
200
+ border-radius: 0.5rem;
201
+ }
202
+ .semics-booking-proposal h3 {
203
+ margin: 0 0 0.5rem;
204
+ font-size: 1rem;
205
+ }
206
+ .semics-booking-proposal-actions {
207
+ display: flex;
208
+ flex-wrap: wrap;
209
+ gap: 0.5rem;
210
+ margin-block: 0.75rem 0.5rem;
211
+ }
212
+ .semics-booking-proposal-actions form {
213
+ margin: 0;
214
+ }
215
+ .semics-booking-proposal-actions .semics-booking-refuse {
216
+ background: transparent;
217
+ color: var(--events-accent, #0b57d0);
218
+ }
166
219
  .semics-booking-order {
167
220
  margin-block-start: 1.25rem;
168
221
  padding-block-start: 1rem;
@@ -129,6 +129,11 @@ export interface BookingView {
129
129
  event?: { title?: string; startsAt?: string; timezone?: string | null; venue?: string | null; slug?: string | null };
130
130
  /** A booking request whose time is still to be agreed (T174a): what was asked for, "Sat 12 Dec, AM". */
131
131
  requested?: string;
132
+ /**
133
+ * Events Pro (T174c): another time the organiser proposed for a request awaiting approval. The buyer accepts it or
134
+ * says it doesn't work (`public/booking/request/accept` / `.../refuse`) by `holdExpiresAt`.
135
+ */
136
+ proposed?: { startsAt: string; endsAt?: string };
132
137
  /** Why the organiser declined (`status: "declined"`), when they said. */
133
138
  declineReason?: string | null;
134
139
  /** Declined, a price was due and no money was taken (`closeBooking`). */
package/src/i18n/ar.ts CHANGED
@@ -120,6 +120,15 @@ export const ar: Messages = {
120
120
  "booking.decideBy": "سيوافق المنظّم على طلبك أو يرفضه بحلول {time}، وسنراسلك بالبريد الإلكتروني.",
121
121
  "booking.requestSent": "أُرسل الطلب: سنتفق معك على موعد.",
122
122
  "booking.requested": "المطلوب: {when}، والموعد قيد الاتفاق.",
123
+ "booking.proposal.title": "اقترح المنظّم موعدًا آخر",
124
+ "booking.proposal.lead": "لا يمكننا الالتزام بالموعد الذي طلبته، لكن يمكننا تقديم هذا الموعد:",
125
+ "booking.proposal.answerBy": "يُرجى الرد بحلول {time}. إن لم تفعل، يسقط الطلب ويُردّ أي مبلغ مدفوع كاملًا.",
126
+ "booking.proposal.accept": "قبول هذا الموعد",
127
+ "booking.proposal.refuse": "هذا الموعد لا يناسبني",
128
+ "booking.proposal.refuseNote": "سيُلغى طلبك ويُردّ أي مبلغ مدفوع كاملًا.",
129
+ "booking.proposal.accepted": "شكرًا لك: تأكّد حجزك في الموعد الجديد.",
130
+ "booking.proposal.refused": "أُلغي طلبك. سيُردّ أي مبلغ مدفوع كاملًا.",
131
+ "booking.proposal.failed": "تعذّر علينا تسجيل ردّك. يُرجى المحاولة مرة أخرى.",
123
132
  "booking.line": "{qty} × {name}",
124
133
  "booking.voucher": "قسيمة هدية",
125
134
  "booking.total": "المجموع",
package/src/i18n/en.ts CHANGED
@@ -114,6 +114,16 @@ export const en = {
114
114
  "booking.decideBy": "The organiser will approve or decline your request by {time}; we will email you.",
115
115
  "booking.requestSent": "Request sent: we'll confirm a time with you.",
116
116
  "booking.requested": "Requested: {when}, time to be agreed.",
117
+ "booking.proposal.title": "The organiser proposed another time",
118
+ "booking.proposal.lead": "We can't do the time you asked for, but can offer this one:",
119
+ "booking.proposal.answerBy":
120
+ "Please answer by {time}. If you don't, the request lapses and any payment is refunded in full.",
121
+ "booking.proposal.accept": "Accept this time",
122
+ "booking.proposal.refuse": "That doesn't work",
123
+ "booking.proposal.refuseNote": "Your request is cancelled and any payment refunded in full.",
124
+ "booking.proposal.accepted": "Thank you: your booking is confirmed for the new time.",
125
+ "booking.proposal.refused": "Your request was cancelled. Any payment will be refunded in full.",
126
+ "booking.proposal.failed": "We could not record your answer. Please try again.",
117
127
  "booking.declinedReason": "The organiser's reason: {reason}",
118
128
  "booking.notCharged": "Your card was not charged.",
119
129
  "booking.lapsed":