2022-09-27 17:33:00 +02:00
|
|
|
<template>
|
2023-01-22 15:42:45 +01:00
|
|
|
<div class="flex flex-col gap-5 mx-auto p-2 w-full max-w-md">
|
|
|
|
<form @submit.prevent="sendNews" class="flex flex-col">
|
|
|
|
<label class="font-bold">Titel</label>
|
|
|
|
<input v-model="form.title" required="true" class="input mb-5" type="text">
|
|
|
|
|
|
|
|
<label class="font-bold">Beschrijving</label>
|
|
|
|
<textarea v-model="form.description" required="true" class="input mb-5" />
|
|
|
|
|
|
|
|
<label class="font-bold">Groep</label>
|
|
|
|
<select v-model="form.topic" required="true" class="input mb-5">
|
|
|
|
<option value="all">Iedereen</option>
|
|
|
|
<option value="test">Test</option>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<div class="w-full flex flex-wrap justify-between">
|
|
|
|
<input :disabled="disableButtons" type="submit" value="Stuur Bericht" class="btn w-full sm:w-40 mb-1">
|
2024-05-15 21:38:47 +02:00
|
|
|
<button @click="router.back()" type="button" class="hover:underline font-bold w-full sm:w-max sm:ml-auto">Annuleer</button>
|
2023-01-22 15:42:45 +01:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
2022-09-27 17:33:00 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
definePageMeta({
|
2023-01-22 15:42:45 +01:00
|
|
|
title: 'Nieuw Bericht',
|
|
|
|
key: 'back'
|
2022-09-27 17:33:00 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
const toast = useToast()
|
2023-03-20 11:23:46 +01:00
|
|
|
const newsStore = useNewsStore()
|
2022-09-27 17:33:00 +02:00
|
|
|
|
|
|
|
const disableButtons = ref(false)
|
|
|
|
|
|
|
|
const sendNews = async () => {
|
2023-01-21 21:36:22 +01:00
|
|
|
try {
|
2023-03-20 11:23:46 +01:00
|
|
|
disableButtons.value = true
|
2022-11-08 15:11:45 +01:00
|
|
|
|
2023-03-20 11:23:46 +01:00
|
|
|
await newsStore.send(form.value)
|
2023-01-21 21:36:22 +01:00
|
|
|
|
2023-03-20 11:23:46 +01:00
|
|
|
disableButtons.value = false
|
2023-01-21 21:36:22 +01:00
|
|
|
} catch (e) {
|
|
|
|
console.log(e)
|
2023-03-20 11:23:46 +01:00
|
|
|
disableButtons.value = false
|
2022-09-27 17:33:00 +02:00
|
|
|
|
2023-03-20 11:23:46 +01:00
|
|
|
toast.error('Error tijdens versturen bericht')
|
2023-01-21 21:36:22 +01:00
|
|
|
}
|
2022-09-27 17:33:00 +02:00
|
|
|
}
|
2023-03-20 11:23:46 +01:00
|
|
|
|
|
|
|
const form = ref({
|
|
|
|
title: '',
|
|
|
|
description: '',
|
|
|
|
topic: ''
|
|
|
|
})
|
2023-01-21 21:36:22 +01:00
|
|
|
</script>
|