import type { ChatMetadata } from '../lib/api' import type { DemoCase } from '../content/cases' import type { NegoState } from '../App' import { PriceChart } from './PriceChart' const FLOW = ['서비스안내', '담당자확인', '협상품목안내', '가격협상', '협상종료'] // 긴장도 구간 → 응대 페르소나 (엔진 프리셋과 동일한 3구간) const PERSONA_ZONE: Record = { '우호적 마무리형': 0, '균형 협상형': 1, '단호한 압박형': 2, } const ZONE_LABELS = ['낮음', '보통', '높음'] function flowIndex(step: string): number { if (step.includes('종료') || step.includes('완료') || step.includes('실패')) return 4 if (step.includes('가격') || step.startsWith('wild_')) return 3 const i = FLOW.indexOf(step) return i >= 0 ? i : 0 } function Panel({ title, children }: { title: string; children: React.ReactNode }) { return (

{title}

{children}
) } function StepCircle({ state }: { state: 'done' | 'current' | 'todo' }) { if (state === 'done') { return ( ) } return ( ) } export function Dashboard({ demoCase, nego, meta, priceTrail, started, finalPrice, }: { demoCase: DemoCase nego: NegoState meta: ChatMetadata | null priceTrail: number[] started: boolean finalPrice: number | null }) { const fi = started ? flowIndex(nego.step) : -1 const tension = meta?.tension ?? null const indicator = meta?.indicator_value ?? null const zone = meta?.persona != null ? PERSONA_ZONE[meta.persona] ?? null : null // 합의가가 마지막 제안가와 다르면(1% 추가 네고 등) 차트 종점으로 잇는다 const series = finalPrice != null && priceTrail[priceTrail.length - 1] !== finalPrice ? [...priceTrail, finalPrice] : priceTrail const current = finalPrice ?? (priceTrail.length ? priceTrail[priceTrail.length - 1] : null) const priceLabel = finalPrice != null ? '최종 합의가' : current != null ? '현재 제안가' : '기존 공급가' const priceValue = current ?? demoCase.item_price const savedPct = current != null && current < demoCase.item_price ? Math.round(((demoCase.item_price - current) / demoCase.item_price) * 1000) / 10 : null return ( ) }