/** * Reusable Heat Badges component * Displays competition heats with compact notation (e.g., "J&J NOV 1 L") * * @param {Array} heats - Array of heat objects with { competitionType, division, heatNumber, role } * @param {number} maxVisible - Maximum number of badges to show before "+X more" (default: 3) * @param {boolean} compact - Use compact display (default: true) * @param {string} className - Additional CSS classes for container * * @example * * // Renders: "J&J NOV 1 L" "STR INT 2 F" "+2" */ const HeatBadges = ({ heats = [], maxVisible = 3, compact = true, className = '' }) => { if (!heats || heats.length === 0) return null; /** * Format heat object into compact notation * Example: { competitionType: 'Jack & Jill', division: 'Novice', heatNumber: 1, role: 'Leader' } * Returns: "J&J NOV 1 L" */ const formatHeat = (heat) => { const parts = [ heat.competitionType?.abbreviation || '', heat.division?.abbreviation || '', heat.heatNumber, ]; if (heat.role) { parts.push(heat.role.charAt(0)); // L or F } return parts.join(' '); }; const visibleHeats = heats.slice(0, maxVisible); const remainingCount = heats.length - maxVisible; return (
{visibleHeats.map((heat, idx) => ( {formatHeat(heat)} ))} {remainingCount > 0 && ( 1 ? 's' : ''}`} > +{remainingCount} )}
); }; export default HeatBadges;