Saison-Auswahl hinzugefügt
Some checks failed
Code Analysis and Production Deploy / analyze (push) Failing after 2m17s
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Has been skipped

This commit is contained in:
Torsten Schulz (local)
2026-05-27 18:01:32 +02:00
parent 7e0c92368e
commit 92099685e6
2 changed files with 54 additions and 10 deletions

View File

@@ -102,7 +102,7 @@
</template> </template>
<script setup> <script setup>
import { ref, onMounted, computed } from 'vue' import { ref, onMounted, computed, watch } from 'vue'
import { Users } from 'lucide-vue-next' import { Users } from 'lucide-vue-next'
const props = defineProps({ const props = defineProps({
@@ -158,6 +158,7 @@ const loadMannschaften = async () => {
const lines = csv.split('\n').filter(line => line.trim() !== '') const lines = csv.split('\n').filter(line => line.trim() !== '')
if (lines.length < 2) { if (lines.length < 2) {
mannschaften.value = []
return return
} }
@@ -234,4 +235,8 @@ const formatDate = (dateString) => {
onMounted(() => { onMounted(() => {
loadMannschaften() loadMannschaften()
}) })
watch(selectedSeason, () => {
loadMannschaften()
})
</script> </script>

View File

@@ -6,8 +6,27 @@
</h1> </h1>
<div class="w-24 h-1 bg-primary-600 mb-8" /> <div class="w-24 h-1 bg-primary-600 mb-8" />
<p class="text-xl text-gray-600 mb-12"> <p class="text-xl text-gray-600 mb-12 flex flex-wrap items-center gap-2">
Unsere aktiven Mannschaften in der Saison {{ selectedSeasonLabel }} <span>Unsere aktiven Mannschaften in der Saison</span>
<label
for="season-select"
class="sr-only"
>
Saison auswählen
</label>
<select
id="season-select"
v-model="selectedSeason"
class="px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-primary-500 bg-white text-base"
>
<option
v-for="season in seasons"
:key="season"
:value="season"
>
{{ formatSeasonLabel(season) }}
</option>
</select>
</p> </p>
<MannschaftenUebersicht :season="selectedSeason" /> <MannschaftenUebersicht :season="selectedSeason" />
@@ -37,6 +56,7 @@ import { computed } from 'vue'
import MannschaftenUebersicht from '~/components/MannschaftenUebersicht.vue' import MannschaftenUebersicht from '~/components/MannschaftenUebersicht.vue'
const route = useRoute() const route = useRoute()
const router = useRouter()
const getCurrentSeasonSlug = () => { const getCurrentSeasonSlug = () => {
const now = new Date() const now = new Date()
@@ -46,18 +66,37 @@ const getCurrentSeasonSlug = () => {
return `${String(startYear).slice(-2)}--${String(endYear).slice(-2)}` return `${String(startYear).slice(-2)}--${String(endYear).slice(-2)}`
} }
const selectedSeason = computed(() => { const currentSeason = getCurrentSeasonSlug()
const value = String(route.query.season || '').trim() const { data: seasonsResult } = await useFetch('/api/mannschaften/seasons')
return /^\d{2}--\d{2}$/.test(value) ? value : getCurrentSeasonSlug()
const seasons = computed(() => {
const availableSeasons = Array.isArray(seasonsResult.value?.seasons)
? seasonsResult.value.seasons
: []
return [...new Set([currentSeason, ...availableSeasons])]
.filter(season => /^\d{2}--\d{2}$/.test(season))
.sort()
.reverse()
}) })
const selectedSeasonLabel = computed(() => { const selectedSeason = computed({
const match = String(selectedSeason.value || '').match(/^(\d{2})--(\d{2})$/) get() {
return match ? `20${match[1]}/${match[2]}` : selectedSeason.value const value = String(route.query.season || '').trim()
return seasons.value.includes(value) ? value : currentSeason
},
set(value) {
const season = seasons.value.includes(value) ? value : currentSeason
router.replace({ query: { ...route.query, season } })
}
}) })
const formatSeasonLabel = (season) => {
const match = String(season || '').match(/^(\d{2})--(\d{2})$/)
return match ? `20${match[1]}/${match[2]}` : season
}
useHead({ useHead({
title: 'Mannschaften - Harheimer TC', title: 'Mannschaften - Harheimer TC',
}) })
</script> </script>