mirror of
https://github.com/ArthurDanjou/website-old.git
synced 2026-01-23 16:30:42 +01:00
Fix form fill
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user