diff --git a/pages/mannschaften/[slug].vue b/pages/mannschaften/[slug].vue
index 6c21e3b..9f3ecc8 100644
--- a/pages/mannschaften/[slug].vue
+++ b/pages/mannschaften/[slug].vue
@@ -76,40 +76,64 @@
-
- Aktueller Spielplan
-
-
- Saison {{ spielplanSeasonLabel }}
-
+
+
+
+ Aktueller Spielplan
+
+
+ Saison {{ spielplanSeasonLabel }}
+
+
+
+
+
+
+
+
Spielplan wird geladen...
{{ spielplanError }}
Für diese Mannschaft sind im aktuellen Spielplan keine Spiele vorhanden.
+
+
+ Tabelle wird geladen...
+
+
+
+ {{ tableError }}
+
+
+
+ Für diese Mannschaft ist aktuell keine Tabelle hinterlegt.
+
+
+
+
+
+
+ |
+ Platz
+ |
+
+ Mannschaft
+ |
+
+ Spiele
+ |
+
+ S/U/N
+ |
+
+ Sätze
+ |
+
+ Bälle
+ |
+
+ Punkte
+ |
+
+
+
+
+ |
+ {{ row.table_rank ?? '-' }}
+ |
+
+ {{ row.team_name || '-' }}
+ |
+
+ {{ row.meetings_count ?? '-' }}
+ |
+
+ {{ formatSun(row) }}
+ |
+
+ {{ row.sets_relation || '-' }}
+ |
+
+ {{ row.games_relation || '-' }}
+ |
+
+ {{ formatPunkte(row) }}
+ |
+
+
+
+
@@ -242,6 +349,15 @@ const mannschaftSpielplan = ref([])
const spielplanSeason = ref('')
const isSpielplanLoading = ref(false)
const spielplanError = ref('')
+const activePanelTab = ref('matches')
+const isTableLoading = ref(false)
+const tableError = ref('')
+const teamTableRows = ref([])
+
+const hasTableLink = computed(() => {
+ const link = String(mannschaft.value?.weitere_informationen_link || '').trim()
+ return link.includes('/tabelle/')
+})
const spielplanSeasonLabel = computed(() => {
const match = String(spielplanSeason.value || '').match(/^(\d{2})--(\d{2})$/)
@@ -317,13 +433,52 @@ const loadMannschaften = async () => {
useHead({
title: `${mannschaft.value.mannschaft} - Harheimer TC`,
})
- await loadSpielplan()
+ await Promise.all([loadSpielplan(), loadTeamTable()])
}
} catch (error) {
console.error('Fehler beim Laden der Mannschaften:', error)
}
}
+const loadTeamTable = async () => {
+ if (!mannschaft.value) return
+
+ if (!hasTableLink.value) {
+ teamTableRows.value = []
+ tableError.value = ''
+ return
+ }
+
+ isTableLoading.value = true
+ tableError.value = ''
+
+ try {
+ const params = new URLSearchParams({ team: mannschaft.value.mannschaft })
+ if (spielplanSeason.value) {
+ params.set('season', spielplanSeason.value)
+ }
+
+ const response = await fetch(`/api/spielplan/table?${params.toString()}`)
+ const result = await response.json()
+
+ if (!result.success) {
+ tableError.value = result.message || 'Tabelle konnte nicht geladen werden.'
+ teamTableRows.value = []
+ return
+ }
+
+ teamTableRows.value = Array.isArray(result?.table?.table?.leagueTable)
+ ? result.table.table.leagueTable
+ : []
+ } catch (error) {
+ console.error('Fehler beim Laden der Tabelle:', error)
+ tableError.value = 'Tabelle konnte nicht geladen werden.'
+ teamTableRows.value = []
+ } finally {
+ isTableLoading.value = false
+ }
+}
+
const getTeamVariants = (cmsMannschaft) => {
const mannschaftMapping = {
'Erwachsene 1': ['harheimer tc'],
@@ -495,6 +650,27 @@ const getRowClass = (row) => {
return 'bg-white'
}
+const formatSun = (row) => {
+ const s = row?.meetings_won
+ const u = row?.meetings_tie
+ const n = row?.meetings_lost
+ if (s == null && u == null && n == null) return '-'
+ return `${s ?? 0}/${u ?? 0}/${n ?? 0}`
+}
+
+const formatPunkte = (row) => {
+ if (row?.points_won == null && row?.points_lost == null) return '-'
+ return `${row?.points_won ?? 0}:${row?.points_lost ?? 0}`
+}
+
+const isCurrentTeamRow = (row) => {
+ const teamName = String(row?.team_name || '').toLowerCase()
+ if (!teamName.includes('harheimer tc')) return false
+
+ const variants = getTeamVariants(mannschaft.value?.mannschaft || '')
+ return variants.some((variant) => isExactHarheimTeam(teamName, variant))
+}
+
onMounted(() => {
loadMannschaften()
})