Files
Negotiation_daegu/frontend/src/components/Dashboard.tsx
T
민헌andClaude Fable 5 2e5fefada7 콘솔 구조 개편 — 시나리오 4분면 선택·상품 정보 섹션·체크 스텝퍼·긴장도 구간 게이지
- 협상 케이스를 4분면(매출 규모×경쟁 강도) 시나리오 A/B/D/C 그리드로 교체
- 상품 정보 섹션 신설: 공급가·인터넷 최저가·공급 유형·거래 기간·응답률/VOC 이동
- 가격 패널 하단(시나리오·최저가·내부기준 문구) 제거
- 협상 진행을 체크 원형 세로 스텝퍼로 교체
- 긴장도를 3구간(낮음·보통·높음) 게이지로, 페르소나를 구간 결과로 묶어 인과 표시
- 차트 첫 제안 점 값 라벨의 좌측 클립 보정

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UFZ7JWdwCaQAwNYJErL8pP
2026-08-31 14:09:17 +09:00

210 lines
8.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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<string, number> = {
'우호적 마무리형': 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 (
<section className="rounded-box bg-base-100 p-5">
<h2 className="text-xs font-semibold text-base-content/55">{title}</h2>
<div className="mt-3">{children}</div>
</section>
)
}
function StepCircle({ state }: { state: 'done' | 'current' | 'todo' }) {
if (state === 'done') {
return (
<span className="flex size-5 shrink-0 items-center justify-center rounded-full bg-primary">
<svg viewBox="0 0 10 8" className="w-2.5" aria-hidden>
<path d="M1 4l2.5 2.5L9 1" fill="none" stroke="white" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" />
</svg>
</span>
)
}
return (
<span
className={`size-5 shrink-0 rounded-full border-2 bg-base-100 ${
state === 'current' ? 'border-primary' : 'border-base-300'
}`}
/>
)
}
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 (
<aside className="flex flex-col gap-4 min-[960px]:min-h-0 min-[960px]:overflow-y-auto">
<Panel title={priceLabel}>
<div className="flex items-baseline gap-2">
<p className="num text-2xl font-bold tracking-tight">
{priceValue.toLocaleString()}
<span className="ml-0.5 text-base font-semibold text-base-content/55">원</span>
</p>
{savedPct != null && (
<span className="num rounded-full bg-primary/10 px-2 py-0.5 text-xs font-semibold text-primary">
기존가 대비 −{savedPct}%
</span>
)}
</div>
<div className="mt-2">
<PriceChart demoCase={demoCase} priceTrail={series} />
</div>
</Panel>
<Panel title="협상 진행">
<ol className="flex flex-col">
{FLOW.map((s, i) => {
const state = i < fi ? 'done' : i === fi ? 'current' : 'todo'
return (
<li key={s} className="flex gap-3">
<div className="flex flex-col items-center">
<StepCircle state={state} />
{i < FLOW.length - 1 && (
<div className={`w-0.5 flex-1 ${i < fi ? 'bg-primary' : 'bg-base-200'}`} />
)}
</div>
<span
className={`pb-4 text-xs leading-5 ${
state === 'current'
? 'font-bold text-primary'
: state === 'done'
? 'font-medium text-base-content/80'
: 'text-base-content/40'
}`}
>
{s}
</span>
</li>
)
})}
</ol>
<div className="mt-1 flex items-center justify-between border-t border-base-300/60 pt-3 text-sm">
<span className="text-base-content/55">가격 라운드</span>
<span className="num font-semibold">{Math.min(nego.iteration + (nego.initial ? 1 : 0), 5)} / 5</span>
</div>
</Panel>
<Panel title="엔진 판단">
{meta ? (
<dl className="flex flex-col gap-4 text-sm">
<div className="flex items-center justify-between gap-2">
<dt className="text-base-content/55">협상 카드</dt>
<dd>
<span className="badge badge-soft badge-primary num font-mono text-[12px] font-semibold">
{meta.card_id ?? '—'}
</span>
</dd>
</div>
<div>
<div className="flex items-center justify-between">
<dt className="text-base-content/55">가격 지표</dt>
<dd className="num text-[13px] font-medium">
{indicator != null ? (
<>
{indicator} <span className="text-base-content/45">/ 99 · {meta.indicator_range}</span>
</>
) : '—'}
</dd>
</div>
<div className="mt-2 h-1.5 rounded-full bg-base-200">
<div
className="h-full rounded-full bg-primary transition-[width] duration-500 motion-reduce:transition-none"
style={{ width: `${indicator ?? 0}%` }}
/>
</div>
</div>
<div>
<div className="flex items-center justify-between">
<dt className="text-base-content/55">협상 긴장도</dt>
<dd className="num text-[13px] font-medium">{tension != null ? tension.toFixed(2) : '—'}</dd>
</div>
<div className="mt-2 flex gap-1" aria-hidden>
{ZONE_LABELS.map((_, i) => (
<div
key={i}
className={`h-1.5 flex-1 rounded-full transition-colors ${
zone === i ? 'bg-warning' : 'bg-base-200'
}`}
/>
))}
</div>
<div className="mt-1.5 flex text-[10px]" aria-hidden>
{ZONE_LABELS.map((l, i) => (
<span
key={l}
className={`flex-1 text-center ${zone === i ? 'font-semibold text-warning' : 'text-base-content/40'}`}
>
{l}
</span>
))}
</div>
<div className="mt-2.5 flex items-center justify-between gap-2">
<span className="text-xs text-base-content/55">적용 페르소나</span>
{meta.persona ? (
<span className="badge badge-soft badge-warning text-[12px] font-semibold">{meta.persona}</span>
) : (
<span className="text-base-content/45">—</span>
)}
</div>
<p className="mt-2 text-[11px] leading-relaxed text-base-content/45">
긴장도 구간에 따라 협상 말투(페르소나)가 정해집니다.
</p>
</div>
</dl>
) : (
<p className="text-xs leading-relaxed text-base-content/55">
{nego.done
? '카드 라운드 없이 조기 합의됐어요 — 첫 제안가가 앵커가 이하면 협상 카드 없이 종료됩니다.'
: '가격 협상이 시작되면 선택된 협상 카드와 가격 지표·긴장도·페르소나가 여기에 표시됩니다.'}
</p>
)}
</Panel>
</aside>
)
}