chore: update devbook.md to mark completion of layout, UI components, and homepage; update dev.db

This commit is contained in:
Julien Froidefond
2025-11-27 13:11:11 +01:00
parent 6a9bf88a65
commit 27e409fb76
12 changed files with 701 additions and 10 deletions

View File

@@ -0,0 +1,71 @@
import { NextResponse } from 'next/server';
import { auth } from '@/lib/auth';
import { prisma } from '@/services/database';
export async function GET() {
try {
const session = await auth();
if (!session?.user?.id) {
return NextResponse.json({ error: 'Non autorisé' }, { status: 401 });
}
const sessions = await prisma.session.findMany({
where: { userId: session.user.id },
include: {
_count: {
select: {
items: true,
actions: true,
},
},
},
orderBy: { updatedAt: 'desc' },
});
return NextResponse.json(sessions);
} catch (error) {
console.error('Error fetching sessions:', error);
return NextResponse.json(
{ error: 'Erreur lors de la récupération des sessions' },
{ status: 500 }
);
}
}
export async function POST(request: Request) {
try {
const session = await auth();
if (!session?.user?.id) {
return NextResponse.json({ error: 'Non autorisé' }, { status: 401 });
}
const body = await request.json();
const { title, collaborator } = body;
if (!title || !collaborator) {
return NextResponse.json(
{ error: 'Titre et collaborateur requis' },
{ status: 400 }
);
}
const newSession = await prisma.session.create({
data: {
title,
collaborator,
userId: session.user.id,
},
});
return NextResponse.json(newSession, { status: 201 });
} catch (error) {
console.error('Error creating session:', error);
return NextResponse.json(
{ error: 'Erreur lors de la création de la session' },
{ status: 500 }
);
}
}