- Repository BovineRepository avec getInventoryStats en DQL - Sécurité ApiProperty ROLE_ADMIN sur pricePerKg et finalPrice - Endpoint inventory-export passe en ROLE_ADMIN - Composable useBovineColumns mutualisé entre inventory et case (admin/user séparés) - Stats par tranche d'âge filtrables par buildingCaseId - Légende avec cartes colorées pleines + texte blanc - Coloration de la cellule Age (badge) au lieu de toute la ligne - Décalage couleurs : red ≥ 24, orange 22-24, yellow 20-22 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
19 lines
744 B
TypeScript
19 lines
744 B
TypeScript
export const formatAgeLabel = (months: number | null | undefined): string => {
|
|
if (months === null || months === undefined) return '—'
|
|
const years = Math.floor(months / 12)
|
|
const remaining = months % 12
|
|
let label = ''
|
|
if (years > 0) label = `${years} an${years > 1 ? 's' : ''}`
|
|
if (remaining > 0) label += `${label ? ' ' : ''}${remaining} mois`
|
|
if (!label) label = '< 1 mois'
|
|
return label
|
|
}
|
|
|
|
export const ageBadgeClass = (months: number | null | undefined): string => {
|
|
if (months === null || months === undefined) return ''
|
|
if (months >= 24) return 'bg-red-500 text-white'
|
|
if (months >= 22) return 'bg-orange-500 text-white'
|
|
if (months >= 20) return 'bg-yellow-500 text-white'
|
|
return ''
|
|
}
|