'use client'; import { Tag } from '@/lib/types'; import { Badge } from './Badge'; interface TagDisplayProps { tags: string[]; availableTags?: Tag[]; // Tags avec couleurs depuis la DB size?: 'sm' | 'md' | 'lg'; maxTags?: number; showColors?: boolean; onClick?: (tagName: string) => void; className?: string; } export function TagDisplay({ tags, availableTags = [], size = 'sm', maxTags, showColors = true, onClick, className = "" }: TagDisplayProps) { if (!tags || tags.length === 0) { return null; } const displayTags = maxTags ? tags.slice(0, maxTags) : tags; const remainingCount = maxTags && tags.length > maxTags ? tags.length - maxTags : 0; const getTagColor = (tagName: string): string => { if (!showColors) return '#6b7280'; // gray-500 const tag = availableTags.find(t => t.name === tagName); return tag?.color || '#6b7280'; }; const sizeClasses = { sm: 'text-xs px-2 py-0.5', md: 'text-sm px-2 py-1', lg: 'text-base px-3 py-1.5' }; return (
{displayTags.map((tagName, index) => { const color = getTagColor(tagName); return (
onClick?.(tagName)} className={`inline-flex items-center gap-1.5 rounded-full border transition-colors ${sizeClasses[size]} ${ onClick ? 'cursor-pointer hover:opacity-80' : '' }`} style={{ backgroundColor: showColors ? `${color}20` : undefined, borderColor: showColors ? `${color}60` : undefined, color: showColors ? color : undefined }} > {showColors && (
)} {tagName}
); })} {remainingCount > 0 && ( +{remainingCount} )}
); } interface TagListProps { tags: Tag[]; onTagClick?: (tag: Tag) => void; onTagEdit?: (tag: Tag) => void; onTagDelete?: (tag: Tag) => void; className?: string; } /** * Composant pour afficher une liste complète de tags avec actions */ export function TagList({ tags, onTagClick, onTagEdit, onTagDelete, className = "" }: TagListProps) { if (!tags || tags.length === 0) { return (
🏷️

Aucun tag trouvé

); } return (
{tags.map((tag) => (
onTagClick?.(tag)} >
{tag.name}
{onTagEdit && ( )} {onTagDelete && ( )}
))}
); }