feat: füge Auswahl für Spielplan-Team-ID hinzu und lade Teams von der API
All checks were successful
Code Analysis and Production Deploy / analyze (push) Successful in 6m55s
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Successful in 2m40s

This commit is contained in:
Torsten Schulz (local)
2026-07-17 11:20:15 +02:00
parent 751c302036
commit 75a7c409cd

View File

@@ -204,15 +204,18 @@
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Spielplan-Team-ID</label>
<input
<select
v-model="formData.spielplan_mannschaft_id"
type="text"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500"
placeholder="myTischtennis-Team-ID"
:disabled="isSaving"
>
<option value="">Keine ID auswählen</option>
<option v-for="team in spielplanTeams" :key="team.id" :value="team.id">
{{ team.label }}
</option>
</select>
<p class="mt-1 text-xs text-gray-500">
Verknüpft diese Mannschaft eindeutig mit dem importierten Spielplan.
Nach dem myTischtennis-Import das passende Team auswählen.
</p>
</div>
<div>
@@ -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