added eigen tijden

This commit is contained in:
xeovalyte 2023-01-26 11:06:07 +01:00
parent 76fec72868
commit eb8a80ce67
2 changed files with 15 additions and 5 deletions

View File

@ -69,22 +69,26 @@
</div>
</div>
</div>
<input type="submit" class="btn mt-10 px-5 w-min mx-auto" value="Wedstrijd toevoegen" />
<input :disabled="disableButtons" type="submit" class="btn mt-10 px-5 w-min mx-auto" value="Wedstrijd toevoegen" />
</form>
</div>
</template>
<script setup>
import { getDocs, collection, writeBatch, doc } from "firebase/firestore"
import { useToast } from 'vue-toastification'
definePageMeta({
title: 'Wedstrijd Toevoegen',
key: 'back'
})
const { userData, db, competitors } = inject('firebase')
const toast = useToast()
const { db, competitors } = inject('firebase')
const showModel = ref(false)
const disableButtons = ref(false)
const modelData = ref({
relatiecode: '',
@ -177,18 +181,20 @@ const submitModelForm = () => {
}
const submitContestForm = async () => {
disableButtons.value = true
const batch = writeBatch(db)
Object.values(contest.value.events).forEach(event => {
event.competitors.forEach(competitor => {
const combinedTime = competitor.time.minutes.toString() + competitor.time.seconds.toString() + competitor.time.milliseconds.toString()
const combinedTime = competitor.time.minutes.toString().padStart(2, '0') + competitor.time.seconds.toString().padStart(2, '0') + competitor.time.milliseconds.toString().padStart(2, '0')
const docRef = doc(collection(db, 'timings'))
batch.set(docRef, {
relatiecode: competitor.relatiecode,
contest: { name: contest.value.name, date: contest.value.date.toString() },
event: event.id,
time: { minutes: competitor.time.minutes, seconds: competitor.time.seconds, milliseconds: competitor.time.milliseconds, combined: combinedTime },
time: { minutes: competitor.time.minutes.toString().padStart(2, '0'), seconds: competitor.time.seconds.toString().padStart(2, '0'), milliseconds: competitor.time.milliseconds.toString().padStart(2, '0'), combined: combinedTime },
dsq: competitor.dsq,
info: competitor.info || ''
})
@ -196,6 +202,10 @@ const submitContestForm = async () => {
})
await batch.commit()
disableButtons.value = false
toast.success('Wedstrijd is toegevoegd')
navigateTo('/wedstrijd')
}
onMounted(() => {

View File

@ -1,7 +1,7 @@
<template>
<div class="flex flex-col justify-center items-center px-2 overflow-hidden">
<div class="container w-full max-w-md">
<NuxtLink to="/news" class="rounded-t item-hover py-2 flex items-center">
<NuxtLink to="/wedstrijd/owntimes" class="rounded-t item-hover py-2 flex items-center">
<span>Eigen Tijden</span>
<Icon class="ml-auto" size="2em" name="ion:arrow-forward"/>
</NuxtLink>