@semics-tech/emdash-events 1.0.0-rc.24 → 1.0.0-rc.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +1 -1
- package/dist/manifest.json +1 -1
- package/package.json +1 -1
- package/src/astro/BookingWidget.astro +5 -1
- package/src/client/booking.ts +7 -0
- package/src/i18n/ar.ts +1 -0
- package/src/i18n/en.ts +1 -0
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.
|
|
10
|
+
"version": "1.0.0-rc.25",
|
|
11
11
|
"format": "standard",
|
|
12
12
|
"entrypoint": "@semics-tech/emdash-events/sandbox",
|
|
13
13
|
"capabilities": [
|
package/dist/manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -395,6 +395,8 @@ const when = (iso: string) => {
|
|
|
395
395
|
{placeTypes.map((type) => {
|
|
396
396
|
const soldOut = type.available === 0;
|
|
397
397
|
const max = Math.min(type.maxPerOrder ?? 50, type.available ?? 50, 50);
|
|
398
|
+
// Its fewest per order (T174g): the script refuses fewer, but not none, before sending.
|
|
399
|
+
const min = type.minPerOrder ?? 1;
|
|
398
400
|
const price = formatMoney(type.priceMinor, data?.currency ?? "GBP", locale);
|
|
399
401
|
// A party package (Events Pro, T174f): one price for the group; its quantity is the people.
|
|
400
402
|
return (
|
|
@@ -403,7 +405,7 @@ const when = (iso: string) => {
|
|
|
403
405
|
<span class="semics-ticket-name">{type.name}</span>
|
|
404
406
|
<span class="semics-ticket-price">{type.package ? t("widget.packagePrice", { price }) : price}</span>
|
|
405
407
|
{type.package && (
|
|
406
|
-
<span class="semics-hint">{t("widget.packagePeople", { min: String(
|
|
408
|
+
<span class="semics-hint">{t("widget.packagePeople", { min: String(min), max: String(max) })}</span>
|
|
407
409
|
)}
|
|
408
410
|
{soldOut && <span class="semics-ticket-soldout">{t("widget.soldOut")}</span>}
|
|
409
411
|
</label>
|
|
@@ -417,6 +419,8 @@ const when = (iso: string) => {
|
|
|
417
419
|
max={String(max)}
|
|
418
420
|
disabled={soldOut}
|
|
419
421
|
data-package={type.package ? "" : undefined}
|
|
422
|
+
data-min={min > 1 ? String(min) : undefined}
|
|
423
|
+
data-min-message={min > 1 ? t("widget.field.minimum", { min: String(min), name: type.name }) : undefined}
|
|
420
424
|
data-price-minor={String(type.priceMinor)}
|
|
421
425
|
/>
|
|
422
426
|
</div>
|
package/src/client/booking.ts
CHANGED
|
@@ -73,6 +73,9 @@ export function orderTotalMinor(lines: ReadonlyArray<{ qty: number; priceMinor:
|
|
|
73
73
|
return total;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/** Fewer than a ticket type's fewest per order (a party package's people, T174g); none is fine. Reserve refuses it too. */
|
|
77
|
+
export const tooFew = (qty: number, min: number) => qty > 0 && qty < min;
|
|
78
|
+
|
|
76
79
|
/**
|
|
77
80
|
* The most of a per-person add-on (T174d) the buyer may order: one each for the places chosen, within the add-on's
|
|
78
81
|
* own limit. Pro's reserve refuses more (`INVALID_QUANTITY`), so without this script the server says so.
|
|
@@ -193,11 +196,15 @@ export function enhance(form: HTMLFormElement): void {
|
|
|
193
196
|
}),
|
|
194
197
|
...missingAnswers(questionStates(form)),
|
|
195
198
|
];
|
|
199
|
+
const short = places.find((i) => tooFew(qtyOf(i), Number(i.dataset.min)));
|
|
200
|
+
if (short && !bad.includes("tickets")) bad.push("tickets");
|
|
196
201
|
const needsCheck = form.dataset.turnstile === "on" && fieldValue(form, "cf-turnstile-response") === "";
|
|
197
202
|
if (bad.length > 0 || needsCheck) {
|
|
198
203
|
event.preventDefault();
|
|
199
204
|
formAlert(form, needsCheck && bad.length === 0 ? (form.dataset.turnstileMessage ?? "") : "");
|
|
200
205
|
showErrors(form, bad);
|
|
206
|
+
const message = short && form.querySelector<HTMLElement>('[data-error-for="tickets"]');
|
|
207
|
+
if (message) message.textContent = short.dataset.minMessage ?? "";
|
|
201
208
|
return;
|
|
202
209
|
}
|
|
203
210
|
formAlert(form, "");
|
package/src/i18n/ar.ts
CHANGED
|
@@ -54,6 +54,7 @@ export const ar: Messages = {
|
|
|
54
54
|
"widget.field.promo": "تحقق من الرمز، أو اترك الحقل فارغًا.",
|
|
55
55
|
"widget.field.voucher": "تحقق من الرمز، أو اترك الحقل فارغًا.",
|
|
56
56
|
"widget.field.tickets": "اختر تذكرة واحدة على الأقل.",
|
|
57
|
+
"widget.field.minimum": "اختر {min} على الأقل من {name}، أو لا شيء.",
|
|
57
58
|
"widget.field.name": "أدخل اسمك.",
|
|
58
59
|
"widget.field.email": "أدخل بريدًا إلكترونيًا صحيحًا.",
|
|
59
60
|
"widget.error.BAD_REQUEST": "يُرجى مراجعة البيانات المحددة.",
|
package/src/i18n/en.ts
CHANGED
|
@@ -55,6 +55,7 @@ export const en = {
|
|
|
55
55
|
"widget.field.promo": "Check the code, or leave it empty.",
|
|
56
56
|
"widget.field.voucher": "Check the code, or leave it empty.",
|
|
57
57
|
"widget.field.tickets": "Choose at least one ticket.",
|
|
58
|
+
"widget.field.minimum": "Choose at least {min} for {name}, or none.",
|
|
58
59
|
"widget.field.name": "Enter your name.",
|
|
59
60
|
"widget.field.email": "Enter a valid email address.",
|
|
60
61
|
"widget.error.BAD_REQUEST": "Please check the highlighted details.",
|