@wodira/browser 1.0.0 → 1.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 +27 -0
- package/README.md +111 -1
- package/dist/index.cjs +36 -0
- package/dist/index.d.ts +90 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/boxes/cdn.js +15 -15
- package/dist/ui/boxes/index.js +4 -4
- package/dist/ui/components.d.ts +33 -1
- package/dist/ui/components.d.ts.map +1 -1
- package/dist/ui/events.d.ts +1 -1
- package/dist/ui/events.d.ts.map +1 -1
- package/dist/ui/i18n.d.ts +1 -1
- package/dist/ui/i18n.d.ts.map +1 -1
- package/dist/ui/index-dqnha6dj.js +1625 -0
- package/dist/ui/index-h2b598n9.js +1624 -0
- package/dist/ui/{index-tfej862z.js → index-k8s7q1sf.js} +50 -1568
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +352 -125
- package/dist/ui/map-view-8tyrehav.js +28737 -0
- package/dist/ui/maplibre-gl-worker.mjs +10 -0
- package/dist/ui/route-3d/cdn.d.ts +2 -0
- package/dist/ui/route-3d/cdn.d.ts.map +1 -0
- package/dist/ui/route-3d/cdn.js +1527 -0
- package/dist/ui/route-3d/gpx.d.ts +14 -0
- package/dist/ui/route-3d/gpx.d.ts.map +1 -0
- package/dist/ui/route-3d/index.d.ts +12 -0
- package/dist/ui/route-3d/index.d.ts.map +1 -0
- package/dist/ui/route-3d/index.js +16 -0
- package/dist/ui/route-3d/map-view.d.ts +73 -0
- package/dist/ui/route-3d/map-view.d.ts.map +1 -0
- package/dist/ui/route-3d/maplibre-gl-worker.mjs +10 -0
- package/dist/ui/route-3d/route-3d.d.ts +168 -0
- package/dist/ui/route-3d/route-3d.d.ts.map +1 -0
- package/dist/ui/route-3d/route-geo.d.ts +77 -0
- package/dist/ui/route-3d/route-geo.d.ts.map +1 -0
- package/dist/ui/shirt-sponsors/cdn.js +29 -27
- package/dist/ui/shirt-sponsors/index.js +5 -3
- package/dist/ui/shirt-sponsors/shirt-auction.d.ts +19 -0
- package/dist/ui/shirt-sponsors/shirt-auction.d.ts.map +1 -1
- package/package.json +15 -6
package/dist/ui/index.js
CHANGED
|
@@ -6,12 +6,18 @@ import {
|
|
|
6
6
|
nothing,
|
|
7
7
|
LitElement,
|
|
8
8
|
WodiraBrowserApiError,
|
|
9
|
-
createWodiraBrowserClient
|
|
9
|
+
createWodiraBrowserClient
|
|
10
|
+
} from "./index-k8s7q1sf.js";
|
|
11
|
+
import {
|
|
10
12
|
wodiraUiStyles,
|
|
11
13
|
WodiraShirtAuction2,
|
|
12
14
|
defineWodiraShirtElements2
|
|
13
|
-
} from "./index-
|
|
14
|
-
|
|
15
|
+
} from "./index-h2b598n9.js";
|
|
16
|
+
import {
|
|
17
|
+
WodiraRoute3d2,
|
|
18
|
+
defineWodiraRouteElements2
|
|
19
|
+
} from "./index-dqnha6dj.js";
|
|
20
|
+
__chunks(import.meta.url,["1xp38xw4","k8s7q1sf","h2b598n9","dqnha6dj","jyks1h8f","8tyrehav","xdhg885t"],[["./index.js",1,2,3],["./index-k8s7q1sf.js"],["./index-h2b598n9.js",1],["./index-dqnha6dj.js",1],["./shirt-3d-renderer-jyks1h8f.js",6],["./map-view-8tyrehav.js",3],["./index-xdhg885t.js"]],0);
|
|
15
21
|
|
|
16
22
|
// ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/iso.js
|
|
17
23
|
var exports_iso = {};
|
|
@@ -117,6 +123,7 @@ var es = {
|
|
|
117
123
|
male: "Masculino",
|
|
118
124
|
phone: "Teléfono",
|
|
119
125
|
participantSlot: "Plaza",
|
|
126
|
+
participant: "Participante",
|
|
120
127
|
noPublishableKey: "Configura publishable-key.",
|
|
121
128
|
processingFee: "Fee procesamiento Stripe",
|
|
122
129
|
promocode: "Código promocional",
|
|
@@ -141,9 +148,12 @@ var es = {
|
|
|
141
148
|
select: "Seleccionar",
|
|
142
149
|
selectCategory: "Selecciona una categoría.",
|
|
143
150
|
selectEvent: "Ver inscripciones",
|
|
151
|
+
yesAnswer: "Sí",
|
|
152
|
+
noAnswer: "No",
|
|
144
153
|
selectOption: "Seleccionar",
|
|
145
154
|
summary: "Resumen",
|
|
146
155
|
teamName: "Nombre del dorsal/equipo",
|
|
156
|
+
bibName: "Nombre del dorsal",
|
|
147
157
|
teamSize: "Equipo de",
|
|
148
158
|
tierTicketsFrom: "Desde la inscripción",
|
|
149
159
|
tierTicketsRange: "Inscripciones",
|
|
@@ -244,6 +254,7 @@ var en = {
|
|
|
244
254
|
male: "Male",
|
|
245
255
|
phone: "Phone",
|
|
246
256
|
participantSlot: "Slot",
|
|
257
|
+
participant: "Participant",
|
|
247
258
|
noPublishableKey: "Configure publishable-key.",
|
|
248
259
|
processingFee: "Stripe processing fee",
|
|
249
260
|
promocode: "Promo code",
|
|
@@ -268,9 +279,12 @@ var en = {
|
|
|
268
279
|
select: "Select",
|
|
269
280
|
selectCategory: "Select a category.",
|
|
270
281
|
selectEvent: "View registrations",
|
|
282
|
+
yesAnswer: "Yes",
|
|
283
|
+
noAnswer: "No",
|
|
271
284
|
selectOption: "Select",
|
|
272
285
|
summary: "Summary",
|
|
273
286
|
teamName: "Bib/team name",
|
|
287
|
+
bibName: "Bib name",
|
|
274
288
|
teamSize: "Team of",
|
|
275
289
|
tierTicketsFrom: "From registration",
|
|
276
290
|
tierTicketsRange: "Registrations",
|
|
@@ -424,7 +438,7 @@ class WodiraSignaturePad extends LitElement {
|
|
|
424
438
|
}));
|
|
425
439
|
}
|
|
426
440
|
}
|
|
427
|
-
// ../../node_modules/.pnpm/@wodira+common@file+packages+common_@wodira+db@file+packages+database_@typescript+
|
|
441
|
+
// ../../node_modules/.pnpm/@wodira+common@file+packages+common_@wodira+db@file+packages+database_@typescript+types_7099b171df80daee011599dba9f7981d/node_modules/@wodira/common/dist/email-validation.js
|
|
428
442
|
var COMMON_EMAIL_DOMAINS = [
|
|
429
443
|
"gmail.com",
|
|
430
444
|
"outlook.com",
|
|
@@ -486,7 +500,7 @@ function suggestEmailCorrection(email) {
|
|
|
486
500
|
return null;
|
|
487
501
|
return `${value.slice(0, value.lastIndexOf("@"))}@${candidates[0]}`;
|
|
488
502
|
}
|
|
489
|
-
// ../../node_modules/.pnpm/@wodira+common@file+packages+common_@wodira+db@file+packages+database_@typescript+
|
|
503
|
+
// ../../node_modules/.pnpm/@wodira+common@file+packages+common_@wodira+db@file+packages+database_@typescript+types_7099b171df80daee011599dba9f7981d/node_modules/@wodira/common/dist/browser-modules/event-waivers.js
|
|
490
504
|
function applicableEventWaivers(waivers, categoryIds) {
|
|
491
505
|
const selected = new Set(typeof categoryIds === "string" ? [categoryIds] : categoryIds ?? []);
|
|
492
506
|
return waivers.filter((waiver) => {
|
|
@@ -6337,7 +6351,7 @@ function time2(params) {
|
|
|
6337
6351
|
function duration2(params) {
|
|
6338
6352
|
return _isoDuration(ZodISODuration, params);
|
|
6339
6353
|
}
|
|
6340
|
-
// ../../node_modules/.pnpm/@wodira+common@file+packages+common_@wodira+db@file+packages+database_@typescript+
|
|
6354
|
+
// ../../node_modules/.pnpm/@wodira+common@file+packages+common_@wodira+db@file+packages+database_@typescript+types_7099b171df80daee011599dba9f7981d/node_modules/@wodira/common/dist/browser-modules/validators/phone.validator.js
|
|
6341
6355
|
var E164_PHONE_PATTERN = /^\+[1-9]\d{6,14}$/;
|
|
6342
6356
|
var E164_VISUAL_SEPARATOR_PATTERN = /[\s().-]/g;
|
|
6343
6357
|
function normalizeE164Phone(value) {
|
|
@@ -6351,7 +6365,7 @@ var OptionalE164PhoneValidator = preprocess((value) => {
|
|
|
6351
6365
|
return normalized === "" ? "" : normalized;
|
|
6352
6366
|
}, E164PhoneValidator.optional().or(literal("")));
|
|
6353
6367
|
|
|
6354
|
-
// ../../node_modules/.pnpm/@wodira+common@file+packages+common_@wodira+db@file+packages+database_@typescript+
|
|
6368
|
+
// ../../node_modules/.pnpm/@wodira+common@file+packages+common_@wodira+db@file+packages+database_@typescript+types_7099b171df80daee011599dba9f7981d/node_modules/@wodira/common/dist/browser-modules/validators/commons.validators.js
|
|
6355
6369
|
var SortOrderEnum = _enum(["asc", "desc"]).describe("Sort Order Enum schema.");
|
|
6356
6370
|
var GenderEnum = _enum(["MALE", "FEMALE"]).describe("Gender Enum schema.");
|
|
6357
6371
|
var ActivityLevelEnum = _enum([
|
|
@@ -6473,7 +6487,7 @@ var SpectatorSchema = object({
|
|
|
6473
6487
|
birthDate: exports_iso.date("Spectator birthDate must be a valid date").describe("Birth Date field.")
|
|
6474
6488
|
});
|
|
6475
6489
|
|
|
6476
|
-
// ../../node_modules/.pnpm/@wodira+common@file+packages+common_@wodira+db@file+packages+database_@typescript+
|
|
6490
|
+
// ../../node_modules/.pnpm/@wodira+common@file+packages+common_@wodira+db@file+packages+database_@typescript+types_7099b171df80daee011599dba9f7981d/node_modules/@wodira/common/dist/browser-modules/validators/payment.validator.js
|
|
6477
6491
|
var promotionAttributionSchema = object({
|
|
6478
6492
|
campaignId: string2().min(1, "Campaign ID is required").describe("Campaign Id field."),
|
|
6479
6493
|
sessionId: string2().min(1, "Session ID is required").describe("Session Id field."),
|
|
@@ -6582,13 +6596,18 @@ var legalSignatureSchema = object({
|
|
|
6582
6596
|
var pendingLegalSignatureSchema = union([legalSignatureSchema, object({}).strict().transform(() => {
|
|
6583
6597
|
return;
|
|
6584
6598
|
})]);
|
|
6599
|
+
var registrationConditionAnswersSchema = array(object({
|
|
6600
|
+
fieldId: string2().min(1),
|
|
6601
|
+
value: unknown()
|
|
6602
|
+
})).max(250);
|
|
6603
|
+
var registrationAthleteSchema = AthleteSchema.extend({ customFields: registrationConditionAnswersSchema.optional() });
|
|
6585
6604
|
var guestRegistrationSchema = object({
|
|
6586
6605
|
guestEmail: email2("Guest email must be valid").describe("Guest Email field."),
|
|
6587
6606
|
guestName: string2().min(2, "Guest name is required").describe("Guest Name field."),
|
|
6588
6607
|
categoryId: string2().min(1, "Category ID is required").describe("Category Id field."),
|
|
6589
6608
|
teamName: string2().min(1, "Team name is required").describe("Team Name field."),
|
|
6590
6609
|
club: string2().optional().describe("Club field."),
|
|
6591
|
-
athletes: array(
|
|
6610
|
+
athletes: array(registrationAthleteSchema).min(1, "At least one athlete is required").describe("Athletes field."),
|
|
6592
6611
|
customFields: array(object({
|
|
6593
6612
|
fieldId: string2().min(1, "Field ID is required").describe("Field Id field."),
|
|
6594
6613
|
value: any().describe("Value field.")
|
|
@@ -6606,7 +6625,7 @@ var buyEventAthleteTicketBaseSchema = object({
|
|
|
6606
6625
|
promocode: string2().uppercase().optional().describe("Promocode field."),
|
|
6607
6626
|
referralCode: string2().trim().max(20).optional().describe("Referral code from a friend link (Invita a tus amigos)."),
|
|
6608
6627
|
useReferralCredit: boolean2().optional().describe("Spend referral credit on this checkout."),
|
|
6609
|
-
athletes: array(
|
|
6628
|
+
athletes: array(registrationAthleteSchema).min(1, "At least one athlete is required").describe("Athletes field."),
|
|
6610
6629
|
deferredTeamCompletion: deferredTeamCompletionSchema.optional().describe("Participant places that will be completed after payment."),
|
|
6611
6630
|
products: array(object({
|
|
6612
6631
|
productId: string2().min(1, "Product ID is required").describe("Product Id field."),
|
|
@@ -6637,11 +6656,13 @@ var buyEventAthleteTicketSchema = buyEventAthleteTicketBaseSchema.superRefine((v
|
|
|
6637
6656
|
});
|
|
6638
6657
|
});
|
|
6639
6658
|
var guestRegistrationSummaryInputSchema = object({
|
|
6659
|
+
participantCustomFields: array(registrationConditionAnswersSchema).max(100).optional(),
|
|
6640
6660
|
categoryId: string2().min(1, "Category ID is required").describe("Category Id field."),
|
|
6641
6661
|
selectedSupplementIds: array(string2()).optional().describe("Selected Supplement Ids field."),
|
|
6642
6662
|
supplementSelections: array(supplementSelectionSchema).optional().describe("Supplement Selections field.")
|
|
6643
6663
|
});
|
|
6644
6664
|
var getBuyAthleteTicketSummarySchema = object({
|
|
6665
|
+
participantCustomFields: array(registrationConditionAnswersSchema).max(100).optional(),
|
|
6645
6666
|
previewToken: string2().trim().min(1).optional().describe("Event preview token."),
|
|
6646
6667
|
categoryId: string2().min(1, "Category ID is required").describe("Category Id field."),
|
|
6647
6668
|
products: array(object({
|
|
@@ -6719,7 +6740,8 @@ var buyAthleteTicketSummaryResponseSchema = object({
|
|
|
6719
6740
|
unavailableReason: _enum([
|
|
6720
6741
|
"INDIVIDUAL_CATEGORY",
|
|
6721
6742
|
"SIGNATURE_REQUIRED",
|
|
6722
|
-
"DEADLINE_PASSED"
|
|
6743
|
+
"DEADLINE_PASSED",
|
|
6744
|
+
"CONDITIONAL_ITEMS"
|
|
6723
6745
|
]).optional()
|
|
6724
6746
|
}).optional().describe("Deferred team participant completion availability."),
|
|
6725
6747
|
referralDiscount: number2().min(0).default(0),
|
|
@@ -6892,7 +6914,7 @@ var boxInvoiceListItemSchema = object({
|
|
|
6892
6914
|
receiptNumber: string2().nullable().optional().describe("Manual operation receipt number.")
|
|
6893
6915
|
}).describe("A single row in the organizer box invoices list.");
|
|
6894
6916
|
var claimGuestRegistrationSchema = object({ claimToken: string2().min(1, "Claim token is required").describe("Claim Token field.") });
|
|
6895
|
-
// ../../node_modules/.pnpm/@wodira+common@file+packages+common_@wodira+db@file+packages+database_@typescript+
|
|
6917
|
+
// ../../node_modules/.pnpm/@wodira+common@file+packages+common_@wodira+db@file+packages+database_@typescript+types_7099b171df80daee011599dba9f7981d/node_modules/@wodira/common/dist/browser-modules/validators/event-form-answer.validator.js
|
|
6896
6918
|
function eventFormAnswerSchema(field) {
|
|
6897
6919
|
const options = field.options ?? [];
|
|
6898
6920
|
let schema;
|
|
@@ -6918,6 +6940,11 @@ function eventFormAnswerSchema(field) {
|
|
|
6918
6940
|
}
|
|
6919
6941
|
return preprocess((value) => value === null || value === undefined || typeof value === "string" && !value.trim() || Array.isArray(value) && !value.length ? undefined : value, field.isRequired ? schema : schema.optional());
|
|
6920
6942
|
}
|
|
6943
|
+
// ../../node_modules/.pnpm/@wodira+common@file+packages+common_@wodira+db@file+packages+database_@typescript+types_7099b171df80daee011599dba9f7981d/node_modules/@wodira/common/dist/browser-modules/registration-visibility.js
|
|
6944
|
+
function matchesRegistrationVisibilityCondition(condition, participants = []) {
|
|
6945
|
+
return condition == null || participants.some((answers) => answers.some(({ fieldId, value }) => fieldId === condition.fieldId && value === condition.value));
|
|
6946
|
+
}
|
|
6947
|
+
|
|
6921
6948
|
// src/ui/events.ts
|
|
6922
6949
|
function emitWodiraEvent(target, name, detail) {
|
|
6923
6950
|
target.dispatchEvent(new CustomEvent(name, {
|
|
@@ -8217,6 +8244,7 @@ class WodiraPricingCards extends RegistrationWindowElement {
|
|
|
8217
8244
|
error: { type: String, state: true }
|
|
8218
8245
|
};
|
|
8219
8246
|
didInitialLoad = false;
|
|
8247
|
+
pricingRequest = 0;
|
|
8220
8248
|
constructor() {
|
|
8221
8249
|
super();
|
|
8222
8250
|
this.publishableKey = "";
|
|
@@ -8262,6 +8290,10 @@ class WodiraPricingCards extends RegistrationWindowElement {
|
|
|
8262
8290
|
const selected = this.selectedCategoryId === card.id;
|
|
8263
8291
|
const unavailable = registrationWindowMessage(this.pricing, this.locale) || categoryAvailabilityMessage(card, this.locale);
|
|
8264
8292
|
const remaining = card.quota === null || card.quota === undefined ? null : Math.max(0, card.quota - card.registered);
|
|
8293
|
+
const details = [
|
|
8294
|
+
card.teamSize > 1 ? `${t(this.locale, "teamSize")} ${formatNumber(card.teamSize, this.locale)}` : "",
|
|
8295
|
+
remaining === null ? "" : `${formatNumber(remaining, this.locale)} ${t(this.locale, "availableSlots")}`
|
|
8296
|
+
].filter(Boolean).join(" · ");
|
|
8265
8297
|
return html`
|
|
8266
8298
|
<article part="card pricing-card ${selected ? "selected" : ""}">
|
|
8267
8299
|
<div part="stack">
|
|
@@ -8272,10 +8304,7 @@ class WodiraPricingCards extends RegistrationWindowElement {
|
|
|
8272
8304
|
zeroAsFree: true
|
|
8273
8305
|
})}
|
|
8274
8306
|
</div>
|
|
8275
|
-
|
|
8276
|
-
${t(this.locale, "teamSize")}
|
|
8277
|
-
${formatNumber(card.teamSize, this.locale)}${remaining === null ? "" : ` · ${formatNumber(remaining, this.locale)} ${t(this.locale, "availableSlots")}`}
|
|
8278
|
-
</p>
|
|
8307
|
+
${details ? html`<p part="meta">${details}</p>` : nothing}
|
|
8279
8308
|
${this.renderTiers(card, currency)}
|
|
8280
8309
|
${unavailable ? html`<p part="hint availability" role="status">${unavailable}</p>` : nothing}
|
|
8281
8310
|
<button
|
|
@@ -8332,23 +8361,36 @@ class WodiraPricingCards extends RegistrationWindowElement {
|
|
|
8332
8361
|
async loadPricing() {
|
|
8333
8362
|
if (!this.isConnected)
|
|
8334
8363
|
return;
|
|
8335
|
-
|
|
8364
|
+
const request = ++this.pricingRequest;
|
|
8365
|
+
const { publishableKey, baseUrl, eventId } = this;
|
|
8366
|
+
const isCurrent = () => request === this.pricingRequest && publishableKey === this.publishableKey && baseUrl === this.baseUrl && eventId === this.eventId;
|
|
8367
|
+
if (!hasText(publishableKey) || !hasText(eventId)) {
|
|
8368
|
+
this.pricing = undefined;
|
|
8369
|
+
this.loading = false;
|
|
8336
8370
|
return;
|
|
8371
|
+
}
|
|
8337
8372
|
this.loading = true;
|
|
8338
8373
|
this.error = "";
|
|
8339
8374
|
try {
|
|
8340
8375
|
this.validateClientConfig();
|
|
8341
|
-
const client = createClient({
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
this.pricing =
|
|
8376
|
+
const client = createClient({ publishableKey: publishableKey.trim(), baseUrl });
|
|
8377
|
+
const pricing = await client.getPricingCards(eventId.trim());
|
|
8378
|
+
if (!isCurrent())
|
|
8379
|
+
return;
|
|
8380
|
+
this.pricing = pricing;
|
|
8346
8381
|
} catch (error) {
|
|
8382
|
+
if (!isCurrent())
|
|
8383
|
+
return;
|
|
8347
8384
|
this.error = getErrorMessage(error);
|
|
8348
8385
|
emitWodiraEvent(this, "wodira:error", { error, message: this.error });
|
|
8386
|
+
return;
|
|
8349
8387
|
} finally {
|
|
8350
|
-
|
|
8388
|
+
if (isCurrent())
|
|
8389
|
+
this.loading = false;
|
|
8351
8390
|
}
|
|
8391
|
+
await this.updateComplete;
|
|
8392
|
+
if (isCurrent() && this.isConnected)
|
|
8393
|
+
emitWodiraEvent(this, "wodira:pricing-ready", { pricing: this.pricing });
|
|
8352
8394
|
}
|
|
8353
8395
|
selectCategory(category) {
|
|
8354
8396
|
if (registrationWindowMessage(this.pricing, this.locale) || categoryAvailabilityMessage(category, this.locale))
|
|
@@ -8373,6 +8415,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8373
8415
|
cancelUrl: { type: String, attribute: "cancel-url" },
|
|
8374
8416
|
locale: { type: String },
|
|
8375
8417
|
autoRedirect: { type: Boolean, attribute: "auto-redirect" },
|
|
8418
|
+
checkoutStep: { type: String, attribute: "checkout-step" },
|
|
8376
8419
|
event: { attribute: false },
|
|
8377
8420
|
loading: { type: Boolean, state: true },
|
|
8378
8421
|
error: { type: String, state: true },
|
|
@@ -8399,7 +8442,9 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8399
8442
|
completedSession: { state: true }
|
|
8400
8443
|
};
|
|
8401
8444
|
signatureDocumentKey = "";
|
|
8445
|
+
nextGuestDraftId = 0;
|
|
8402
8446
|
checkoutAttempt;
|
|
8447
|
+
reviewedFingerprint = "";
|
|
8403
8448
|
summaryRequestId = 0;
|
|
8404
8449
|
summaryTimer;
|
|
8405
8450
|
constructor() {
|
|
@@ -8411,6 +8456,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8411
8456
|
this.cancelUrl = "";
|
|
8412
8457
|
this.locale = "";
|
|
8413
8458
|
this.autoRedirect = true;
|
|
8459
|
+
this.checkoutStep = "direct";
|
|
8414
8460
|
this.loading = false;
|
|
8415
8461
|
this.error = "";
|
|
8416
8462
|
this.teamName = "";
|
|
@@ -8451,7 +8497,16 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8451
8497
|
this.watchRegistrationWindow(this.event);
|
|
8452
8498
|
if (changed.has("eventId") || changed.has("categoryId") || changed.has("publishableKey") || changed.has("baseUrl"))
|
|
8453
8499
|
this.completedSession = undefined;
|
|
8454
|
-
const
|
|
8500
|
+
const waiverEntries = this.waiverEntries;
|
|
8501
|
+
const visibleWaiverKeys = new Set(waiverEntries.map(({ waiver, guest }) => this.waiverAcceptanceKey(waiver, guest)));
|
|
8502
|
+
if (Object.keys(this.waiversAccepted).some((key) => !visibleWaiverKeys.has(key))) {
|
|
8503
|
+
this.waiversAccepted = Object.fromEntries(Object.entries(this.waiversAccepted).filter(([key]) => visibleWaiverKeys.has(key)));
|
|
8504
|
+
}
|
|
8505
|
+
const signatureKey = JSON.stringify(this.signatureWaivers.map((waiver) => [
|
|
8506
|
+
waiver.id,
|
|
8507
|
+
waiver.version,
|
|
8508
|
+
waiver.visibilityCondition ? waiverEntries.filter((entry) => entry.waiver.id === waiver.id).map(({ guest }) => [this.waiverEntryId(guest), guest?.categoryId ?? this.categoryId]) : null
|
|
8509
|
+
]));
|
|
8455
8510
|
if (signatureKey !== this.signatureDocumentKey) {
|
|
8456
8511
|
this.signatureDocumentKey = signatureKey;
|
|
8457
8512
|
this.signatureDraft = {
|
|
@@ -8478,7 +8533,13 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8478
8533
|
}
|
|
8479
8534
|
if (changed.has("summary") || changed.has("event"))
|
|
8480
8535
|
this.syncDeferredParticipantPositions();
|
|
8481
|
-
|
|
8536
|
+
const previousAthletes = changed.get("athletes");
|
|
8537
|
+
const conditionalAnswersChanged = this.conditionFieldIds(this.categoryId).size > 0 && (changed.has("customFieldValues") || changed.has("pendingParticipantPositions") || changed.has("athletes") && this.athletes.some((athlete, index) => athlete.conditionalFieldValues !== previousAthletes?.[index]?.conditionalFieldValues));
|
|
8538
|
+
if (conditionalAnswersChanged)
|
|
8539
|
+
this.syncRequiredSupplements();
|
|
8540
|
+
if (changed.has("guestRegistrations"))
|
|
8541
|
+
this.syncGuestRegistrations();
|
|
8542
|
+
if (changed.has("categoryId") || changed.has("purchaserEmail") || changed.has("promocode") || changed.has("selectedSupplementIds") || changed.has("supplementSelections") || changed.has("event") || conditionalAnswersChanged || changed.has("guestRegistrations")) {
|
|
8482
8543
|
this.scheduleSummaryLoad();
|
|
8483
8544
|
}
|
|
8484
8545
|
}
|
|
@@ -8514,7 +8575,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8514
8575
|
<div part="grid purchaser-grid">
|
|
8515
8576
|
${this.renderInput(t(this.locale, "buyerName"), "purchaserName", this.purchaserName, "text", true)}
|
|
8516
8577
|
${this.renderInput(t(this.locale, "buyerEmail"), "purchaserEmail", this.purchaserEmail, "email", true)}
|
|
8517
|
-
${this.renderInput(t(this.locale, "teamName"), "teamName", this.teamName, "text", true)}
|
|
8578
|
+
${this.renderInput(t(this.locale, category?.teamSize === 1 ? "bibName" : "teamName"), "teamName", this.teamName, "text", true)}
|
|
8518
8579
|
${this.renderInput(t(this.locale, "club"), "club", this.club, "text", false)}
|
|
8519
8580
|
${this.renderInput(t(this.locale, "promocode"), "promocode", this.promocode, "text", false)}
|
|
8520
8581
|
</div>
|
|
@@ -8563,10 +8624,12 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8563
8624
|
const category = this.selectedCategory;
|
|
8564
8625
|
if (!category || category.teamSize <= 1)
|
|
8565
8626
|
return false;
|
|
8627
|
+
if (this.conditionFieldIds(category.id).size)
|
|
8628
|
+
return false;
|
|
8566
8629
|
const summaryDecision = this.summary?.categoryId === category.id ? this.summary.teamCompletion : undefined;
|
|
8567
8630
|
if (summaryDecision)
|
|
8568
8631
|
return summaryDecision.available;
|
|
8569
|
-
if (applicableEventWaivers(this.event?.waivers ?? [], category.id).some((waiver) => waiver.requiresSignature))
|
|
8632
|
+
if (applicableEventWaivers(this.event?.waivers ?? [], category.id).some((waiver) => waiver.visibilityCondition == null && waiver.requiresSignature))
|
|
8570
8633
|
return false;
|
|
8571
8634
|
const eventStart = new Date(this.event?.startDate ?? "").getTime();
|
|
8572
8635
|
return Number.isFinite(eventStart) && eventStart - 24 * 60 * 60 * 1000 > Date.now();
|
|
@@ -8577,8 +8640,58 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8577
8640
|
get activeSupplements() {
|
|
8578
8641
|
return this.getSupplementsForCategory(this.categoryId);
|
|
8579
8642
|
}
|
|
8580
|
-
getSupplementsForCategory(categoryId) {
|
|
8581
|
-
return (this.event?.supplements ?? []).filter((supplement) => supplement.isActive !== false && isSupplementAvailableForCategory(supplement, categoryId));
|
|
8643
|
+
getSupplementsForCategory(categoryId, answers = this.conditionAnswers(categoryId)) {
|
|
8644
|
+
return (this.event?.supplements ?? []).filter((supplement) => supplement.isActive !== false && isSupplementAvailableForCategory(supplement, categoryId) && matchesRegistrationVisibilityCondition(supplement.visibilityCondition, answers));
|
|
8645
|
+
}
|
|
8646
|
+
fieldAnswers(categoryId, values) {
|
|
8647
|
+
return (this.event?.eventFormFields ?? []).flatMap((field) => {
|
|
8648
|
+
const value = values?.[field.id];
|
|
8649
|
+
return !isBlank(value) && isFormFieldTargetAthlete(field) && isFormFieldAvailableForCategory(field, categoryId) ? [{ fieldId: field.id, value }] : [];
|
|
8650
|
+
});
|
|
8651
|
+
}
|
|
8652
|
+
conditionAnswers(categoryId, guest) {
|
|
8653
|
+
const conditionIds = this.conditionFieldIds(categoryId);
|
|
8654
|
+
const answersFor = (values) => this.fieldAnswers(categoryId, values).filter(({ fieldId }) => conditionIds.has(fieldId));
|
|
8655
|
+
const mainAnswers = answersFor(guest ? guest.customFieldValues : this.customFieldValues);
|
|
8656
|
+
const athletes = guest?.athletes ?? this.athletes;
|
|
8657
|
+
return [
|
|
8658
|
+
mainAnswers,
|
|
8659
|
+
...athletes.slice(1).flatMap((athlete, index) => !guest && this.isParticipantDeferred(index + 1) ? [] : [answersFor(athlete.conditionalFieldValues)])
|
|
8660
|
+
];
|
|
8661
|
+
}
|
|
8662
|
+
conditionFieldIds(categoryId) {
|
|
8663
|
+
const eligibleFields = new Set((this.event?.eventFormFields ?? []).filter((field) => isFormFieldTargetAthlete(field) && isFormFieldAvailableForCategory(field, categoryId)).map((field) => field.id));
|
|
8664
|
+
return new Set([
|
|
8665
|
+
...applicableEventWaivers(this.event?.waivers ?? [], categoryId),
|
|
8666
|
+
...(this.event?.supplements ?? []).filter((supplement) => supplement.isActive !== false && isSupplementAvailableForCategory(supplement, categoryId))
|
|
8667
|
+
].flatMap(({ visibilityCondition }) => visibilityCondition && eligibleFields.has(visibilityCondition.fieldId) ? [visibilityCondition.fieldId] : []));
|
|
8668
|
+
}
|
|
8669
|
+
checkoutWaivers(categoryId, guest) {
|
|
8670
|
+
const answers = this.conditionAnswers(categoryId, guest);
|
|
8671
|
+
return applicableEventWaivers(this.event?.waivers ?? [], categoryId).filter((waiver) => matchesRegistrationVisibilityCondition(waiver.visibilityCondition, answers));
|
|
8672
|
+
}
|
|
8673
|
+
get waiverEntries() {
|
|
8674
|
+
return [
|
|
8675
|
+
...this.checkoutWaivers(this.categoryId).map((waiver) => ({ waiver })),
|
|
8676
|
+
...this.guestRegistrations.flatMap((guest) => this.checkoutWaivers(guest.categoryId, guest).map((waiver) => ({ waiver, guest })))
|
|
8677
|
+
];
|
|
8678
|
+
}
|
|
8679
|
+
get visibleWaivers() {
|
|
8680
|
+
return [...new Map(this.waiverEntries.map(({ waiver }) => [waiver.id, waiver])).values()];
|
|
8681
|
+
}
|
|
8682
|
+
isEntryWaiver(waiver) {
|
|
8683
|
+
return waiver.visibilityCondition != null && !waiver.requiresSignature;
|
|
8684
|
+
}
|
|
8685
|
+
waiverEntryId(guest) {
|
|
8686
|
+
if (!guest)
|
|
8687
|
+
return "main";
|
|
8688
|
+
return guest.draftId === undefined ? `guest-index-${this.guestRegistrations.indexOf(guest)}` : `guest-${guest.draftId}`;
|
|
8689
|
+
}
|
|
8690
|
+
waiverAcceptanceKey(waiver, guest) {
|
|
8691
|
+
return this.isEntryWaiver(waiver) ? JSON.stringify([this.waiverEntryId(guest), waiver.id]) : waiver.id;
|
|
8692
|
+
}
|
|
8693
|
+
checkoutWaiverAcceptances(guest) {
|
|
8694
|
+
return Object.fromEntries(this.checkoutWaivers(guest?.categoryId ?? this.categoryId, guest).filter((waiver) => this.waiversAccepted[this.waiverAcceptanceKey(waiver, guest)] === true).map((waiver) => [waiver.id, true]));
|
|
8582
8695
|
}
|
|
8583
8696
|
renderEligibilitySummary(category) {
|
|
8584
8697
|
const messages = this.describeEligibility(category);
|
|
@@ -8629,13 +8742,13 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8629
8742
|
if (category.genders.length === 1) {
|
|
8630
8743
|
messages.push(this.isEnglish ? `Allowed gender: ${this.genderLabel(allowed[0])}` : `Género permitido: ${this.genderLabel(allowed[0])}`);
|
|
8631
8744
|
}
|
|
8632
|
-
if (compositions.length === 1) {
|
|
8745
|
+
if (category.teamSize > 1 && compositions.length === 1) {
|
|
8633
8746
|
messages.push(`${this.isEnglish ? "Team composition" : "Composición del equipo"}: ${formatGenderComposition(compositions[0], this.locale)}`);
|
|
8634
|
-
} else if (category.genderPolicy === "ALL_SAME") {
|
|
8747
|
+
} else if (category.teamSize > 1 && category.genderPolicy === "ALL_SAME") {
|
|
8635
8748
|
messages.push(this.isEnglish ? "Every athlete must have the same gender." : "Todos los atletas deben tener el mismo género.");
|
|
8636
|
-
} else if (category.genderPolicy === "MINIMUM_ONE_EACH") {
|
|
8749
|
+
} else if (category.teamSize > 1 && category.genderPolicy === "MINIMUM_ONE_EACH") {
|
|
8637
8750
|
messages.push(this.isEnglish ? "The team must include at least one athlete of each allowed gender." : "El equipo debe incluir al menos un atleta de cada género permitido.");
|
|
8638
|
-
} else if (category.genderPolicy === "BALANCED") {
|
|
8751
|
+
} else if (category.teamSize > 1 && category.genderPolicy === "BALANCED") {
|
|
8639
8752
|
messages.push(this.isEnglish ? "No gender may represent more than 60% of the team." : "Ningún género puede representar más del 60 % del equipo.");
|
|
8640
8753
|
}
|
|
8641
8754
|
if (category.minAge != null && category.maxAge != null) {
|
|
@@ -8645,7 +8758,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8645
8758
|
} else if (category.maxAge != null) {
|
|
8646
8759
|
messages.push(this.isEnglish ? `Maximum age on the event date: ${category.maxAge} years.` : `Edad máxima en la fecha del evento: ${category.maxAge} años.`);
|
|
8647
8760
|
}
|
|
8648
|
-
if (category.minimumCombinedAge != null) {
|
|
8761
|
+
if (category.teamSize > 1 && category.minimumCombinedAge != null) {
|
|
8649
8762
|
messages.push(this.isEnglish ? `Minimum combined team age: ${category.minimumCombinedAge} years.` : `Edad mínima combinada del equipo: ${category.minimumCombinedAge} años.`);
|
|
8650
8763
|
}
|
|
8651
8764
|
return messages;
|
|
@@ -8710,6 +8823,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8710
8823
|
}
|
|
8711
8824
|
renderAthlete(athlete, index) {
|
|
8712
8825
|
const category = this.selectedCategory;
|
|
8826
|
+
const isTeam = (category?.teamSize ?? 1) > 1;
|
|
8713
8827
|
const allowedGenders = category ? getAllowedGenders(category) : ["FEMALE", "MALE"];
|
|
8714
8828
|
const slotPlan = this.getGenderSlotPlan(category, this.athletes, this.selectedGenderCompositionIndex);
|
|
8715
8829
|
const genderLocked = this.isGenderSlotLocked(category, slotPlan, index);
|
|
@@ -8718,8 +8832,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8718
8832
|
return html`
|
|
8719
8833
|
<fieldset part="card athlete ${deferred ? "deferred" : ""}">
|
|
8720
8834
|
<legend part="title" id=${`participant-slot-title-${index}`}>
|
|
8721
|
-
${t(this.locale, "participantSlot")}
|
|
8722
|
-
${index + 1}${slotPlan?.[index] ? ` · ${this.genderLabel(slotPlan[index])}` : ""}${index === 0 ? ` · ${t(this.locale, "captain")}` : ""}
|
|
8835
|
+
${isTeam ? `${t(this.locale, "participantSlot")} ${index + 1}` : t(this.locale, "participant")}${slotPlan?.[index] ? ` · ${this.genderLabel(slotPlan[index])}` : ""}${isTeam && index === 0 ? ` · ${t(this.locale, "captain")}` : ""}
|
|
8723
8836
|
</legend>
|
|
8724
8837
|
${this.deferredTeamCompletionAvailable && index > 0 ? html`
|
|
8725
8838
|
<div
|
|
@@ -8774,6 +8887,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8774
8887
|
${this.renderFieldError(genderErrorKey)}
|
|
8775
8888
|
</label>
|
|
8776
8889
|
</div>
|
|
8890
|
+
${index > 0 ? this.renderCustomFields(this.categoryId, undefined, index) : nothing}
|
|
8777
8891
|
`}
|
|
8778
8892
|
</fieldset>
|
|
8779
8893
|
`;
|
|
@@ -8802,22 +8916,26 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8802
8916
|
</div>
|
|
8803
8917
|
`;
|
|
8804
8918
|
}
|
|
8805
|
-
renderCustomFields(categoryId = this.categoryId, guestIndex) {
|
|
8806
|
-
const
|
|
8919
|
+
renderCustomFields(categoryId = this.categoryId, guestIndex, participantIndex) {
|
|
8920
|
+
const conditionIds = this.conditionFieldIds(categoryId);
|
|
8921
|
+
const fields = this.event?.eventFormFields.filter((field) => isFormFieldTargetAthlete(field) && isFormFieldAvailableForCategory(field, categoryId) && (participantIndex === undefined || conditionIds.has(field.id))) ?? [];
|
|
8807
8922
|
if (!fields.length)
|
|
8808
8923
|
return nothing;
|
|
8809
8924
|
return html`
|
|
8810
8925
|
<fieldset part="card custom-fields">
|
|
8811
8926
|
<legend part="title">${t(this.locale, "customFieldsTitle")}</legend>
|
|
8812
8927
|
<div part="grid custom-fields-grid">
|
|
8813
|
-
${fields.map((field) => this.renderCustomField(field, guestIndex))}
|
|
8928
|
+
${fields.map((field) => this.renderCustomField(field, conditionIds.has(field.id), guestIndex, participantIndex))}
|
|
8814
8929
|
</div>
|
|
8815
8930
|
</fieldset>
|
|
8816
8931
|
`;
|
|
8817
8932
|
}
|
|
8818
|
-
renderCustomField(field, guestIndex) {
|
|
8819
|
-
const
|
|
8820
|
-
const
|
|
8933
|
+
renderCustomField(field, drivesVisibility, guestIndex, participantIndex) {
|
|
8934
|
+
const guest = guestIndex === undefined ? undefined : this.guestRegistrations[guestIndex];
|
|
8935
|
+
const athlete = participantIndex === undefined ? undefined : (guest?.athletes ?? this.athletes)[participantIndex];
|
|
8936
|
+
const values = participantIndex === undefined ? guest ? guest.customFieldValues ?? {} : this.customFieldValues : athlete?.conditionalFieldValues ?? {};
|
|
8937
|
+
const errorKey = this.customFieldErrorKey(field.id, guestIndex, participantIndex);
|
|
8938
|
+
const update = (value) => this.updateCustomField(field.id, value, guestIndex, participantIndex);
|
|
8821
8939
|
const id = fieldErrorId(errorKey);
|
|
8822
8940
|
if (field.type === "MULTI_SELECT") {
|
|
8823
8941
|
const selected = Array.isArray(values[field.id]) ? values[field.id] : [];
|
|
@@ -8828,7 +8946,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8828
8946
|
multiple
|
|
8829
8947
|
aria-invalid=${this.fieldErrors[errorKey] ? "true" : "false"}
|
|
8830
8948
|
aria-describedby=${this.fieldErrors[errorKey] ? id : nothing}
|
|
8831
|
-
@change=${(event) =>
|
|
8949
|
+
@change=${(event) => update(Array.from(event.target.selectedOptions, (option) => option.value))}
|
|
8832
8950
|
>
|
|
8833
8951
|
${field.options.map((option) => html`<option value=${option} ?selected=${selected.includes(option)}>${option}</option>`)}</select
|
|
8834
8952
|
>${this.renderFieldError(errorKey)}</label
|
|
@@ -8848,7 +8966,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8848
8966
|
name=${errorKey}
|
|
8849
8967
|
value=${option}
|
|
8850
8968
|
.checked=${values[field.id] === option}
|
|
8851
|
-
@change=${() =>
|
|
8969
|
+
@change=${() => update(option)}
|
|
8852
8970
|
/>${option}</span
|
|
8853
8971
|
></label
|
|
8854
8972
|
>`)}
|
|
@@ -8864,7 +8982,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8864
8982
|
.value=${String(values[field.id] ?? "")}
|
|
8865
8983
|
aria-invalid=${this.fieldErrors[errorKey] ? "true" : "false"}
|
|
8866
8984
|
aria-describedby=${this.fieldErrors[errorKey] ? id : nothing}
|
|
8867
|
-
@change=${(event) =>
|
|
8985
|
+
@change=${(event) => update(event.target.value)}
|
|
8868
8986
|
>
|
|
8869
8987
|
<option value="">${t(this.locale, "selectOption")}</option>
|
|
8870
8988
|
${field.options.map((option) => html`<option value=${option}>${option}</option>`)}
|
|
@@ -8873,6 +8991,28 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8873
8991
|
</label>
|
|
8874
8992
|
`;
|
|
8875
8993
|
}
|
|
8994
|
+
if (isCheckboxField(field) && drivesVisibility) {
|
|
8995
|
+
return html`
|
|
8996
|
+
<label part="label field custom-field">
|
|
8997
|
+
<span>${field.label}${field.isRequired ? " *" : ""}</span>
|
|
8998
|
+
<select
|
|
8999
|
+
part="select"
|
|
9000
|
+
.value=${typeof values[field.id] === "boolean" ? String(values[field.id]) : ""}
|
|
9001
|
+
aria-invalid=${this.fieldErrors[errorKey] ? "true" : "false"}
|
|
9002
|
+
aria-describedby=${this.fieldErrors[errorKey] ? id : nothing}
|
|
9003
|
+
@change=${(event) => {
|
|
9004
|
+
const value = event.target.value;
|
|
9005
|
+
update(value ? value === "true" : undefined);
|
|
9006
|
+
}}
|
|
9007
|
+
>
|
|
9008
|
+
<option value="">${t(this.locale, "selectOption")}</option>
|
|
9009
|
+
<option value="true">${t(this.locale, "yesAnswer")}</option>
|
|
9010
|
+
<option value="false">${t(this.locale, "noAnswer")}</option>
|
|
9011
|
+
</select>
|
|
9012
|
+
${this.renderFieldError(errorKey)}
|
|
9013
|
+
</label>
|
|
9014
|
+
`;
|
|
9015
|
+
}
|
|
8876
9016
|
if (isCheckboxField(field)) {
|
|
8877
9017
|
return html`
|
|
8878
9018
|
<label part="label checkbox custom-field">
|
|
@@ -8882,7 +9022,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8882
9022
|
type="checkbox"
|
|
8883
9023
|
.checked=${values[field.id] === true}
|
|
8884
9024
|
aria-invalid=${this.fieldErrors[errorKey] ? "true" : "false"}
|
|
8885
|
-
@change=${(event) =>
|
|
9025
|
+
@change=${(event) => update(event.target.checked)}
|
|
8886
9026
|
/>
|
|
8887
9027
|
${field.label}${field.isRequired ? " *" : ""}
|
|
8888
9028
|
</span>
|
|
@@ -8899,7 +9039,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8899
9039
|
.value=${String(values[field.id] ?? "")}
|
|
8900
9040
|
aria-invalid=${this.fieldErrors[errorKey] ? "true" : "false"}
|
|
8901
9041
|
aria-describedby=${this.fieldErrors[errorKey] ? id : nothing}
|
|
8902
|
-
@input=${(event) =>
|
|
9042
|
+
@input=${(event) => update(event.target.value)}
|
|
8903
9043
|
></textarea>
|
|
8904
9044
|
${this.renderFieldError(errorKey)}
|
|
8905
9045
|
</label>
|
|
@@ -8915,7 +9055,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8915
9055
|
.value=${String(values[field.id] ?? "")}
|
|
8916
9056
|
aria-invalid=${this.fieldErrors[errorKey] ? "true" : "false"}
|
|
8917
9057
|
aria-describedby=${this.fieldErrors[errorKey] ? id : nothing}
|
|
8918
|
-
@input=${(event) =>
|
|
9058
|
+
@input=${(event) => update(event.target.value)}
|
|
8919
9059
|
/>
|
|
8920
9060
|
${this.renderFieldError(errorKey)}
|
|
8921
9061
|
</label>
|
|
@@ -8925,19 +9065,22 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
8925
9065
|
return this.renderCategorySupplements(this.categoryId);
|
|
8926
9066
|
}
|
|
8927
9067
|
renderCategorySupplements(categoryId, guestIndex) {
|
|
8928
|
-
const
|
|
9068
|
+
const guest = guestIndex === undefined ? undefined : this.guestRegistrations[guestIndex];
|
|
9069
|
+
const supplements = this.getSupplementsForCategory(categoryId, this.conditionAnswers(categoryId, guest));
|
|
8929
9070
|
if (!supplements.length)
|
|
8930
9071
|
return nothing;
|
|
9072
|
+
const category = this.event?.categories.find((item) => item.id === categoryId);
|
|
9073
|
+
const isTeam = (category?.teamSize ?? 1) > 1;
|
|
8931
9074
|
return html`<fieldset
|
|
8932
9075
|
part="card ${guestIndex === undefined ? "supplements" : "guest-supplements"}"
|
|
8933
9076
|
>
|
|
8934
9077
|
<legend part="title">Extras</legend>
|
|
8935
9078
|
<div part="stack">
|
|
8936
|
-
${supplements.map((supplement) => this.renderSupplement(supplement, guestIndex))}
|
|
9079
|
+
${supplements.map((supplement) => this.renderSupplement(supplement, isTeam, guestIndex))}
|
|
8937
9080
|
</div>
|
|
8938
9081
|
</fieldset>`;
|
|
8939
9082
|
}
|
|
8940
|
-
renderSupplement(supplement, guestIndex) {
|
|
9083
|
+
renderSupplement(supplement, isTeam, guestIndex) {
|
|
8941
9084
|
const ids = guestIndex === undefined ? this.selectedSupplementIds : this.guestRegistrations[guestIndex]?.selectedSupplementIds ?? [];
|
|
8942
9085
|
const selections = guestIndex === undefined ? this.supplementSelections : this.guestRegistrations[guestIndex]?.supplementSelections ?? [];
|
|
8943
9086
|
const selection = selections.find((item) => item.supplementId === supplement.id);
|
|
@@ -9000,7 +9143,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9000
9143
|
@input=${(event) => update({ quantity: event.target.valueAsNumber })}
|
|
9001
9144
|
/>
|
|
9002
9145
|
</label>` : nothing}
|
|
9003
|
-
${supplement.pricingMode === "PER_TEAM_MEMBER" ? html`<small part="hint">${t(this.locale, "perParticipant")}</small>` : nothing}
|
|
9146
|
+
${isTeam && supplement.pricingMode === "PER_TEAM_MEMBER" ? html`<small part="hint">${t(this.locale, "perParticipant")}</small>` : nothing}
|
|
9004
9147
|
${perUnit ? html`<small part="hint">${t(this.locale, "perUnit")}</small>` : nothing}
|
|
9005
9148
|
${supplement.description ? html`<small part="hint">${supplement.description}</small>` : nothing}
|
|
9006
9149
|
${this.renderFieldError(errorKey)}
|
|
@@ -9067,7 +9210,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9067
9210
|
</select>
|
|
9068
9211
|
${this.renderFieldError(`guestRegistrations.${index}.categoryId`)}
|
|
9069
9212
|
</label>
|
|
9070
|
-
${this.renderGuestInput(index, "teamName", t(this.locale, "teamName"), guest.teamName, "text", true)}
|
|
9213
|
+
${this.renderGuestInput(index, "teamName", t(this.locale, guestCategory?.teamSize === 1 ? "bibName" : "teamName"), guest.teamName, "text", true)}
|
|
9071
9214
|
${this.renderGuestInput(index, "club", t(this.locale, "club"), guest.club, "text", false)}
|
|
9072
9215
|
</div>
|
|
9073
9216
|
${guestCategory ? this.renderEligibilitySummary(guestCategory) : nothing}
|
|
@@ -9077,6 +9220,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9077
9220
|
${this.renderFieldError(`guestRegistrations.${index}.ageRule`)}
|
|
9078
9221
|
${this.renderCustomFields(guest.categoryId, index)}
|
|
9079
9222
|
${this.renderGuestSupplements(guest, index)}
|
|
9223
|
+
${this.checkoutWaivers(guest.categoryId, guest).filter((waiver) => this.isEntryWaiver(waiver)).map((waiver) => this.renderWaiver(waiver, guest))}
|
|
9080
9224
|
<button
|
|
9081
9225
|
part="button secondary remove-guest"
|
|
9082
9226
|
type="button"
|
|
@@ -9084,7 +9228,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9084
9228
|
>
|
|
9085
9229
|
${t(this.locale, "remove")}
|
|
9086
9230
|
</button>
|
|
9087
|
-
${guestCategory ? html`<small part="hint"
|
|
9231
|
+
${guestCategory && guestCategory.teamSize > 1 ? html`<small part="hint"
|
|
9088
9232
|
>${t(this.locale, "teamSize")}
|
|
9089
9233
|
${formatNumber(guestCategory.teamSize, this.locale)}</small
|
|
9090
9234
|
>` : nothing}
|
|
@@ -9147,6 +9291,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9147
9291
|
${this.renderFieldError(genderErrorKey)}
|
|
9148
9292
|
</label>
|
|
9149
9293
|
</div>
|
|
9294
|
+
${athleteIndex > 0 ? this.renderCustomFields(this.guestRegistrations[guestIndex]?.categoryId, guestIndex, athleteIndex) : nothing}
|
|
9150
9295
|
</fieldset>
|
|
9151
9296
|
`;
|
|
9152
9297
|
}
|
|
@@ -9179,10 +9324,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9179
9324
|
return this.renderCategorySupplements(guest.categoryId, guestIndex);
|
|
9180
9325
|
}
|
|
9181
9326
|
get signatureWaivers() {
|
|
9182
|
-
return
|
|
9183
|
-
this.categoryId,
|
|
9184
|
-
...this.guestRegistrations.map((guest) => guest.categoryId)
|
|
9185
|
-
]).filter((waiver) => waiver.requiresSignature);
|
|
9327
|
+
return this.visibleWaivers.filter((waiver) => waiver.requiresSignature);
|
|
9186
9328
|
}
|
|
9187
9329
|
get hasMinorParticipants() {
|
|
9188
9330
|
const today = new Date;
|
|
@@ -9282,10 +9424,10 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9282
9424
|
</section>`;
|
|
9283
9425
|
}
|
|
9284
9426
|
renderWaivers() {
|
|
9285
|
-
const waivers =
|
|
9286
|
-
this.
|
|
9287
|
-
...this.
|
|
9288
|
-
]
|
|
9427
|
+
const waivers = [
|
|
9428
|
+
...this.visibleWaivers.filter((waiver) => !this.isEntryWaiver(waiver)),
|
|
9429
|
+
...this.checkoutWaivers(this.categoryId).filter((waiver) => this.isEntryWaiver(waiver))
|
|
9430
|
+
];
|
|
9289
9431
|
if (!waivers.length)
|
|
9290
9432
|
return nothing;
|
|
9291
9433
|
return html`
|
|
@@ -9295,17 +9437,18 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9295
9437
|
</fieldset>
|
|
9296
9438
|
`;
|
|
9297
9439
|
}
|
|
9298
|
-
renderWaiver(waiver) {
|
|
9299
|
-
const
|
|
9440
|
+
renderWaiver(waiver, guest) {
|
|
9441
|
+
const acceptanceKey = this.waiverAcceptanceKey(waiver, guest);
|
|
9442
|
+
const errorKey = `waivers.${acceptanceKey}`;
|
|
9300
9443
|
return html`
|
|
9301
9444
|
<label part="label checkbox waiver">
|
|
9302
9445
|
<span>
|
|
9303
9446
|
<input
|
|
9304
9447
|
part="checkbox"
|
|
9305
9448
|
type="checkbox"
|
|
9306
|
-
.checked=${this.waiversAccepted[
|
|
9449
|
+
.checked=${this.waiversAccepted[acceptanceKey] === true}
|
|
9307
9450
|
aria-invalid=${this.fieldErrors[errorKey] ? "true" : "false"}
|
|
9308
|
-
@change=${(event) => this.updateWaiver(
|
|
9451
|
+
@change=${(event) => this.updateWaiver(acceptanceKey, event.target.checked)}
|
|
9309
9452
|
/>
|
|
9310
9453
|
${waiver.name}${waiver.isRequired ? " *" : ""}
|
|
9311
9454
|
</span>
|
|
@@ -9467,8 +9610,8 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9467
9610
|
if (JSON.stringify(selections) !== JSON.stringify(this.supplementSelections))
|
|
9468
9611
|
this.supplementSelections = selections;
|
|
9469
9612
|
}
|
|
9470
|
-
normalizeSupplementSelections(categoryId, selections) {
|
|
9471
|
-
return this.getSupplementsForCategory(categoryId).flatMap((supplement) => {
|
|
9613
|
+
normalizeSupplementSelections(categoryId, selections, answers = this.conditionAnswers(categoryId)) {
|
|
9614
|
+
return this.getSupplementsForCategory(categoryId, answers).flatMap((supplement) => {
|
|
9472
9615
|
const selection = selections.find((item) => item.supplementId === supplement.id);
|
|
9473
9616
|
const options = (supplement.options ?? []).filter((option) => option.isActive);
|
|
9474
9617
|
if (options.length && !options.some((option) => option.id === selection?.optionId))
|
|
@@ -9493,14 +9636,14 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9493
9636
|
this.guestRegistrations = next;
|
|
9494
9637
|
}
|
|
9495
9638
|
}
|
|
9496
|
-
getRequiredSupplementIds(categoryId) {
|
|
9497
|
-
return this.getSupplementsForCategory(categoryId).filter((supplement) => supplement.isRequired && supplement.pricingMode !== "PER_UNIT" && !(supplement.options ?? []).some((option) => option.isActive)).map((supplement) => supplement.id);
|
|
9639
|
+
getRequiredSupplementIds(categoryId, answers = this.conditionAnswers(categoryId)) {
|
|
9640
|
+
return this.getSupplementsForCategory(categoryId, answers).filter((supplement) => supplement.isRequired && supplement.pricingMode !== "PER_UNIT" && !(supplement.options ?? []).some((option) => option.isActive)).map((supplement) => supplement.id);
|
|
9498
9641
|
}
|
|
9499
|
-
normalizeSupplementIdsForCategory(categoryId, selectedIds) {
|
|
9500
|
-
const availableIds = new Set(this.getSupplementsForCategory(categoryId).filter((supplement) => supplement.pricingMode !== "PER_UNIT" && !(supplement.options ?? []).some((option) => option.isActive)).map((supplement) => supplement.id));
|
|
9642
|
+
normalizeSupplementIdsForCategory(categoryId, selectedIds, answers = this.conditionAnswers(categoryId)) {
|
|
9643
|
+
const availableIds = new Set(this.getSupplementsForCategory(categoryId, answers).filter((supplement) => supplement.pricingMode !== "PER_UNIT" && !(supplement.options ?? []).some((option) => option.isActive)).map((supplement) => supplement.id));
|
|
9501
9644
|
return [
|
|
9502
9645
|
...new Set([
|
|
9503
|
-
...this.getRequiredSupplementIds(categoryId),
|
|
9646
|
+
...this.getRequiredSupplementIds(categoryId, answers),
|
|
9504
9647
|
...selectedIds.filter((supplementId) => availableIds.has(supplementId))
|
|
9505
9648
|
])
|
|
9506
9649
|
];
|
|
@@ -9511,13 +9654,14 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9511
9654
|
createGuestRegistration() {
|
|
9512
9655
|
const categoryId = (categoryAvailabilityMessage(this.selectedCategory, this.locale) ? "" : this.categoryId) || this.event?.categories.find((category) => !categoryAvailabilityMessage(category, this.locale))?.id || "";
|
|
9513
9656
|
return this.normalizeGuestRegistration({
|
|
9657
|
+
draftId: this.nextGuestDraftId++,
|
|
9514
9658
|
guestName: "",
|
|
9515
9659
|
guestEmail: "",
|
|
9516
9660
|
categoryId,
|
|
9517
9661
|
teamName: "",
|
|
9518
9662
|
club: "",
|
|
9519
9663
|
athletes: [emptyAthlete()],
|
|
9520
|
-
selectedSupplementIds:
|
|
9664
|
+
selectedSupplementIds: [],
|
|
9521
9665
|
selectedGenderCompositionIndex: this.defaultGenderCompositionIndex(this.getCategory(categoryId))
|
|
9522
9666
|
});
|
|
9523
9667
|
}
|
|
@@ -9527,8 +9671,8 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9527
9671
|
const sizedAthletes = Array.from({ length: teamSize }, (_, index) => guest.athletes[index] ?? emptyAthlete());
|
|
9528
9672
|
const selectedGenderCompositionIndex = this.normalizeGenderCompositionIndex(category, guest.selectedGenderCompositionIndex);
|
|
9529
9673
|
const athletes = this.normalizeAthleteGenders(category, sizedAthletes, selectedGenderCompositionIndex);
|
|
9530
|
-
const selectedSupplementIds = this.normalizeSupplementIdsForCategory(guest.categoryId, guest.selectedSupplementIds);
|
|
9531
|
-
const supplementSelections = this.normalizeSupplementSelections(guest.categoryId, guest.supplementSelections ?? []);
|
|
9674
|
+
const selectedSupplementIds = this.normalizeSupplementIdsForCategory(guest.categoryId, guest.selectedSupplementIds, this.conditionAnswers(guest.categoryId, { ...guest, athletes }));
|
|
9675
|
+
const supplementSelections = this.normalizeSupplementSelections(guest.categoryId, guest.supplementSelections ?? [], this.conditionAnswers(guest.categoryId, { ...guest, athletes }));
|
|
9532
9676
|
return {
|
|
9533
9677
|
...guest,
|
|
9534
9678
|
athletes,
|
|
@@ -9612,21 +9756,30 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9612
9756
|
this.clearFieldError("genderComposition");
|
|
9613
9757
|
this.clearFieldError("genderPolicy");
|
|
9614
9758
|
}
|
|
9615
|
-
|
|
9759
|
+
customFieldErrorKey(fieldId, guestIndex, participantIndex) {
|
|
9760
|
+
const registration = guestIndex === undefined ? "" : `guestRegistrations.${guestIndex}.`;
|
|
9761
|
+
const participant = participantIndex === undefined ? "" : `athletes.${participantIndex}.`;
|
|
9762
|
+
return `${registration}${participant}customFields.${fieldId}`;
|
|
9763
|
+
}
|
|
9764
|
+
updateCustomField(fieldId, value, guestIndex, participantIndex) {
|
|
9765
|
+
const updateAthletes = (athletes) => athletes.map((athlete, position) => position === participantIndex ? {
|
|
9766
|
+
...athlete,
|
|
9767
|
+
conditionalFieldValues: { ...athlete.conditionalFieldValues, [fieldId]: value }
|
|
9768
|
+
} : athlete);
|
|
9616
9769
|
if (guestIndex === undefined) {
|
|
9617
|
-
|
|
9618
|
-
|
|
9770
|
+
if (participantIndex === undefined) {
|
|
9771
|
+
this.customFieldValues = { ...this.customFieldValues, [fieldId]: value };
|
|
9772
|
+
} else {
|
|
9773
|
+
this.athletes = updateAthletes(this.athletes);
|
|
9774
|
+
}
|
|
9619
9775
|
} else {
|
|
9620
|
-
this.guestRegistrations = this.guestRegistrations.map((guest, index) => index !== guestIndex ? guest : {
|
|
9621
|
-
...guest,
|
|
9622
|
-
customFieldValues: { ...guest.customFieldValues, [fieldId]: value }
|
|
9623
|
-
});
|
|
9624
|
-
this.clearFieldError(`guestRegistrations.${guestIndex}.customFields.${fieldId}`);
|
|
9776
|
+
this.guestRegistrations = this.guestRegistrations.map((guest, index) => index !== guestIndex ? guest : participantIndex === undefined ? { ...guest, customFieldValues: { ...guest.customFieldValues, [fieldId]: value } } : { ...guest, athletes: updateAthletes(guest.athletes) });
|
|
9625
9777
|
}
|
|
9778
|
+
this.clearFieldError(this.customFieldErrorKey(fieldId, guestIndex, participantIndex));
|
|
9626
9779
|
}
|
|
9627
|
-
updateWaiver(
|
|
9628
|
-
this.waiversAccepted = { ...this.waiversAccepted, [
|
|
9629
|
-
this.clearFieldError(`waivers.${
|
|
9780
|
+
updateWaiver(acceptanceKey, accepted) {
|
|
9781
|
+
this.waiversAccepted = { ...this.waiversAccepted, [acceptanceKey]: accepted };
|
|
9782
|
+
this.clearFieldError(`waivers.${acceptanceKey}`);
|
|
9630
9783
|
}
|
|
9631
9784
|
updateSupplement(supplementId, selected) {
|
|
9632
9785
|
this.selectedSupplementIds = selected ? [...new Set([...this.selectedSupplementIds, supplementId])] : this.selectedSupplementIds.filter((id) => id !== supplementId);
|
|
@@ -9651,8 +9804,8 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9651
9804
|
const positionsAreValid = uniquePositions.size === this.pendingParticipantPositions.length && this.pendingParticipantPositions.every((position) => Number.isInteger(position) && position > 0 && position < category.teamSize);
|
|
9652
9805
|
return positionsAreValid ? null : t(this.locale, "invalidSelection");
|
|
9653
9806
|
}
|
|
9654
|
-
validateSupplements(errors, categoryId, ids, selections, prefix = "") {
|
|
9655
|
-
for (const supplement of this.getSupplementsForCategory(categoryId)) {
|
|
9807
|
+
validateSupplements(errors, categoryId, ids, selections, prefix = "", guest) {
|
|
9808
|
+
for (const supplement of this.getSupplementsForCategory(categoryId, this.conditionAnswers(categoryId, guest))) {
|
|
9656
9809
|
const selection = selections.find((item) => item.supplementId === supplement.id);
|
|
9657
9810
|
const options = (supplement.options ?? []).filter((option) => option.isActive);
|
|
9658
9811
|
const key = `${prefix}supplements.${supplement.id}`;
|
|
@@ -9664,10 +9817,24 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9664
9817
|
errors[key] = t(this.locale, "invalidNumber");
|
|
9665
9818
|
}
|
|
9666
9819
|
}
|
|
9820
|
+
validateRegistrationFields(errors, categoryId, values, guestIndex, participantIndex) {
|
|
9821
|
+
const conditions = this.conditionFieldIds(categoryId);
|
|
9822
|
+
for (const field of this.event?.eventFormFields ?? []) {
|
|
9823
|
+
if (!isFormFieldTargetAthlete(field) || !isFormFieldAvailableForCategory(field, categoryId) || participantIndex !== undefined && !conditions.has(field.id))
|
|
9824
|
+
continue;
|
|
9825
|
+
const value = values?.[field.id];
|
|
9826
|
+
const input = isCheckboxField(field) && conditions.has(field.id) ? {
|
|
9827
|
+
value: typeof value === "boolean" ? String(value) : undefined,
|
|
9828
|
+
type: "SELECT",
|
|
9829
|
+
options: ["true", "false"]
|
|
9830
|
+
} : { value, type: field.type, options: field.options };
|
|
9831
|
+
setValidationError(errors, this.locale, this.customFieldErrorKey(field.id, guestIndex, participantIndex), validateCustomFieldValue(input.value, input.type, input.options, field.isRequired));
|
|
9832
|
+
}
|
|
9833
|
+
}
|
|
9667
9834
|
validate() {
|
|
9668
9835
|
const errors = {};
|
|
9669
9836
|
this.validateSupplements(errors, this.categoryId, this.selectedSupplementIds, this.supplementSelections);
|
|
9670
|
-
this.guestRegistrations.forEach((guest, index) => this.validateSupplements(errors, guest.categoryId, guest.selectedSupplementIds, guest.supplementSelections ?? [], `guestRegistrations.${index}
|
|
9837
|
+
this.guestRegistrations.forEach((guest, index) => this.validateSupplements(errors, guest.categoryId, guest.selectedSupplementIds, guest.supplementSelections ?? [], `guestRegistrations.${index}.`, guest));
|
|
9671
9838
|
setValidationError(errors, this.locale, "purchaserName", validateRequiredText(this.purchaserName));
|
|
9672
9839
|
setValidationError(errors, this.locale, "purchaserEmail", validateEmail(this.purchaserEmail, true));
|
|
9673
9840
|
setValidationError(errors, this.locale, "teamName", validateRequiredText(this.teamName));
|
|
@@ -9711,9 +9878,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9711
9878
|
}
|
|
9712
9879
|
for (const [guestIndex, guest] of this.guestRegistrations.entries()) {
|
|
9713
9880
|
const guestCategory = this.getCategory(guest.categoryId);
|
|
9714
|
-
|
|
9715
|
-
setValidationError(errors, this.locale, `guestRegistrations.${guestIndex}.customFields.${field.id}`, validateCustomFieldValue(guest.customFieldValues?.[field.id], field.type, field.options, field.isRequired));
|
|
9716
|
-
}
|
|
9881
|
+
this.validateRegistrationFields(errors, guest.categoryId, guest.customFieldValues, guestIndex);
|
|
9717
9882
|
setValidationError(errors, this.locale, `guestRegistrations.${guestIndex}.guestName`, validateRequiredText(guest.guestName));
|
|
9718
9883
|
setValidationError(errors, this.locale, `guestRegistrations.${guestIndex}.guestEmail`, validateEmail(guest.guestEmail, true));
|
|
9719
9884
|
setValidationError(errors, this.locale, `guestRegistrations.${guestIndex}.teamName`, validateRequiredText(guest.teamName));
|
|
@@ -9721,6 +9886,8 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9721
9886
|
if (guestUnavailable)
|
|
9722
9887
|
errors[`guestRegistrations.${guestIndex}.categoryId`] = guestUnavailable;
|
|
9723
9888
|
for (const [athleteIndex, athlete] of guest.athletes.entries()) {
|
|
9889
|
+
if (athleteIndex > 0)
|
|
9890
|
+
this.validateRegistrationFields(errors, guest.categoryId, athlete.conditionalFieldValues, guestIndex, athleteIndex);
|
|
9724
9891
|
setValidationError(errors, this.locale, `guestRegistrations.${guestIndex}.athletes.${athleteIndex}.fullname`, validateRequiredText(athlete.fullname));
|
|
9725
9892
|
setValidationError(errors, this.locale, `guestRegistrations.${guestIndex}.athletes.${athleteIndex}.email`, validateEmail(athlete.email, true));
|
|
9726
9893
|
setValidationError(errors, this.locale, `guestRegistrations.${guestIndex}.athletes.${athleteIndex}.phone`, validateRequiredText(athlete.phone));
|
|
@@ -9746,15 +9913,15 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9746
9913
|
}
|
|
9747
9914
|
}
|
|
9748
9915
|
}
|
|
9749
|
-
|
|
9750
|
-
|
|
9916
|
+
this.validateRegistrationFields(errors, this.categoryId, this.customFieldValues);
|
|
9917
|
+
for (const [index, athlete] of this.athletes.entries()) {
|
|
9918
|
+
if (index > 0 && !this.isParticipantDeferred(index))
|
|
9919
|
+
this.validateRegistrationFields(errors, this.categoryId, athlete.conditionalFieldValues, undefined, index);
|
|
9751
9920
|
}
|
|
9752
|
-
for (const waiver of
|
|
9753
|
-
this.
|
|
9754
|
-
|
|
9755
|
-
|
|
9756
|
-
if (waiver.isRequired && this.waiversAccepted[waiver.id] !== true) {
|
|
9757
|
-
errors[`waivers.${waiver.id}`] = t(this.locale, "requiredWaiver");
|
|
9921
|
+
for (const { waiver, guest } of this.waiverEntries) {
|
|
9922
|
+
const acceptanceKey = this.waiverAcceptanceKey(waiver, guest);
|
|
9923
|
+
if (waiver.isRequired && this.waiversAccepted[acceptanceKey] !== true) {
|
|
9924
|
+
errors[`waivers.${acceptanceKey}`] = t(this.locale, "requiredWaiver");
|
|
9758
9925
|
}
|
|
9759
9926
|
}
|
|
9760
9927
|
if (this.signatureWaivers.length && (!this.signatureInput() || this.hasMinorParticipants && (!this.signatureDraft.minorRelationship || !this.signatureDraft.guardianAuthorityAccepted)))
|
|
@@ -9775,10 +9942,23 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9775
9942
|
buildGuestRegistrationsSummaryInput() {
|
|
9776
9943
|
return this.guestRegistrations.filter((guest) => hasText(guest.categoryId)).map((guest) => ({
|
|
9777
9944
|
categoryId: guest.categoryId.trim(),
|
|
9945
|
+
...this.conditionFieldIds(guest.categoryId).size ? { participantCustomFields: this.conditionAnswers(guest.categoryId, guest) } : {},
|
|
9778
9946
|
...guest.supplementSelections?.length ? { supplementSelections: guest.supplementSelections } : {},
|
|
9779
9947
|
...guest.selectedSupplementIds.length > 0 ? { selectedSupplementIds: guest.selectedSupplementIds } : {}
|
|
9780
9948
|
}));
|
|
9781
9949
|
}
|
|
9950
|
+
checkoutAthlete(athlete, categoryId) {
|
|
9951
|
+
const { conditionalFieldValues, ...details } = athlete;
|
|
9952
|
+
const customFields = this.fieldAnswers(categoryId, conditionalFieldValues);
|
|
9953
|
+
return {
|
|
9954
|
+
...details,
|
|
9955
|
+
fullname: details.fullname.trim(),
|
|
9956
|
+
email: details.email.trim(),
|
|
9957
|
+
phone: details.phone.trim(),
|
|
9958
|
+
idNumber: details.idNumber.trim(),
|
|
9959
|
+
...customFields.length ? { customFields } : {}
|
|
9960
|
+
};
|
|
9961
|
+
}
|
|
9782
9962
|
buildGuestRegistrationsCheckoutInput() {
|
|
9783
9963
|
if (!this.guestRegistrations.length)
|
|
9784
9964
|
return;
|
|
@@ -9793,14 +9973,8 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9793
9973
|
...guest.customFieldValues ? {
|
|
9794
9974
|
customFields: Object.entries(guest.customFieldValues).filter(([fieldId, value]) => !isBlank(value) && this.event?.eventFormFields.some((field) => field.id === fieldId && isFormFieldTargetAthlete(field) && isFormFieldAvailableForCategory(field, guest.categoryId))).map(([fieldId, value]) => ({ fieldId, value }))
|
|
9795
9975
|
} : {},
|
|
9796
|
-
waiversAccepted:
|
|
9797
|
-
athletes: guest.athletes.map((athlete) => (
|
|
9798
|
-
...athlete,
|
|
9799
|
-
fullname: athlete.fullname.trim(),
|
|
9800
|
-
email: athlete.email.trim(),
|
|
9801
|
-
phone: athlete.phone.trim(),
|
|
9802
|
-
idNumber: athlete.idNumber.trim()
|
|
9803
|
-
}))
|
|
9976
|
+
waiversAccepted: this.checkoutWaiverAcceptances(guest),
|
|
9977
|
+
athletes: guest.athletes.map((athlete) => this.checkoutAthlete(athlete, guest.categoryId))
|
|
9804
9978
|
}));
|
|
9805
9979
|
}
|
|
9806
9980
|
buildDeferredTeamCompletion() {
|
|
@@ -9814,7 +9988,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9814
9988
|
pendingParticipantPositions,
|
|
9815
9989
|
...slotGenders ? { slotGenders } : {},
|
|
9816
9990
|
participantWaivers: Array.from({ length: providedParticipantCount }, () => ({
|
|
9817
|
-
waiversAccepted:
|
|
9991
|
+
waiversAccepted: this.checkoutWaiverAcceptances()
|
|
9818
9992
|
}))
|
|
9819
9993
|
};
|
|
9820
9994
|
}
|
|
@@ -9838,6 +10012,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9838
10012
|
const input = {
|
|
9839
10013
|
categoryId: this.categoryId.trim(),
|
|
9840
10014
|
purchaserEmail: this.purchaserEmail.trim(),
|
|
10015
|
+
...this.conditionFieldIds(this.categoryId).size ? { participantCustomFields: this.conditionAnswers(this.categoryId) } : {},
|
|
9841
10016
|
selectedSupplementIds: this.selectedSupplementIds,
|
|
9842
10017
|
...this.supplementSelections.length ? { supplementSelections: this.supplementSelections } : {},
|
|
9843
10018
|
...this.buildGuestRegistrationsSummaryInput().length > 0 ? { guestRegistrations: this.buildGuestRegistrationsSummaryInput() } : {},
|
|
@@ -9857,17 +10032,74 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9857
10032
|
this.summaryLoading = false;
|
|
9858
10033
|
}
|
|
9859
10034
|
}
|
|
10035
|
+
async prepareReview() {
|
|
10036
|
+
await this.updateComplete;
|
|
10037
|
+
if (!this.isConnected || this.loading)
|
|
10038
|
+
return false;
|
|
10039
|
+
this.error = this.registrationUnavailableMessage;
|
|
10040
|
+
if (this.error || !this.validate()) {
|
|
10041
|
+
await this.focusRegistrationError();
|
|
10042
|
+
return false;
|
|
10043
|
+
}
|
|
10044
|
+
const fingerprint = this.reviewFingerprint();
|
|
10045
|
+
clearTimeout(this.summaryTimer);
|
|
10046
|
+
await this.loadSummary();
|
|
10047
|
+
await this.updateComplete;
|
|
10048
|
+
if (!this.isConnected || this.loading || this.summaryLoading || this.summaryError || this.summary?.categoryId !== this.categoryId || typeof this.summary?.total !== "number" || !Number.isFinite(this.summary.total) || this.summary.total < 0 || fingerprint !== this.reviewFingerprint() || Boolean(this.registrationUnavailableMessage)) {
|
|
10049
|
+
if (this.summaryError)
|
|
10050
|
+
await this.focusRegistrationError();
|
|
10051
|
+
return false;
|
|
10052
|
+
}
|
|
10053
|
+
this.reviewedFingerprint = fingerprint;
|
|
10054
|
+
this.checkoutStep = "review";
|
|
10055
|
+
return true;
|
|
10056
|
+
}
|
|
10057
|
+
reviewFingerprint() {
|
|
10058
|
+
return JSON.stringify([
|
|
10059
|
+
this.event,
|
|
10060
|
+
this.categoryId,
|
|
10061
|
+
this.purchaserName,
|
|
10062
|
+
this.purchaserEmail,
|
|
10063
|
+
this.teamName,
|
|
10064
|
+
this.club,
|
|
10065
|
+
this.promocode,
|
|
10066
|
+
this.athletes,
|
|
10067
|
+
this.selectedGenderCompositionIndex,
|
|
10068
|
+
this.pendingParticipantPositions,
|
|
10069
|
+
this.customFieldValues,
|
|
10070
|
+
this.waiversAccepted,
|
|
10071
|
+
this.signatureDraft,
|
|
10072
|
+
this.selectedSupplementIds,
|
|
10073
|
+
this.supplementSelections,
|
|
10074
|
+
this.guestRegistrations,
|
|
10075
|
+
this.termsAccepted
|
|
10076
|
+
]);
|
|
10077
|
+
}
|
|
10078
|
+
async focusRegistrationError() {
|
|
10079
|
+
await this.updateComplete;
|
|
10080
|
+
const invalidField = this.renderRoot.querySelector('input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"]');
|
|
10081
|
+
const target = invalidField ?? this.renderRoot.querySelector('[part~="field-error"], [role="alert"], [part~="availability"]');
|
|
10082
|
+
if (target && !target.hasAttribute("tabindex") && target.tagName !== "INPUT" && target.tagName !== "SELECT" && target.tagName !== "TEXTAREA")
|
|
10083
|
+
target.tabIndex = -1;
|
|
10084
|
+
target?.focus();
|
|
10085
|
+
}
|
|
9860
10086
|
async submit(event) {
|
|
9861
10087
|
event.preventDefault();
|
|
9862
10088
|
if (this.loading)
|
|
9863
10089
|
return;
|
|
10090
|
+
if (this.checkoutStep === "details" || this.checkoutStep === "review" && this.reviewedFingerprint !== this.reviewFingerprint()) {
|
|
10091
|
+
this.checkoutStep = "details";
|
|
10092
|
+
emitWodiraEvent(this, "wodira:review-requested", {
|
|
10093
|
+
eventId: this.eventId,
|
|
10094
|
+
categoryId: this.categoryId
|
|
10095
|
+
});
|
|
10096
|
+
return;
|
|
10097
|
+
}
|
|
9864
10098
|
this.error = this.registrationUnavailableMessage;
|
|
9865
10099
|
if (this.error)
|
|
9866
10100
|
return;
|
|
9867
10101
|
if (!this.validate()) {
|
|
9868
|
-
await this.
|
|
9869
|
-
const invalidField = this.renderRoot.querySelector('input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"]');
|
|
9870
|
-
(invalidField ?? this.renderRoot.querySelector('[part~="field-error"]'))?.focus();
|
|
10102
|
+
await this.focusRegistrationError();
|
|
9871
10103
|
return;
|
|
9872
10104
|
}
|
|
9873
10105
|
this.loading = true;
|
|
@@ -9889,22 +10121,14 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9889
10121
|
purchaserName: this.purchaserName.trim(),
|
|
9890
10122
|
teamName: this.teamName.trim(),
|
|
9891
10123
|
termsAccepted: this.termsAccepted,
|
|
9892
|
-
waiversAccepted:
|
|
10124
|
+
waiversAccepted: this.checkoutWaiverAcceptances(),
|
|
9893
10125
|
selectedSupplementIds: this.selectedSupplementIds,
|
|
9894
10126
|
...this.supplementSelections.length ? { supplementSelections: this.supplementSelections } : {},
|
|
9895
10127
|
successUrl: this.successUrl.trim(),
|
|
9896
10128
|
cancelUrl: this.cancelUrl.trim(),
|
|
9897
10129
|
customFields,
|
|
9898
10130
|
...this.signatureInput() ? { legalSignature: this.signatureInput() } : {},
|
|
9899
|
-
athletes: this.athletes.flatMap((athlete, position) => this.isParticipantDeferred(position) ? [] : [
|
|
9900
|
-
{
|
|
9901
|
-
...athlete,
|
|
9902
|
-
fullname: athlete.fullname.trim(),
|
|
9903
|
-
email: athlete.email.trim(),
|
|
9904
|
-
phone: athlete.phone.trim(),
|
|
9905
|
-
idNumber: athlete.idNumber.trim()
|
|
9906
|
-
}
|
|
9907
|
-
])
|
|
10131
|
+
athletes: this.athletes.flatMap((athlete, position) => this.isParticipantDeferred(position) ? [] : [this.checkoutAthlete(athlete, this.categoryId)])
|
|
9908
10132
|
};
|
|
9909
10133
|
const deferredTeamCompletion = this.buildDeferredTeamCompletion();
|
|
9910
10134
|
if (deferredTeamCompletion)
|
|
@@ -9946,11 +10170,10 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
|
|
|
9946
10170
|
if (!session.sessionUrl)
|
|
9947
10171
|
return;
|
|
9948
10172
|
emitWodiraEvent(this, "wodira:redirect", { sessionUrl: session.sessionUrl, session });
|
|
9949
|
-
if (this.autoRedirect)
|
|
10173
|
+
if (this.autoRedirect && this.isConnected)
|
|
9950
10174
|
globalThis.location.assign(session.sessionUrl);
|
|
9951
10175
|
}
|
|
9952
10176
|
}
|
|
9953
|
-
|
|
9954
10177
|
class WodiraRegistrationReceiptSender extends LitElement {
|
|
9955
10178
|
static styles = [wodiraUiStyles, wodiraLayoutStyles];
|
|
9956
10179
|
static properties = {
|
|
@@ -10072,6 +10295,7 @@ class WodiraRegistrationReceiptSender extends LitElement {
|
|
|
10072
10295
|
}
|
|
10073
10296
|
}
|
|
10074
10297
|
}
|
|
10298
|
+
|
|
10075
10299
|
class WodiraCheckoutFlow extends LitElement {
|
|
10076
10300
|
static styles = [wodiraUiStyles, wodiraLayoutStyles];
|
|
10077
10301
|
static properties = {
|
|
@@ -10250,6 +10474,7 @@ class WodiraCheckoutFlow extends LitElement {
|
|
|
10250
10474
|
var ELEMENTS = [
|
|
10251
10475
|
["wodira-signature-pad", WodiraSignaturePad],
|
|
10252
10476
|
["wodira-shirt-auction", WodiraShirtAuction2],
|
|
10477
|
+
["wodira-route-3d", WodiraRoute3d2],
|
|
10253
10478
|
["wodira-event-card", WodiraEventCard],
|
|
10254
10479
|
["wodira-event-list", WodiraEventList],
|
|
10255
10480
|
["wodira-pricing-cards", WodiraPricingCards],
|
|
@@ -10305,12 +10530,14 @@ export {
|
|
|
10305
10530
|
WodiraPricingCards,
|
|
10306
10531
|
WodiraRegistrationForm,
|
|
10307
10532
|
WodiraRegistrationReceiptSender,
|
|
10533
|
+
WodiraRoute3d2 as WodiraRoute3d,
|
|
10308
10534
|
WodiraShirtAuction2 as WodiraShirtAuction,
|
|
10309
10535
|
WodiraSignaturePad,
|
|
10310
10536
|
applyWodiraTheme,
|
|
10311
10537
|
createWodiraCheckoutFlow,
|
|
10312
10538
|
createWodiraRegistrationReceiptSender,
|
|
10313
10539
|
defineWodiraElements,
|
|
10540
|
+
defineWodiraRouteElements2 as defineWodiraRouteElements,
|
|
10314
10541
|
defineWodiraShirtElements2 as defineWodiraShirtElements,
|
|
10315
10542
|
wodiraThemeTokens,
|
|
10316
10543
|
wodiraThemes
|