레이아웃 재배치 + 미니 사분면 즉시 전환 + 가격 라운드 섹션 신설
- 좌측: 협상 케이스(상시 미니 4분면 — 클릭 시 해당 케이스로 즉시 재시작)·상품 정보·가격/차트 - 우측: 협상 진행(스텝 전용)·가격 라운드·엔진 판단 - 가격 라운드: 라운드별 제안가·기존가 대비 %·응수 협상 카드 기록 (카드는 확인 뒤 응답에 실려오므로 비어 있는 마지막 라운드에 지연 채움) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UFZ7JWdwCaQAwNYJErL8pP
This commit is contained in:
1 parent
fdfb235774
commit
cf23ca264a
4 files changed
+186
-87
No files matched your search
+39
-13
@@ -2,6 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'
|
|||||||
import { DEMO_CASES, type DemoCase } from './content/cases'
|
import { DEMO_CASES, type DemoCase } from './content/cases'
|
||||||
import { buildCardData, chat, invalidateSession, serverAlive, type ChatMetadata } from './lib/api'
|
import { buildCardData, chat, invalidateSession, serverAlive, type ChatMetadata } from './lib/api'
|
||||||
import { CasePanel } from './components/CasePanel'
|
import { CasePanel } from './components/CasePanel'
|
||||||
|
import { PricePanel } from './components/PricePanel'
|
||||||
import { ChatPanel, type Msg } from './components/ChatPanel'
|
import { ChatPanel, type Msg } from './components/ChatPanel'
|
||||||
import { Dashboard } from './components/Dashboard'
|
import { Dashboard } from './components/Dashboard'
|
||||||
|
|
||||||
@@ -16,6 +17,12 @@ export interface NegoState {
|
|||||||
done: boolean
|
done: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 가격 라운드 기록 — 제안가와 그에 응수한 협상 카드
|
||||||
|
export interface Round {
|
||||||
|
price: number
|
||||||
|
card: string | null
|
||||||
|
}
|
||||||
|
|
||||||
const IDLE: NegoState = {
|
const IDLE: NegoState = {
|
||||||
step: '시작', index: 0, iteration: 0, price: null, initial: null,
|
step: '시작', index: 0, iteration: 0, price: null, initial: null,
|
||||||
mode: 'null', options: [], done: false,
|
mode: 'null', options: [], done: false,
|
||||||
@@ -28,6 +35,7 @@ export default function App() {
|
|||||||
const [meta, setMeta] = useState<ChatMetadata | null>(null)
|
const [meta, setMeta] = useState<ChatMetadata | null>(null)
|
||||||
const [finalPrice, setFinalPrice] = useState<number | null>(null)
|
const [finalPrice, setFinalPrice] = useState<number | null>(null)
|
||||||
const [priceTrail, setPriceTrail] = useState<number[]>([])
|
const [priceTrail, setPriceTrail] = useState<number[]>([])
|
||||||
|
const [rounds, setRounds] = useState<Round[]>([])
|
||||||
const [busy, setBusy] = useState(false)
|
const [busy, setBusy] = useState(false)
|
||||||
const [started, setStarted] = useState(false)
|
const [started, setStarted] = useState(false)
|
||||||
const [runId, setRunId] = useState(0)
|
const [runId, setRunId] = useState(0)
|
||||||
@@ -42,7 +50,7 @@ export default function App() {
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const send = useCallback(
|
const send = useCallback(
|
||||||
async (userInput: string | null, state: NegoState, userLabel?: string) => {
|
async (userInput: string | null, state: NegoState, userLabel?: string, isOffer = false) => {
|
||||||
if (!demoCase) return
|
if (!demoCase) return
|
||||||
setBusy(true)
|
setBusy(true)
|
||||||
setError(null)
|
setError(null)
|
||||||
@@ -71,6 +79,20 @@ export default function App() {
|
|||||||
setMessages((m) => [...m, { role: 'bot', text: res.script, step: res.step, meta: res.chat_metadata }])
|
setMessages((m) => [...m, { role: 'bot', text: res.script, step: res.step, meta: res.chat_metadata }])
|
||||||
if (res.chat_metadata?.card_id || res.chat_metadata?.tension != null) setMeta(res.chat_metadata)
|
if (res.chat_metadata?.card_id || res.chat_metadata?.tension != null) setMeta(res.chat_metadata)
|
||||||
if (res.step === '협상완료' && res.chat_metadata?.price != null) setFinalPrice(res.chat_metadata.price)
|
if (res.step === '협상완료' && res.chat_metadata?.price != null) setFinalPrice(res.chat_metadata.price)
|
||||||
|
// 제안 시 라운드 추가 — 카드는 제안 직후가 아니라 [예] 확인 뒤 응답에 실려오므로,
|
||||||
|
// 카드가 비어 있는 마지막 라운드를 뒤따르는 응답의 카드로 채운다
|
||||||
|
const cardId = res.chat_metadata?.card_id ?? null
|
||||||
|
if (isOffer && state.price != null) {
|
||||||
|
const offered = state.price
|
||||||
|
setRounds((r) => [...r, { price: offered, card: cardId }])
|
||||||
|
} else if (cardId) {
|
||||||
|
setRounds((r) => {
|
||||||
|
if (!r.length || r[r.length - 1].card != null) return r
|
||||||
|
const next = [...r]
|
||||||
|
next[next.length - 1] = { ...next[next.length - 1], card: cardId }
|
||||||
|
return next
|
||||||
|
})
|
||||||
|
}
|
||||||
setNego({
|
setNego({
|
||||||
...state,
|
...state,
|
||||||
step: res.step,
|
step: res.step,
|
||||||
@@ -96,6 +118,7 @@ export default function App() {
|
|||||||
setMeta(null)
|
setMeta(null)
|
||||||
setFinalPrice(null)
|
setFinalPrice(null)
|
||||||
setPriceTrail([])
|
setPriceTrail([])
|
||||||
|
setRounds([])
|
||||||
setStarted(true)
|
setStarted(true)
|
||||||
setNego(IDLE)
|
setNego(IDLE)
|
||||||
setRunId((r) => r + 1)
|
setRunId((r) => r + 1)
|
||||||
@@ -115,6 +138,7 @@ export default function App() {
|
|||||||
setMeta(null)
|
setMeta(null)
|
||||||
setFinalPrice(null)
|
setFinalPrice(null)
|
||||||
setPriceTrail([])
|
setPriceTrail([])
|
||||||
|
setRounds([])
|
||||||
setStarted(false)
|
setStarted(false)
|
||||||
setNego(IDLE)
|
setNego(IDLE)
|
||||||
}, [])
|
}, [])
|
||||||
@@ -126,14 +150,14 @@ export default function App() {
|
|||||||
if (next.initial == null) next.initial = v
|
if (next.initial == null) next.initial = v
|
||||||
else next.iteration = nego.iteration + 1
|
else next.iteration = nego.iteration + 1
|
||||||
setPriceTrail((t) => [...t, v])
|
setPriceTrail((t) => [...t, v])
|
||||||
send(null, next, `${v.toLocaleString()}원 제안`)
|
send(null, next, `${v.toLocaleString()}원 제안`, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex min-h-dvh flex-col min-[960px]:h-dvh">
|
<div className="flex min-h-dvh flex-col min-[960px]:h-dvh">
|
||||||
<header className="flex items-center justify-between bg-base-100 px-6 py-3.5">
|
<header className="flex items-center justify-between bg-base-100 px-6 py-3.5">
|
||||||
<div className="flex items-baseline gap-3">
|
<div className="flex items-baseline gap-3">
|
||||||
<h1 className="text-lg font-extrabold tracking-tight">NEGO 협상 콘솔</h1>
|
<h1 className="text-xl font-extrabold tracking-tight">NEGO 협상 콘솔</h1>
|
||||||
<span className="hidden text-sm text-base-content/55 sm:inline">
|
<span className="hidden text-sm text-base-content/55 sm:inline">
|
||||||
구매 협상 에이전트 시연 — 당신은 공급사입니다
|
구매 협상 에이전트 시연 — 당신은 공급사입니다
|
||||||
</span>
|
</span>
|
||||||
@@ -151,8 +175,17 @@ export default function App() {
|
|||||||
</div>
|
</div>
|
||||||
</header>
|
</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]">
|
<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-[290px_minmax(0,1fr)_330px]">
|
||||||
<CasePanel selected={demoCase} busy={busy} onChange={changeScenario} />
|
<aside className="flex flex-col gap-4 min-[960px]:min-h-0 min-[960px]:overflow-y-auto">
|
||||||
|
<CasePanel
|
||||||
|
cases={DEMO_CASES}
|
||||||
|
selected={demoCase}
|
||||||
|
busy={busy}
|
||||||
|
onSelect={start}
|
||||||
|
onChange={changeScenario}
|
||||||
|
/>
|
||||||
|
<PricePanel demoCase={demoCase} priceTrail={priceTrail} finalPrice={finalPrice} />
|
||||||
|
</aside>
|
||||||
<ChatPanel
|
<ChatPanel
|
||||||
messages={messages}
|
messages={messages}
|
||||||
nego={nego}
|
nego={nego}
|
||||||
@@ -167,14 +200,7 @@ export default function App() {
|
|||||||
onRestart={() => demoCase && start(demoCase)}
|
onRestart={() => demoCase && start(demoCase)}
|
||||||
onSelect={start}
|
onSelect={start}
|
||||||
/>
|
/>
|
||||||
<Dashboard
|
<Dashboard demoCase={demoCase} nego={nego} meta={meta} rounds={rounds} started={started} />
|
||||||
demoCase={demoCase}
|
|
||||||
nego={nego}
|
|
||||||
meta={meta}
|
|
||||||
priceTrail={priceTrail}
|
|
||||||
started={started}
|
|
||||||
finalPrice={finalPrice}
|
|
||||||
/>
|
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,30 +1,30 @@
|
|||||||
import { DIST_LABEL, PARTNER_LABEL, SCENARIO_QUADRANTS, type DemoCase } from '../content/cases'
|
import { DIST_LABEL, PARTNER_LABEL, SCENARIO_QUADRANTS, type DemoCase } from '../content/cases'
|
||||||
|
|
||||||
export function CasePanel({
|
export function CasePanel({
|
||||||
selected, busy, onChange,
|
cases, selected, busy, onSelect, onChange,
|
||||||
}: {
|
}: {
|
||||||
|
cases: DemoCase[]
|
||||||
selected: DemoCase | null
|
selected: DemoCase | null
|
||||||
busy: boolean
|
busy: boolean
|
||||||
|
onSelect: (c: DemoCase) => void
|
||||||
onChange: () => void
|
onChange: () => void
|
||||||
}) {
|
}) {
|
||||||
if (!selected) {
|
if (!selected) {
|
||||||
return (
|
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">
|
||||||
<section className="rounded-box bg-base-100 p-5">
|
<h2 className="text-[13px] font-semibold text-base-content/55">협상 케이스</h2>
|
||||||
<h2 className="text-[13px] font-semibold text-base-content/55">협상 케이스</h2>
|
<p className="mt-3 text-[13px] leading-relaxed text-base-content/50">
|
||||||
<p className="mt-3 text-[13px] leading-relaxed text-base-content/50">
|
가운데 화면에서 시나리오를 선택하면 진행 중인 케이스와 상품 정보가
|
||||||
가운데 화면에서 시나리오를 선택하면 진행 중인 케이스와 상품 정보가
|
여기에 표시됩니다.
|
||||||
여기에 표시됩니다.
|
</p>
|
||||||
</p>
|
</section>
|
||||||
</section>
|
|
||||||
</aside>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const q = SCENARIO_QUADRANTS.find((x) => x.scenario === selected.scenario)
|
const selectedQ = SCENARIO_QUADRANTS.find((x) => x.scenario === selected.scenario)
|
||||||
|
|
||||||
return (
|
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">
|
<section className="rounded-box bg-base-100 p-5">
|
||||||
<div className="flex items-center justify-between gap-2">
|
<div className="flex items-center justify-between gap-2">
|
||||||
<h2 className="text-[13px] font-semibold text-base-content/55">협상 케이스</h2>
|
<h2 className="text-[13px] font-semibold text-base-content/55">협상 케이스</h2>
|
||||||
@@ -34,20 +34,40 @@ export function CasePanel({
|
|||||||
disabled={busy}
|
disabled={busy}
|
||||||
className="btn btn-ghost btn-xs -mr-1 text-base-content/55"
|
className="btn btn-ghost btn-xs -mr-1 text-base-content/55"
|
||||||
>
|
>
|
||||||
시나리오 변경
|
처음으로
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-2 flex items-center gap-2.5">
|
{/* 미니 사분면 — 누르면 해당 케이스로 즉시 새 협상 시작 */}
|
||||||
<span
|
<div className="mt-3 grid grid-cols-2 gap-1.5">
|
||||||
className={`flex size-10 shrink-0 items-center justify-center rounded-field text-xl font-extrabold ${q?.badgeCls ?? 'bg-base-200'}`}
|
{[['B', 'A'], ['C', 'D']].flat().map((letter) => {
|
||||||
>
|
const q = SCENARIO_QUADRANTS.find((x) => x.letter === letter)
|
||||||
{q?.letter ?? '?'}
|
const c = q && cases.find((x) => x.scenario === q.scenario)
|
||||||
</span>
|
if (!q || !c) return null
|
||||||
<div className="min-w-0">
|
const active = c.id === selected.id
|
||||||
<p className="text-[15px] font-bold">시나리오 {q?.letter}</p>
|
return (
|
||||||
<p className="truncate text-xs text-base-content/50">{q?.axis}</p>
|
<button
|
||||||
</div>
|
key={q.scenario}
|
||||||
|
type="button"
|
||||||
|
disabled={busy}
|
||||||
|
onClick={() => !active && onSelect(c)}
|
||||||
|
aria-pressed={active}
|
||||||
|
aria-label={`시나리오 ${q.letter} — ${q.axis}`}
|
||||||
|
className={`cursor-pointer rounded-field py-2 text-center text-base font-extrabold transition-colors focus-visible:ring-2 focus-visible:ring-primary focus-visible:outline-none ${
|
||||||
|
active
|
||||||
|
? `${q.badgeCls} ring-1 ring-current`
|
||||||
|
: 'bg-base-200/60 text-base-content/55 hover:bg-base-200'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{q.letter}
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
<p className="mt-2.5 text-xs text-base-content/50">
|
||||||
|
시나리오 <span className={`font-bold ${selectedQ?.textCls ?? ''}`}>{selectedQ?.letter}</span>
|
||||||
|
<span className="mx-1">·</span>
|
||||||
|
{selectedQ?.axis}
|
||||||
|
</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section className="rounded-box bg-base-100 p-5">
|
<section className="rounded-box bg-base-100 p-5">
|
||||||
@@ -80,6 +100,6 @@ export function CasePanel({
|
|||||||
</div>
|
</div>
|
||||||
</dl>
|
</dl>
|
||||||
</section>
|
</section>
|
||||||
</aside>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import type { ChatMetadata } from '../lib/api'
|
import type { ChatMetadata } from '../lib/api'
|
||||||
import type { DemoCase } from '../content/cases'
|
import type { DemoCase } from '../content/cases'
|
||||||
import type { NegoState } from '../App'
|
import type { NegoState, Round } from '../App'
|
||||||
import { PriceChart } from './PriceChart'
|
|
||||||
|
|
||||||
const FLOW = ['서비스안내', '담당자확인', '협상품목안내', '가격협상', '협상종료']
|
const FLOW = ['서비스안내', '담당자확인', '협상품목안내', '가격협상', '협상종료']
|
||||||
|
const MAX_ROUNDS = 5
|
||||||
|
|
||||||
// 긴장도 구간 → 응대 페르소나 (엔진 프리셋과 동일한 3구간)
|
// 긴장도 구간 → 응대 페르소나 (엔진 프리셋과 동일한 3구간)
|
||||||
const PERSONA_ZONE: Record<string, number> = {
|
const PERSONA_ZONE: Record<string, number> = {
|
||||||
@@ -20,10 +20,13 @@ function flowIndex(step: string): number {
|
|||||||
return i >= 0 ? i : 0
|
return i >= 0 ? i : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function Panel({ title, children }: { title: string; children: React.ReactNode }) {
|
function Panel({ title, right, children }: { title: string; right?: React.ReactNode; children: React.ReactNode }) {
|
||||||
return (
|
return (
|
||||||
<section className="rounded-box bg-base-100 p-5">
|
<section className="rounded-box bg-base-100 p-5">
|
||||||
<h2 className="text-[13px] font-semibold text-base-content/55">{title}</h2>
|
<div className="flex items-center justify-between gap-2">
|
||||||
|
<h2 className="text-[13px] font-semibold text-base-content/55">{title}</h2>
|
||||||
|
{right}
|
||||||
|
</div>
|
||||||
<div className="mt-3">{children}</div>
|
<div className="mt-3">{children}</div>
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
@@ -49,65 +52,27 @@ function StepCircle({ state }: { state: 'done' | 'current' | 'todo' }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function Dashboard({
|
export function Dashboard({
|
||||||
demoCase, nego, meta, priceTrail, started, finalPrice,
|
demoCase, nego, meta, rounds, started,
|
||||||
}: {
|
}: {
|
||||||
demoCase: DemoCase | null
|
demoCase: DemoCase | null
|
||||||
nego: NegoState
|
nego: NegoState
|
||||||
meta: ChatMetadata | null
|
meta: ChatMetadata | null
|
||||||
priceTrail: number[]
|
rounds: Round[]
|
||||||
started: boolean
|
started: boolean
|
||||||
finalPrice: number | null
|
|
||||||
}) {
|
}) {
|
||||||
const fi = started ? flowIndex(nego.step) : -1
|
const fi = started ? flowIndex(nego.step) : -1
|
||||||
const tension = meta?.tension ?? null
|
const tension = meta?.tension ?? null
|
||||||
const indicator = meta?.indicator_value ?? null
|
const indicator = meta?.indicator_value ?? null
|
||||||
const zone = meta?.persona != null ? PERSONA_ZONE[meta.persona] ?? null : 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 ?? 0
|
|
||||||
const savedPct = demoCase && current != null && current < demoCase.item_price
|
|
||||||
? Math.round(((demoCase.item_price - current) / demoCase.item_price) * 1000) / 10
|
|
||||||
: null
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<aside className="flex flex-col gap-4 min-[960px]:min-h-0 min-[960px]:overflow-y-auto">
|
<aside className="flex flex-col gap-4 min-[960px]:min-h-0 min-[960px]:overflow-y-auto">
|
||||||
<Panel title={demoCase ? priceLabel : '가격'}>
|
|
||||||
{demoCase ? (
|
|
||||||
<>
|
|
||||||
<div className="flex items-baseline gap-2">
|
|
||||||
<p className="num text-[28px] font-bold tracking-tight">
|
|
||||||
{priceValue.toLocaleString()}
|
|
||||||
<span className="ml-0.5 text-lg font-semibold text-base-content/55">원</span>
|
|
||||||
</p>
|
|
||||||
{savedPct != null && (
|
|
||||||
<span className="num rounded-full bg-primary/10 px-2 py-0.5 text-[13px] font-semibold text-primary">
|
|
||||||
기존가 대비 −{savedPct}%
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className="mt-2">
|
|
||||||
<PriceChart demoCase={demoCase} priceTrail={series} />
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<p className="text-[13px] leading-relaxed text-base-content/55">
|
|
||||||
시나리오를 선택하면 기존 공급가와 제안가 추이가 표시됩니다.
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</Panel>
|
|
||||||
|
|
||||||
<Panel title="협상 진행">
|
<Panel title="협상 진행">
|
||||||
<ol className="flex flex-col">
|
<ol className="flex flex-col">
|
||||||
{FLOW.map((s, i) => {
|
{FLOW.map((s, i) => {
|
||||||
const state = i < fi ? 'done' : i === fi ? 'current' : 'todo'
|
const state = i < fi ? 'done' : i === fi ? 'current' : 'todo'
|
||||||
return (
|
return (
|
||||||
<li key={s} className="flex gap-3">
|
<li key={s} className={`flex gap-3 ${i === FLOW.length - 1 ? '' : ''}`}>
|
||||||
<div className="flex flex-col items-center">
|
<div className="flex flex-col items-center">
|
||||||
<StepCircle state={state} />
|
<StepCircle state={state} />
|
||||||
{i < FLOW.length - 1 && (
|
{i < FLOW.length - 1 && (
|
||||||
@@ -115,7 +80,7 @@ export function Dashboard({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<span
|
<span
|
||||||
className={`pb-4 text-[13px] leading-5 ${
|
className={`text-[13px] leading-5 ${i < FLOW.length - 1 ? 'pb-4' : ''} ${
|
||||||
state === 'current'
|
state === 'current'
|
||||||
? 'font-bold text-primary'
|
? 'font-bold text-primary'
|
||||||
: state === 'done'
|
: state === 'done'
|
||||||
@@ -129,10 +94,46 @@ export function Dashboard({
|
|||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</ol>
|
</ol>
|
||||||
<div className="mt-1 flex items-center justify-between border-t border-base-300/60 pt-3 text-[15px]">
|
</Panel>
|
||||||
<span className="text-base-content/55">가격 라운드</span>
|
|
||||||
<span className="num font-semibold">{Math.min(nego.iteration + (nego.initial ? 1 : 0), 5)} / 5</span>
|
<Panel
|
||||||
</div>
|
title="가격 라운드"
|
||||||
|
right={<span className="num text-[13px] font-semibold text-base-content/70">{rounds.length} / {MAX_ROUNDS}</span>}
|
||||||
|
>
|
||||||
|
{rounds.length === 0 ? (
|
||||||
|
<p className="text-[13px] leading-relaxed text-base-content/55">
|
||||||
|
가격 협상에서 제안할 때마다 제안가와 엔진이 응수한 협상 카드가
|
||||||
|
여기에 기록됩니다.
|
||||||
|
</p>
|
||||||
|
) : (
|
||||||
|
<ol className="flex flex-col gap-2.5">
|
||||||
|
{rounds.map((r, i) => {
|
||||||
|
const pct = demoCase
|
||||||
|
? Math.round(((demoCase.item_price - r.price) / demoCase.item_price) * 1000) / 10
|
||||||
|
: null
|
||||||
|
return (
|
||||||
|
<li key={i} className="flex items-center gap-2.5">
|
||||||
|
<span className="num flex size-5 shrink-0 items-center justify-center rounded-full bg-base-200 text-[11px] font-bold text-base-content/60">
|
||||||
|
{i + 1}
|
||||||
|
</span>
|
||||||
|
<span className="num min-w-0 flex-1 truncate text-[14px] font-semibold">
|
||||||
|
{r.price.toLocaleString()}원
|
||||||
|
</span>
|
||||||
|
{pct != null && (
|
||||||
|
<span className={`num text-xs font-medium ${pct >= 0 ? 'text-primary' : 'text-base-content/45'}`}>
|
||||||
|
{pct >= 0 ? `−${pct}%` : `+${Math.abs(pct)}%`}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{r.card && (
|
||||||
|
<span className="num shrink-0 rounded-full bg-primary/10 px-1.5 py-px font-mono text-[11px] font-semibold text-primary">
|
||||||
|
{r.card}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</li>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</ol>
|
||||||
|
)}
|
||||||
</Panel>
|
</Panel>
|
||||||
|
|
||||||
<Panel title="엔진 판단">
|
<Panel title="엔진 판단">
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import type { DemoCase } from '../content/cases'
|
||||||
|
import { PriceChart } from './PriceChart'
|
||||||
|
|
||||||
|
export function PricePanel({
|
||||||
|
demoCase, priceTrail, finalPrice,
|
||||||
|
}: {
|
||||||
|
demoCase: DemoCase | null
|
||||||
|
priceTrail: number[]
|
||||||
|
finalPrice: number | 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 ?? 0
|
||||||
|
const savedPct = demoCase && current != null && current < demoCase.item_price
|
||||||
|
? Math.round(((demoCase.item_price - current) / demoCase.item_price) * 1000) / 10
|
||||||
|
: null
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section className="rounded-box bg-base-100 p-5">
|
||||||
|
<h2 className="text-[13px] font-semibold text-base-content/55">{demoCase ? priceLabel : '가격'}</h2>
|
||||||
|
<div className="mt-3">
|
||||||
|
{demoCase ? (
|
||||||
|
<>
|
||||||
|
<div className="flex flex-wrap items-baseline gap-2">
|
||||||
|
<p className="num text-[28px] font-bold tracking-tight">
|
||||||
|
{priceValue.toLocaleString()}
|
||||||
|
<span className="ml-0.5 text-lg font-semibold text-base-content/55">원</span>
|
||||||
|
</p>
|
||||||
|
{savedPct != null && (
|
||||||
|
<span className="num rounded-full bg-primary/10 px-2 py-0.5 text-[13px] font-semibold text-primary">
|
||||||
|
기존가 대비 −{savedPct}%
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="mt-2">
|
||||||
|
<PriceChart demoCase={demoCase} priceTrail={series} />
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<p className="text-[13px] leading-relaxed text-base-content/55">
|
||||||
|
시나리오를 선택하면 기존 공급가와 제안가 추이가 표시됩니다.
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
Reference in new issue
Block a user