simplifying export format

This commit is contained in:
Sebastian 2025-10-16 12:38:06 +02:00
parent 619b51e990
commit 73aea84e8e

View file

@ -304,42 +304,28 @@
function exportRegistrations() {
if (typeof window === 'undefined') return;
const lines: string[] = [];
const timestamp = formatDateTime(new Date().toISOString()) ?? new Date().toISOString();
lines.push(`${tournament.title} ${registrations.length} anmälningar`);
lines.push(`Genererad ${timestamp}`);
lines.push('');
if (registrations.length === 0) {
lines.push('Inga anmälningar.');
} else {
for (const registration of registrations) {
lines.push(`Anmälan #${registration.id}`);
const created = formatDateTime(registration.created_at) ?? registration.created_at;
lines.push(`Skapad: ${created}`);
if (entryFields().length > 0) {
lines.push('Lag / deltagare:');
for (const field of entryFields()) {
lines.push(` ${field.label}: ${fieldValue(registration.entry, field) || '—'}`);
}
lines.push(registrationHeading(registration));
for (const field of entryFields()) {
const value = fieldValue(registration.entry, field).trim();
lines.push(`${field.label}: ${value || '—'}`);
}
if (participantFields().length === 0) {
if (registration.participants.length > 0) {
lines.push(`Spelare: ${registration.participants.length}`);
}
} else if (registration.participants.length === 0) {
lines.push('Spelare: inga angivna');
} else {
lines.push('Spelare:');
if (participantFields().length > 0 && registration.participants.length > 0) {
registration.participants.forEach((participant, index) => {
lines.push(` Spelare ${index + 1}`);
lines.push('');
lines.push(`Spelare ${index + 1}`);
for (const field of participantFields()) {
lines.push(` ${field.label}: ${fieldValue(participant, field) || '—'}`);
const value = fieldValue(participant, field).trim();
lines.push(`${field.label}: ${value || '—'}`);
}
});
}
lines.push('');
}
}