simplifying export format
This commit is contained in:
parent
619b51e990
commit
73aea84e8e
1 changed files with 9 additions and 23 deletions
|
|
@ -304,42 +304,28 @@
|
||||||
function exportRegistrations() {
|
function exportRegistrations() {
|
||||||
if (typeof window === 'undefined') return;
|
if (typeof window === 'undefined') return;
|
||||||
const lines: string[] = [];
|
const lines: string[] = [];
|
||||||
const timestamp = formatDateTime(new Date().toISOString()) ?? new Date().toISOString();
|
|
||||||
lines.push(`${tournament.title} – ${registrations.length} anmälningar`);
|
lines.push(`${tournament.title} – ${registrations.length} anmälningar`);
|
||||||
lines.push(`Genererad ${timestamp}`);
|
|
||||||
lines.push('');
|
lines.push('');
|
||||||
|
|
||||||
if (registrations.length === 0) {
|
if (registrations.length === 0) {
|
||||||
lines.push('Inga anmälningar.');
|
lines.push('Inga anmälningar.');
|
||||||
} else {
|
} else {
|
||||||
for (const registration of registrations) {
|
for (const registration of registrations) {
|
||||||
lines.push(`Anmälan #${registration.id}`);
|
lines.push(registrationHeading(registration));
|
||||||
const created = formatDateTime(registration.created_at) ?? registration.created_at;
|
for (const field of entryFields()) {
|
||||||
lines.push(`Skapad: ${created}`);
|
const value = fieldValue(registration.entry, field).trim();
|
||||||
|
lines.push(`${field.label}: ${value || '—'}`);
|
||||||
if (entryFields().length > 0) {
|
|
||||||
lines.push('Lag / deltagare:');
|
|
||||||
for (const field of entryFields()) {
|
|
||||||
lines.push(` ${field.label}: ${fieldValue(registration.entry, field) || '—'}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (participantFields().length > 0 && registration.participants.length > 0) {
|
||||||
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:');
|
|
||||||
registration.participants.forEach((participant, index) => {
|
registration.participants.forEach((participant, index) => {
|
||||||
lines.push(` Spelare ${index + 1}`);
|
lines.push('');
|
||||||
|
lines.push(`Spelare ${index + 1}`);
|
||||||
for (const field of participantFields()) {
|
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('');
|
lines.push('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue