feat: implement email sending functionality with nodemailer; add contact form handling and success/error notifications
This commit is contained in:
@@ -1,29 +1,29 @@
|
||||
// app/api/stats/route.ts
|
||||
import { NextResponse } from "next/server";
|
||||
// app/api/stats/route.tsx
|
||||
import {NextResponse} from "next/server";
|
||||
|
||||
const stats = {
|
||||
views: 0,
|
||||
projectsViewed: {} as { [key: string]: number },
|
||||
views: 0,
|
||||
projectsViewed: {} as { [key: string]: number },
|
||||
};
|
||||
|
||||
export async function GET() {
|
||||
return NextResponse.json(stats);
|
||||
return NextResponse.json(stats);
|
||||
}
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const { type, projectId } = await request.json();
|
||||
const {type, projectId} = await request.json();
|
||||
|
||||
if (type === "page_view") {
|
||||
stats.views += 1;
|
||||
}
|
||||
|
||||
if (type === "project_view" && projectId) {
|
||||
if (stats.projectsViewed[projectId]) {
|
||||
stats.projectsViewed[projectId] += 1;
|
||||
} else {
|
||||
stats.projectsViewed[projectId] = 1;
|
||||
if (type === "page_view") {
|
||||
stats.views += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Stats updated", stats });
|
||||
if (type === "project_view" && projectId) {
|
||||
if (stats.projectsViewed[projectId]) {
|
||||
stats.projectsViewed[projectId] += 1;
|
||||
} else {
|
||||
stats.projectsViewed[projectId] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return NextResponse.json({message: "Stats updated", stats});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user