import React from 'react'; import PropTypes from 'prop-types'; import {Copy, Check} from 'lucide-react'; import Tooltip from '@ui/Tooltip'; function FormatCard({ format, onEdit, onClone, sortBy, isSelectionMode, isSelected, willBeSelected, onSelect }) { const {content} = format; const totalTests = content.tests?.length || 0; const passedTests = content.tests?.filter(t => t.passes)?.length || 0; const passRate = Math.round((passedTests / totalTests) * 100) || 0; const getConditionStyle = condition => { if (condition.negate) { return 'bg-red-100 border-red-200 text-red-700 dark:bg-red-900/30 dark:border-red-700 dark:text-red-300'; } if (condition.required) { return 'bg-green-100 border-green-200 text-green-700 dark:bg-green-900/30 dark:border-green-700 dark:text-green-300'; } return 'bg-blue-100 border-blue-200 text-blue-700 dark:bg-blue-900/30 dark:border-blue-700 dark:text-blue-300'; }; const getDisplayConditions = conditions => { if (!conditions?.length) return []; // Sort conditions: required first, then non-required const sortedConditions = [...conditions].sort((a, b) => { if (a.required && !b.required) return -1; if (!a.required && b.required) return 1; return 0; }); if (sortedConditions.length <= 5) return sortedConditions; // Take first 6 conditions and add a count of remaining ones const displayConditions = sortedConditions.slice(0, 6); const remainingCount = sortedConditions.length - 6; // Add a virtual condition for the count displayConditions.push({ name: `+${remainingCount} more...`, isCounter: true }); return displayConditions; }; const handleClick = e => { if (isSelectionMode) { onSelect(e); } else { onEdit(); } }; const handleCloneClick = e => { e.stopPropagation(); onClone(format); }; const handleMouseDown = e => { // Prevent text selection when shift-clicking if (e.shiftKey) { e.preventDefault(); } }; return (
Modified:{' '} {new Date( format.modified_date ).toLocaleString()}
)}{content.description}
)} {/* Conditions and Test Results */}