feat(mannschaften): align public pages with season query logic
This commit is contained in:
@@ -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() !== '')
|
||||
|
||||
Reference in New Issue
Block a user