feat(mannschaften): align public pages with season query logic
Some checks failed
Code Analysis and Production Deploy / deploy-production (push) Has been cancelled
Code Analysis and Production Deploy / deploy-test (push) Has been cancelled
Code Analysis and Production Deploy / analyze (push) Has been cancelled

This commit is contained in:
Torsten Schulz (local)
2026-05-20 18:01:07 +02:00
parent cfd9365d07
commit 11ff823fe2
4 changed files with 97 additions and 11 deletions

View File

@@ -52,7 +52,7 @@
<!-- Mannschaftsaufstellung -->
<div class="border-t border-gray-200 pt-6">
<h3 class="text-xl font-semibold text-gray-900 mb-4">
Mannschaftsaufstellung Saison 2025/26
Mannschaftsaufstellung Saison {{ selectedSeasonLabel }}
</h3>
<div class="grid sm:grid-cols-2 lg:grid-cols-4 gap-4">
<div
@@ -102,11 +102,36 @@
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { ref, onMounted, computed } from 'vue'
import { Users } from 'lucide-vue-next'
const props = defineProps({
season: {
type: String,
default: ''
}
})
const mannschaften = ref([])
const getCurrentSeasonSlug = () => {
const now = new Date()
const year = now.getFullYear()
const startYear = now.getMonth() >= 6 ? year : year - 1
const endYear = startYear + 1
return `${String(startYear).slice(-2)}--${String(endYear).slice(-2)}`
}
const selectedSeason = computed(() => {
const value = String(props.season || '').trim()
return /^\d{2}--\d{2}$/.test(value) ? value : getCurrentSeasonSlug()
})
const selectedSeasonLabel = computed(() => {
const match = String(selectedSeason.value || '').match(/^(\d{2})--(\d{2})$/)
return match ? `20${match[1]}/${match[2]}` : selectedSeason.value
})
async function fetchCsvText(url) {
const attempt = async () => {
const withBuster = `${url}${url.includes('?') ? '&' : '?'}_t=${Date.now()}`
@@ -125,7 +150,9 @@ async function fetchCsvText(url) {
const loadMannschaften = async () => {
try {
const csv = await fetchCsvText('/api/mannschaften')
const params = new URLSearchParams()
if (selectedSeason.value) params.set('season', selectedSeason.value)
const csv = await fetchCsvText(`/api/mannschaften${params.toString() ? `?${params.toString()}` : ''}`)
// Vereinfachter CSV-Parser
const lines = csv.split('\n').filter(line => line.trim() !== '')