42 lines
1000 B
Vue
42 lines
1000 B
Vue
<template>
|
|
<MainPoll :question-component="QuestionChoice" @submit="submitForm">
|
|
<template #submit>
|
|
<button type="submit" id="form-submit">Valider</button>
|
|
</template>
|
|
</MainPoll>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { MainPoll } from '#components';
|
|
import QuestionChoice from '~/components/QuestionChoice.vue';
|
|
|
|
|
|
const runtimeConfig = useRuntimeConfig()
|
|
|
|
const route = useRoute()
|
|
|
|
async function submitForm(e: Event) {
|
|
const target = e.target
|
|
if (!target || !(target instanceof HTMLFormElement)) {
|
|
throw Error("Form target not found")
|
|
}
|
|
await $fetch(`${runtimeConfig.public.apiBase}/vote/${route.query.code}`, {
|
|
method: "POST",
|
|
body: Object.fromEntries(new FormData(target))
|
|
})
|
|
|
|
navigateTo({ path: "/results", query: route.query })
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
#form-submit {
|
|
padding: .375rem .75rem;
|
|
border-width: 0px;
|
|
border-color: rgb(0, 0, 0);
|
|
border-radius: 5px;
|
|
background-color: rgb(17, 95, 239);
|
|
color: white;
|
|
font-size: 1em;
|
|
}
|
|
</style> |