added eigen tijden
This commit is contained in:
parent
76fec72868
commit
eb8a80ce67
@ -69,22 +69,26 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</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>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { getDocs, collection, writeBatch, doc } from "firebase/firestore"
|
import { getDocs, collection, writeBatch, doc } from "firebase/firestore"
|
||||||
|
import { useToast } from 'vue-toastification'
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
title: 'Wedstrijd Toevoegen',
|
title: 'Wedstrijd Toevoegen',
|
||||||
key: 'back'
|
key: 'back'
|
||||||
})
|
})
|
||||||
|
|
||||||
const { userData, db, competitors } = inject('firebase')
|
const toast = useToast()
|
||||||
|
|
||||||
|
const { db, competitors } = inject('firebase')
|
||||||
|
|
||||||
const showModel = ref(false)
|
const showModel = ref(false)
|
||||||
|
const disableButtons = ref(false)
|
||||||
|
|
||||||
const modelData = ref({
|
const modelData = ref({
|
||||||
relatiecode: '',
|
relatiecode: '',
|
||||||
@ -177,18 +181,20 @@ const submitModelForm = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const submitContestForm = async () => {
|
const submitContestForm = async () => {
|
||||||
|
disableButtons.value = true
|
||||||
|
|
||||||
const batch = writeBatch(db)
|
const batch = writeBatch(db)
|
||||||
|
|
||||||
Object.values(contest.value.events).forEach(event => {
|
Object.values(contest.value.events).forEach(event => {
|
||||||
event.competitors.forEach(competitor => {
|
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'))
|
const docRef = doc(collection(db, 'timings'))
|
||||||
batch.set(docRef, {
|
batch.set(docRef, {
|
||||||
relatiecode: competitor.relatiecode,
|
relatiecode: competitor.relatiecode,
|
||||||
contest: { name: contest.value.name, date: contest.value.date.toString() },
|
contest: { name: contest.value.name, date: contest.value.date.toString() },
|
||||||
event: event.id,
|
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,
|
dsq: competitor.dsq,
|
||||||
info: competitor.info || ''
|
info: competitor.info || ''
|
||||||
})
|
})
|
||||||
@ -196,6 +202,10 @@ const submitContestForm = async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
await batch.commit()
|
await batch.commit()
|
||||||
|
disableButtons.value = false
|
||||||
|
|
||||||
|
toast.success('Wedstrijd is toegevoegd')
|
||||||
|
navigateTo('/wedstrijd')
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col justify-center items-center px-2 overflow-hidden">
|
<div class="flex flex-col justify-center items-center px-2 overflow-hidden">
|
||||||
<div class="container w-full max-w-md">
|
<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>
|
<span>Eigen Tijden</span>
|
||||||
<Icon class="ml-auto" size="2em" name="ion:arrow-forward"/>
|
<Icon class="ml-auto" size="2em" name="ion:arrow-forward"/>
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
|
Loading…
Reference in New Issue
Block a user