// Shared Status Badge Components /** * Job status configuration */ const JOB_STATUS_CONFIG = { queued: { color: 'bg-slate-100 text-slate-700', icon: '⏳', label: 'In coda' }, running: { color: 'bg-blue-100 text-blue-700', icon: '⚡', label: 'In esecuzione' }, completed: { color: 'bg-emerald-100 text-emerald-700', icon: '✓', label: 'Completato' }, error: { color: 'bg-red-100 text-red-700', icon: '✕', label: 'Errore' }, cancelled: { color: 'bg-amber-100 text-amber-700', icon: '⛔', label: 'Annullato' }, }; /** * Priority configuration */ const PRIORITY_CONFIG = { low: { color: 'bg-slate-100 text-slate-600', label: 'Bassa' }, medium: { color: 'bg-orange-100 text-orange-700', label: 'Media' }, high: { color: 'bg-red-100 text-red-700', label: 'Alta' }, }; /** * Progress bar color based on percentage */ const PROGRESS_COLORS = { complete: 'bg-green-500', high: 'bg-blue-500', medium: 'bg-amber-500', low: 'bg-slate-300', }; /** * Get job status configuration * @param {string} status - Job status (queued, running, completed, error, cancelled) * @returns {Object} Status configuration with color, icon, label */ const getJobStatusConfig = (status) => { return JOB_STATUS_CONFIG[status] || JOB_STATUS_CONFIG.queued; }; /** * Get priority configuration * @param {string} priority - Priority level (low, medium, high) * @returns {Object} Priority configuration with color, label */ const getPriorityConfig = (priority) => { return PRIORITY_CONFIG[priority] || { color: 'bg-gray-100 text-gray-700', label: priority }; }; /** * Get progress bar color based on percentage * @param {number} percent - Progress percentage (0-100) * @returns {string} Tailwind CSS class for the color */ const getProgressColor = (percent) => { if (percent === 100) return PROGRESS_COLORS.complete; if (percent >= 50) return PROGRESS_COLORS.high; if (percent > 0) return PROGRESS_COLORS.medium; return PROGRESS_COLORS.low; }; /** * Job Status Badge Component * Displays a badge with icon for job status */ const JobStatusBadge = ({ status, showSpinner = true, className = '' }) => { const config = getJobStatusConfig(status); return (