diff --git a/package-lock.json b/package-lock.json index a844b24..5967a90 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "vue": "^3.4.21", "vue-loading-overlay": "^6.0.6", "vue-preloader": "^1.1.4", + "vue-toastification": "^2.0.0-rc.5", "vue-typer": "^1.2.0", "vue3-typer": "^1.0.0" }, @@ -2963,6 +2964,15 @@ "node": ">=14" } }, + "node_modules/vue-toastification": { + "version": "2.0.0-rc.5", + "resolved": "https://registry.npmjs.org/vue-toastification/-/vue-toastification-2.0.0-rc.5.tgz", + "integrity": "sha512-q73e5jy6gucEO/U+P48hqX+/qyXDozAGmaGgLFm5tXX4wJBcVsnGp4e/iJqlm9xzHETYOilUuwOUje2Qg1JdwA==", + "license": "MIT", + "peerDependencies": { + "vue": "^3.0.2" + } + }, "node_modules/vue-typer": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/vue-typer/-/vue-typer-1.2.0.tgz", diff --git a/package.json b/package.json index 865ae91..4d9e6de 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "vue": "^3.4.21", "vue-loading-overlay": "^6.0.6", "vue-preloader": "^1.1.4", + "vue-toastification": "^2.0.0-rc.5", "vue-typer": "^1.2.0", "vue3-typer": "^1.0.0" }, diff --git a/src/components/sections/ContactSection.vue b/src/components/sections/ContactSection.vue index 89af111..8af85c3 100644 --- a/src/components/sections/ContactSection.vue +++ b/src/components/sections/ContactSection.vue @@ -2,7 +2,8 @@ import {ref} from 'vue' import {Github, Globe, Linkedin, Mail, MapPin, Phone} from 'lucide-vue-next' import type {Profile} from '@/domain/models/Profile' - +import { useToast } from "vue-toastification"; +const toast = useToast(); defineProps<{ profile: Profile }>() @@ -27,23 +28,37 @@ function getSocialIcon(platform) { async function handleSubmit() { isSubmitting.value = true - // Simulate form submission - await new Promise(resolve => setTimeout(resolve, 1000)) + try { + const payload = { + from: form.value.email, + subject: form.value.name, + body: form.value.message + } - // Here you would typically send the form data to your backend - console.log('Form submitted:', form.value) + const response = await fetch(`${import.meta.env.VITE_MAIL_API_URL}/mail`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(payload) + }) - // Reset form - form.value = { - name: '', - email: '', - message: '' + if (!response.ok) { + throw new Error(`Error en el envío: ${response.status}`) + } + + form.value = { + name: '', + email: '', + message: '' + } + + toast.success("✅ ¡Mensaje enviado correctamente! Te responderé pronto.") + } catch (error) { + toast.error("❌ Hubo un error al enviar el mensaje. Inténtalo de nuevo.") + } finally { + isSubmitting.value = false } - - isSubmitting.value = false - - // Show success message (you could use a toast notification) - alert('¡Mensaje enviado correctamente! Te responderé pronto.') } @@ -117,15 +132,12 @@ async function handleSubmit() {
¡Hola! Por el momento mi servidor SMTP está de vacaciones 😅.
-Si quieres contactarme, envíame un correo electrónico directamente y prometo responderte - rápido.