From 75a7c409cd9268a175f1004c9fdf50dac2b22cf4 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Fri, 17 Jul 2026 11:20:15 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20f=C3=BCge=20Auswahl=20f=C3=BCr=20Spielp?= =?UTF-8?q?lan-Team-ID=20hinzu=20und=20lade=20Teams=20von=20der=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/cms/CmsMannschaften.vue | 35 +++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/components/cms/CmsMannschaften.vue b/components/cms/CmsMannschaften.vue index 4ce6c9b..901d818 100755 --- a/components/cms/CmsMannschaften.vue +++ b/components/cms/CmsMannschaften.vue @@ -204,15 +204,18 @@
- + + +

- Verknüpft diese Mannschaft eindeutig mit dem importierten Spielplan. + Nach dem myTischtennis-Import das passende Team auswählen.

@@ -424,6 +427,7 @@ const isLoading = ref(true) const isSaving = ref(false) const isCreatingSeason = ref(false) const mannschaften = ref([]) +const spielplanTeams = ref([]) const seasons = ref([]) const selectedSeason = ref('') const showModal = ref(false) @@ -516,6 +520,27 @@ const loadMannschaften = async () => { } catch (error) { console.error('Fehler beim Laden:', error); errorMessage.value = 'Fehler beim Laden der Mannschaften'; throw error } finally { isLoading.value = false } } +const loadSpielplanTeams = async () => { + try { + const response = await fetch('/api/spielplan', { cache: 'no-store' }) + const result = await response.json() + if (!result.success || !Array.isArray(result.data)) return + const teams = new Map() + for (const row of result.data) { + for (const side of ['Heim', 'Gast']) { + const isHarheimer = String(row[`${side}VereinNr`] || '') === '43030' || String(row[`${side}VereinName`] || '') === 'Harheimer TC' + const id = String(row[`${side}MannschaftId`] || '').trim() + if (!isHarheimer || !id || teams.has(id)) continue + const label = [row[`${side}Mannschaft`], row[`${side}MannschaftAltersklasse`], row[`${side}MannschaftNr`] ? `Nr. ${row[`${side}MannschaftNr`]}` : ''].filter(Boolean).join(' · ') + teams.set(id, { id, label: `${label} [${id}]` }) + } + } + spielplanTeams.value = [...teams.values()].sort((a, b) => a.label.localeCompare(b.label, 'de')) + } catch (error) { + console.error('Spielplan-Teams konnten nicht geladen werden:', error) + } +} + const onSeasonChange = async () => { await loadMannschaften().catch(() => {}) } @@ -691,7 +716,7 @@ const confirmDelete = (mannschaft, index) => { onMounted(async () => { await loadSeasons() - await loadMannschaften().catch(() => {}) + await Promise.all([loadMannschaften().catch(() => {}), loadSpielplanTeams()]) }) // Expose load function to parent components