Added Participation Page

This commit is contained in:
2026-02-15 14:36:28 +01:00
parent da2e32d004
commit 5185a41bb6
23 changed files with 2643 additions and 67 deletions

View File

@@ -1,6 +1,7 @@
import { NextRequest, NextResponse } from 'next/server';
import { prisma } from '@/lib/prisma';
import { getCurrentUser } from '@/lib/auth';
import { createParticipationForTrajet } from '@/lib/participation-financiere';
// POST - Valider un trajet et déduire les heures du chauffeur
export async function POST(
@@ -23,11 +24,12 @@ export async function POST(
);
}
// Récupérer le trajet avec le chauffeur
// Récupérer le trajet avec le chauffeur et univers pro
const trajet = await prisma.trajet.findUnique({
where: { id: params.id },
include: {
chauffeur: true,
universPro: true,
},
});
@@ -97,6 +99,13 @@ export async function POST(
}),
]);
// Créer la participation financière (document)
try {
await createParticipationForTrajet(params.id);
} catch (err) {
console.error('Erreur création participation:', err);
}
return NextResponse.json({
trajet: trajetUpdated,
chauffeur: {