시작 화면을 시나리오 선택으로 — 채팅 영역 4분면 피커·좌측 패널은 선택 요약으로 역할 변경

- 첫 화면: 채팅 영역에 시나리오 설명 + A/B/D/C 카드(상품명 제거), 선택 시 협상 시작
- 좌측 패널: 선택 UI 중복 제거 — 선택된 시나리오 요약 + '시나리오 변경'(피커 복귀)
- 상품 정보: 공급 유형·협력사 유형(X/단독/다수) 두 행으로 분리
- 채팅 하단 옵션 버튼 우측 정렬, 선택 전 우측 가격 패널은 빈 상태 안내

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UFZ7JWdwCaQAwNYJErL8pP
This commit is contained in:
민헌andClaude Fable 5 committed 2026-08-31 14:18:44 +09:00
1 parent 2e5fefada7
commit e781583412
5 files changed
+195 -139

No files matched your search

+18 -3
View File
@@ -22,7 +22,7 @@ const IDLE: NegoState = {
}
export default function App() {
const [demoCase, setDemoCase] = useState<DemoCase>(DEMO_CASES[0])
const [demoCase, setDemoCase] = useState<DemoCase | null>(null)
const [nego, setNego] = useState<NegoState>(IDLE)
const [messages, setMessages] = useState<Msg[]>([])
const [meta, setMeta] = useState<ChatMetadata | null>(null)
@@ -43,6 +43,7 @@ export default function App() {
const send = useCallback(
async (userInput: string | null, state: NegoState, userLabel?: string) => {
if (!demoCase) return
setBusy(true)
setError(null)
if (userLabel) setMessages((m) => [...m, { role: 'user', text: userLabel }])
@@ -106,6 +107,18 @@ export default function App() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [runId])
// 시나리오 선택 화면으로 복귀 (채팅 영역이 선택 UI가 된다)
const changeScenario = useCallback(async () => {
await invalidateSession(session.current).catch(() => {})
setDemoCase(null)
setMessages([])
setMeta(null)
setFinalPrice(null)
setPriceTrail([])
setStarted(false)
setNego(IDLE)
}, [])
const answer = (label: string) => send(label, nego, label)
const offer = (v: number) => {
@@ -139,7 +152,7 @@ export default function App() {
</header>
<main className="mx-auto grid w-full max-w-screen-2xl flex-1 grid-cols-1 gap-4 p-4 min-[960px]:min-h-0 min-[960px]:grid-cols-[260px_minmax(0,1fr)_330px]">
<CasePanel cases={DEMO_CASES} selected={demoCase} started={started} busy={busy} onStart={start} />
<CasePanel selected={demoCase} busy={busy} onChange={changeScenario} />
<ChatPanel
messages={messages}
nego={nego}
@@ -147,10 +160,12 @@ export default function App() {
started={started}
error={error}
demoCase={demoCase}
cases={DEMO_CASES}
finalPrice={finalPrice}
onAnswer={answer}
onOffer={offer}
onRestart={() => start(demoCase)}
onRestart={() => demoCase && start(demoCase)}
onSelect={start}
/>
<Dashboard
demoCase={demoCase}
+44 -49
View File
@@ -1,60 +1,51 @@
import { DIST_LABEL, type DemoCase } from '../content/cases'
// 시나리오 4분면 — 행: 매출 규모(높음/낮음), 열: 경쟁 강도(높음/낮음)
const QUADRANTS = [
{ scenario: 'Scenario_A', letter: 'A', axis: '매출 높음 · 경쟁 높음' },
{ scenario: 'Scenario_B', letter: 'B', axis: '매출 높음 · 경쟁 낮음' },
{ scenario: 'Scenario_D', letter: 'D', axis: '매출 낮음 · 경쟁 높음' },
{ scenario: 'Scenario_C', letter: 'C', axis: '매출 낮음 · 경쟁 낮음' },
]
import { DIST_LABEL, PARTNER_LABEL, SCENARIO_QUADRANTS, type DemoCase } from '../content/cases'
export function CasePanel({
cases, selected, started, busy, onStart,
selected, busy, onChange,
}: {
cases: DemoCase[]
selected: DemoCase
started: boolean
selected: DemoCase | null
busy: boolean
onStart: (c: DemoCase) => void
onChange: () => void
}) {
if (!selected) {
return (
<aside className="flex flex-col gap-4 min-[960px]:min-h-0 min-[960px]:overflow-y-auto">
<section className="rounded-box bg-base-100 p-5">
<h2 className="text-xs font-semibold text-base-content/55">협상 케이스</h2>
<p className="mt-3 text-xs leading-relaxed text-base-content/50">
가운데 화면에서 시나리오를 선택하면 진행 중인 케이스와 상품 정보가
여기에 표시됩니다.
</p>
</section>
</aside>
)
}
const q = SCENARIO_QUADRANTS.find((x) => x.scenario === selected.scenario)
return (
<aside className="flex flex-col gap-4 min-[960px]:min-h-0 min-[960px]:overflow-y-auto">
<section className="rounded-box bg-base-100 p-5">
<h2 className="text-xs font-semibold text-base-content/55">협상 케이스</h2>
<div className="mt-3 grid grid-cols-2 gap-2">
{QUADRANTS.map((q) => {
const c = cases.find((x) => x.scenario === q.scenario)
if (!c) return null
const active = started && c.id === selected.id
return (
<button
key={q.scenario}
type="button"
disabled={busy}
onClick={() => onStart(c)}
aria-pressed={active}
className={`cursor-pointer rounded-field p-3 text-left transition-colors focus-visible:ring-2 focus-visible:ring-primary focus-visible:outline-none ${
active ? 'bg-primary/8 ring-1 ring-primary/30' : 'bg-base-200/60 hover:bg-base-200'
} ${busy ? 'opacity-60' : ''}`}
>
<div className="flex items-baseline gap-1.5">
<span className={`text-lg font-extrabold ${active ? 'text-primary' : ''}`}>{q.letter}</span>
<span className="text-[10px] font-medium text-base-content/45">시나리오</span>
</div>
<p className="mt-0.5 text-[10px] leading-tight text-base-content/50">{q.axis}</p>
<p className={`mt-1.5 truncate text-xs font-semibold ${active ? 'text-primary' : 'text-base-content/80'}`}>
{c.item_name}
</p>
</button>
)
})}
<div className="flex items-center justify-between gap-2">
<h2 className="text-xs font-semibold text-base-content/55">협상 케이스</h2>
<button
type="button"
onClick={onChange}
disabled={busy}
className="btn btn-ghost btn-xs -mr-1 text-base-content/55"
>
시나리오 변경
</button>
</div>
<div className="mt-2 flex items-center gap-2.5">
<span className="flex size-9 shrink-0 items-center justify-center rounded-field bg-primary/10 text-lg font-extrabold text-primary">
{q?.letter ?? '?'}
</span>
<div className="min-w-0">
<p className="text-sm font-bold">시나리오 {q?.letter}</p>
<p className="truncate text-[11px] text-base-content/50">{q?.axis}</p>
</div>
</div>
{!started && (
<p className="mt-3 text-xs leading-relaxed text-base-content/50">
시나리오를 선택하면 협상이 시작됩니다. 챗봇은 구매 담당자(MD) 역할이고,
당신은 공급사로서 가격 제안에 응답합니다.
</p>
)}
</section>
<section className="rounded-box bg-base-100 p-5">
@@ -71,7 +62,11 @@ export function CasePanel({
</div>
<div className="flex items-center justify-between gap-2">
<dt className="text-base-content/50">공급 유형</dt>
<dd className="font-medium">{DIST_LABEL[selected.dist]} · 협력사 {selected.partners_yn}</dd>
<dd className="font-medium">{DIST_LABEL[selected.dist]}</dd>
</div>
<div className="flex items-center justify-between gap-2">
<dt className="text-base-content/50">협력사 유형</dt>
<dd className="font-medium">{PARTNER_LABEL[selected.partners_yn]}</dd>
</div>
<div className="flex items-center justify-between gap-2">
<dt className="text-base-content/50">거래 기간</dt>
+98 -70
View File
@@ -1,6 +1,6 @@
import { useEffect, useRef, useState } from 'react'
import type { ChatMetadata } from '../lib/api'
import type { DemoCase } from '../content/cases'
import { SCENARIO_QUADRANTS, type DemoCase } from '../content/cases'
import type { NegoState } from '../App'
export interface Msg {
@@ -19,18 +19,20 @@ const STEP_LABELS: Record<string, string> = {
const stepLabel = (s: string) => STEP_LABELS[s] ?? s
export function ChatPanel({
messages, nego, busy, started, error, demoCase, finalPrice, onAnswer, onOffer, onRestart,
messages, nego, busy, started, error, demoCase, cases, finalPrice, onAnswer, onOffer, onRestart, onSelect,
}: {
messages: Msg[]
nego: NegoState
busy: boolean
started: boolean
error: string | null
demoCase: DemoCase
demoCase: DemoCase | null
cases: DemoCase[]
finalPrice: number | null
onAnswer: (label: string) => void
onOffer: (v: number) => void
onRestart: () => void
onSelect: (c: DemoCase) => void
}) {
const [priceInput, setPriceInput] = useState('')
const scroller = useRef<HTMLDivElement>(null)
@@ -47,13 +49,13 @@ export function ChatPanel({
onOffer(Math.round(v))
}
const savedPct = finalPrice != null
const savedPct = finalPrice != null && demoCase != null
? Math.round(((demoCase.item_price - finalPrice) / demoCase.item_price) * 1000) / 10
: null
return (
<section className="flex min-h-[70vh] flex-col rounded-box bg-base-100 min-[960px]:h-full min-[960px]:min-h-0">
{started && (
{started && demoCase && (
<div className="flex items-center justify-between gap-3 border-b border-base-300/60 px-5 py-3">
<span className="truncate text-sm font-bold">{demoCase.item_name}</span>
{!nego.done && (
@@ -71,11 +73,37 @@ export function ChatPanel({
<div ref={scroller} className="flex-1 overflow-y-auto px-5 py-4">
{!started && (
<div className="flex h-full flex-col items-center justify-center gap-2 text-center">
<p className="text-lg font-bold">어떤 품목으로 협상해 볼까요?</p>
<p className="max-w-sm text-sm leading-relaxed text-base-content/55">
왼쪽에서 협상 케이스를 선택하면 시작됩니다. 엔진의 판단 근거는
오른쪽 계기판에 실시간으로 표시돼요.
<div className="flex h-full flex-col items-center justify-center gap-6 py-8 text-center">
<div>
<p className="text-lg font-bold">어떤 시나리오로 협상해 볼까요?</p>
<p className="mx-auto mt-2 max-w-md text-sm leading-relaxed text-base-content/55">
구매 엔진은 상품의 매출 규모와 경쟁 강도에 따라 가격 전략을 다르게 씁니다.
시나리오를 선택하면 해당 조건의 품목으로 협상이 시작됩니다.
</p>
</div>
<div className="grid w-full max-w-sm grid-cols-2 gap-3">
{SCENARIO_QUADRANTS.map((q) => {
const c = cases.find((x) => x.scenario === q.scenario)
if (!c) return null
return (
<button
key={q.scenario}
type="button"
disabled={busy}
onClick={() => onSelect(c)}
className="cursor-pointer rounded-field bg-base-200/60 p-4 text-left transition-colors hover:bg-primary/10 focus-visible:ring-2 focus-visible:ring-primary focus-visible:outline-none"
>
<div className="flex items-baseline gap-1.5">
<span className="text-2xl font-extrabold">{q.letter}</span>
<span className="text-[10px] font-medium text-base-content/45">시나리오</span>
</div>
<p className="mt-1 text-[11px] leading-tight text-base-content/55">{q.axis}</p>
</button>
)
})}
</div>
<p className="text-xs text-base-content/45">
챗봇은 구매 담당자(MD) 역할이고, 당신은 공급사로서 가격 제안에 응답합니다.
</p>
</div>
)}
@@ -119,67 +147,67 @@ export function ChatPanel({
)}
</div>
<div className="border-t border-base-300/60 p-4">
{nego.done ? (
<div className="flex flex-wrap items-center justify-between gap-3">
{finalPrice != null ? (
<div>
<p className="text-xs font-semibold text-success">협상 완료</p>
<p className="num mt-0.5 text-lg font-bold">
{finalPrice.toLocaleString()}원
<span className="num ml-2 align-[2px] rounded-full bg-primary/10 px-2 py-0.5 text-xs font-semibold text-primary">
기존가 대비 −{savedPct}%
</span>
</p>
</div>
) : (
<span className="text-sm font-bold">협상이 종료되었습니다</span>
)}
<button type="button" onClick={onRestart} className="btn btn-neutral rounded-field">
같은 케이스로 다시 협상
</button>
</div>
) : nego.mode === 'price' ? (
<form className="flex gap-2" onSubmit={(e) => { e.preventDefault(); submitPrice() }}>
<label htmlFor="price" className="sr-only">공급 제안가 (원)</label>
<input
id="price"
inputMode="numeric"
autoComplete="off"
placeholder={`제안가 입력 (기존가 ${demoCase.item_price.toLocaleString()}원)`}
value={priceInput}
onChange={(e) => setPriceInput(e.target.value)}
disabled={busy}
className="input num min-w-0 flex-1 bg-base-200 text-[15px] focus:outline-primary"
/>
<button
type="submit"
disabled={busy || !priceInput.trim()}
className="btn btn-primary shrink-0 rounded-field px-6"
>
제안하기
</button>
</form>
) : nego.options.length > 0 ? (
<div className="flex flex-wrap gap-2">
{nego.options.map((opt) => (
<button
key={opt}
type="button"
disabled={busy}
onClick={() => onAnswer(opt)}
className="btn rounded-field border-0 bg-base-200 px-5 font-semibold hover:bg-primary/10 hover:text-primary"
>
{opt}
{started && (
<div className="border-t border-base-300/60 p-4">
{nego.done ? (
<div className="flex flex-wrap items-center justify-between gap-3">
{finalPrice != null ? (
<div>
<p className="text-xs font-semibold text-success">협상 완료</p>
<p className="num mt-0.5 text-lg font-bold">
{finalPrice.toLocaleString()}원
<span className="num ml-2 align-[2px] rounded-full bg-primary/10 px-2 py-0.5 text-xs font-semibold text-primary">
기존가 대비 −{savedPct}%
</span>
</p>
</div>
) : (
<span className="text-sm font-bold">협상이 종료되었습니다</span>
)}
<button type="button" onClick={onRestart} className="btn btn-neutral rounded-field">
같은 케이스로 다시 협상
</button>
))}
</div>
) : (
<p className="py-1 text-center text-sm text-base-content/45">
{started ? '응답을 기다리는 중…' : '케이스를 선택하면 입력이 열립니다'}
</p>
)}
</div>
</div>
) : nego.mode === 'price' ? (
<form className="flex gap-2" onSubmit={(e) => { e.preventDefault(); submitPrice() }}>
<label htmlFor="price" className="sr-only">공급 제안가 (원)</label>
<input
id="price"
inputMode="numeric"
autoComplete="off"
placeholder={`제안가 입력 (기존가 ${demoCase?.item_price.toLocaleString() ?? ''}원)`}
value={priceInput}
onChange={(e) => setPriceInput(e.target.value)}
disabled={busy}
className="input num min-w-0 flex-1 bg-base-200 text-[15px] focus:outline-primary"
/>
<button
type="submit"
disabled={busy || !priceInput.trim()}
className="btn btn-primary shrink-0 rounded-field px-6"
>
제안하기
</button>
</form>
) : nego.options.length > 0 ? (
<div className="flex flex-wrap justify-end gap-2">
{nego.options.map((opt) => (
<button
key={opt}
type="button"
disabled={busy}
onClick={() => onAnswer(opt)}
className="btn rounded-field border-0 bg-base-200 px-5 font-semibold hover:bg-primary/10 hover:text-primary"
>
{opt}
</button>
))}
</div>
) : (
<p className="py-1 text-center text-sm text-base-content/45">응답을 기다리는 중…</p>
)}
</div>
)}
</section>
)
}
+25 -17
View File
@@ -51,7 +51,7 @@ function StepCircle({ state }: { state: 'done' | 'current' | 'todo' }) {
export function Dashboard({
demoCase, nego, meta, priceTrail, started, finalPrice,
}: {
demoCase: DemoCase
demoCase: DemoCase | null
nego: NegoState
meta: ChatMetadata | null
priceTrail: number[]
@@ -70,28 +70,36 @@ export function Dashboard({
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
const priceValue = current ?? demoCase?.item_price ?? 0
const savedPct = demoCase && 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>
<Panel title={demoCase ? priceLabel : '가격'}>
{demoCase ? (
<>
<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>
</>
) : (
<p className="text-xs leading-relaxed text-base-content/55">
시나리오를 선택하면 기존 공급가와 제안가 추이가 표시됩니다.
</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="협상 진행">
+10
View File
@@ -72,3 +72,13 @@ export const DEMO_CASES: DemoCase[] = [
]
export const DIST_LABEL: Record<string, string> = { R: '유통', W: '총판', M: '제조' }
export const PARTNER_LABEL: Record<string, string> = { 없음: 'X', 단독: '단독', 다수: '다수' }
// 시나리오 4분면 — 행: 매출 규모(높음/낮음), 열: 경쟁 강도(높음/낮음)
export const SCENARIO_QUADRANTS = [
{ scenario: 'Scenario_A', letter: 'A', axis: '매출 높음 · 경쟁 높음' },
{ scenario: 'Scenario_B', letter: 'B', axis: '매출 높음 · 경쟁 낮음' },
{ scenario: 'Scenario_D', letter: 'D', axis: '매출 낮음 · 경쟁 높음' },
{ scenario: 'Scenario_C', letter: 'C', axis: '매출 낮음 · 경쟁 낮음' },
] as const