Fix form fill

This commit is contained in:
2021-04-17 13:24:37 +02:00
parent 167670f092
commit 539c474a06
4 changed files with 62 additions and 46 deletions

View File

@@ -59,50 +59,9 @@ export default {
}
})
const error = ref(false)
const success = ref(false)
const {$axios} = useContext()
const form = ref<Form>({} as Form)
const handleForm = async () => {
await $axios.post('subscribers',
{
email: form.value.email,
name: form.value.name,
content: form.value.content,
subject: form.value.subject
})
.then(() => {
success.value = true
setTimeout(() => {
success.value = false
form.value = {} as Form
}, 5000)
}).catch(() => {
error.value = true
setTimeout(() => {
error.value = false
}, 5000)
})
}
const isSendable = computed(() => {
const {email, name, content, subject} = form.value
return isNotEmpty(email) && isNotEmpty(name)
})
const isNotEmpty = (object: string | undefined) => {
return object !== undefined && object.length > 0 && object !== "" && object !== ''
}
return {
info,
getColor,
handleForm,
success,
error,
form,
isSendable
}
}
}

View File

@@ -12,7 +12,7 @@
<h1 class="text-gray-700 dark:text-gray-400 text-xl mt-4">{{ $t('projects.description') }}</h1>
<div class="flex flex-col items-center md:items-start md:flex-row flex-wrap w-full space-y-3 md:space-y-0">
<div class="flex py-8 w-full flex-wrap" >
<div class="md:mx-3 my-2 w-full" v-for="project in projects">
<div class="md:mx-3 my-2 w-full xl:w-auto" v-for="project in projects">
<Project
:title="project.title"
:cover="project.cover"