diff --git a/.env b/.env index 5d9467f..8f89e83 100644 --- a/.env +++ b/.env @@ -1,2 +1,4 @@ VITE_BASE_URL=http://localhost:3000 -VITE_YANDEX_MAPS_KEY=13f4c06b-cb7e-4eeb-81f1-af52f12587b2 \ No newline at end of file +VITE_YANDEX_MAPS_KEY=13f4c06b-cb7e-4eeb-81f1-af52f12587b2 +SMTP_USER=rentalservicekg@yandex.ru +SMTP_APP_PASSWORD=uljislsoihthciju diff --git a/Dockerfile b/Dockerfile index 564cb64..8001666 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,9 @@ COPY --from=build /app/.output/ ./ ENV PORT=80 ENV VITE_BASE_URL=https://rental.koptilnya.xyz ENV VITE_YANDEX_MAPS_KEY=13f4c06b-cb7e-4eeb-81f1-af52f12587b2 +ENV SMTP_USER=rentalservicekg@yandex.ru +ENV SMTP_APP_PASSWORD=uljislsoihthciju + EXPOSE 80 diff --git a/components/Contacts.vue b/components/Contacts.vue index 267d7ad..7614ac8 100644 --- a/components/Contacts.vue +++ b/components/Contacts.vue @@ -43,9 +43,7 @@ - - - + Как к вам обращаться @@ -125,13 +123,6 @@ - - - - - - - @@ -207,28 +198,17 @@ const [phone, phoneAttrs] = defineField('phone') const [service, serviceAttrs] = defineField('service') const [comment, commentAttrs] = defineField('comment') -function encode(data: Record) { - return Object.keys(data) - .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(data[key])}`) - .join('&') -} - const onSubmit = handleSubmit(async (values) => { - await fetch('/', { + const res = await $fetch('/api/send_mail', { method: 'POST', - headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, - body: encode({ - 'form-name': 'contacts', - 'name': values.name, - 'phone': values.phone, - 'service': values.service, - 'comment': values.comment, - }), + body: values, }) - toast.add({ - title: 'Заявка успешно отправлена!', - }) + if (res.ok) { + toast.add({ + title: 'Заявка успешно отправлена!', + }) + } }) diff --git a/layouts/default.vue b/layouts/default.vue index d7adc7b..5c76e44 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -1,29 +1,31 @@ - - - - Rental - + + + + + Rental + - - - + + + - - - - - + + + + + + diff --git a/nuxt.config.ts b/nuxt.config.ts index aa0b8e5..1f2a63d 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -5,7 +5,7 @@ import { process } from 'std-env' const { resolve } = createResolver(import.meta.url) export default defineNuxtConfig({ - ssr: false, + ssr: true, compatibilityDate: '2025-05-15', devtools: { enabled: true }, modules: [ @@ -60,10 +60,4 @@ export default defineNuxtConfig({ fonts: { provider: 'google', }, - nitro: { - preset: 'static', - }, - routeRules: { - '/**': { prerender: true }, - }, }) diff --git a/package.json b/package.json index 8baed9d..86c8ae4 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ }, "dependencies": { "@nuxt/content": "^3.7.1", - "gsap": "3.13", "@nuxt/fonts": "0.11.4", "@nuxt/icon": "1.15.0", "@nuxt/image": "1.10.0", @@ -26,7 +25,9 @@ "axios": "^1.12.2", "dayjs": "^1.11.13", "decimal.js": "^10.5.0", + "gsap": "3.13", "maska": "^3.2.0", + "nodemailer": "^7.0.11", "nuxt": "^4.1.3", "swiper": "^12.0.2", "typescript": "^5.6.3", diff --git a/public/netlify-form-dummy.html b/public/netlify-form-dummy.html deleted file mode 100644 index 8c0bf52..0000000 --- a/public/netlify-form-dummy.html +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/server/api/send_mail.post.ts b/server/api/send_mail.post.ts new file mode 100644 index 0000000..5e29b72 --- /dev/null +++ b/server/api/send_mail.post.ts @@ -0,0 +1,29 @@ +import nodemailer from 'nodemailer' + +export default defineEventHandler(async (event) => { + const body = await readBody(event) + + const transporter = nodemailer.createTransport({ + host: 'smtp.yandex.ru', + port: 465, + secure: true, + auth: { + user: process.env.SMTP_USER, + pass: process.env.SMTP_APP_PASSWORD, + }, + }) + + await transporter.sendMail({ + from: `"Rental Concierge" <${process.env.SMTP_USER}>`, + to: 'info@rental-concierge.com', + subject: 'Новая заявка', + html: ` + Имя: ${body.name} + Телефон: ${body.phone} + Услуга: ${body.service} + Комментарий: ${body.comment} + `, + }) + + return { ok: true } +}) diff --git a/yarn.lock b/yarn.lock index a3e6339..7cf38fe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7068,6 +7068,11 @@ node-releases@^2.0.27: resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.27.tgz#eedca519205cf20f650f61d56b070db111231e4e" integrity sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA== +nodemailer@^7.0.11: + version "7.0.11" + resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-7.0.11.tgz#5f7b06afaec20073cff36bea92d1c7395cc3e512" + integrity sha512-gnXhNRE0FNhD7wPSCGhdNh46Hs6nm+uTyg+Kq0cZukNQiYdnCsoQjodNP9BQVG9XrcK/v6/MgpAPBUFyzh9pvw== + nopt@^9.0.0: version "9.0.0" resolved "https://registry.yarnpkg.com/nopt/-/nopt-9.0.0.tgz#6bff0836b2964d24508b6b41b5a9a49c4f4a1f96"