30 lines
775 B
Vue
30 lines
775 B
Vue
<template>
|
|
<MainPoll :question-component="QuestionChoice" @submit="submitForm">
|
|
<template #submit>
|
|
<button type="submit">Submit</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> |