import React, { useState } from 'react'; import { Innovation, Classification, ResultResponse } from '../types'; import { ChevronDown, ChevronUp, Trash2, Check, Zap, FileText } from 'lucide-react'; import { COLOR_MAP } from '../constants'; import { format } from 'path'; interface InnovationCardProps { innovation: ResultResponse; onClassify: (id: string, classification: Classification) => void; } const InnovationCard: React.FC = ({ innovation, onClassify }) => { const [isExpanded, setIsExpanded] = useState(false); const getBorderColor = (cls: Classification) => { return cls === Classification.UNCLASSIFIED ? 'border-l-4 border-l-slate-300' : `border-l-4 border-l-[${COLOR_MAP[cls]}]`; }; // Inline style for border color since Tailwind arbitrary values in template literals can be tricky const borderStyle = { borderLeftColor: COLOR_MAP[innovation.classification] }; // Extraction Logic console.log(innovation) const contextText = innovation.context; const problemText = innovation.problem; const methodologyText = formatToHTML(innovation.methodology) return (
setIsExpanded(!isExpanded)}>

Context

{contextText}

Problem Description

{problemText}

{/* Quick Actions (Always visible) */}
{isExpanded && (

Methodology

)}
); }; function formatToHTML(rawInput) { if (!rawInput) return ""; // Convert bold markdown (**text**) to text let formatted = rawInput.replace(/\*\*(.*?)\*\*/g, "$1"); // Split into lines (handle cases where everything is in one line) formatted = formatted.replace(/(\d+\.)/g, "\n$1"); formatted = formatted.replace(/\*/g, "\n*"); const lines = formatted.split("\n").map(line => line.trim()).filter(Boolean); let html = ""; let inOrderedList = false; let inUnorderedList = false; lines.forEach(line => { // Ordered list (e.g., "1. Something") if (/^\d+\.\s/.test(line)) { if (!inOrderedList) { html += "
    "; inOrderedList = true; } if (inUnorderedList) { html += ""; inUnorderedList = false; } html += `
  1. ${line.replace(/^\d+\.\s/, "")}
  2. `; } // Unordered list (e.g., "* Something") else if (/^\*\s/.test(line)) { if (!inUnorderedList) { html += "
      "; inUnorderedList = true; } if (inOrderedList) { html += "
"; inOrderedList = false; } html += `
  • ${line.replace(/^\*\s/, "")}
  • `; } // Paragraph fallback else { if (inOrderedList) { html += ""; inOrderedList = false; } if (inUnorderedList) { html += ""; inUnorderedList = false; } html += `

    ${line}

    `; } }); // Close any open lists if (inOrderedList) html += ""; if (inUnorderedList) html += ""; return html; } export default InnovationCard;