- Correction des erreurs TypeScript dans userService.ts et workflowTester.ts - Ajout des propriétés manquantes aux objets User mockés - Conversion des dates de string vers objets Date - Correction des appels asynchrones et des types incompatibles - Ajout de dynamic rendering pour résoudre les erreurs useSearchParams - Enveloppement de useSearchParams dans Suspense boundary - Configuration de force-dynamic au niveau du layout principal Build réussi: 126 pages générées avec succès 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
209 lines
6.6 KiB
TypeScript
209 lines
6.6 KiB
TypeScript
// import { apiService } from './api'; // TODO: Use when implementing real API calls
|
|
|
|
export interface Notification {
|
|
id: string;
|
|
type: 'info' | 'warning' | 'success' | 'error';
|
|
titre: string;
|
|
message: string;
|
|
date: Date;
|
|
lu: boolean;
|
|
userId?: string;
|
|
metadata?: {
|
|
chantierId?: string;
|
|
chantierNom?: string;
|
|
clientId?: string;
|
|
clientNom?: string;
|
|
action?: string;
|
|
};
|
|
}
|
|
|
|
export interface NotificationStats {
|
|
total: number;
|
|
nonLues: number;
|
|
parType: Record<string, number>;
|
|
tendance: {
|
|
periode: string;
|
|
nombre: number;
|
|
}[];
|
|
}
|
|
|
|
class NotificationService {
|
|
/**
|
|
* Récupérer toutes les notifications
|
|
* TODO: Implement with proper API service method
|
|
*/
|
|
async getNotifications(): Promise<Notification[]> {
|
|
return this.getMockNotifications();
|
|
}
|
|
|
|
/**
|
|
* Récupérer les notifications non lues
|
|
* TODO: Implement with proper API service method
|
|
*/
|
|
async getUnreadNotifications(): Promise<Notification[]> {
|
|
return this.getMockNotifications().filter(n => !n.lu);
|
|
}
|
|
|
|
/**
|
|
* Marquer une notification comme lue
|
|
* TODO: Implement with proper API service method
|
|
*/
|
|
async markAsRead(notificationId: string): Promise<void> {
|
|
console.log('TODO: Implement markAsRead', notificationId);
|
|
return Promise.resolve();
|
|
}
|
|
|
|
/**
|
|
* Marquer toutes les notifications comme lues
|
|
* TODO: Implement with proper API service method
|
|
*/
|
|
async markAllAsRead(): Promise<void> {
|
|
console.log('TODO: Implement markAllAsRead');
|
|
return Promise.resolve();
|
|
}
|
|
|
|
/**
|
|
* Créer une nouvelle notification
|
|
* TODO: Implement with proper API service method
|
|
*/
|
|
async createNotification(notification: Omit<Notification, 'id' | 'date'>): Promise<Notification> {
|
|
console.log('TODO: Implement createNotification', notification);
|
|
return {
|
|
...notification,
|
|
id: Math.random().toString(36).substring(2, 11),
|
|
date: new Date(),
|
|
lu: false
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Supprimer une notification
|
|
* TODO: Implement with proper API service method
|
|
*/
|
|
async deleteNotification(notificationId: string): Promise<void> {
|
|
console.log('TODO: Implement deleteNotification', notificationId);
|
|
return Promise.resolve();
|
|
}
|
|
|
|
/**
|
|
* Récupérer les statistiques des notifications
|
|
* TODO: Implement with proper API service method
|
|
*/
|
|
async getNotificationStats(): Promise<NotificationStats> {
|
|
return this.getMockNotificationStats();
|
|
}
|
|
|
|
/**
|
|
* Diffuser une notification à plusieurs utilisateurs
|
|
* TODO: Implement with proper API service method
|
|
*/
|
|
async broadcastNotification(notification: {
|
|
type: 'info' | 'warning' | 'success' | 'error';
|
|
titre: string;
|
|
message: string;
|
|
userIds?: string[];
|
|
roles?: string[];
|
|
}): Promise<void> {
|
|
console.log('TODO: Implement broadcastNotification', notification);
|
|
return Promise.resolve();
|
|
}
|
|
|
|
/**
|
|
* Notifications mockées
|
|
*/
|
|
private getMockNotifications(): Notification[] {
|
|
return [
|
|
{
|
|
id: '1',
|
|
type: 'info',
|
|
titre: 'Nouveau devis disponible',
|
|
message: 'Le devis pour votre extension cuisine est maintenant disponible',
|
|
date: new Date(Date.now() - 2 * 24 * 60 * 60 * 1000),
|
|
lu: false,
|
|
metadata: {
|
|
chantierId: 'chantier-1',
|
|
chantierNom: 'Extension cuisine',
|
|
action: 'devis_cree'
|
|
}
|
|
},
|
|
{
|
|
id: '2',
|
|
type: 'warning',
|
|
titre: 'Rendez-vous prévu',
|
|
message: 'Rendez-vous avec votre gestionnaire demain à 14h00',
|
|
date: new Date(Date.now() - 24 * 60 * 60 * 1000),
|
|
lu: false,
|
|
metadata: {
|
|
action: 'rendez_vous_planifie'
|
|
}
|
|
},
|
|
{
|
|
id: '3',
|
|
type: 'success',
|
|
titre: 'Phase terminée',
|
|
message: 'La phase "Gros œuvre" de votre chantier a été terminée',
|
|
date: new Date(Date.now() - 3 * 24 * 60 * 60 * 1000),
|
|
lu: true,
|
|
metadata: {
|
|
chantierId: 'chantier-2',
|
|
chantierNom: 'Rénovation appartement',
|
|
action: 'phase_terminee'
|
|
}
|
|
},
|
|
{
|
|
id: '4',
|
|
type: 'error',
|
|
titre: 'Retard détecté',
|
|
message: 'Le chantier "Villa moderne" accuse un retard de 3 jours',
|
|
date: new Date(Date.now() - 4 * 24 * 60 * 60 * 1000),
|
|
lu: true,
|
|
metadata: {
|
|
chantierId: 'chantier-3',
|
|
chantierNom: 'Villa moderne',
|
|
action: 'retard_detecte'
|
|
}
|
|
},
|
|
{
|
|
id: '5',
|
|
type: 'info',
|
|
titre: 'Nouveau client attribué',
|
|
message: 'Vous avez été désigné gestionnaire pour M. Durand',
|
|
date: new Date(Date.now() - 5 * 24 * 60 * 60 * 1000),
|
|
lu: true,
|
|
metadata: {
|
|
clientId: 'client-4',
|
|
clientNom: 'M. Durand',
|
|
action: 'client_attribue'
|
|
}
|
|
}
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Statistiques mockées
|
|
*/
|
|
private getMockNotificationStats(): NotificationStats {
|
|
const notifications = this.getMockNotifications();
|
|
return {
|
|
total: notifications.length,
|
|
nonLues: notifications.filter(n => !n.lu).length,
|
|
parType: {
|
|
info: notifications.filter(n => n.type === 'info').length,
|
|
warning: notifications.filter(n => n.type === 'warning').length,
|
|
success: notifications.filter(n => n.type === 'success').length,
|
|
error: notifications.filter(n => n.type === 'error').length
|
|
},
|
|
tendance: [
|
|
{ periode: 'Lundi', nombre: 3 },
|
|
{ periode: 'Mardi', nombre: 7 },
|
|
{ periode: 'Mercredi', nombre: 2 },
|
|
{ periode: 'Jeudi', nombre: 5 },
|
|
{ periode: 'Vendredi', nombre: 4 },
|
|
{ periode: 'Samedi', nombre: 1 },
|
|
{ periode: 'Dimanche', nombre: 0 }
|
|
]
|
|
};
|
|
}
|
|
}
|
|
|
|
export default new NotificationService(); |