Added Participation Page
This commit is contained in:
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user