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