"use client"; import React from "react"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/Card"; import type { CreativeAnalysisData } from "@/types/api"; interface CreativeAnalysisProps { analysis: CreativeAnalysisData; onImprovementClick?: (improvement: string) => void; onMultipleImprovementsApply?: (improvements: string[]) => void; } export const CreativeAnalysis: React.FC = ({ analysis, onImprovementClick, onMultipleImprovementsApply, }) => { const [selectedImprovements, setSelectedImprovements] = React.useState>(new Set()); const toggleImprovement = (index: number) => { setSelectedImprovements(prev => { const newSet = new Set(prev); if (newSet.has(index)) { newSet.delete(index); } else { newSet.add(index); } return newSet; }); }; const handleApplySelected = () => { const selected = Array.from(selectedImprovements).map(idx => analysis.areas_for_improvement[idx]); if (selected.length > 0 && onMultipleImprovementsApply) { onMultipleImprovementsApply(selected); setSelectedImprovements(new Set()); } }; return ( Creative Analysis {/* Visual Style & Mood */}

Visual Style

{analysis.visual_style}

Mood

{analysis.mood}

{/* Color Palette */}

Color Palette

{analysis.color_palette.map((color, index) => ( {color} ))}
{/* Composition & Subject */}

Composition

{analysis.composition}

Subject Matter

{analysis.subject_matter}

{/* Text Content (if any) */} {analysis.text_content && (

Text Content

"{analysis.text_content}"

)} {/* Current Angle & Concept */}
{analysis.current_angle && (

Current Angle

{analysis.current_angle}

)} {analysis.current_concept && (

Current Concept

{analysis.current_concept}

)}
{/* Target Audience */} {analysis.target_audience && (

Target Audience

{analysis.target_audience}

)} {/* Strengths */}

Strengths

    {analysis.strengths.map((strength, index) => (
  • {strength}
  • ))}
{/* Areas for Improvement */}

Areas for Improvement {onMultipleImprovementsApply && ( (Select multiple and apply together) )}

{onMultipleImprovementsApply && selectedImprovements.size > 0 && ( )}
    {analysis.areas_for_improvement.map((area, index) => (
  • {onMultipleImprovementsApply && ( toggleImprovement(index)} className="w-4 h-4 text-amber-600 border-gray-300 rounded focus:ring-amber-500 mt-0.5 cursor-pointer" /> )} {area} {!onMultipleImprovementsApply && onImprovementClick && ( )}
  • ))}
); };