disagreements.tsx
2,349 bytes
| 1 | 'use client'; |
|---|---|
| 2 | |
| 3 | import { GitFork } from 'lucide-react'; |
| 4 | import type { Disagreement, Participant } from '@/core/types'; |
| 5 | import { participantColor, participantTag } from '@/lib/model-visuals'; |
| 6 | |
| 7 | export function Disagreements({ |
| 8 | disagreements, |
| 9 | participants, |
| 10 | }: { |
| 11 | disagreements: Disagreement[]; |
| 12 | participants: Participant[]; |
| 13 | }) { |
| 14 | const byId = new Map(participants.map((p, i) => [p.id, { p, i }])); |
| 15 | if (disagreements.length === 0) return null; |
| 16 | |
| 17 | return ( |
| 18 | <div className="rounded-xl border border-amber-500/30 bg-amber-500/5 p-4"> |
| 19 | <div className="mb-3 flex items-center gap-2 text-sm font-semibold text-amber-600 dark:text-amber-400"> |
| 20 | <GitFork className="h-4 w-4" /> Where views still differ |
| 21 | </div> |
| 22 | <div className="space-y-3"> |
| 23 | {disagreements.map((d, i) => ( |
| 24 | <div key={i} className="rounded-lg border bg-card p-3"> |
| 25 | <div className="text-sm font-medium">{d.topic}</div> |
| 26 | {d.summary && <p className="mt-0.5 text-xs text-muted-foreground">{d.summary}</p>} |
| 27 | {d.positions.length > 0 && ( |
| 28 | <ul className="mt-2 space-y-1.5"> |
| 29 | {d.positions.map((pos, j) => { |
| 30 | const entry = pos.participantId ? byId.get(pos.participantId) : undefined; |
| 31 | return ( |
| 32 | <li key={j} className="flex items-start gap-2 text-xs"> |
| 33 | <span |
| 34 | className="mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded text-[9px] font-bold text-white" |
| 35 | style={{ |
| 36 | backgroundColor: entry |
| 37 | ? participantColor(entry.i) |
| 38 | : 'hsl(var(--muted-foreground))', |
| 39 | }} |
| 40 | > |
| 41 | {entry ? participantTag(entry.i) : pos.label} |
| 42 | </span> |
| 43 | <span> |
| 44 | <span className="font-medium"> |
| 45 | {entry ? entry.p.displayName : `Response ${pos.label}`}: |
| 46 | </span>{' '} |
| 47 | <span className="text-muted-foreground">{pos.stance}</span> |
| 48 | </span> |
| 49 | </li> |
| 50 | ); |
| 51 | })} |
| 52 | </ul> |
| 53 | )} |
| 54 | </div> |
| 55 | ))} |
| 56 | </div> |
| 57 | </div> |
| 58 | ); |
| 59 | } |
| 60 | |