[feat] 공급사 포털: 협상완료 부가정보(select·종료 동의폼)·상태 라벨 통일·예아니오 Enter=예·목록 결과열·재협상 요청/철회 API·테스트
This commit is contained in:
1 parent
cfee6e89d0
commit
d7c4e86f30
46 files changed
+1715
-270
No files matched your search
@@ -6,7 +6,6 @@ import type { ChatMessage as ChatMessageType } from '@/features/chat/types'
|
||||
import { renderEmphasis } from '@/features/chat/lib/emphasis'
|
||||
import { Indicator } from '@/features/chat/components/templates/Indicator'
|
||||
import { Summary } from '@/features/chat/components/templates/Summary'
|
||||
import { ExtraInfoForm } from '@/features/chat/components/templates/ExtraInfoForm'
|
||||
import { BidSummary } from '@/features/chat/components/templates/BidSummary'
|
||||
import { RejectRSP } from '@/features/chat/components/templates/RejectRSP'
|
||||
import { RejectCM } from '@/features/chat/components/templates/RejectCM'
|
||||
@@ -22,7 +21,7 @@ export function ChatMessage() {
|
||||
스크롤 시 여백도 함께 밀려 올라가도록 스크롤 컨테이너 안쪽에 둔다 */}
|
||||
<div
|
||||
ref={scrollRef}
|
||||
className="chat-scroll h-full overflow-y-auto flex flex-col pt-4 lg:pt-[64px] pb-6 px-4 sm:px-6 min-[1180px]:pl-[80px] min-[1180px]:pr-[72px] min-[1350px]:pl-[140px] min-[1350px]:pr-[126px]"
|
||||
className="chat-scroll h-full overflow-y-auto flex flex-col pt-0 lg:pt-[64px] pb-6 px-4 sm:px-6 min-[1180px]:pl-[80px] min-[1180px]:pr-[72px] min-[1350px]:pl-[140px] min-[1350px]:pr-[126px]"
|
||||
>
|
||||
<ChatList scrollRef={scrollRef} />
|
||||
</div>
|
||||
@@ -48,7 +47,7 @@ function ChatList({ scrollRef }: { scrollRef: RefObject<HTMLDivElement | null> }
|
||||
scroller.scrollTo({ top: scroller.scrollHeight, behavior })
|
||||
})
|
||||
return () => cancelAnimationFrame(id)
|
||||
}, [chats, isLoading])
|
||||
}, [chats, isLoading, scrollRef])
|
||||
|
||||
if (!chats || chats.length === 0) {
|
||||
return (
|
||||
@@ -124,12 +123,7 @@ const BotMessage = memo(function BotMessage({ message }: { message: ChatMessageT
|
||||
{showIndicator && message.bot_chat_type === 'indicator' && message.indicator_value != null && (
|
||||
<Indicator number={message.indicator_value} />
|
||||
)}
|
||||
{message.bot_chat_type === 'summaryRSP' && message.summary && (
|
||||
<>
|
||||
<Summary data={message.summary} />
|
||||
<ExtraInfoForm />
|
||||
</>
|
||||
)}
|
||||
{message.bot_chat_type === 'summaryRSP' && message.summary && <Summary data={message.summary} />}
|
||||
{message.bot_chat_type === 'summaryCM' && message.summary && (
|
||||
<BidSummary
|
||||
itemName={message.summary.item_name}
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
import { useState } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
import { useMeQuery, useSaveExtraInfoMutation, getApiErrorMessage } from '@/apis'
|
||||
import type { SessionField } from '@/apis/auth/auth.type'
|
||||
import { useChatStore } from '@/features/chat/stores/useChatStore'
|
||||
import { useChatInitStore } from '@/features/chat/stores/useChatInitStore'
|
||||
|
||||
// 타결 요약의 '동의' 단계 하단 액션바 = 부가정보 입력 + 동의를 한 자리에서.
|
||||
// 다른 입력(가격·배송)과 같은 자리에서 받는다. proceedText = 동의 문구(누르면 저장 후 그 텍스트로 협상 종료).
|
||||
// 필드 정의(session_fields)가 없으면 폼 없이 동의 버튼만 둔다. 저장 후에도 세션 목록에서 수정할 수 있다.
|
||||
export function ExtraInfoBar({ proceedText }: { proceedText: string }) {
|
||||
const sessionId = useChatStore((s) => s.sessionId)
|
||||
const sendMessage = useChatStore((s) => s.sendMessage)
|
||||
const { data: user } = useMeQuery()
|
||||
const fields: SessionField[] = user?.sessionFields ?? []
|
||||
const save = useSaveExtraInfoMutation()
|
||||
const existing = useChatInitStore((s) => s.custom) // 기존 입력값(재진입 프리필)
|
||||
|
||||
// 사용자가 건드린 값만 state 로 두고, 나머지는 기존값/기본값에서 렌더마다 파생한다(초기화 effect 불필요).
|
||||
const [overrides, setOverrides] = useState<Record<string, unknown>>({})
|
||||
const values: Record<string, unknown> = {}
|
||||
for (const f of fields) values[f.key] = overrides[f.key] ?? existing?.[f.key] ?? (f.type === 'boolean' ? false : '')
|
||||
|
||||
const proceed = () => sendMessage(proceedText)
|
||||
|
||||
// 필드 미정의 회사 → 부가정보 없이 동의만.
|
||||
if (fields.length === 0) {
|
||||
return (
|
||||
<div className="flex w-full justify-center">
|
||||
<button className={PRIMARY} onClick={proceed}>
|
||||
{proceedText || '확인'}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const set = (key: string, value: unknown) => setOverrides((v) => ({ ...v, [key]: value }))
|
||||
|
||||
// 저장 성공 후에만 동의(협상 종료)로 넘어간다 — 저장 실패 시 화면 유지.
|
||||
const handleSaveAndProceed = () => {
|
||||
if (save.isPending) return
|
||||
const custom: Record<string, unknown> = {}
|
||||
for (const f of fields) {
|
||||
const v = values[f.key]
|
||||
if (f.type === 'boolean') custom[f.key] = !!v
|
||||
else if (v !== '' && v != null) custom[f.key] = f.type === 'number' ? Number(v) : v
|
||||
}
|
||||
save.mutate(
|
||||
{ sessionId, request: { custom } },
|
||||
{
|
||||
onSuccess: () => proceed(),
|
||||
onError: (error) => toast.error(getApiErrorMessage(error, '부가정보 저장에 실패했습니다.')),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="w-full">
|
||||
<p className="mb-3 text-sm font-semibold text-neutral-90">아래 정보를 입력하고 협상을 마무리해 주세요.</p>
|
||||
{/* overflow-y-auto 는 overflow-x 도 auto 로 만들어(스펙상) 인풋 focus ring 을 좌우로 잘라낸다.
|
||||
p-1 로 링 여백을 주고 -m-1 로 원래 정렬(버튼과 좌우폭)을 유지한다. */}
|
||||
<div className="max-h-[36vh] space-y-3 overflow-y-auto p-1 -m-1">
|
||||
{fields.map((f) => (
|
||||
<div key={f.key} className="flex items-center gap-3">
|
||||
<label className="w-28 shrink-0 text-sm font-semibold text-neutral-80">{f.label}</label>
|
||||
{f.type === 'boolean' ? (
|
||||
<button
|
||||
type="button"
|
||||
role="switch"
|
||||
aria-checked={!!values[f.key]}
|
||||
onClick={() => set(f.key, !values[f.key])}
|
||||
className={`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors ${
|
||||
values[f.key] ? 'bg-brand-600' : 'bg-neutral-30'
|
||||
}`}
|
||||
>
|
||||
<span
|
||||
className={`inline-block size-5 transform rounded-full bg-white shadow transition-transform ${
|
||||
values[f.key] ? 'translate-x-5' : 'translate-x-0.5'
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
) : f.type === 'select' ? (
|
||||
<select
|
||||
value={String(values[f.key] ?? '')}
|
||||
onChange={(e) => set(f.key, e.target.value)}
|
||||
className="h-10 w-full rounded-xl border border-border bg-white px-3 text-sm outline-none focus:border-brand-600 focus:ring-1 focus:ring-brand-600"
|
||||
>
|
||||
<option value="">선택</option>
|
||||
{(f.options ?? []).map((o) => (
|
||||
<option key={o} value={o}>{o}</option>
|
||||
))}
|
||||
</select>
|
||||
) : (
|
||||
<input
|
||||
type={f.type === 'number' ? 'number' : 'text'}
|
||||
value={String(values[f.key] ?? '')}
|
||||
onChange={(e) => set(f.key, e.target.value)}
|
||||
onKeyDown={(e) => e.key === 'Enter' && !e.nativeEvent.isComposing && handleSaveAndProceed()}
|
||||
className="h-10 w-full rounded-xl border border-border bg-white px-3 text-sm outline-none focus:border-brand-600 focus:ring-1 focus:ring-brand-600"
|
||||
placeholder={f.label}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<button type="button" onClick={handleSaveAndProceed} disabled={save.isPending} className={`${PRIMARY} mt-3 w-full`}>
|
||||
{save.isPending ? '저장 중…' : proceedText || '저장하고 마무리'}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const PRIMARY =
|
||||
'h-[46px] min-w-[120px] rounded-xl bg-brand-600 px-6 text-sm font-bold text-white shadow-sm transition-all hover:bg-brand-700 active:scale-[0.98] disabled:opacity-50'
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Check } from 'lucide-react'
|
||||
import { cn } from '@/lib'
|
||||
import { useChatStore } from '@/features/chat/stores/useChatStore'
|
||||
import { STEPS } from '@/features/chat/components/menu/NegoStep'
|
||||
import { STEPS } from '@/features/chat/lib/negoSteps'
|
||||
|
||||
// 모바일 전용: 협상절차를 채팅 상단에 가로 스텝바로 항상 표시한다. (데스크톱은 우측 패널 사용)
|
||||
export function MobileStepBar() {
|
||||
|
||||
@@ -20,12 +20,23 @@ export function RemainingTime() {
|
||||
return (
|
||||
<span
|
||||
className={cn(
|
||||
'inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-bold whitespace-nowrap tabular-nums',
|
||||
// min-w-0 + truncate: 헤더가 좁아도 잘려나가지 않고 말줄임으로 접힌다.
|
||||
'inline-flex min-w-0 shrink items-center gap-1.5 rounded-full px-3 py-1 text-xs font-bold tabular-nums',
|
||||
ended ? 'bg-neutral-20 text-neutral-60' : 'bg-brand-light text-brand-600',
|
||||
)}
|
||||
>
|
||||
<Clock className="size-3.5" />
|
||||
협상 마감 {remaining}
|
||||
<Clock className="size-3.5 shrink-0" />
|
||||
<span className="truncate">
|
||||
{ended ? (
|
||||
// 종료 시엔 어느 폭에서도 긴 문장('종료되었습니다.')을 쓰지 않는다 — 헤더에서 잘리던 원인.
|
||||
'마감 종료'
|
||||
) : (
|
||||
<>
|
||||
<span className="hidden sm:inline">협상 마감 </span>
|
||||
{remaining}
|
||||
</>
|
||||
)}
|
||||
</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
import { useEffect } from 'react'
|
||||
import { useNavigate } from 'react-router'
|
||||
import { cn } from '@/lib'
|
||||
import { useChatStore } from '@/features/chat/stores/useChatStore'
|
||||
import { Percent, Price } from '@/features/chat/components/userInputs'
|
||||
import { ExtraInfoBar } from '@/features/chat/components/ExtraInfoBar'
|
||||
import { GO_TO_LIST_TEXT } from '@/features/chat/lib/userButtonConfig'
|
||||
import type { UserButtonConfig } from '@/features/chat/types'
|
||||
|
||||
@@ -17,6 +19,15 @@ const style = {
|
||||
export function UserButton({ type, text, textList, priceErrorMessage }: UserButtonConfig) {
|
||||
if (type === '') return null
|
||||
|
||||
// 부가정보 입력은 폼이라 가운데정렬 덱이 아니라 전체폭으로 편다. text = 저장 후 보낼 동의 문구.
|
||||
if (type === 'extra-info') {
|
||||
return (
|
||||
<div className="w-full px-6 py-4 max-[1180px]:px-4">
|
||||
<ExtraInfoBar proceedText={text || ''} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex w-full justify-center overflow-x-auto px-6 py-4 max-[1180px]:px-4">
|
||||
<div className="flex justify-center">
|
||||
@@ -82,6 +93,18 @@ function ThreeBlack({ textList }: { textList: [string, string, string] }) {
|
||||
|
||||
function BlackWhite({ textList }: { textList: [string, string] }) {
|
||||
const sendMessage = useChatStore((s) => s.sendMessage)
|
||||
// Enter = 첫 버튼(예). 입력창이 없는 선택 단계라 전역 Enter 를 잡아도 안전하다.
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Enter' && !e.isComposing) {
|
||||
e.preventDefault()
|
||||
sendMessage(textList[0])
|
||||
}
|
||||
}
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [sendMessage, textList])
|
||||
|
||||
return (
|
||||
<div className="flex gap-3">
|
||||
<button className={style.black} onClick={() => sendMessage(textList[0])}>
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
import { Check, ChevronDown } from 'lucide-react'
|
||||
import { cn } from '@/lib'
|
||||
import { useChatStore } from '@/features/chat/stores/useChatStore'
|
||||
import { STEPS } from '@/features/chat/lib/negoSteps'
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean
|
||||
setIsOpen: (isOpen: boolean) => void
|
||||
}
|
||||
|
||||
export const STEPS = [
|
||||
{ name: '서비스안내', desc: '협상 방식과 유의사항을 확인합니다.' },
|
||||
{ name: '담당자확인', desc: '협상 담당자 본인 여부를 확인합니다.' },
|
||||
{ name: '협상품목안내', desc: '대상 품목과 기준 단가를 확인합니다.' },
|
||||
{ name: '가격협상', desc: '공급 단가를 제안하고 조율합니다.' },
|
||||
{ name: '협상종료', desc: '최종 합의 후 결과를 확인합니다.' },
|
||||
]
|
||||
|
||||
export function NegoStep({ isOpen, setIsOpen }: Props) {
|
||||
const chats = useChatStore((s) => s.messages)
|
||||
const currentStep = chats[chats.length - 1]?.display_step || '서비스안내'
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { CheckCircle2 } from 'lucide-react'
|
||||
import { toast } from 'sonner'
|
||||
import { useMeQuery, useSaveExtraInfoMutation, getApiErrorMessage } from '@/apis'
|
||||
import type { SessionField } from '@/apis/auth/auth.type'
|
||||
import { useChatStore } from '@/features/chat/stores/useChatStore'
|
||||
import { useChatInitStore } from '@/features/chat/stores/useChatInitStore'
|
||||
|
||||
// 협상 타결(Summary) 직후 부가정보 입력 폼. 필드 정의(session_fields)는 회사 설정(/me)에서 온다.
|
||||
// 저장하면 sessions.custom 에 기록되고 negodata 견적상세에 표시된다. 정의가 없으면 렌더하지 않는다.
|
||||
export function ExtraInfoForm() {
|
||||
const sessionId = useChatStore((s) => s.sessionId)
|
||||
const { data: user } = useMeQuery()
|
||||
const fields: SessionField[] = user?.sessionFields ?? []
|
||||
const save = useSaveExtraInfoMutation()
|
||||
const existing = useChatInitStore((s) => s.custom) // 기존 입력값(재진입 프리필)
|
||||
|
||||
const [values, setValues] = useState<Record<string, unknown>>({})
|
||||
const [inited, setInited] = useState(false)
|
||||
const [saved, setSaved] = useState(false)
|
||||
|
||||
// fields(회사 설정)와 기존값(sessions.custom)이 준비된 첫 시점에 프리필 — 이후 사용자 편집은 보존.
|
||||
useEffect(() => {
|
||||
if (inited || fields.length === 0) return
|
||||
const init: Record<string, unknown> = {}
|
||||
for (const f of fields) init[f.key] = existing?.[f.key] ?? (f.type === 'boolean' ? false : '')
|
||||
setValues(init)
|
||||
setInited(true)
|
||||
}, [inited, fields, existing])
|
||||
|
||||
if (fields.length === 0) return null
|
||||
|
||||
const set = (key: string, value: unknown) => setValues((v) => ({ ...v, [key]: value }))
|
||||
|
||||
const handleSave = () => {
|
||||
const custom: Record<string, unknown> = {}
|
||||
for (const f of fields) {
|
||||
const v = values[f.key]
|
||||
if (f.type === 'boolean') custom[f.key] = !!v
|
||||
else if (v !== '' && v != null) custom[f.key] = f.type === 'number' ? Number(v) : v
|
||||
}
|
||||
save.mutate(
|
||||
{ sessionId, request: { custom } },
|
||||
{
|
||||
onSuccess: () => {
|
||||
setSaved(true)
|
||||
toast.success('부가정보가 저장되었습니다.')
|
||||
},
|
||||
onError: (error) => toast.error(getApiErrorMessage(error, '부가정보 저장에 실패했습니다.')),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="w-full rounded-2xl border border-border bg-white p-5 shadow-sm">
|
||||
<div className="mb-3 flex items-center gap-2">
|
||||
<CheckCircle2 className="size-5 text-brand-600" />
|
||||
<h3 className="text-sm font-bold text-neutral-90">부가정보 입력</h3>
|
||||
</div>
|
||||
<p className="text-sm leading-relaxed text-neutral-70 break-keep">
|
||||
협상이 완료되었습니다. 아래 정보를 입력해 주세요. (저장 후에도 세션 목록에서 수정할 수 있습니다.)
|
||||
</p>
|
||||
|
||||
<div className="mt-4 space-y-4">
|
||||
{fields.map((f) => (
|
||||
<div key={f.key} className="space-y-1.5">
|
||||
<label className="block text-sm font-semibold text-neutral-80">{f.label}</label>
|
||||
{f.type === 'boolean' ? (
|
||||
<button
|
||||
type="button"
|
||||
role="switch"
|
||||
aria-checked={!!values[f.key]}
|
||||
onClick={() => set(f.key, !values[f.key])}
|
||||
disabled={saved}
|
||||
className={`relative inline-flex h-6 w-11 items-center rounded-full transition-colors disabled:opacity-50 ${
|
||||
values[f.key] ? 'bg-brand-600' : 'bg-neutral-30'
|
||||
}`}
|
||||
>
|
||||
<span
|
||||
className={`inline-block size-5 transform rounded-full bg-white shadow transition-transform ${
|
||||
values[f.key] ? 'translate-x-5' : 'translate-x-0.5'
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
) : (
|
||||
<input
|
||||
type={f.type === 'number' ? 'number' : 'text'}
|
||||
value={String(values[f.key] ?? '')}
|
||||
onChange={(e) => set(f.key, e.target.value)}
|
||||
disabled={saved}
|
||||
className="h-11 w-full rounded-xl border border-border bg-white px-3 text-sm outline-none focus:border-brand-600 focus:ring-1 focus:ring-brand-600 disabled:bg-neutral-10"
|
||||
placeholder={f.label}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleSave}
|
||||
disabled={save.isPending || saved}
|
||||
className="mt-4 h-11 w-full rounded-xl bg-brand-600 text-sm font-bold text-white transition-colors hover:bg-brand-700 disabled:opacity-50"
|
||||
>
|
||||
{saved ? '저장 완료' : save.isPending ? '저장 중…' : '부가정보 저장'}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -10,6 +10,7 @@ export function OtherReason({
|
||||
onChange,
|
||||
isError,
|
||||
disabled,
|
||||
onSubmit,
|
||||
}: {
|
||||
inputValue: string
|
||||
setInputValue: (value: string) => void
|
||||
@@ -18,6 +19,7 @@ export function OtherReason({
|
||||
onChange: (value: string) => void
|
||||
isError: boolean
|
||||
disabled?: boolean
|
||||
onSubmit?: () => void
|
||||
}) {
|
||||
const isChecked = selectedValue === '기타'
|
||||
const ref = useRef<HTMLTextAreaElement>(null)
|
||||
@@ -73,6 +75,13 @@ export function OtherReason({
|
||||
)}
|
||||
value={inputValue}
|
||||
onChange={(e) => setInputValue(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
// Enter=제출, Shift+Enter=줄바꿈. 한글 조합 중 Enter 는 무시.
|
||||
if (e.key === 'Enter' && !e.shiftKey && !e.nativeEvent.isComposing && onSubmit) {
|
||||
e.preventDefault()
|
||||
onSubmit()
|
||||
}
|
||||
}}
|
||||
placeholder="제시한 가격을 수용할 수 없는 이유를 작성해주세요."
|
||||
disabled={isTextareaDisabled}
|
||||
rows={1}
|
||||
|
||||
@@ -79,6 +79,7 @@ export function RejectCM() {
|
||||
)}
|
||||
value={price ? parseInt(price).toLocaleString() : ''}
|
||||
onChange={(e) => handlePriceChange(e.target.value)}
|
||||
onKeyDown={(e) => e.key === 'Enter' && !e.nativeEvent.isComposing && handleSubmit()}
|
||||
placeholder="0"
|
||||
disabled={isDisabled}
|
||||
/>
|
||||
|
||||
@@ -109,6 +109,7 @@ export function RejectRSP() {
|
||||
)}
|
||||
value={price ? parseInt(price).toLocaleString() : ''}
|
||||
onChange={(e) => handlePriceChange(e.target.value)}
|
||||
onKeyDown={(e) => e.key === 'Enter' && !e.nativeEvent.isComposing && handleSubmit()}
|
||||
placeholder="0"
|
||||
disabled={isDisabled}
|
||||
/>
|
||||
@@ -147,6 +148,7 @@ export function RejectRSP() {
|
||||
onChange={handleRadioChange}
|
||||
isError={!!radioErrorMessage}
|
||||
disabled={isDisabled}
|
||||
onSubmit={handleSubmit}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// 협상 절차 5단계 — NegoStep(사이드) · MobileStepBar(모바일 상단)가 공유.
|
||||
export const STEPS = [
|
||||
{ name: '서비스안내', desc: '협상 방식과 유의사항을 확인합니다.' },
|
||||
{ name: '담당자확인', desc: '협상 담당자 본인 여부를 확인합니다.' },
|
||||
{ name: '협상품목안내', desc: '대상 품목과 기준 단가를 확인합니다.' },
|
||||
{ name: '가격협상', desc: '공급 단가를 제안하고 조율합니다.' },
|
||||
{ name: '협상종료', desc: '최종 합의 후 결과를 확인합니다.' },
|
||||
]
|
||||
@@ -16,7 +16,12 @@ export function deriveUserButtonConfig(
|
||||
const options = last.next_input_type
|
||||
|
||||
if (last.chat_end) return { type: 'one-black', text: GO_TO_LIST_TEXT }
|
||||
if (mode === 'confirm') return { type: 'one-black', text: options?.[0] || '' }
|
||||
// 타결 요약이 뜬 뒤의 '동의' 단계 = 부가정보 입력 + 동의를 한 자리(액션바)에서 받는다.
|
||||
// (요약 이후 confirm 단계에만 적용 — 재견적의 투찰확정/정보수정 같은 선택 단계는 그대로 둔다.)
|
||||
const dealt = messages.some((m) => m.bot_chat_type === 'summaryRSP' || m.bot_chat_type === 'summaryCM')
|
||||
if (mode === 'confirm') {
|
||||
return dealt ? { type: 'extra-info', text: options?.[0] || '' } : { type: 'one-black', text: options?.[0] || '' }
|
||||
}
|
||||
if (mode === 'yes_no') return { type: 'black-white', textList: options || [] }
|
||||
if (mode === 'percent') return { type: 'percent' }
|
||||
if (mode === 'price') return { type: 'price', priceErrorMessage: priceErrorMessage || undefined }
|
||||
|
||||
@@ -53,6 +53,7 @@ export type UserButtonType =
|
||||
| 'percent'
|
||||
| 'three-black'
|
||||
| 'price'
|
||||
| 'extra-info'
|
||||
| 'loading'
|
||||
| ''
|
||||
|
||||
|
||||
@@ -78,6 +78,17 @@ export function ExtraInfoPopup({ target, onClose, onSubmit }: ExtraInfoPopupProp
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
) : f.type === 'select' ? (
|
||||
<select
|
||||
value={String(values[f.key] ?? '')}
|
||||
onChange={(e) => set(f.key, e.target.value)}
|
||||
className="h-11 w-full rounded-xl border border-border bg-white px-3 text-sm outline-none focus:border-brand-600 focus:ring-1 focus:ring-brand-600"
|
||||
>
|
||||
<option value="">선택</option>
|
||||
{(f.options ?? []).map((o) => (
|
||||
<option key={o} value={o}>{o}</option>
|
||||
))}
|
||||
</select>
|
||||
) : (
|
||||
<input
|
||||
type={f.type === 'number' ? 'number' : 'text'}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
import { X } from 'lucide-react'
|
||||
import { Modal } from '@/components'
|
||||
import { cn, interactive } from '@/lib'
|
||||
|
||||
// 공급사 포털 목록 화면 이용안내. 상태(진행)·결과(마감)·재협상 3파트로 최근 추가된 용어를 설명한다.
|
||||
// 헤더의 '이용안내' 버튼으로 여는 수동형 팝업. X·배경 클릭·ESC 로 닫는다.
|
||||
export function GuidePopup({ onClose }: { onClose: () => void }) {
|
||||
return (
|
||||
<Modal onClose={onClose}>
|
||||
<div className="m-4 flex max-h-[90vh] w-full max-w-[560px] flex-col overflow-y-auto rounded-2xl border border-border bg-white p-6 shadow-xl animate-scale-in sm:p-8">
|
||||
<div className="mb-5 flex items-start justify-between gap-4">
|
||||
<div>
|
||||
<h2 className="text-lg font-extrabold text-neutral-90">이용안내</h2>
|
||||
<p className="mt-1 text-[13px] text-neutral-60">협상 목록의 상태·결과·재협상을 안내합니다.</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
aria-label="닫기"
|
||||
onClick={onClose}
|
||||
className={cn('flex size-9 shrink-0 items-center justify-center rounded-full bg-neutral-10 text-neutral-70 hover:bg-neutral-20', interactive)}
|
||||
>
|
||||
<X size={18} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-6">
|
||||
<Section title="진행 상태" desc="협상 세션이 지금 어느 단계인지 — 내가 무엇을 할지 알려줍니다.">
|
||||
<Row badge="협상 대기" tone="wait" text="초청받은 협상. 입장해서 가격 협상을 시작하세요." />
|
||||
<Row badge="협상 중" tone="prog" text="가격을 조율하는 중입니다. 이어서 진행하세요." />
|
||||
<Row badge="협상 완료" tone="done" text="가격 제출을 마쳤습니다. 최종 결과는 견적 마감 후 아래 '결과'로 표시됩니다." />
|
||||
<Row badge="협상 미참여" tone="none" text="기한 내 참여하지 않아 종료된 건입니다." />
|
||||
<Row badge="협상 거절" tone="reject" text="내가 참여를 거절한 건입니다." />
|
||||
</Section>
|
||||
|
||||
<Section title="협상 결과" desc="견적이 마감된 뒤 정해지는 낙찰 결과입니다. 마감 전에는 표시되지 않습니다.">
|
||||
<Row badge="낙찰" tone="win" text="내가 낙찰되어 계약 대상이 된 건입니다." />
|
||||
<Row badge="미낙찰" tone="lost" text="다른 공급사가 낙찰되어 이번 계약에서는 제외된 건입니다." />
|
||||
<Row badge="결렬" tone="open" text="낙찰자 없이 마감된 건입니다. 조건이 바뀌었다면 재협상을 요청할 수 있습니다." />
|
||||
</Section>
|
||||
|
||||
<Section title="재협상 요청" desc="결렬(낙찰자 미정 마감) 건에 한해 가능합니다.">
|
||||
<p className="text-[13px] leading-relaxed text-neutral-70">
|
||||
결렬 건의 <b className="font-bold text-neutral-90">재협상 요청</b> 버튼으로 사유·희망가를 담아 요청하면,
|
||||
구매 담당자 검토 후 <b className="font-bold text-neutral-90">승인 시 다음 차수 협상</b>이 새로 열립니다.
|
||||
요청 상태(심사 중·승인·반려)는 목록에서 확인할 수 있습니다.
|
||||
</p>
|
||||
</Section>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="mt-7 h-11 w-full rounded-xl bg-brand-600 text-sm font-bold text-white transition-colors hover:bg-brand-700"
|
||||
>
|
||||
확인했어요
|
||||
</button>
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
function Section({ title, desc, children }: { title: string; desc: string; children: React.ReactNode }) {
|
||||
return (
|
||||
<section>
|
||||
<h3 className="text-sm font-extrabold text-neutral-90">{title}</h3>
|
||||
<p className="mb-3 mt-0.5 text-xs text-neutral-60">{desc}</p>
|
||||
<div className="flex flex-col gap-2.5">{children}</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
const TONE: Record<string, string> = {
|
||||
wait: 'bg-brand-light text-brand-700',
|
||||
prog: 'bg-[#FFF3E5] text-[#F5A623]',
|
||||
done: 'bg-[#EAFDF3] text-success',
|
||||
none: 'bg-neutral-20 text-neutral-60',
|
||||
reject: 'bg-[#FFEBEB] text-[#FF4D4F]',
|
||||
win: 'bg-[#EAFDF3] text-success',
|
||||
lost: 'bg-neutral-20 text-neutral-60',
|
||||
open: 'bg-[#FFF3E5] text-[#F5A623]',
|
||||
}
|
||||
|
||||
function Row({ badge, tone, text }: { badge: string; tone: string; text: string }) {
|
||||
return (
|
||||
<div className="flex items-start gap-2.5">
|
||||
<span className={cn('mt-0.5 inline-flex shrink-0 items-center rounded-full px-2.5 py-1 text-xs font-bold', TONE[tone])}>
|
||||
{badge}
|
||||
</span>
|
||||
<p className="text-[13px] leading-relaxed text-neutral-70">{text}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,54 +1,85 @@
|
||||
import { AlertTriangle, CheckCircle2, FileText, RefreshCw } from 'lucide-react'
|
||||
import type { ReactNode } from 'react'
|
||||
import { cn } from '@/lib'
|
||||
import { useSessionCounts, type KpiCount } from '@/features/list/hooks/useSessionCounts'
|
||||
|
||||
// key → 아이콘/색 스타일 (콕핏 카드)
|
||||
const STYLE: Record<string, { icon: typeof FileText; tile: string; iconColor: string; spin?: boolean }> = {
|
||||
created: { icon: FileText, tile: 'bg-brand-light', iconColor: 'text-brand-600' },
|
||||
progress: { icon: RefreshCw, tile: 'bg-sky-50', iconColor: 'text-sky-500', spin: true },
|
||||
done: { icon: CheckCircle2, tile: 'bg-emerald-50', iconColor: 'text-success' },
|
||||
rejected: { icon: AlertTriangle, tile: 'bg-red-50', iconColor: 'text-[#FF4D4F]' },
|
||||
}
|
||||
|
||||
// 목업(claude artifact) 그대로: 진행(내가 할 일=상태축) / 결과(마감 후=결과축) 두 묶음.
|
||||
// 모든 카드 동일 크기·높이 — 강조는 색·CTA 로만. 낙찰=초록, 결렬=amber(재협상 가능), 미낙찰=회색.
|
||||
interface KpiCardsProps {
|
||||
selectedStatus: string | null
|
||||
onSelect: (status: string) => void
|
||||
selectedResult: number | null
|
||||
onSelectStatus: (status: string) => void
|
||||
onSelectResult: (code: number) => void
|
||||
}
|
||||
|
||||
export function KpiCards({ selectedStatus, onSelect }: KpiCardsProps) {
|
||||
const counts = useSessionCounts()
|
||||
// key → 배지 점 색 / 숫자 색 / 카드 배경·테두리 / CTA.
|
||||
const STYLE: Record<string, { dot?: string; num: string; card?: string; cta?: string; ctaText?: string }> = {
|
||||
created: { num: 'text-brand-600' },
|
||||
progress: { num: 'text-neutral-90' },
|
||||
won: { dot: 'bg-success', num: 'text-success', card: 'border-success/40 bg-gradient-to-b from-emerald-50 to-white', cta: 'text-success', ctaText: '★ 계약 대상' },
|
||||
open: { dot: 'bg-warning', num: 'text-warning', card: 'border-warning/40', cta: 'text-warning', ctaText: '▲ 재협상 요청 가능' },
|
||||
lost: { dot: 'bg-neutral-50', num: 'text-neutral-70' },
|
||||
}
|
||||
|
||||
export function KpiCards({ selectedStatus, selectedResult, onSelectStatus, onSelectResult }: KpiCardsProps) {
|
||||
const { progress, result } = useSessionCounts()
|
||||
|
||||
const isActive = (c: KpiCount) =>
|
||||
c.kind === 'status' ? selectedStatus === c.statusLabel : selectedResult === c.resultCode
|
||||
const onClick = (c: KpiCount) =>
|
||||
c.kind === 'status' ? onSelectStatus(c.statusLabel!) : onSelectResult(c.resultCode!)
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-2 gap-3 sm:gap-4 lg:grid-cols-4">
|
||||
{counts.map((c) => (
|
||||
<Card key={c.key} data={c} active={selectedStatus === c.status} onClick={() => onSelect(c.status)} />
|
||||
))}
|
||||
<div className="grid gap-4 lg:grid-cols-[2fr_3fr]">
|
||||
<Cluster label="진행 · 내가 할 일" dot="bg-brand-600" cols="grid-cols-2">
|
||||
{progress.map((c) => (
|
||||
<Card key={c.key} data={c} active={isActive(c)} onClick={() => onClick(c)} />
|
||||
))}
|
||||
</Cluster>
|
||||
<Cluster label="결과 · 마감 후" dot="bg-success" cols="grid-cols-3">
|
||||
{result.map((c) => (
|
||||
<Card key={c.key} data={c} active={isActive(c)} onClick={() => onClick(c)} />
|
||||
))}
|
||||
</Cluster>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function Cluster({ label, dot, cols, children }: { label: string; dot: string; cols: string; children: ReactNode }) {
|
||||
return (
|
||||
<div>
|
||||
<div className="mb-2 flex items-center gap-1.5 px-0.5 text-[11px] font-extrabold uppercase tracking-wider text-neutral-60">
|
||||
<span className={cn('size-1.5 rounded-full', dot)} />
|
||||
{label}
|
||||
</div>
|
||||
<div className={cn('grid gap-2.5', cols)}>{children}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function Card({ data, active, onClick }: { data: KpiCount; active: boolean; onClick: () => void }) {
|
||||
const s = STYLE[data.key]
|
||||
const Icon = s.icon
|
||||
const s = STYLE[data.key] ?? STYLE.created
|
||||
const ctaText = s.ctaText ?? ' ' // 빈 카드도 CTA 줄 높이를 확보(nbsp) → 5개 카드 높이 완전 동일
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClick}
|
||||
className={cn(
|
||||
'flex items-center gap-3.5 rounded-2xl border bg-white p-4 text-left transition-all sm:p-5',
|
||||
'hover:shadow-md active:scale-[0.99]',
|
||||
active ? 'border-brand-600 ring-2 ring-brand-600/10 shadow-sm' : 'border-border shadow-sm',
|
||||
'flex h-full flex-col rounded-2xl border bg-white p-4 text-left shadow-sm transition-all hover:-translate-y-0.5 hover:shadow-md active:scale-[0.99]',
|
||||
s.card ?? 'border-border',
|
||||
// 오프셋 링이라 카드 배경색(낙찰 초록·결렬 amber)과 무관하게 선택이 또렷하게 보인다.
|
||||
active && 'ring-2 ring-brand-600 ring-offset-2 ring-offset-surface',
|
||||
)}
|
||||
>
|
||||
<div className={cn('flex size-10 shrink-0 items-center justify-center rounded-xl', s.tile)}>
|
||||
<Icon className={cn('size-5', s.iconColor, s.spin && 'animate-spin-slow')} />
|
||||
</div>
|
||||
<div className="min-w-0">
|
||||
<p className="truncate text-[11px] font-bold text-neutral-60">{data.label}</p>
|
||||
<p className="text-lg font-extrabold tabular-nums text-neutral-90">
|
||||
{data.isLoading ? '–' : data.count.toLocaleString()}
|
||||
<span className="ml-0.5 text-xs font-bold text-neutral-60">건</span>
|
||||
</p>
|
||||
</div>
|
||||
<p className="mb-2 flex items-center gap-1.5 whitespace-nowrap text-xs font-bold text-neutral-70">
|
||||
{s.dot && <span className={cn('size-1.5 rounded-full', s.dot)} />}
|
||||
{data.label}
|
||||
</p>
|
||||
<p className={cn('text-2xl font-extrabold tabular-nums', s.num)}>
|
||||
{data.isLoading ? '–' : data.count.toLocaleString()}
|
||||
<span className="ml-0.5 text-xs font-bold text-neutral-60">건</span>
|
||||
</p>
|
||||
{/* CTA 는 좁은 카드(모바일 3열)에서 nowrap 이면 넘치므로 단어 단위로만 줄바꿈 */}
|
||||
<p className={cn('mt-1.5 break-keep text-[11px] font-extrabold', s.cta)}>{ctaText}</p>
|
||||
</button>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import { X } from 'lucide-react'
|
||||
import { Modal } from '@/components'
|
||||
import { RENEGO_STATUS_LABEL } from '@/apis/negotiation/negotiation.type'
|
||||
import type { ListItem } from '../types'
|
||||
|
||||
export interface RenegotiationMemoPopupProps {
|
||||
target: ListItem
|
||||
onClose: () => void
|
||||
}
|
||||
|
||||
// 재협상 심사 결과의 담당자 메모 열람 팝업. 목록에는 상태 배지만 두고 메모 전문은 여기서 보여준다.
|
||||
export function RenegotiationMemoPopup({ target, onClose }: RenegotiationMemoPopupProps) {
|
||||
return (
|
||||
<Modal onClose={onClose}>
|
||||
<div className="w-full max-w-md overflow-hidden rounded-2xl border border-border bg-white shadow-xl animate-scale-in">
|
||||
<div className="flex items-center justify-between border-b border-border p-5">
|
||||
<div>
|
||||
<h3 className="text-base font-bold text-neutral-90">
|
||||
{RENEGO_STATUS_LABEL[target.renegotiationStatus] ?? '재협상 심사 결과'}
|
||||
</h3>
|
||||
<p className="mt-0.5 text-xs text-neutral-60">
|
||||
{target.qt_number} · {target.item_name}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
aria-label="닫기"
|
||||
className="flex size-8 items-center justify-center rounded-full text-neutral-60 hover:bg-neutral-10"
|
||||
>
|
||||
<X className="size-4" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="p-5">
|
||||
<p className="text-sm font-semibold text-neutral-80">담당자 메모</p>
|
||||
<p className="mt-1.5 max-h-64 overflow-y-auto whitespace-pre-wrap break-keep rounded-xl bg-neutral-10 p-3 text-sm leading-relaxed text-neutral-80">
|
||||
{target.renegotiationMemo}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="border-t border-border p-5">
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="w-full rounded-xl bg-brand-600 py-3 text-sm font-bold text-white shadow-sm transition-all hover:bg-brand-700 active:scale-[0.98]"
|
||||
>
|
||||
확인
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
import { useState } from 'react'
|
||||
import { X } from 'lucide-react'
|
||||
import { Modal } from '@/components'
|
||||
import type { ListItem } from '../types'
|
||||
|
||||
export interface RenegotiationPopupProps {
|
||||
target: ListItem
|
||||
onClose: () => void
|
||||
onSubmit: (reason: string, desiredPrice: number | null) => void
|
||||
}
|
||||
|
||||
// 재협상 요청 팝업. 결렬(낙찰자 미정) 건에만 열리며, 담당자 승인 시 다음 차수가 생성된다.
|
||||
// 사유는 자주 쓰는 것을 프리셋으로 두고, 직접 입력도 허용한다.
|
||||
const PRESETS = ['가격 조건 재검토', '재고·납기 확보', '단가 정정', '수량 조건 변경'] as const
|
||||
|
||||
export function RenegotiationPopup({ target, onClose, onSubmit }: RenegotiationPopupProps) {
|
||||
const [preset, setPreset] = useState<string>(PRESETS[0])
|
||||
const [custom, setCustom] = useState('')
|
||||
const [price, setPrice] = useState('')
|
||||
|
||||
const isDirect = preset === '직접 입력'
|
||||
const reason = isDirect ? custom.trim() : preset
|
||||
const canSubmit = reason.length > 0
|
||||
|
||||
const handleSubmit = () => {
|
||||
if (!canSubmit) return
|
||||
const parsed = Number(price.replace(/[^0-9]/g, ''))
|
||||
onSubmit(reason, parsed > 0 ? parsed : null)
|
||||
onClose()
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal onClose={onClose}>
|
||||
<div className="w-full max-w-md overflow-hidden rounded-2xl border border-border bg-white shadow-xl animate-scale-in">
|
||||
<div className="flex items-center justify-between border-b border-border p-5">
|
||||
<div>
|
||||
<h3 className="text-base font-bold text-neutral-90">재협상 요청</h3>
|
||||
<p className="mt-0.5 text-xs text-neutral-60">
|
||||
{target.qt_number} · {target.item_name}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
aria-label="닫기"
|
||||
className="flex size-8 items-center justify-center rounded-full text-neutral-60 hover:bg-neutral-10"
|
||||
>
|
||||
<X className="size-4" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4 p-5">
|
||||
<p className="rounded-xl bg-neutral-10 p-3 text-xs leading-relaxed text-neutral-70">
|
||||
이 건은 낙찰자 없이 마감되었습니다. 요청하면 구매 담당자가 검토 후 승인 시
|
||||
<b> 다시 협상할 기회</b>가 열립니다. 승인·반려 결과는 목록에서 확인할 수 있습니다.
|
||||
</p>
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<label className="block text-sm font-semibold text-neutral-80">요청 사유</label>
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{[...PRESETS, '직접 입력'].map((p) => (
|
||||
<button
|
||||
key={p}
|
||||
type="button"
|
||||
onClick={() => setPreset(p)}
|
||||
className={`rounded-lg border px-3 py-1.5 text-xs font-bold transition-all active:scale-[0.98] ${
|
||||
preset === p
|
||||
? 'border-brand-600 bg-brand-50 text-brand-700'
|
||||
: 'border-border text-neutral-70 hover:bg-neutral-10'
|
||||
}`}
|
||||
>
|
||||
{p}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
{isDirect && (
|
||||
<input
|
||||
value={custom}
|
||||
onChange={(e) => setCustom(e.target.value)}
|
||||
maxLength={255}
|
||||
placeholder="요청 사유를 입력해 주세요"
|
||||
className="mt-1.5 h-11 w-full rounded-xl border border-border bg-white px-3 text-sm outline-none focus:border-brand-600 focus:ring-1 focus:ring-brand-600"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<label className="block text-sm font-semibold text-neutral-80">
|
||||
희망 공급가 <span className="font-medium text-neutral-60">(선택)</span>
|
||||
</label>
|
||||
<input
|
||||
inputMode="numeric"
|
||||
value={price}
|
||||
onChange={(e) => setPrice(e.target.value)}
|
||||
placeholder="예: 14,500,000"
|
||||
className="h-11 w-full rounded-xl border border-border bg-white px-3 text-sm outline-none focus:border-brand-600 focus:ring-1 focus:ring-brand-600"
|
||||
/>
|
||||
<p className="text-xs text-neutral-60">담당자 검토 참고용입니다. 실제 가격은 재협상에서 다시 조율합니다.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2 border-t border-border p-5">
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="flex-1 rounded-xl border border-border py-3 text-sm font-bold text-neutral-70 transition-all hover:bg-neutral-10 active:scale-[0.98]"
|
||||
>
|
||||
취소
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleSubmit}
|
||||
disabled={!canSubmit}
|
||||
className="flex-[2] rounded-xl bg-brand-600 py-3 text-sm font-bold text-white shadow-sm transition-all hover:bg-brand-700 active:scale-[0.98] disabled:opacity-50"
|
||||
>
|
||||
요청 보내기
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -18,7 +18,7 @@ interface StatusTabsProps {
|
||||
|
||||
export function StatusTabs({ selected, onSelect }: StatusTabsProps) {
|
||||
return (
|
||||
<div className="flex flex-wrap items-center gap-1 rounded-xl bg-neutral-20 p-1">
|
||||
<div className="flex flex-wrap items-center gap-1">
|
||||
{TABS.map((t) => {
|
||||
const active = selected === t.value
|
||||
return (
|
||||
@@ -27,8 +27,8 @@ export function StatusTabs({ selected, onSelect }: StatusTabsProps) {
|
||||
type="button"
|
||||
onClick={() => onSelect(t.value)}
|
||||
className={cn(
|
||||
'rounded-lg px-3.5 py-1.5 text-[13px] font-bold transition-all active:scale-[0.98]',
|
||||
active ? 'bg-white text-neutral-90 shadow-sm' : 'text-neutral-60 hover:text-neutral-80',
|
||||
'whitespace-nowrap rounded-[10px] px-3 py-[7px] text-[13px] font-bold transition-all active:scale-[0.98]',
|
||||
active ? 'bg-brand-light text-brand-700' : 'text-neutral-60 hover:text-neutral-80',
|
||||
)}
|
||||
>
|
||||
{t.label}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Loader2 } from 'lucide-react'
|
||||
import { Loader2, MessageSquareText } from 'lucide-react'
|
||||
import { cn, formatKstDateTime } from '@/lib'
|
||||
import { RENEGO_STATUS_LABEL } from '@/apis/negotiation/negotiation.type'
|
||||
import type { ListItem } from '@/features/list/types'
|
||||
import { statusMeta } from '@/features/list/lib/status'
|
||||
import { statusMeta, RESULT_META } from '@/features/list/lib/status'
|
||||
|
||||
interface WorkspaceCardsProps {
|
||||
items: ListItem[]
|
||||
@@ -10,10 +11,12 @@ interface WorkspaceCardsProps {
|
||||
onEnter: (item: ListItem) => void
|
||||
onReject: (item: ListItem) => void
|
||||
onExtraInfo: (item: ListItem) => void
|
||||
onRenegotiate: (item: ListItem) => void
|
||||
onMemo: (item: ListItem) => void
|
||||
}
|
||||
|
||||
// 모바일(lg 미만) 협상 목록: 테이블 대신 카드 스택.
|
||||
export function WorkspaceCards({ items, isLoading, busyId, onEnter, onReject, onExtraInfo }: WorkspaceCardsProps) {
|
||||
export function WorkspaceCards({ items, isLoading, busyId, onEnter, onReject, onExtraInfo, onRenegotiate, onMemo }: WorkspaceCardsProps) {
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-16">
|
||||
@@ -28,7 +31,7 @@ export function WorkspaceCards({ items, isLoading, busyId, onEnter, onReject, on
|
||||
return (
|
||||
<div className="divide-y divide-border">
|
||||
{items.map((item) => (
|
||||
<Card key={item.session_id} item={item} busy={busyId === item.session_id} onEnter={onEnter} onReject={onReject} onExtraInfo={onExtraInfo} />
|
||||
<Card key={item.session_id} item={item} busy={busyId === item.session_id} onEnter={onEnter} onReject={onReject} onExtraInfo={onExtraInfo} onRenegotiate={onRenegotiate} onMemo={onMemo} />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
@@ -40,12 +43,16 @@ function Card({
|
||||
onEnter,
|
||||
onReject,
|
||||
onExtraInfo,
|
||||
onRenegotiate,
|
||||
onMemo,
|
||||
}: {
|
||||
item: ListItem
|
||||
busy: boolean
|
||||
onEnter: (item: ListItem) => void
|
||||
onReject: (item: ListItem) => void
|
||||
onExtraInfo: (item: ListItem) => void
|
||||
onRenegotiate: (item: ListItem) => void
|
||||
onMemo: (item: ListItem) => void
|
||||
}) {
|
||||
const meta = statusMeta(item.session_status)
|
||||
const canEnter = !['미참여', '협상거부'].includes(item.session_status)
|
||||
@@ -53,6 +60,8 @@ function Card({
|
||||
const isDone = item.session_status === '협상완료'
|
||||
const enterLabel = isDone ? '결과 보기' : '협상 입장'
|
||||
const hasExtra = item.custom && Object.keys(item.custom).length > 0
|
||||
// 재협상: 요청 가능하면 버튼, 이미 요청했으면 진행 상태를 보여준다.
|
||||
const renegoLabel = RENEGO_STATUS_LABEL[item.renegotiationStatus] ?? ''
|
||||
|
||||
return (
|
||||
<div className="p-4">
|
||||
@@ -67,10 +76,17 @@ function Card({
|
||||
{item.model_name && <span> · {item.model_name}</span>}
|
||||
</p>
|
||||
</div>
|
||||
<span className={cn('inline-flex shrink-0 items-center gap-1 rounded-full px-2.5 py-1 text-xs font-bold', meta.badge)}>
|
||||
<span className={cn('size-1.5 rounded-full', meta.dot)} />
|
||||
{meta.display}
|
||||
</span>
|
||||
<div className="flex shrink-0 items-center gap-1.5">
|
||||
{RESULT_META[item.result] && (
|
||||
<span className={cn('inline-flex items-center whitespace-nowrap rounded-full px-2 py-1 text-xs font-bold', RESULT_META[item.result].badge)}>
|
||||
{RESULT_META[item.result].label}
|
||||
</span>
|
||||
)}
|
||||
<span className={cn('inline-flex items-center gap-1 whitespace-nowrap rounded-full px-2.5 py-1 text-xs font-bold', meta.badge)}>
|
||||
<span className={cn('size-1.5 rounded-full', meta.dot)} />
|
||||
{meta.display}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-2.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-neutral-60">
|
||||
@@ -78,8 +94,36 @@ function Card({
|
||||
<span>마감 {formatKstDateTime(item.qt_end_time)}</span>
|
||||
</div>
|
||||
|
||||
{(canEnter || canReject || isDone) && (
|
||||
{renegoLabel &&
|
||||
(item.renegotiationMemo ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onMemo(item)}
|
||||
className="mt-2.5 flex w-full items-center justify-between rounded-xl bg-neutral-10 px-3 py-2 transition-all hover:bg-neutral-20 active:scale-[0.99]"
|
||||
>
|
||||
<span className="whitespace-nowrap text-xs font-bold text-neutral-80">{renegoLabel}</span>
|
||||
<span className="flex items-center gap-1 whitespace-nowrap text-[11px] text-neutral-60">
|
||||
담당자 메모
|
||||
<MessageSquareText className="size-3.5 text-neutral-50" />
|
||||
</span>
|
||||
</button>
|
||||
) : (
|
||||
<div className="mt-2.5 rounded-xl bg-neutral-10 px-3 py-2">
|
||||
<p className="text-xs font-bold text-neutral-80">{renegoLabel}</p>
|
||||
</div>
|
||||
))}
|
||||
|
||||
{(canEnter || canReject || isDone || item.renegotiable) && (
|
||||
<div className="mt-3 flex gap-2">
|
||||
{item.renegotiable && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onRenegotiate(item)}
|
||||
className="flex-1 rounded-lg border border-brand-600/40 py-2 text-xs font-bold text-brand-700 transition-all hover:bg-brand-50 active:scale-[0.98]"
|
||||
>
|
||||
재협상 요청
|
||||
</button>
|
||||
)}
|
||||
{isDone && (
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { type ReactNode } from 'react'
|
||||
import { Loader2 } from 'lucide-react'
|
||||
import { Loader2, MessageSquareText } from 'lucide-react'
|
||||
import { cn, formatKstDateTime } from '@/lib'
|
||||
import { RENEGO_STATUS_LABEL } from '@/apis/negotiation/negotiation.type'
|
||||
import type { ListItem } from '@/features/list/types'
|
||||
import { statusMeta } from '@/features/list/lib/status'
|
||||
import { statusMeta, RESULT_META } from '@/features/list/lib/status'
|
||||
|
||||
interface WorkspaceTableProps {
|
||||
items: ListItem[]
|
||||
@@ -11,22 +12,26 @@ interface WorkspaceTableProps {
|
||||
onEnter: (item: ListItem) => void
|
||||
onReject: (item: ListItem) => void
|
||||
onExtraInfo: (item: ListItem) => void
|
||||
onRenegotiate: (item: ListItem) => void
|
||||
onMemo: (item: ListItem) => void
|
||||
}
|
||||
|
||||
const HEAD = 'px-5 py-3.5 text-left text-[11px] font-bold uppercase tracking-wider text-neutral-60 whitespace-nowrap'
|
||||
// th 기본 정렬은 center — 정렬은 베이스에 넣지 않고 컬럼마다 명시한다(cn 이 tailwind-merge 가 아니라 충돌 시 승자가 불명확).
|
||||
const HEAD = 'px-5 py-3.5 text-[11px] font-bold uppercase tracking-wider text-neutral-60 whitespace-nowrap'
|
||||
const CELL = 'px-5 py-4 align-middle text-sm text-neutral-80'
|
||||
|
||||
export function WorkspaceTable({ items, isLoading, busyId, onEnter, onReject, onExtraInfo }: WorkspaceTableProps) {
|
||||
export function WorkspaceTable({ items, isLoading, busyId, onEnter, onReject, onExtraInfo, onRenegotiate, onMemo }: WorkspaceTableProps) {
|
||||
return (
|
||||
<div className="w-full overflow-x-auto">
|
||||
<table className="w-full min-w-[900px] border-collapse">
|
||||
<thead>
|
||||
<tr className="border-b border-border bg-table-header">
|
||||
<th className={HEAD}>견적번호</th>
|
||||
<th className={HEAD}>상품</th>
|
||||
<th className={HEAD}>제조사</th>
|
||||
<th className={cn(HEAD, 'text-center')}>상태</th>
|
||||
<th className={HEAD}>마감일</th>
|
||||
<th className={cn(HEAD, 'text-left')}>견적번호</th>
|
||||
<th className={cn(HEAD, 'text-left')}>상품</th>
|
||||
<th className={cn(HEAD, 'text-left')}>제조사</th>
|
||||
<th className={cn(HEAD, 'text-right')}>상태</th>
|
||||
<th className={cn(HEAD, 'text-center')}>결과</th>
|
||||
<th className={cn(HEAD, 'text-left')}>마감일</th>
|
||||
<th className={cn(HEAD, 'text-right')}>액션</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -41,7 +46,7 @@ export function WorkspaceTable({ items, isLoading, busyId, onEnter, onReject, on
|
||||
</StateRow>
|
||||
) : (
|
||||
items.map((item) => (
|
||||
<Row key={item.session_id} item={item} busy={busyId === item.session_id} onEnter={onEnter} onReject={onReject} onExtraInfo={onExtraInfo} />
|
||||
<Row key={item.session_id} item={item} busy={busyId === item.session_id} onEnter={onEnter} onReject={onReject} onExtraInfo={onExtraInfo} onRenegotiate={onRenegotiate} onMemo={onMemo} />
|
||||
))
|
||||
)}
|
||||
</tbody>
|
||||
@@ -56,12 +61,16 @@ function Row({
|
||||
onEnter,
|
||||
onReject,
|
||||
onExtraInfo,
|
||||
onRenegotiate,
|
||||
onMemo,
|
||||
}: {
|
||||
item: ListItem
|
||||
busy: boolean
|
||||
onEnter: (item: ListItem) => void
|
||||
onReject: (item: ListItem) => void
|
||||
onExtraInfo: (item: ListItem) => void
|
||||
onRenegotiate: (item: ListItem) => void
|
||||
onMemo: (item: ListItem) => void
|
||||
}) {
|
||||
const meta = statusMeta(item.session_status)
|
||||
const canEnter = !['미참여', '협상거부'].includes(item.session_status)
|
||||
@@ -83,15 +92,50 @@ function Row({
|
||||
</p>
|
||||
</td>
|
||||
<td className={cn(CELL, 'whitespace-nowrap text-neutral-70')}>{item.maker_name || '-'}</td>
|
||||
<td className={cn(CELL, 'text-center')}>
|
||||
<span className={cn('inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-bold', meta.badge)}>
|
||||
<td className={cn(CELL, 'text-right')}>
|
||||
<span className={cn('inline-flex items-center gap-1 whitespace-nowrap rounded-full px-2.5 py-1 text-xs font-bold', meta.badge)}>
|
||||
<span className={cn('size-1.5 rounded-full', meta.dot)} />
|
||||
{meta.display}
|
||||
</span>
|
||||
</td>
|
||||
<td className={cn(CELL, 'text-center')}>
|
||||
{RESULT_META[item.result] ? (
|
||||
<span className={cn('inline-flex items-center whitespace-nowrap rounded-full px-2 py-1 text-xs font-bold', RESULT_META[item.result].badge)}>
|
||||
{RESULT_META[item.result].label}
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-xs text-neutral-40">–</span>
|
||||
)}
|
||||
</td>
|
||||
<td className={cn(CELL, 'whitespace-nowrap text-neutral-70')}>{formatKstDateTime(item.qt_end_time)}</td>
|
||||
<td className={CELL}>
|
||||
<div className="flex items-center justify-end gap-2">
|
||||
{/* 재협상: 요청 가능하면 버튼, 요청 이력이 있으면 상태 텍스트(담당자 메모 있으면 클릭 시 팝업) */}
|
||||
{item.renegotiable ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onRenegotiate(item)}
|
||||
className="rounded-lg border border-brand-600/40 px-3 py-1.5 text-xs font-bold text-brand-700 transition-all hover:bg-brand-50 active:scale-[0.98]"
|
||||
>
|
||||
재협상 요청
|
||||
</button>
|
||||
) : (
|
||||
RENEGO_STATUS_LABEL[item.renegotiationStatus] &&
|
||||
(item.renegotiationMemo ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onMemo(item)}
|
||||
className="inline-flex items-center gap-1.5 whitespace-nowrap rounded-lg bg-neutral-10 px-2.5 py-1.5 text-xs font-bold text-neutral-70 transition-all hover:bg-neutral-20 active:scale-[0.98]"
|
||||
>
|
||||
{RENEGO_STATUS_LABEL[item.renegotiationStatus]}
|
||||
<MessageSquareText className="size-3.5 text-neutral-50" />
|
||||
</button>
|
||||
) : (
|
||||
<span className="whitespace-nowrap rounded-lg bg-neutral-10 px-2.5 py-1.5 text-xs font-bold text-neutral-70">
|
||||
{RENEGO_STATUS_LABEL[item.renegotiationStatus]}
|
||||
</span>
|
||||
))
|
||||
)}
|
||||
{isDone && (
|
||||
<button
|
||||
type="button"
|
||||
@@ -120,9 +164,7 @@ function Row({
|
||||
{busy && <Loader2 className="size-3 animate-spin" />}
|
||||
{enterLabel}
|
||||
</button>
|
||||
) : (
|
||||
!canReject && <span className="text-xs text-neutral-50">–</span>
|
||||
)}
|
||||
) : null}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -132,7 +174,7 @@ function Row({
|
||||
function StateRow({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<tr>
|
||||
<td colSpan={6} className="py-20">
|
||||
<td colSpan={7} className="py-20">
|
||||
<div className="flex items-center justify-center">{children}</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
import { useState } from 'react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useNavigate } from 'react-router'
|
||||
import { useShallow } from 'zustand/react/shallow'
|
||||
import { Search } from 'lucide-react'
|
||||
import { getApiErrorMessage, useMeQuery, useParticipateMutation, useRejectMutation, useSaveExtraInfoMutation } from '@/apis'
|
||||
import { HelpCircle, Search } from 'lucide-react'
|
||||
import {
|
||||
getApiErrorMessage,
|
||||
useMeQuery,
|
||||
useParticipateMutation,
|
||||
useRejectMutation,
|
||||
useRequestRenegotiationMutation,
|
||||
useSaveExtraInfoMutation,
|
||||
} from '@/apis'
|
||||
import { cn, toast } from '@/lib'
|
||||
import { useList } from '@/features/list/hooks/useList'
|
||||
import { useListStore } from '@/features/list/stores/useListStore'
|
||||
@@ -13,6 +20,9 @@ import { WorkspaceCards } from '@/features/list/components/WorkspaceCards'
|
||||
import { Pagination } from '@/features/list/components/Pagination'
|
||||
import { RejectPopup } from '@/features/list/components/RejectPopup'
|
||||
import { ExtraInfoPopup } from '@/features/list/components/ExtraInfoPopup'
|
||||
import { RenegotiationPopup } from '@/features/list/components/RenegotiationPopup'
|
||||
import { RenegotiationMemoPopup } from '@/features/list/components/RenegotiationMemoPopup'
|
||||
import { GuidePopup } from '@/features/list/components/GuidePopup'
|
||||
import type { ListItem } from '@/features/list/types'
|
||||
|
||||
// 상태별 거부 불가 안내
|
||||
@@ -30,18 +40,30 @@ export function ListWorkspace() {
|
||||
const participate = useParticipateMutation()
|
||||
const reject = useRejectMutation()
|
||||
const saveExtra = useSaveExtraInfoMutation()
|
||||
const requestRenego = useRequestRenegotiationMutation()
|
||||
|
||||
const { selectedStatus, setStatus } = useListStore(
|
||||
const { selectedStatus, selectedResult, setStatus, toggleResult, setKeyword } = useListStore(
|
||||
useShallow((s) => ({
|
||||
selectedStatus: s.selectedStatus,
|
||||
selectedResult: s.selectedResult,
|
||||
setStatus: s.setStatus,
|
||||
toggleResult: s.toggleResult,
|
||||
setKeyword: s.setKeyword,
|
||||
})),
|
||||
)
|
||||
|
||||
// 입력은 즉시 반영하되, 서버 요청은 300ms 디바운스(타이핑마다 호출 방지). 변경 시 store 가 페이지를 1로 되돌린다.
|
||||
const [search, setSearch] = useState('')
|
||||
useEffect(() => {
|
||||
const id = setTimeout(() => setKeyword(search), 300)
|
||||
return () => clearTimeout(id)
|
||||
}, [search, setKeyword])
|
||||
const [enteringId, setEnteringId] = useState<string | null>(null)
|
||||
const [rejectTarget, setRejectTarget] = useState<ListItem | null>(null)
|
||||
const [extraTarget, setExtraTarget] = useState<ListItem | null>(null)
|
||||
const [renegoTarget, setRenegoTarget] = useState<ListItem | null>(null)
|
||||
const [memoTarget, setMemoTarget] = useState<ListItem | null>(null)
|
||||
const [guideOpen, setGuideOpen] = useState(false)
|
||||
|
||||
const handleEnter = (item: ListItem) => {
|
||||
setEnteringId(item.session_id)
|
||||
@@ -85,22 +107,46 @@ export function ListWorkspace() {
|
||||
)
|
||||
}
|
||||
|
||||
const handleRenegoSubmit = (reason: string, desiredPrice: number | null) => {
|
||||
if (!renegoTarget) return
|
||||
requestRenego.mutate(
|
||||
{ sessionId: renegoTarget.session_id, request: { reason, desired_price: desiredPrice } },
|
||||
{
|
||||
onSuccess: () => toast.success('재협상을 요청했습니다. 담당자 검토 후 결과가 목록에 표시됩니다.'),
|
||||
onError: (error) => toast.error(getApiErrorMessage(error, '재협상 요청에 실패했습니다.')),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-5">
|
||||
{/* 환영 배너 */}
|
||||
<div className="flex flex-wrap items-center justify-between gap-2 rounded-2xl border border-border bg-white px-5 py-4 shadow-[0_2px_12px_rgba(0,0,0,0.02)]">
|
||||
{/* 헤더 */}
|
||||
<div className="flex flex-wrap items-baseline justify-between gap-2">
|
||||
<div>
|
||||
<p className="text-[15px] font-bold text-neutral-90">
|
||||
{user?.supplierName ? `${user.supplierName} 담당자님, 환영합니다.` : '공급 파트너님, 환영합니다.'}
|
||||
</p>
|
||||
<p className="mt-0.5 text-xs text-neutral-60">
|
||||
진행 중인 협상 건을 확인하고 가격 협상에 참여해 주세요.
|
||||
<h1 className="text-xl font-extrabold tracking-tight text-neutral-90">협상 워크스페이스</h1>
|
||||
<p className="mt-0.5 text-[13px] text-neutral-60">
|
||||
{user?.supplierName ? `${user.supplierName} (공급 파트너)` : '공급 파트너'} · 진행/결과를 한눈에
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2.5">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setGuideOpen(true)}
|
||||
className="inline-flex items-center gap-1.5 rounded-lg border border-border bg-white px-3 py-1.5 text-[13px] font-bold text-neutral-70 transition-colors hover:bg-neutral-10"
|
||||
>
|
||||
<HelpCircle className="size-4 text-neutral-50" />
|
||||
이용안내
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* KPI 콕핏 */}
|
||||
<KpiCards selectedStatus={selectedStatus} onSelect={(s) => setStatus(selectedStatus === s ? null : s)} />
|
||||
{/* KPI 콕핏 — 진행/결과 두 묶음 */}
|
||||
<KpiCards
|
||||
selectedStatus={selectedStatus}
|
||||
selectedResult={selectedResult}
|
||||
onSelectStatus={(s) => setStatus(selectedStatus === s ? null : s)}
|
||||
onSelectResult={toggleResult}
|
||||
/>
|
||||
|
||||
{/* 워크스페이스 카드 */}
|
||||
<div className="overflow-hidden rounded-2xl border border-border bg-white shadow-sm">
|
||||
@@ -131,6 +177,8 @@ export function ListWorkspace() {
|
||||
onEnter={handleEnter}
|
||||
onReject={handleReject}
|
||||
onExtraInfo={setExtraTarget}
|
||||
onRenegotiate={setRenegoTarget}
|
||||
onMemo={setMemoTarget}
|
||||
/>
|
||||
</div>
|
||||
<div className="lg:hidden">
|
||||
@@ -141,6 +189,8 @@ export function ListWorkspace() {
|
||||
onEnter={handleEnter}
|
||||
onReject={handleReject}
|
||||
onExtraInfo={setExtraTarget}
|
||||
onRenegotiate={setRenegoTarget}
|
||||
onMemo={setMemoTarget}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -149,6 +199,8 @@ export function ListWorkspace() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{guideOpen && <GuidePopup onClose={() => setGuideOpen(false)} />}
|
||||
|
||||
{rejectTarget && (
|
||||
<RejectPopup onClose={() => setRejectTarget(null)} onSubmit={handleRejectSubmit} />
|
||||
)}
|
||||
@@ -156,6 +208,18 @@ export function ListWorkspace() {
|
||||
{extraTarget && (
|
||||
<ExtraInfoPopup target={extraTarget} onClose={() => setExtraTarget(null)} onSubmit={handleExtraSubmit} />
|
||||
)}
|
||||
|
||||
{renegoTarget && (
|
||||
<RenegotiationPopup
|
||||
target={renegoTarget}
|
||||
onClose={() => setRenegoTarget(null)}
|
||||
onSubmit={handleRenegoSubmit}
|
||||
/>
|
||||
)}
|
||||
|
||||
{memoTarget && (
|
||||
<RenegotiationMemoPopup target={memoTarget} onClose={() => setMemoTarget(null)} />
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -7,11 +7,13 @@ const PAGE_SIZE = 20
|
||||
|
||||
// 필터/정렬/페이지는 서버에 위임하고, 응답(정수 코드)을 화면용 라벨로 변환한다.
|
||||
export function useList() {
|
||||
const { selectedStatus, selectedDeadline, currentPage, setCurrentPage } = useListStore()
|
||||
const { selectedStatus, selectedDeadline, selectedResult, keyword, currentPage, setCurrentPage } = useListStore()
|
||||
|
||||
const query = useSessionListQuery({
|
||||
status: selectedStatus ? statusLabelToCode(selectedStatus) : undefined,
|
||||
order: selectedDeadline ? deadlineToOrder(selectedDeadline) : undefined,
|
||||
result: selectedResult ?? undefined,
|
||||
keyword: keyword.trim() || undefined,
|
||||
page: currentPage,
|
||||
page_size: PAGE_SIZE,
|
||||
})
|
||||
|
||||
@@ -1,35 +1,63 @@
|
||||
import { useQueries } from '@tanstack/react-query'
|
||||
import { negotiationApi, negotiationKeys, SessionStatus } from '@/apis'
|
||||
import { negotiationApi, negotiationKeys, SessionStatus, SessionResult } from '@/apis'
|
||||
|
||||
// KPI 콕핏에 노출할 상태별 집계. 각 상태를 page_size=1 로 조회해 total 만 읽는다(목록과 캐시 공유).
|
||||
// KPI 콕핏 집계. 진행(상태축)·결과(결과축) 두 묶음. 각 항목을 page_size=1 로 조회해 total 만 읽는다(목록과 캐시 공유).
|
||||
// 클릭 시 걸 필터가 상태냐 결과냐가 다르므로 kind 로 구분해 컨테이너가 올바른 setter 로 보낸다.
|
||||
export interface KpiCount {
|
||||
key: string
|
||||
label: string
|
||||
status: string // 클릭 시 필터에 넣을 원본 상태 라벨
|
||||
code: number
|
||||
kind: 'status' | 'result'
|
||||
statusLabel?: string // kind=status: 필터에 넣을 원본 상태 라벨
|
||||
resultCode?: number // kind=result: 필터에 넣을 SessionResult 코드
|
||||
count: number
|
||||
isLoading: boolean
|
||||
}
|
||||
|
||||
const KPI = [
|
||||
{ key: 'created', label: '협상 대기', status: '협상생성', code: SessionStatus.CREATED },
|
||||
{ key: 'progress', label: '조율 진행중', status: '협상중', code: SessionStatus.IN_PROGRESS },
|
||||
{ key: 'done', label: '타결 완료', status: '협상완료', code: SessionStatus.DONE },
|
||||
{ key: 'rejected', label: '거부/반려', status: '협상거부', code: SessionStatus.REJECTED },
|
||||
// 진행 묶음(내가 할 일) — 세션 상태축.
|
||||
const PROGRESS = [
|
||||
{ key: 'created', label: '협상 대기', statusLabel: '협상생성', code: SessionStatus.CREATED },
|
||||
{ key: 'progress', label: '협상 중', statusLabel: '협상중', code: SessionStatus.IN_PROGRESS },
|
||||
] as const
|
||||
|
||||
export function useSessionCounts(): KpiCount[] {
|
||||
const results = useQueries({
|
||||
queries: KPI.map((k) => ({
|
||||
// 결과 묶음(마감 후) — 결과축. 낙찰=주강조, 결렬=재협상 가능(액션).
|
||||
const RESULT = [
|
||||
{ key: 'won', label: '낙찰', code: SessionResult.WON },
|
||||
{ key: 'open', label: '결렬', code: SessionResult.OPEN },
|
||||
{ key: 'lost', label: '미낙찰', code: SessionResult.LOST },
|
||||
] as const
|
||||
|
||||
export function useSessionCounts(): { progress: KpiCount[]; result: KpiCount[] } {
|
||||
const statusQ = useQueries({
|
||||
queries: PROGRESS.map((k) => ({
|
||||
queryKey: negotiationKeys.sessionList({ status: k.code, page: 1, page_size: 1 }),
|
||||
queryFn: () => negotiationApi.getSessions({ status: k.code, page: 1, page_size: 1 }),
|
||||
staleTime: 60 * 1000,
|
||||
})),
|
||||
})
|
||||
const resultQ = useQueries({
|
||||
queries: RESULT.map((k) => ({
|
||||
queryKey: negotiationKeys.sessionList({ result: k.code, page: 1, page_size: 1 }),
|
||||
queryFn: () => negotiationApi.getSessions({ result: k.code, page: 1, page_size: 1 }),
|
||||
staleTime: 60 * 1000,
|
||||
})),
|
||||
})
|
||||
|
||||
return KPI.map((k, i) => ({
|
||||
...k,
|
||||
count: results[i].data?.total ?? 0,
|
||||
isLoading: results[i].isLoading,
|
||||
}))
|
||||
return {
|
||||
progress: PROGRESS.map((k, i) => ({
|
||||
key: k.key,
|
||||
label: k.label,
|
||||
kind: 'status',
|
||||
statusLabel: k.statusLabel,
|
||||
count: statusQ[i].data?.total ?? 0,
|
||||
isLoading: statusQ[i].isLoading,
|
||||
})),
|
||||
result: RESULT.map((k, i) => ({
|
||||
key: k.key,
|
||||
label: k.label,
|
||||
kind: 'result',
|
||||
resultCode: k.code,
|
||||
count: resultQ[i].data?.total ?? 0,
|
||||
isLoading: resultQ[i].isLoading,
|
||||
})),
|
||||
}
|
||||
}
|
||||
@@ -38,5 +38,9 @@ export function toListItem(api: SessionListItem): ListItem {
|
||||
model_name: api.model_name,
|
||||
maker_name: api.maker_name,
|
||||
custom: api.custom ?? {},
|
||||
renegotiable: api.renegotiable ?? false,
|
||||
renegotiationStatus: api.renegotiation_status ?? 0,
|
||||
renegotiationMemo: api.renegotiation_memo ?? '',
|
||||
result: api.result ?? 0,
|
||||
}
|
||||
}
|
||||
@@ -7,13 +7,21 @@ export interface StatusMeta {
|
||||
}
|
||||
|
||||
export const STATUS_META: Record<string, StatusMeta> = {
|
||||
협상생성: { display: '대기', badge: 'bg-brand-light text-brand-600', dot: 'bg-brand-600' },
|
||||
협상중: { display: '조율중', badge: 'bg-[#FFF3E5] text-[#F5A623]', dot: 'bg-[#F5A623]' },
|
||||
협상완료: { display: '타결', badge: 'bg-[#EAFDF3] text-success', dot: 'bg-success' },
|
||||
미참여: { display: '미참여', badge: 'bg-neutral-20 text-neutral-60', dot: 'bg-neutral-60' },
|
||||
협상거부: { display: '거부', badge: 'bg-[#FFEBEB] text-[#FF4D4F]', dot: 'bg-[#FF4D4F]' },
|
||||
협상생성: { display: '협상 대기', badge: 'bg-brand-light text-brand-600', dot: 'bg-brand-600' },
|
||||
협상중: { display: '협상 중', badge: 'bg-[#FFF3E5] text-[#F5A623]', dot: 'bg-[#F5A623]' },
|
||||
협상완료: { display: '협상 완료', badge: 'bg-[#EAFDF3] text-success', dot: 'bg-success' },
|
||||
미참여: { display: '협상 미참여', badge: 'bg-neutral-20 text-neutral-60', dot: 'bg-neutral-60' },
|
||||
협상거부: { display: '협상 거절', badge: 'bg-[#FFEBEB] text-[#FF4D4F]', dot: 'bg-[#FF4D4F]' },
|
||||
}
|
||||
|
||||
export function statusMeta(label: string): StatusMeta {
|
||||
return STATUS_META[label] ?? { display: label || '-', badge: 'bg-neutral-20 text-neutral-60', dot: 'bg-neutral-60' }
|
||||
}
|
||||
|
||||
// 협상 결과(SessionResult 코드) → 완료 건에 붙는 결과 배지. 0(미정)은 표시하지 않는다.
|
||||
// 결렬(3)은 재협상 요청 대상이라 눈에 띄게 노랑으로 둔다.
|
||||
export const RESULT_META: Record<number, { label: string; badge: string }> = {
|
||||
1: { label: '낙찰', badge: 'bg-[#EAFDF3] text-success' },
|
||||
2: { label: '미낙찰', badge: 'bg-neutral-20 text-neutral-60' },
|
||||
3: { label: '결렬', badge: 'bg-[#FFF3E5] text-[#F5A623]' },
|
||||
}
|
||||
@@ -4,6 +4,8 @@ interface ListState {
|
||||
selectedType: string | null
|
||||
selectedStatus: string | null
|
||||
selectedDeadline: string | null
|
||||
selectedResult: number | null // 결과 필터(SessionResult 코드). 상태와 별개 축이라 함께 걸린다
|
||||
keyword: string
|
||||
currentPage: number
|
||||
|
||||
toggleType: (item: string) => void
|
||||
@@ -11,6 +13,8 @@ interface ListState {
|
||||
toggleStatus: (item: string) => void
|
||||
setStatus: (item: string | null) => void
|
||||
toggleDeadline: (item: string) => void
|
||||
toggleResult: (code: number) => void
|
||||
setKeyword: (keyword: string) => void
|
||||
setCurrentPage: (page: number) => void
|
||||
resetFilters: () => void
|
||||
}
|
||||
@@ -21,17 +25,23 @@ export const useListStore = create<ListState>((set) => ({
|
||||
selectedType: null,
|
||||
selectedStatus: null,
|
||||
selectedDeadline: null,
|
||||
selectedResult: null,
|
||||
keyword: '',
|
||||
currentPage: 1,
|
||||
|
||||
toggleType: (item) =>
|
||||
set((s) => ({ selectedType: toggle(s.selectedType, item), currentPage: 1 })),
|
||||
setType: (item) => set({ selectedType: item, currentPage: 1 }),
|
||||
// 상태(진행)와 결과는 마감 전/후라 서로 배타적 — 한 축을 고르면 다른 축은 해제한다(동시 선택=거의 0건).
|
||||
toggleStatus: (item) =>
|
||||
set((s) => ({ selectedStatus: toggle(s.selectedStatus, item), currentPage: 1 })),
|
||||
setStatus: (item) => set({ selectedStatus: item, currentPage: 1 }),
|
||||
set((s) => ({ selectedStatus: toggle(s.selectedStatus, item), selectedResult: null, currentPage: 1 })),
|
||||
setStatus: (item) => set({ selectedStatus: item, selectedResult: null, currentPage: 1 }),
|
||||
toggleDeadline: (item) =>
|
||||
set((s) => ({ selectedDeadline: toggle(s.selectedDeadline, item), currentPage: 1 })),
|
||||
toggleResult: (code) =>
|
||||
set((s) => ({ selectedResult: s.selectedResult === code ? null : code, selectedStatus: null, currentPage: 1 })),
|
||||
setKeyword: (keyword) => set({ keyword, currentPage: 1 }),
|
||||
setCurrentPage: (page) => set({ currentPage: page }),
|
||||
resetFilters: () =>
|
||||
set({ selectedType: null, selectedStatus: null, selectedDeadline: null, currentPage: 1 }),
|
||||
set({ selectedType: null, selectedStatus: null, selectedDeadline: null, selectedResult: null, keyword: '', currentPage: 1 }),
|
||||
}))
|
||||
@@ -9,4 +9,8 @@ export type ListItem = {
|
||||
model_name: string
|
||||
maker_name: string
|
||||
custom: Record<string, unknown> // 협상완료 부가정보(입력값). 미입력이면 {}
|
||||
renegotiable: boolean // 재협상 요청 가능(서버 판정)
|
||||
renegotiationStatus: number // 0=없음 1=심사중 2=승인 3=반려 4=철회
|
||||
renegotiationMemo: string // 담당자 심사 메모(반려 사유)
|
||||
result: number // 협상 결과: 0=미정 1=낙찰 2=미낙찰 3=결렬(개찰)
|
||||
}
|
||||
Reference in new issue
Block a user