Added new design to modals

This commit is contained in:
2026-02-08 14:16:55 +01:00
parent ccff904464
commit ff6201a42c
15 changed files with 1134 additions and 435 deletions

View File

@@ -1,6 +1,7 @@
import { NextRequest, NextResponse } from 'next/server';
import { prisma } from '@/lib/prisma';
import { getCurrentUser } from '@/lib/auth';
import { createNotificationForAllUsers } from '@/lib/notifications';
// GET - Récupérer un trajet spécifique
export async function GET(
@@ -103,6 +104,57 @@ export async function PUT(
},
});
// Créer une notification si le statut a changé
if (statut) {
const oldTrajet = await prisma.trajet.findUnique({
where: { id: params.id },
include: {
adherent: {
select: {
nom: true,
prenom: true,
},
},
},
});
if (oldTrajet && oldTrajet.statut !== statut) {
const dateFormatted = new Date(trajet.date).toLocaleDateString('fr-FR', {
day: 'numeric',
month: 'long',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
});
let notificationType: 'trajet_cancelled' | 'trajet_completed' | null = null;
let notificationTitle = '';
let notificationMessage = '';
if (statut === 'Annulé') {
notificationType = 'trajet_cancelled';
notificationTitle = 'Trajet annulé';
notificationMessage = `Le trajet pour ${trajet.adherent.prenom} ${trajet.adherent.nom} du ${dateFormatted} a été annulé`;
} else if (statut === 'Terminé') {
notificationType = 'trajet_completed';
notificationTitle = 'Trajet terminé';
notificationMessage = `Le trajet pour ${trajet.adherent.prenom} ${trajet.adherent.nom} du ${dateFormatted} est terminé`;
}
if (notificationType) {
await createNotificationForAllUsers(
{
type: notificationType,
title: notificationTitle,
message: notificationMessage,
link: '/dashboard/calendrier',
},
user.id
);
}
}
}
return NextResponse.json(trajet);
} catch (error) {
console.error('Erreur lors de la mise à jour du trajet:', error);