Fix Next.js 15 compatibility and TypeScript errors
- Update API route handlers to use async params for Next.js 15 compatibility - Fix MUI DataGrid deprecated props (pageSize -> initialState.pagination) - Replace Material-UI Grid components with Box for better compatibility - Fix admin authentication system with proper request parameters - Update permission constants to match available AdminPermission enum values - Add missing properties to Page interface for type safety - Update .gitignore to exclude venv/, import logs, and large data directories - Optimize Next.js config to reduce memory usage during builds 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@ import { verifyAdminAuth } from '@/lib/admin-auth';
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
const adminUser = await verifyAdminAuth(request);
|
||||
@@ -12,8 +12,9 @@ export async function GET(
|
||||
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
}
|
||||
|
||||
const resolvedParams = await params;
|
||||
const page = await prisma.page.findUnique({
|
||||
where: { id: params.id },
|
||||
where: { id: resolvedParams.id },
|
||||
include: {
|
||||
creator: { select: { name: true, email: true } },
|
||||
updater: { select: { name: true, email: true } }
|
||||
@@ -42,7 +43,7 @@ export async function GET(
|
||||
|
||||
export async function PUT(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
const adminUser = await verifyAdminAuth(request);
|
||||
@@ -50,6 +51,7 @@ export async function PUT(
|
||||
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
}
|
||||
|
||||
const resolvedParams = await params;
|
||||
const body = await request.json();
|
||||
const {
|
||||
title,
|
||||
@@ -69,7 +71,7 @@ export async function PUT(
|
||||
|
||||
// Check if page exists
|
||||
const existingPage = await prisma.page.findUnique({
|
||||
where: { id: params.id }
|
||||
where: { id: resolvedParams.id }
|
||||
});
|
||||
|
||||
if (!existingPage) {
|
||||
@@ -85,7 +87,7 @@ export async function PUT(
|
||||
where: { slug }
|
||||
});
|
||||
|
||||
if (conflictingPage && conflictingPage.id !== params.id) {
|
||||
if (conflictingPage && conflictingPage.id !== resolvedParams.id) {
|
||||
return NextResponse.json(
|
||||
{ success: false, error: 'A page with this slug already exists' },
|
||||
{ status: 400 }
|
||||
@@ -94,7 +96,7 @@ export async function PUT(
|
||||
}
|
||||
|
||||
const updatedPage = await prisma.page.update({
|
||||
where: { id: params.id },
|
||||
where: { id: resolvedParams.id },
|
||||
data: {
|
||||
title,
|
||||
slug,
|
||||
@@ -137,7 +139,7 @@ export async function PUT(
|
||||
|
||||
export async function DELETE(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
const adminUser = await verifyAdminAuth(request);
|
||||
@@ -145,8 +147,9 @@ export async function DELETE(
|
||||
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
}
|
||||
|
||||
const resolvedParams = await params;
|
||||
const page = await prisma.page.findUnique({
|
||||
where: { id: params.id }
|
||||
where: { id: resolvedParams.id }
|
||||
});
|
||||
|
||||
if (!page) {
|
||||
@@ -157,7 +160,7 @@ export async function DELETE(
|
||||
}
|
||||
|
||||
await prisma.page.delete({
|
||||
where: { id: params.id }
|
||||
where: { id: resolvedParams.id }
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
|
||||
Reference in New Issue
Block a user