mirror of
https://github.com/ArthurDanjou/website.git
synced 2026-01-30 03:38:36 +01:00
Improve guestbook page
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import type { GuestbookMessage } from '@prisma/client'
|
||||||
import { providers } from '~~/types'
|
import { providers } from '~~/types'
|
||||||
|
|
||||||
useHead({
|
useHead({
|
||||||
title: 'Sign my guestbook • Arthur Danjou',
|
title: 'Sign my guestbook • Arthur Danjou',
|
||||||
})
|
})
|
||||||
|
|
||||||
const { loggedIn, clear , user} = useUserSession()
|
const { loggedIn, clear, user } = useUserSession()
|
||||||
|
|
||||||
const { data: messages, refresh } = useFetch('/api/messages', { method: 'get' })
|
const { data: messages, refresh } = useFetch<Array<GuestbookMessage>>('/api/messages', { method: 'get' })
|
||||||
|
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
const messageContent = ref<string>('')
|
const messageContent = ref<string>('')
|
||||||
@@ -20,12 +21,14 @@ async function sign() {
|
|||||||
body: {
|
body: {
|
||||||
message: messageContent.value,
|
message: messageContent.value,
|
||||||
},
|
},
|
||||||
}).then(() => {
|
}).then(async () => {
|
||||||
toast.add({
|
toast.add({
|
||||||
title: `Thank's for leaving a message!`,
|
title: `Thank's for leaving a message!`,
|
||||||
|
description: 'Your can see it at the top of the messages.',
|
||||||
icon: 'i-material-symbols-check-circle-outline-rounded',
|
icon: 'i-material-symbols-check-circle-outline-rounded',
|
||||||
timeout: 4000,
|
timeout: 4000,
|
||||||
})
|
})
|
||||||
|
await refresh()
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
toast.add({
|
toast.add({
|
||||||
title: 'An error occured when signing the book!',
|
title: 'An error occured when signing the book!',
|
||||||
@@ -33,7 +36,6 @@ async function sign() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
messageContent.value = ''
|
messageContent.value = ''
|
||||||
await refresh()
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user