diff --git a/backend/__pycache__/config.cpython-312.pyc b/backend/__pycache__/config.cpython-312.pyc index ed6f7e2..6346c2e 100644 Binary files a/backend/__pycache__/config.cpython-312.pyc and b/backend/__pycache__/config.cpython-312.pyc differ diff --git a/backend/__pycache__/models.cpython-312.pyc b/backend/__pycache__/models.cpython-312.pyc index 0e0e66e..89c8c2f 100644 Binary files a/backend/__pycache__/models.cpython-312.pyc and b/backend/__pycache__/models.cpython-312.pyc differ diff --git a/frontend/next.config.mjs b/frontend/next.config.mjs index 4678774..f19712c 100644 --- a/frontend/next.config.mjs +++ b/frontend/next.config.mjs @@ -1,4 +1,13 @@ /** @type {import('next').NextConfig} */ -const nextConfig = {}; +const nextConfig = { + async rewrites() { + return [ + { + source: '/backend/:path*', + destination: `http://192.168.50.107:5580/:path*`, + }, + ] + }, +}; export default nextConfig; diff --git a/frontend/package.json b/frontend/package.json index f37ebcf..74ed1ba 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -2,10 +2,11 @@ "name": "kevos-attire", "version": "0.1.0", "private": true, + "proxy": "http://192.168.50.107:5580/", "scripts": { "dev": "next dev", "build": "next build", - "start": "next start", + "start": "next start -p 3003", "lint": "next lint" }, "dependencies": { diff --git a/frontend/src/app/api/emails/route.ts b/frontend/src/app/api/emails/route.ts index 44dd174..24795c0 100644 --- a/frontend/src/app/api/emails/route.ts +++ b/frontend/src/app/api/emails/route.ts @@ -1,5 +1,6 @@ +"use server" import { sendEmails } from "@/lib/mail.utils" -import { NextRequest } from "next/server" +import { NextRequest, NextResponse } from "next/server" export async function POST(request: NextRequest) { const sender = { @@ -18,14 +19,18 @@ export async function POST(request: NextRequest) { const result = await sendEmails({ sender, recipients, - subject: "New Email!", - message: `New order from ${clientEmail}` + subject: "New Order!", + message: `New order from ${clientEmail.senderEmail}` }) - return Response.json({ + return NextResponse.json({ accepted: result.accepted, }) } catch (error){ - return Response.json({message: 'Unable to send email at this time.'}, {status: 500}) + return NextResponse.json({message: 'Unable to send email at this time.'}, {status: 500}) } +} + +export async function GET(req: NextRequest){ + return NextResponse.json({message: 'Hello'}) } \ No newline at end of file diff --git a/frontend/src/app/favicon.ico b/frontend/src/app/favicon.ico deleted file mode 100644 index 718d6fe..0000000 Binary files a/frontend/src/app/favicon.ico and /dev/null differ diff --git a/frontend/src/app/icon.png b/frontend/src/app/icon.png new file mode 100644 index 0000000..35c35b5 Binary files /dev/null and b/frontend/src/app/icon.png differ diff --git a/frontend/src/app/page.tsx b/frontend/src/app/page.tsx index 18d0bce..2bc17f7 100644 --- a/frontend/src/app/page.tsx +++ b/frontend/src/app/page.tsx @@ -37,24 +37,21 @@ export default function Home() { // Send new order email to self const clientEmail = formData.get('senderEmail') as string + console.log(JSON.stringify({"senderEmail":clientEmail})) await fetch("/api/emails", { method: "POST", headers: { "Content-type": "application/json", }, - body: JSON.stringify(clientEmail), + body: JSON.stringify({"senderEmail":clientEmail}), }) - // .then((response) => response.json()) - // .then((data) => { - // console.log(data); - // }) .catch((error) => { console.error(error); }); - // const response = await fetch("http://192.168.50.107:5580/new-order", { - const response = await fetch("http://localhost:5080/new-order", { + const response = await fetch("/backend/new-order", { + // const response = await fetch("http://localhost:5080/new-order", { method: "POST", headers: { "Content-type": "application/json", @@ -62,9 +59,6 @@ export default function Home() { body: JSON.stringify(payload), }) .then((response) => response.json()) - // .then((data) => { - // console.log(data); - // }) .catch((error) => { console.error(error); }); @@ -74,7 +68,7 @@ export default function Home() { emails: "", orders: "", }); - // alert("Order Placed! Please check your email.") + alert("Order Placed! Please check your email.") } return ( diff --git a/frontend/src/lib/mail.utils.ts b/frontend/src/lib/mail.utils.ts index de5830d..7a9bd39 100644 --- a/frontend/src/lib/mail.utils.ts +++ b/frontend/src/lib/mail.utils.ts @@ -1,12 +1,12 @@ +"use server" import nodemailer from "nodemailer"; import Mail from "nodemailer/lib/mailer"; import SMTPTransport from "nodemailer/lib/smtp-transport"; -import * as React from 'react'; const transport = nodemailer.createTransport({ host: process.env.MAIL_HOST, port: process.env.MAIL_PORT, - secure: process.env.NODE_ENV !== 'development', //true + // secure: process.env.NODE_ENV !== 'development', //true // DO NOT USE FOR PRODUCTION BUILD auth: { user: process.env.MAIL_USER, pass: process.env.MAIL_PASSWORD