/** * Composant réutilisable pour afficher l'avancement d'un chantier */ import React from 'react'; import { ProgressBar } from 'primereact/progressbar'; import { AVANCEMENT_CONFIG, COMMON_CLASSES } from './ChantierStyles'; interface ChantierProgressBarProps { value: number; showValue?: boolean; showPercentage?: boolean; size?: 'small' | 'normal' | 'large'; showCompletionIcon?: boolean; className?: string; style?: React.CSSProperties; } const ChantierProgressBar: React.FC = ({ value, showValue = false, showPercentage = true, size = 'normal', showCompletionIcon = true, className = '', style = {} }) => { // Déterminer la configuration couleur selon l'avancement const getProgressConfig = () => { if (value < AVANCEMENT_CONFIG.CRITIQUE.threshold) return AVANCEMENT_CONFIG.CRITIQUE; if (value < AVANCEMENT_CONFIG.ATTENTION.threshold) return AVANCEMENT_CONFIG.ATTENTION; if (value < AVANCEMENT_CONFIG.PROGRES.threshold) return AVANCEMENT_CONFIG.PROGRES; return AVANCEMENT_CONFIG.TERMINE; }; const config = getProgressConfig(); const sizeConfig = { small: { height: '8px', fontSize: 'text-xs' }, normal: { height: '16px', fontSize: 'text-sm' }, large: { height: '20px', fontSize: 'text-base' } }; const currentSize = sizeConfig[size]; return (
{showPercentage && ( {value}% )} {showCompletionIcon && value === 100 && ( )}
); }; export default ChantierProgressBar;