52 lines
1.1 KiB
TypeScript
Executable File
52 lines
1.1 KiB
TypeScript
Executable File
/**
|
|
* Composant pour les indicateurs d'urgence des chantiers
|
|
*/
|
|
|
|
import React from 'react';
|
|
import { URGENCE_INDICATORS } from './ChantierStyles';
|
|
import { ChantierActif } from '../../hooks/useDashboard';
|
|
|
|
interface ChantierUrgencyIndicatorProps {
|
|
chantier: ChantierActif;
|
|
size?: 'small' | 'normal' | 'large';
|
|
className?: string;
|
|
}
|
|
|
|
const ChantierUrgencyIndicator: React.FC<ChantierUrgencyIndicatorProps> = ({
|
|
chantier,
|
|
size = 'normal',
|
|
className = ''
|
|
}) => {
|
|
const sizeClasses = {
|
|
small: 'text-sm',
|
|
normal: 'text-base',
|
|
large: 'text-xl'
|
|
};
|
|
|
|
const getUrgencyType = () => {
|
|
if (chantier.statut === 'EN_RETARD') {
|
|
return 'RETARD';
|
|
}
|
|
if (chantier.avancement >= 90) {
|
|
return 'BIENTOT_TERMINE';
|
|
}
|
|
return null;
|
|
};
|
|
|
|
const urgencyType = getUrgencyType();
|
|
|
|
if (!urgencyType) {
|
|
return null;
|
|
}
|
|
|
|
const indicator = URGENCE_INDICATORS[urgencyType];
|
|
|
|
return (
|
|
<i
|
|
className={`${indicator.icon} ${indicator.color} ${sizeClasses[size]} ${className}`}
|
|
title={indicator.tooltip}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default ChantierUrgencyIndicator; |