mirror of
https://github.com/arthur-pbty/contact.git
synced 2026-06-03 15:07:21 +02:00
f63eeb2e84
- Implemented a contact page with a form for user inquiries. - Added validation for form fields using Zod schema. - Integrated PostgreSQL database for storing contact messages. - Created necessary API endpoints for form submission. - Added admin authentication and session management. - Developed CGU, cookies policy, privacy policy, and legal mentions pages. - Set up Docker configuration for PostgreSQL and application services. - Enhanced UI with responsive design and accessibility features.
28 lines
743 B
TypeScript
28 lines
743 B
TypeScript
import { NextResponse } from "next/server";
|
|
import { isAdminAuthenticated } from "@/lib/admin-auth";
|
|
import { listMessages } from "@/lib/db";
|
|
|
|
export async function GET() {
|
|
const authenticated = await isAdminAuthenticated();
|
|
if (!authenticated) {
|
|
return NextResponse.json({ message: "Unauthorized" }, { status: 401 });
|
|
}
|
|
|
|
const messages = await listMessages();
|
|
|
|
return NextResponse.json({
|
|
messages: messages.map((row) => ({
|
|
id: row.id,
|
|
name: row.name,
|
|
email: row.email,
|
|
project: row.project,
|
|
requestType: row.request_type,
|
|
message: row.message,
|
|
createdAt: row.created_at,
|
|
repliedAt: row.replied_at,
|
|
adminReply: row.admin_reply,
|
|
status: row.status,
|
|
})),
|
|
});
|
|
}
|