import { CheckCircle, XCircle, Clock, Lightbulb, ChevronDown, ChevronUp } from 'lucide-react'; import { useState } from 'react'; import type { ButlerProposal } from '../../lib/viking-client'; import { updateButlerProposalStatus } from '../../lib/viking-client'; interface ProposalsSectionProps { proposals: ButlerProposal[]; onStatusChange?: () => void; } function ProposalStatusBadge({ status }: { status: ButlerProposal['status'] }) { const config = { pending: { bg: 'bg-amber-100 dark:bg-amber-900/30', text: 'text-amber-700 dark:text-amber-300', icon: Clock, label: '待处理' }, accepted: { bg: 'bg-blue-100 dark:bg-blue-900/30', text: 'text-blue-700 dark:text-blue-300', icon: CheckCircle, label: '已接受' }, rejected: { bg: 'bg-gray-100 dark:bg-gray-800', text: 'text-gray-500 dark:text-gray-400', icon: XCircle, label: '已拒绝' }, completed: { bg: 'bg-emerald-100 dark:bg-emerald-900/30', text: 'text-emerald-700 dark:text-emerald-300', icon: CheckCircle, label: '已完成' }, }; const c = config[status]; const Icon = c.icon; return ( {c.label} ); } export function ProposalsSection({ proposals, onStatusChange }: ProposalsSectionProps) { const [expandedId, setExpandedId] = useState(null); const [updating, setUpdating] = useState(null); const handleStatusUpdate = async (proposalId: string, status: string) => { setUpdating(proposalId); try { await updateButlerProposalStatus(proposalId, status); onStatusChange?.(); } catch { // Status update failed — clear local optimistic state on next refresh onStatusChange?.(); } finally { setUpdating(null); } }; if (proposals.length === 0) { return (

暂无方案

当管家发现高置信度痛点时,会自动生成解决方案

); } return (
{proposals.map((proposal) => { const isExpanded = expandedId === proposal.id; const isUpdating = updating === proposal.id; return (
{isExpanded && (

{proposal.description}

{proposal.steps.length > 0 && (
步骤:
{proposal.steps.map((step) => (
{step.index}
{step.action}
{step.detail}
))}
)} {proposal.status === 'pending' && (
)}
)}
); })}
); }