'use client' import { memo } from 'react' import { Handle, Position } from '@xyflow/react' import type { NodeProps } from '@xyflow/react' import type { OutcomeNodeData } from '@/lib/types' function OutcomeNode({ data, selected }: NodeProps) { const nodeData = data as OutcomeNodeData const { label, description, fundingReceived, fundingTarget, status } = nodeData const progress = fundingTarget > 0 ? Math.min(100, (fundingReceived / fundingTarget) * 100) : 0 const isFunded = fundingReceived >= fundingTarget const isPartial = fundingReceived > 0 && fundingReceived < fundingTarget const statusColors = { 'not-started': { bg: 'bg-slate-100', text: 'text-slate-600', border: 'border-slate-300' }, 'in-progress': { bg: 'bg-blue-100', text: 'text-blue-700', border: 'border-blue-300' }, 'completed': { bg: 'bg-emerald-100', text: 'text-emerald-700', border: 'border-emerald-300' }, 'blocked': { bg: 'bg-red-100', text: 'text-red-700', border: 'border-red-300' }, } const colors = statusColors[status] || statusColors['not-started'] return (
{label} {nodeData.source?.type === 'rvote' && nodeData.source.rvoteSpaceSlug && nodeData.source.rvoteProposalId ? ( e.stopPropagation()} > rVote • score +{nodeData.source.rvoteProposalScore ?? 0} ) : nodeData.source?.type === 'rvote' ? ( rVote • score +{nodeData.source.rvoteProposalScore ?? 0} ) : null}
{description && (

{description}

)}
{status.replace('-', ' ')} {isFunded && ( )}
Funding ${Math.floor(fundingReceived).toLocaleString()} / ${fundingTarget.toLocaleString()}
{progress.toFixed(0)}%
) } export default memo(OutcomeNode)