diff --git a/app/components/AppFooter.vue b/app/components/AppFooter.vue index 87e125f..8925a36 100644 --- a/app/components/AppFooter.vue +++ b/app/components/AppFooter.vue @@ -27,6 +27,7 @@ import type { NavigationMenuItem } from '@nuxt/ui'; import { version } from '../../package.json'; +const toast = useToast(); const { isMobile } = useDevice(); const orientation = computed(() => (isMobile ? 'vertical' : 'horizontal')); const { getMeta } = useBackend(); @@ -48,4 +49,13 @@ const items = computed(() => [ to: 'https://rust-lang.org/', }, ]); +watch(error, (value) => { + if (value) { + toast.add({ + title: $t('backend.errors.title'), + description: $t(value.message ?? 'backend.errors.unknown'), + color: 'error', + }); + } +}); diff --git a/app/composables/useApi.test.ts b/app/composables/useApi.test.ts index d58a51c..65a476f 100644 --- a/app/composables/useApi.test.ts +++ b/app/composables/useApi.test.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ + import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; import { nextTick } from 'vue'; import type { FetchError } from 'ofetch'; @@ -14,10 +16,6 @@ vi.mock('#app', () => ({ })); // Mock $fetch globally -declare global { - var $fetch: ReturnType; -} -// global.$fetch = vi.fn(); vi.mock('#app', () => ({ useRuntimeConfig: vi.fn(() => ({ public: { diff --git a/app/composables/useBackend.ts b/app/composables/useBackend.ts index 6f1dcab..aed2476 100644 --- a/app/composables/useBackend.ts +++ b/app/composables/useBackend.ts @@ -7,7 +7,7 @@ export const useBackend = () => { const getMeta = (): UseApiResponse => api.get('/meta'); const postContact = (): UseApiResponse => - api.post('/contact', undefined, true); + api.post('/contact', undefined, false); return { getMeta, postContact }; }; diff --git a/app/pages/contact.vue b/app/pages/contact.vue index 211c5df..021280a 100644 --- a/app/pages/contact.vue +++ b/app/pages/contact.vue @@ -43,18 +43,27 @@ +
+ If you see this input, you may be using accessibility tools to access this website. This input is meant to + be hidden to human visitors, but not bots which do not necessarily render the website the way it is meant + to. Unfortunately, this also affects accessibility tools, such as the ones for visually-impared people. If + that is indeed, please ignore this input, as it is not meant to be filled by human beings. Filling this + input will result in a discarded contact form. +
{{ $t('pages.contact.form.sendButton') }} @@ -86,6 +96,7 @@ diff --git a/i18n/locales/en.json b/i18n/locales/en.json index ae73e86..b893b13 100644 --- a/i18n/locales/en.json +++ b/i18n/locales/en.json @@ -38,6 +38,11 @@ "name": "Languages & Worldbuilding" }, "contact": { + "name": "Contact", + "toast": { + "success": "Email sent!", + "error": "Failure sending message" + }, "form": { "sendButton": "Send Message", "validation": { @@ -59,8 +64,7 @@ "message": "Hello, ...", "website": "https://example.com" } - }, - "name": "Contact" + } } }, "footer": { @@ -81,7 +85,7 @@ "unknown": "The website encountered an unknown error. Please try again later." }, "contact": { - "success": "Email sent! We’ve also sent you a confirmation email!", + "success": "We’ve also sent you a confirmation email. If you haven’t received anything in a few minutes, please check your junk mail.", "honeypot": "Mmmmmh, I love me some honey from the honeypot!", "errors": { "internal": "The website encountered an internal error. Please try again later.", diff --git a/i18n/locales/fr.json b/i18n/locales/fr.json index eb754b2..fca459e 100644 --- a/i18n/locales/fr.json +++ b/i18n/locales/fr.json @@ -39,6 +39,10 @@ }, "contact": { "name": "Contact", + "toast": { + "success": "Couriel envoyé !", + "error": "Erreur lors de l'envoi du message" + }, "form": { "sendButton": "Envoyer le message", "validation": { @@ -81,7 +85,7 @@ "unknown": "Une erreur inconnue est survenue. Veuillez réessayer plus tard." }, "contact": { - "success": "Message envoyé ! Un email de confirmation vous a été également envoyé.", + "success": "Un email de confirmation vous a été également envoyé. Si vous n’avez rien reçu d’ici quelques minutes, vérifiez vos spams.", "honeypot": "Miam, du bon miel pour le robot !", "errors": { "internal": "Une erreur interne est survenue, veuillez réessayer plus tard.",