feat(mannschaften): align public pages with season query logic
This commit is contained in:
@@ -325,7 +325,7 @@
|
||||
<!-- Zurück-Button -->
|
||||
<div class="text-center">
|
||||
<NuxtLink
|
||||
to="/mannschaften"
|
||||
:to="{ path: '/mannschaften', query: selectedSeason ? { season: selectedSeason } : {} }"
|
||||
class="inline-flex items-center px-6 py-3 bg-primary-600 hover:bg-primary-700 text-white font-semibold rounded-lg transition-colors"
|
||||
>
|
||||
← Zurück zur Übersicht
|
||||
@@ -359,6 +359,19 @@ import { ref, computed, onMounted } from 'vue'
|
||||
import { Users } from 'lucide-vue-next'
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
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(route.query.season || '').trim()
|
||||
return /^\d{2}--\d{2}$/.test(value) ? value : getCurrentSeasonSlug()
|
||||
})
|
||||
const mannschaft = ref(null)
|
||||
const mannschaftSpielplan = ref([])
|
||||
const spielplanSeason = ref('')
|
||||
@@ -413,7 +426,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()}` : ''}`)
|
||||
if (!csv) return
|
||||
const lines = csv.split('\n').filter(line => line.trim() !== '')
|
||||
|
||||
@@ -485,7 +500,9 @@ const loadTeamTable = async () => {
|
||||
|
||||
try {
|
||||
const params = new URLSearchParams({ team: mannschaft.value.mannschaft })
|
||||
if (spielplanSeason.value) {
|
||||
if (selectedSeason.value) {
|
||||
params.set('season', selectedSeason.value)
|
||||
} else if (spielplanSeason.value) {
|
||||
params.set('season', spielplanSeason.value)
|
||||
}
|
||||
|
||||
@@ -594,7 +611,9 @@ const loadSpielplan = async () => {
|
||||
spielplanError.value = ''
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/spielplan')
|
||||
const params = new URLSearchParams()
|
||||
if (selectedSeason.value) params.set('season', selectedSeason.value)
|
||||
const response = await fetch(`/api/spielplan${params.toString() ? `?${params.toString()}` : ''}`)
|
||||
const result = await response.json()
|
||||
|
||||
if (!result.success) {
|
||||
|
||||
Reference in New Issue
Block a user