added eigen tijden
This commit is contained in:
parent
76fec72868
commit
eb8a80ce67
@ -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(() => {
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user