시작 화면을 시나리오 선택으로 — 채팅 영역 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

+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>
)
}