From a44375298c955d994a368e20d76148934ee791db Mon Sep 17 00:00:00 2001 From: EdiFarcas Date: Fri, 11 Jul 2025 11:15:45 +0300 Subject: [PATCH] Latest update --- .../migration.sql | 32 ++++ prisma/schema.prisma | 24 +++ src/app/about/page.tsx | 15 ++ src/app/api/bugs/route.ts | 11 ++ src/app/api/contact/route.ts | 11 ++ src/app/api/improvment_ideas/route.ts | 11 ++ src/app/bugs/page.tsx | 52 ++++++ src/app/contact/page.tsx | 52 ++++++ src/app/improvment_ideas/page.tsx | 52 ++++++ src/app/page.tsx | 161 +++++++++++------- src/app/privacy/page.tsx | 14 ++ 11 files changed, 371 insertions(+), 64 deletions(-) create mode 100644 prisma/migrations/20250710203250_add_submission_models/migration.sql create mode 100644 src/app/about/page.tsx create mode 100644 src/app/api/bugs/route.ts create mode 100644 src/app/api/contact/route.ts create mode 100644 src/app/api/improvment_ideas/route.ts create mode 100644 src/app/bugs/page.tsx create mode 100644 src/app/contact/page.tsx create mode 100644 src/app/improvment_ideas/page.tsx create mode 100644 src/app/privacy/page.tsx diff --git a/prisma/migrations/20250710203250_add_submission_models/migration.sql b/prisma/migrations/20250710203250_add_submission_models/migration.sql new file mode 100644 index 0000000..0fadab4 --- /dev/null +++ b/prisma/migrations/20250710203250_add_submission_models/migration.sql @@ -0,0 +1,32 @@ +-- CreateTable +CREATE TABLE "BugReport" ( + "id" TEXT NOT NULL, + "name" TEXT, + "email" TEXT, + "bug" TEXT NOT NULL, + "date" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "BugReport_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "ImprovementIdea" ( + "id" TEXT NOT NULL, + "name" TEXT, + "email" TEXT, + "idea" TEXT NOT NULL, + "date" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "ImprovementIdea_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "ContactMessage" ( + "id" TEXT NOT NULL, + "name" TEXT, + "email" TEXT, + "message" TEXT NOT NULL, + "date" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "ContactMessage_pkey" PRIMARY KEY ("id") +); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 3775af4..80d122d 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -49,6 +49,30 @@ model MileageEntry { date DateTime @default(now()) } +model BugReport { + id String @id @default(cuid()) + name String? + email String? + bug String + date DateTime @default(now()) +} + +model ImprovementIdea { + id String @id @default(cuid()) + name String? + email String? + idea String + date DateTime @default(now()) +} + +model ContactMessage { + id String @id @default(cuid()) + name String? + email String? + message String + date DateTime @default(now()) +} + enum FuelType { GASOLINE DIESEL diff --git a/src/app/about/page.tsx b/src/app/about/page.tsx new file mode 100644 index 0000000..713f347 --- /dev/null +++ b/src/app/about/page.tsx @@ -0,0 +1,15 @@ +export default function AboutPage() { + return ( +
+

About Car Fuel Tracker

+

Car Fuel Tracker is a modern web app designed to help you track your car’s fuel fill-ups, EV charging, mileage, and costs. Whether you drive a gasoline, diesel, LPG, hybrid, or electric vehicle, our app makes it easy to log, analyze, and optimize your driving habits.

+ +

Built with Next.js, Prisma, and Tailwind CSS.

+
+ ); +} diff --git a/src/app/api/bugs/route.ts b/src/app/api/bugs/route.ts new file mode 100644 index 0000000..5d080b8 --- /dev/null +++ b/src/app/api/bugs/route.ts @@ -0,0 +1,11 @@ +import { NextResponse } from 'next/server'; +import { prisma } from '@/lib/prisma'; + +export async function POST(req: Request) { + const { name, email, bug } = await req.json(); + if (!bug) return NextResponse.json({ error: 'Bug description required' }, { status: 400 }); + const report = await prisma.bugReport.create({ + data: { name, email, bug }, + }); + return NextResponse.json({ success: true, id: report.id }); +} diff --git a/src/app/api/contact/route.ts b/src/app/api/contact/route.ts new file mode 100644 index 0000000..33dadb4 --- /dev/null +++ b/src/app/api/contact/route.ts @@ -0,0 +1,11 @@ +import { NextResponse } from 'next/server'; +import { prisma } from '@/lib/prisma'; + +export async function POST(req: Request) { + const { name, email, message } = await req.json(); + if (!message) return NextResponse.json({ error: 'Message required' }, { status: 400 }); + const contact = await prisma.contactMessage.create({ + data: { name, email, message }, + }); + return NextResponse.json({ success: true, id: contact.id }); +} diff --git a/src/app/api/improvment_ideas/route.ts b/src/app/api/improvment_ideas/route.ts new file mode 100644 index 0000000..80d5e92 --- /dev/null +++ b/src/app/api/improvment_ideas/route.ts @@ -0,0 +1,11 @@ +import { NextResponse } from 'next/server'; +import { prisma } from '@/lib/prisma'; + +export async function POST(req: Request) { + const { name, email, idea } = await req.json(); + if (!idea) return NextResponse.json({ error: 'Idea description required' }, { status: 400 }); + const improvement = await prisma.improvementIdea.create({ + data: { name, email, idea }, + }); + return NextResponse.json({ success: true, id: improvement.id }); +} diff --git a/src/app/bugs/page.tsx b/src/app/bugs/page.tsx new file mode 100644 index 0000000..ef15037 --- /dev/null +++ b/src/app/bugs/page.tsx @@ -0,0 +1,52 @@ +"use client"; +import { useState } from "react"; + +export default function BugReportPage() { + const [submitted, setSubmitted] = useState(false); + const [form, setForm] = useState({ name: "", email: "", bug: "" }); + const [error, setError] = useState(""); + + function handleChange(e: React.ChangeEvent) { + setForm({ ...form, [e.target.name]: e.target.value }); + } + + async function handleSubmit(e: React.FormEvent) { + e.preventDefault(); + setError(""); + try { + const res = await fetch("/api/bugs", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(form), + }); + if (!res.ok) { + const data = await res.json(); + setError(data.error || "Submission failed."); + return; + } + setSubmitted(true); + setForm({ name: "", email: "", bug: "" }); + } catch (err) { + setError("Submission failed. Please try again."); + } + } + + return ( +
+

Report a Bug

+

Found a bug or issue? Please let us know so we can fix it quickly!

+ {submitted ? ( +
Thank you for your bug report! We appreciate your help in improving Car Fuel Tracker.
+ ) : ( +
+ + +