Added Money System
This commit is contained in:
@@ -46,7 +46,7 @@ export async function PUT(
|
||||
}
|
||||
|
||||
const body = await request.json();
|
||||
const { nom, prenom, dateNaissance, adresse, email, telephone, situation, prescripteur, facturation, commentaire, telephoneSecondaire, instructions } = body;
|
||||
const { nom, prenom, dateNaissance, adresse, email, telephone, situation, prescripteur, facturation, forfait, commentaire, telephoneSecondaire, instructions } = body;
|
||||
|
||||
const updateData: any = {};
|
||||
if (nom) updateData.nom = nom;
|
||||
@@ -58,6 +58,7 @@ export async function PUT(
|
||||
if (situation !== undefined) updateData.situation = situation || null;
|
||||
if (prescripteur !== undefined) updateData.prescripteur = prescripteur || null;
|
||||
if (facturation !== undefined) updateData.facturation = facturation || null;
|
||||
if (forfait !== undefined) updateData.forfait = forfait || null;
|
||||
if (commentaire !== undefined) updateData.commentaire = commentaire || null;
|
||||
if (telephoneSecondaire !== undefined) updateData.telephoneSecondaire = telephoneSecondaire || null;
|
||||
if (instructions !== undefined) updateData.instructions = instructions || null;
|
||||
|
||||
@@ -54,7 +54,7 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
|
||||
const body = await request.json();
|
||||
const { nom, prenom, dateNaissance, adresse, email, telephone, situation, prescripteur, facturation, commentaire, telephoneSecondaire, instructions } = body;
|
||||
const { nom, prenom, dateNaissance, adresse, email, telephone, situation, prescripteur, facturation, forfait, commentaire, telephoneSecondaire, instructions } = body;
|
||||
|
||||
if (!nom || !prenom || !dateNaissance || !adresse || !email || !telephone) {
|
||||
return NextResponse.json(
|
||||
@@ -74,6 +74,7 @@ export async function POST(request: NextRequest) {
|
||||
situation: situation || null,
|
||||
prescripteur: prescripteur || null,
|
||||
facturation: facturation || null,
|
||||
forfait: forfait || null,
|
||||
commentaire: commentaire || null,
|
||||
telephoneSecondaire: telephoneSecondaire || null,
|
||||
instructions: instructions || null,
|
||||
|
||||
@@ -11,7 +11,7 @@ export async function GET(request: NextRequest) {
|
||||
}
|
||||
|
||||
const searchParams = request.nextUrl.searchParams;
|
||||
const type = searchParams.get('type'); // "situation", "prescripteur", "facturation"
|
||||
const type = searchParams.get('type'); // "situation", "prescripteur", "facturation", "forfait"
|
||||
|
||||
const where: any = {};
|
||||
if (type) {
|
||||
@@ -64,9 +64,9 @@ export async function POST(request: NextRequest) {
|
||||
);
|
||||
}
|
||||
|
||||
if (!['situation', 'prescripteur', 'facturation'].includes(type)) {
|
||||
if (!['situation', 'prescripteur', 'facturation', 'forfait'].includes(type)) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Type invalide. Doit être: situation, prescripteur ou facturation' },
|
||||
{ error: 'Type invalide. Doit être: situation, prescripteur, facturation ou forfait' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,10 @@ export async function GET(
|
||||
nom: true,
|
||||
prenom: true,
|
||||
telephone: true,
|
||||
telephoneSecondaire: true,
|
||||
email: true,
|
||||
adresse: true,
|
||||
forfait: true,
|
||||
},
|
||||
},
|
||||
chauffeur: {
|
||||
@@ -64,7 +66,7 @@ export async function PUT(
|
||||
}
|
||||
|
||||
const body = await request.json();
|
||||
const { date, adresseDepart, adresseArrivee, commentaire, statut, adherentId, chauffeurId } = body;
|
||||
const { date, adresseDepart, adresseArrivee, commentaire, instructions, statut, adherentId, chauffeurId } = body;
|
||||
|
||||
const trajet = await prisma.trajet.update({
|
||||
where: { id: params.id },
|
||||
@@ -73,6 +75,7 @@ export async function PUT(
|
||||
...(adresseDepart && { adresseDepart }),
|
||||
...(adresseArrivee && { adresseArrivee }),
|
||||
...(commentaire !== undefined && { commentaire }),
|
||||
...(instructions !== undefined && { instructions }),
|
||||
...(statut && { statut }),
|
||||
...(adherentId && { adherentId }),
|
||||
...(chauffeurId !== undefined && { chauffeurId }),
|
||||
@@ -84,7 +87,9 @@ export async function PUT(
|
||||
nom: true,
|
||||
prenom: true,
|
||||
telephone: true,
|
||||
telephoneSecondaire: true,
|
||||
email: true,
|
||||
forfait: true,
|
||||
},
|
||||
},
|
||||
chauffeur: {
|
||||
|
||||
@@ -45,7 +45,9 @@ export async function GET(request: NextRequest) {
|
||||
nom: true,
|
||||
prenom: true,
|
||||
telephone: true,
|
||||
telephoneSecondaire: true,
|
||||
email: true,
|
||||
forfait: true,
|
||||
},
|
||||
},
|
||||
chauffeur: {
|
||||
@@ -80,7 +82,7 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
|
||||
const body = await request.json();
|
||||
const { date, adresseDepart, adresseArrivee, commentaire, statut, adherentId, chauffeurId } = body;
|
||||
const { date, adresseDepart, adresseArrivee, commentaire, instructions, statut, adherentId, chauffeurId } = body;
|
||||
|
||||
if (!date || !adresseDepart || !adresseArrivee || !adherentId) {
|
||||
return NextResponse.json(
|
||||
@@ -95,6 +97,7 @@ export async function POST(request: NextRequest) {
|
||||
adresseDepart,
|
||||
adresseArrivee,
|
||||
commentaire: commentaire || null,
|
||||
instructions: instructions || null,
|
||||
statut: statut || 'Planifié',
|
||||
adherentId,
|
||||
chauffeurId: chauffeurId || null,
|
||||
@@ -106,7 +109,9 @@ export async function POST(request: NextRequest) {
|
||||
nom: true,
|
||||
prenom: true,
|
||||
telephone: true,
|
||||
telephoneSecondaire: true,
|
||||
email: true,
|
||||
forfait: true,
|
||||
},
|
||||
},
|
||||
chauffeur: {
|
||||
|
||||
Reference in New Issue
Block a user