import { useState } from 'react' import { ChevronRight, Search } from 'lucide-react' import { Button, Card } from '../common' import { t, tf, isRtl } from '../../lib/i18n' import type { SprintArticle, SprintResult } from '../../types' import type { GenerationConfig } from './SelectPostTypeStep' interface ArticleReviewStepProps { articles: SprintArticle[] sprintResult: SprintResult config: GenerationConfig onApprove: (approvedArticles: SprintArticle[]) => void onBack: () => void onRequestMore: () => void } const confidenceStyles: Record = { high: 'text-green-700 bg-green-50 border-green-200', medium: 'text-yellow-700 bg-yellow-50 border-yellow-200', low: 'text-red-700 bg-red-50 border-red-200', } const confidenceLabels: Record = { high: 'High confidence', medium: 'Medium confidence', low: 'Low confidence', } export function ArticleReviewStep({ articles, sprintResult, // eslint-disable-next-line @typescript-eslint/no-unused-vars config: _, onApprove, onBack, onRequestMore, }: ArticleReviewStepProps) { const [selectedArticles, setSelectedArticles] = useState>( () => new Set(articles.map((_, i) => i)), ) const toggleArticle = (index: number) => { setSelectedArticles((prev) => { const next = new Set(prev) if (next.has(index)) { next.delete(index) } else { next.add(index) } return next }) } const toggleAll = () => { if (selectedArticles.size === articles.length) { setSelectedArticles(new Set()) } else { setSelectedArticles(new Set(articles.map((_, i) => i))) } } const handleApprove = () => { const approved = articles.filter((_, i) => selectedArticles.has(i)) onApprove(approved) } return (

{tf('Proposed Articles (%d)', articles.length)}

{t('Review the articles found by the research sprint. Select the ones you want to generate.')}

{/* Sprint summary */}

{t('Research Summary')}

{t('Rounds')}
{sprintResult.rounds}
{t('Findings')}
{sprintResult.findings}
{t('Articles')}
{sprintResult.articleCount || articles.length}
{t('Cost')}
{sprintResult.costUsd.toFixed(3)}$
{/* Selection controls */}
{tf('%d of %d selected', selectedArticles.size, articles.length)}
{/* Article cards */}
{articles.map((article, i) => { const isSelected = selectedArticles.has(i) return (
toggleArticle(i)} onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault() toggleArticle(i) } }} >
toggleArticle(i)} className="mt-1 shrink-0" onClick={(e) => e.stopPropagation()} />

{article.angle}

{article.hook && (

{article.hook}

)}
{t(confidenceLabels[article.confidence] || 'Medium confidence')} {article.backingFindings && article.backingFindings.length > 0 && ( {tf('%d backing findings', article.backingFindings.length)} )} {article.branchName && ( {article.branchName} )}
) })}
{articles.length === 0 && (

{t('No articles were proposed by the research sprint.')}

)} {/* Actions */}
) }