[feat] negodata/front: 협상대화 카드내용 렌더 + 견적상세 헤더·테이블 UI 정리
- 협상대화: 사용 카드 번호/멘트(Slate 서식본)/와일드 조건·메모 표시, SlateRenderer
밑줄·헥스색·{변수} 치환 보정, 말풍선 우측정렬·발신자 아바타 제거
- 견적상세 헤더: DB 컬럼명 라벨 제거, 견적정보/(진행상태+세팅)/상품(이미지) 2열 재배치,
협상카드 탭에 사용 카드 수 표시
- DataTable 행 패딩 축소, 협력사명 아바타 제거, 카드관리 본인 카드 안내문
- orval 재생성(QuotationCardData 신규 필드)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
df68609c49
commit
7186446068
114 files changed
+4731
-5537
No files matched your search
@@ -1,16 +1,18 @@
|
||||
import { useState } from 'react';
|
||||
import { Link } from 'react-router';
|
||||
import {
|
||||
StopCircle,
|
||||
X,
|
||||
UserCheck,
|
||||
MessageSquare,
|
||||
Layers,
|
||||
Info,
|
||||
Sparkles,
|
||||
Package,
|
||||
} from 'lucide-react';
|
||||
import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell } from '@/components/ui/table';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import SlateRenderer from '@/components/SlateRenderer';
|
||||
import {
|
||||
useGetQuotationSessions,
|
||||
useGetSessionChat,
|
||||
@@ -66,6 +68,24 @@ export function QuotationDetailDrawer({
|
||||
const currentSession = serverSessions.find((s) => s.session_id === effectiveSessionId);
|
||||
const currentSupplierName =
|
||||
partners.find((p) => p.id === currentSession?.supplier_id)?.name || currentSession?.supplier_id || '-';
|
||||
// 현재 세션의 상품(이미지·규격 등 상세 + 카드 변수 치환용 상품명).
|
||||
const currentProduct = products.find((p) => p.id === currentSession?.item_id);
|
||||
// 상품 상세 패널 행(negowiz 협상대화의 상품 정보 대응). negodata 컬럼명: maker_name→manufacturer, min_order_quantity→moq.
|
||||
const fmtYn = (b: boolean | null | undefined, yes: string, no: string) => (b == null ? '-' : b ? yes : no);
|
||||
const productSpecRows = currentProduct
|
||||
? [
|
||||
{ label: '상품코드', value: currentProduct.code || '-' },
|
||||
{ label: '단가', value: currentProduct.price != null ? `₩${Number(currentProduct.price).toLocaleString()}` : '-' },
|
||||
{ label: '모델명', value: currentProduct.model_name || '-' },
|
||||
{ label: '규격', value: currentProduct.spec || '-' },
|
||||
{ label: '제조사', value: currentProduct.manufacturer || '-' },
|
||||
{ label: '원산지', value: currentProduct.made_in || '-' },
|
||||
{ label: 'MOQ', value: currentProduct.moq || '-' },
|
||||
{ label: '리드타임', value: currentProduct.lead_time != null ? `${currentProduct.lead_time}일` : '-' },
|
||||
{ label: 'VAT', value: fmtYn(currentProduct.vat_yn, '포함', '별도') },
|
||||
{ label: '배송비', value: fmtYn(currentProduct.delivery_fee_yn, '포함', '별도') },
|
||||
]
|
||||
: [];
|
||||
|
||||
const selectedSettingObj = quotationSettings.find((qs) => qs.qt_setting_id === estimate.settingApplied);
|
||||
|
||||
@@ -93,7 +113,7 @@ export function QuotationDetailDrawer({
|
||||
const tabs: { id: DrawerTab; label: string; icon: typeof UserCheck }[] = [
|
||||
{ id: 'status', label: '협상 현황', icon: UserCheck },
|
||||
{ id: 'chat', label: '협상 대화', icon: MessageSquare },
|
||||
{ id: 'cards', label: '협상 카드', icon: Layers },
|
||||
{ id: 'cards', label: `협상 카드 (${serverCards.length})`, icon: Layers },
|
||||
];
|
||||
|
||||
return (
|
||||
@@ -117,7 +137,7 @@ export function QuotationDetailDrawer({
|
||||
onClick={() => setShowHeaderCards(!showHeaderCards)}
|
||||
className="flex items-center gap-1.5 px-2.5 py-1.5 bg-muted hover:bg-muted-foreground/15 text-foreground border border-border rounded text-xs font-semibold cursor-pointer transition-colors"
|
||||
>
|
||||
<span>{showHeaderCards ? '데이터베이스 매핑 정보 접기 ▲' : '데이터베이스 매핑 정보 펼치기 ▼'}</span>
|
||||
<span>{showHeaderCards ? '견적 상세 정보 접기 ▲' : '견적 상세 정보 펼치기 ▼'}</span>
|
||||
</button>
|
||||
{statusKey === '견적진행중' && (
|
||||
<button
|
||||
@@ -139,33 +159,35 @@ export function QuotationDetailDrawer({
|
||||
|
||||
{/* DB mapping info cards */}
|
||||
{showHeaderCards && (
|
||||
<div className="grid grid-cols-1 lg:grid-cols-3 gap-4 mt-4 text-xs font-mono">
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-4 mt-4 text-xs font-mono">
|
||||
{/* 좌측 컬럼: 견적정보 + 진행상태 */}
|
||||
<div className="space-y-4">
|
||||
{/* Quotations */}
|
||||
<div className="p-3 bg-card border border-border/80 rounded shadow-xs space-y-2">
|
||||
<span className="font-bold text-foreground text-[11px] border-b border-border pb-1 block font-sans">
|
||||
견적 정보 (quotations)
|
||||
견적 정보
|
||||
</span>
|
||||
<div className="grid grid-cols-2 gap-x-2 gap-y-1.5 font-mono text-muted-foreground">
|
||||
<div>
|
||||
<span className="text-[10px] block opacity-70">견적명 (name)</span>
|
||||
<span className="text-[10px] block opacity-70">견적명</span>
|
||||
<span className="text-foreground font-semibold font-sans">{q_name}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-[10px] block opacity-70">견적번호 (number)</span>
|
||||
<span className="text-[10px] block opacity-70">견적번호</span>
|
||||
<span className="text-foreground font-semibold">{q_number}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-[10px] block opacity-70">유형 (type)</span>
|
||||
<span className="text-[10px] block opacity-70">유형</span>
|
||||
<span className="text-foreground font-semibold">
|
||||
{q_type === 'RE_NEGOTIATION' ? '재협상 (RE_NEGOTIATION)' : '재견적 (RE_ESTIMATE)'}
|
||||
{q_type === 'RE_NEGOTIATION' ? '재협상' : '재견적'}
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-[10px] block opacity-70">차수 (round)</span>
|
||||
<span className="text-foreground font-semibold">{q_round}차 (round)</span>
|
||||
<span className="text-[10px] block opacity-70">차수</span>
|
||||
<span className="text-foreground font-semibold">{q_round}차</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-[10px] block opacity-90 font-bold mb-1">견적상태 (status)</span>
|
||||
<span className="text-[10px] block opacity-90 font-bold mb-1">견적상태</span>
|
||||
<span
|
||||
className={`inline-flex items-center gap-1.5 px-2.5 py-0.5 text-[11px] font-bold rounded-full border shadow-2xs ${
|
||||
statusKey === '견적생성'
|
||||
@@ -196,15 +218,15 @@ export function QuotationDetailDrawer({
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-[10px] block opacity-70">마감시각 (end_time)</span>
|
||||
<span className="text-[10px] block opacity-70">마감시각</span>
|
||||
<span className="text-foreground font-semibold">{q_end_time}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-[10px] block opacity-70">담당자 (manager_name)</span>
|
||||
<span className="text-[10px] block opacity-70">담당자</span>
|
||||
<span className="text-foreground font-semibold font-sans">{q_manager_name} ({q_manager_email})</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-[10px] block opacity-70">메모 (memo)</span>
|
||||
<span className="text-[10px] block opacity-70">메모</span>
|
||||
<span className="text-foreground font-semibold font-sans truncate block" title={q_memo || ''}>
|
||||
{q_memo}
|
||||
</span>
|
||||
@@ -215,69 +237,103 @@ export function QuotationDetailDrawer({
|
||||
{/* Bid Summary */}
|
||||
<div className="p-3 bg-card border border-border/80 rounded shadow-xs space-y-2">
|
||||
<span className="font-bold text-foreground text-[11px] border-b border-border pb-1 block font-sans">
|
||||
견적 진행상태/결과 (bid_summary)
|
||||
견적 진행상태/결과
|
||||
</span>
|
||||
<div className="grid grid-cols-2 gap-x-2 gap-y-1.5 font-mono text-muted-foreground">
|
||||
<div>
|
||||
<span className="text-[10px] block opacity-70">식별자 (bid_summary_id)</span>
|
||||
<span className="text-[10px] block opacity-70">식별자</span>
|
||||
<span className="text-foreground font-semibold">{bidSummaryObj.bid_summary_id}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-[10px] block opacity-70">진행/결과 상태 (status)</span>
|
||||
<span className="text-[10px] block opacity-70">진행/결과 상태</span>
|
||||
<span className="text-foreground font-semibold">{bidSummaryObj.status}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-[10px] block opacity-70">반복횟수 (qt_iteration)</span>
|
||||
<span className="text-foreground font-semibold">{bidSummaryObj.qt_iteration}회 (qt_iteration)</span>
|
||||
<span className="text-[10px] block opacity-70">반복횟수</span>
|
||||
<span className="text-foreground font-semibold">{bidSummaryObj.qt_iteration}회</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-[10px] block opacity-70">우선협상자 존재여부 (has_preferred)</span>
|
||||
<span className="text-[10px] block opacity-70">우선협상자 존재여부</span>
|
||||
<span className={`text-foreground font-semibold ${bidSummaryObj.has_preferred ? 'text-emerald-600 font-bold' : ''}`}>
|
||||
{bidSummaryObj.has_preferred ? '존재 (true)' : '미존재 (false)'}
|
||||
{bidSummaryObj.has_preferred ? '존재' : '미존재'}
|
||||
</span>
|
||||
</div>
|
||||
<div className="col-span-2">
|
||||
<span className="text-[10px] block opacity-70">우선협상자명 (preferred_sp_name)</span>
|
||||
<span className="text-[10px] block opacity-70">우선협상자명</span>
|
||||
<span className="text-foreground font-semibold font-sans">{bidSummaryObj.preferred_sp_name}</span>
|
||||
</div>
|
||||
<div className="col-span-2">
|
||||
<span className="text-[10px] block opacity-70">동가입찰정보 (equal_data)</span>
|
||||
<span className="text-[10px] block opacity-70">동가입찰정보</span>
|
||||
<code className="text-foreground font-semibold bg-muted/60 p-1 rounded text-[10px] block overflow-x-auto whitespace-pre">
|
||||
{bidSummaryObj.equal_data}
|
||||
</code>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 우측 컬럼: 상품정보 + 세팅 */}
|
||||
<div className="space-y-4">
|
||||
{/* 상품 정보 (협상 대상 상품) */}
|
||||
<div className="p-3 bg-card border border-border/80 rounded shadow-xs space-y-2">
|
||||
<span className="font-bold text-foreground text-[11px] border-b border-border pb-1 block font-sans">
|
||||
상품 정보
|
||||
</span>
|
||||
{currentProduct ? (
|
||||
<div className="flex gap-4">
|
||||
<div className="h-24 w-24 shrink-0 rounded-md border border-border bg-background overflow-hidden flex items-center justify-center">
|
||||
{currentProduct.image_url ? (
|
||||
<img
|
||||
src={currentProduct.image_url}
|
||||
alt={currentProduct.name || '상품'}
|
||||
className="h-full w-full object-cover"
|
||||
/>
|
||||
) : (
|
||||
<Package size={28} className="text-muted-foreground/50" />
|
||||
)}
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<Link
|
||||
to={`/products?edit=${currentProduct.id}`}
|
||||
className="text-foreground font-bold font-sans text-[12px] mb-2 truncate block hover:text-primary hover:underline"
|
||||
title={`${currentProduct.name || ''} — 상품 상세로 이동`}
|
||||
>
|
||||
{currentProduct.name || '-'}
|
||||
</Link>
|
||||
<div className="grid grid-cols-2 lg:grid-cols-3 gap-x-3 gap-y-1.5 font-mono text-muted-foreground">
|
||||
{productSpecRows.map((r) => (
|
||||
<div key={r.label}>
|
||||
<span className="text-[10px] block opacity-70">{r.label}</span>
|
||||
<span className="text-foreground font-semibold font-sans truncate block" title={r.value}>
|
||||
{r.value}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-muted-foreground py-6 text-center">상품 정보가 비어있습니다.</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Quotation Settings */}
|
||||
<div className="p-3 bg-card border border-border/80 rounded shadow-xs space-y-2">
|
||||
<span className="font-bold text-foreground text-[11px] border-b border-border pb-1 block font-sans">
|
||||
견적 세팅 (quotation_settings)
|
||||
견적 세팅
|
||||
</span>
|
||||
{selectedSettingObj ? (
|
||||
<div className="grid grid-cols-2 gap-x-2 gap-y-1.5 font-mono text-muted-foreground">
|
||||
<div>
|
||||
<span className="text-[10px] block opacity-70">세팅 아이디 (qt_setting_id)</span>
|
||||
<span className="text-foreground font-semibold text-[10px] truncate block" title={selectedSettingObj.qt_setting_id}>
|
||||
{selectedSettingObj.qt_setting_id}
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-[10px] block opacity-70">유저 아이디 (user_id)</span>
|
||||
<span className="text-foreground font-semibold text-[10px] truncate block" title={selectedSettingObj.user_id}>
|
||||
{selectedSettingObj.user_id}
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-[10px] block opacity-70">목표 마진율 (target_margin)</span>
|
||||
<span className="text-[10px] block opacity-70">목표 마진율</span>
|
||||
<span className="text-foreground font-bold text-emerald-600 dark:text-emerald-400 font-sans">{selectedSettingObj.target_margin}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-[10px] block opacity-70">앵커링 설정 값 (anchoring_value)</span>
|
||||
<span className="text-[10px] block opacity-70">앵커링 설정 값</span>
|
||||
<span className="text-foreground font-semibold font-sans">{selectedSettingObj.anchoring_value}</span>
|
||||
</div>
|
||||
<div className="col-span-2 col-start-1">
|
||||
<span className="text-[10px] block opacity-70">카드 사용 횟수 (card_use_count)</span>
|
||||
<span className="text-[10px] block opacity-70">카드 사용 횟수</span>
|
||||
<span className="text-foreground font-semibold">{selectedSettingObj.card_use_count}</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -285,6 +341,7 @@ export function QuotationDetailDrawer({
|
||||
<div className="text-muted-foreground py-6 text-center">적용된 견적 세팅이 비어있습니다.</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -299,8 +356,12 @@ export function QuotationDetailDrawer({
|
||||
key={tab.id}
|
||||
onClick={() => {
|
||||
setActiveTab(tab.id);
|
||||
if (tab.id === 'chat' && serverSessions.length > 0 && !selectedSessionId) {
|
||||
setSelectedSessionId(serverSessions[0].session_id);
|
||||
if (tab.id === 'chat') {
|
||||
// 협상 대화 탭에선 대화 영역을 넓게 쓰도록 견적 상세 정보를 접는다.
|
||||
setShowHeaderCards(false);
|
||||
if (serverSessions.length > 0 && !selectedSessionId) {
|
||||
setSelectedSessionId(serverSessions[0].session_id);
|
||||
}
|
||||
}
|
||||
}}
|
||||
className={`flex items-center gap-2 py-4 px-3 text-xs tracking-tight font-semibold border-b-2 transition-all cursor-pointer ${
|
||||
@@ -399,11 +460,6 @@ export function QuotationDetailDrawer({
|
||||
{/* Tab: Quotation Cards */}
|
||||
{activeTab === 'cards' && (
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center gap-2 p-3 bg-muted/40 rounded border border-border text-xs text-muted-foreground">
|
||||
<Info size={14} />
|
||||
<span>이 견적서에서 사용할 수 있는 협상카드 리스트입니다.</span>
|
||||
</div>
|
||||
|
||||
<div className="border border-border rounded-lg bg-card overflow-hidden">
|
||||
<Table className="w-full text-left text-xs border-collapse font-mono">
|
||||
<TableHeader className="bg-muted text-muted-foreground text-[10px] border-b border-border">
|
||||
@@ -418,7 +474,19 @@ export function QuotationDetailDrawer({
|
||||
quotationCardViews.map((qc) => (
|
||||
<TableRow key={qc.session_card_id} className="hover:bg-muted/30 transition-colors text-[11px]">
|
||||
<TableCell className="p-3 text-muted-foreground">{qc.session_card_id}</TableCell>
|
||||
<TableCell className="p-3 text-foreground font-sans font-semibold">{qc.card_name}</TableCell>
|
||||
<TableCell className="p-3 text-foreground font-sans font-semibold">
|
||||
{qc.card_id ? (
|
||||
<Link
|
||||
to={`/cards?edit=${qc.card_id}`}
|
||||
className="hover:text-primary hover:underline"
|
||||
title={`${qc.card_name} — 협상카드 상세로 이동`}
|
||||
>
|
||||
{qc.card_name}
|
||||
</Link>
|
||||
) : (
|
||||
qc.card_name
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell className="p-3">
|
||||
<span
|
||||
className={`inline-flex px-2 py-0.5 rounded text-[10px] font-bold ${
|
||||
@@ -501,7 +569,7 @@ export function QuotationDetailDrawer({
|
||||
<div className="flex-1 flex flex-col bg-background justify-between">
|
||||
<div className="p-3 bg-muted/30 border-b border-border text-xs flex items-center justify-between font-mono">
|
||||
<div className="text-muted-foreground">
|
||||
채널: <strong className="text-foreground">{currentSupplierName}</strong>
|
||||
협력사: <strong className="text-foreground">{currentSupplierName}</strong>
|
||||
</div>
|
||||
<div className="text-xs text-muted-foreground">
|
||||
기록: <span className="font-semibold text-foreground">{chatMessages.length}</span> 메시지
|
||||
@@ -511,7 +579,7 @@ export function QuotationDetailDrawer({
|
||||
<div className="flex-1 p-4 overflow-y-auto space-y-4">
|
||||
{!effectiveSessionId ? (
|
||||
<div className="h-full flex items-center justify-center text-muted-foreground font-mono text-xs">
|
||||
선택된 대화 채널이 없습니다.
|
||||
선택된 협력사가 없습니다.
|
||||
</div>
|
||||
) : chatMessages.length === 0 ? (
|
||||
<div className="h-full flex items-center justify-center text-muted-foreground font-mono text-xs">
|
||||
@@ -520,25 +588,20 @@ export function QuotationDetailDrawer({
|
||||
) : (
|
||||
chatMessages.map((m) => {
|
||||
const isBot = m.sender === 1;
|
||||
const cardName = m.card_used_yn
|
||||
? serverCards.find((c) => c.session_card_id === m.chat_id)?.name
|
||||
: null;
|
||||
// 메시지가 쓴 협상카드 전체(이름만이 아니라 멘트/조건/메모까지) 를 chat_id 로 매칭.
|
||||
const usedCard = m.card_used_yn
|
||||
? serverCards.find((c) => c.session_card_id === m.chat_id)
|
||||
: undefined;
|
||||
const cardNodes = Array.isArray(usedCard?.edit_script) ? (usedCard.edit_script as unknown[]) : null;
|
||||
const isWildCard = usedCard?.type === 2;
|
||||
return (
|
||||
<div
|
||||
key={m.chat_id}
|
||||
className={`flex items-start gap-2.5 max-w-[85%] ${isBot ? 'mr-auto' : 'ml-auto flex-row-reverse'}`}
|
||||
className={`flex ${isBot ? 'justify-start' : 'justify-end'}`}
|
||||
>
|
||||
<div
|
||||
className={`h-7 w-7 rounded-sm flex items-center justify-center text-[10px] font-bold uppercase ${
|
||||
isBot ? 'bg-secondary text-secondary-foreground border border-border' : 'bg-primary text-primary-foreground'
|
||||
}`}
|
||||
>
|
||||
{isBot ? 'BOT' : 'VN'}
|
||||
</div>
|
||||
|
||||
<div className="space-y-1">
|
||||
<div className="space-y-1 max-w-[85%]">
|
||||
<div className={`text-[10px] text-muted-foreground font-mono flex items-center gap-1.5 ${isBot ? '' : 'justify-end'}`}>
|
||||
<span>{isBot ? 'Negosium AI Bot' : currentSupplierName}</span>
|
||||
<span>{isBot ? 'Negosium Bot' : currentSupplierName}</span>
|
||||
<span>·</span>
|
||||
<span>#{m.index}</span>
|
||||
</div>
|
||||
@@ -549,13 +612,68 @@ export function QuotationDetailDrawer({
|
||||
}`}
|
||||
>
|
||||
<div className="font-bold">제시 단가 ₩{Number(m.target_price).toLocaleString()}</div>
|
||||
{cardName && (
|
||||
{usedCard && (
|
||||
<div
|
||||
className={`mt-1.5 inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-semibold ${
|
||||
isBot ? 'bg-amber-100 text-amber-800 dark:bg-amber-950/30 dark:text-amber-300' : 'bg-white/20'
|
||||
className={`mt-2 rounded border p-2 ${
|
||||
isBot
|
||||
? 'bg-amber-50/70 border-amber-200 dark:bg-amber-950/20 dark:border-amber-900/40'
|
||||
: 'bg-white/10 border-white/20'
|
||||
}`}
|
||||
>
|
||||
<Sparkles size={10} /> 협상카드: {cardName}
|
||||
{/* 헤더: 어떤 카드인지(번호·이름·종류) */}
|
||||
<div
|
||||
className={`flex items-center gap-1 text-[10px] font-semibold ${
|
||||
isBot ? 'text-amber-800 dark:text-amber-300' : 'text-primary-foreground'
|
||||
}`}
|
||||
>
|
||||
<Sparkles size={10} />
|
||||
<span>협상카드</span>
|
||||
{usedCard.number && <span className="font-mono opacity-70">#{usedCard.number}</span>}
|
||||
{usedCard.name && <span>· {usedCard.name}</span>}
|
||||
<span
|
||||
className={`ml-auto px-1.5 py-0.5 rounded font-bold ${
|
||||
isWildCard
|
||||
? 'bg-amber-200 text-amber-900 dark:bg-amber-400/25 dark:text-amber-100'
|
||||
: 'bg-zinc-200 text-zinc-700 dark:bg-zinc-600/40 dark:text-zinc-100'
|
||||
}`}
|
||||
>
|
||||
{isWildCard ? '와일드' : '협상'}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* 멘트 본문: 서식본(edit_script) 우선, 없으면 평문 script */}
|
||||
{cardNodes ? (
|
||||
<div className="mt-1.5">
|
||||
<SlateRenderer
|
||||
nodes={cardNodes}
|
||||
variables={{
|
||||
target_price: m.target_price,
|
||||
partner_name: currentSupplierName,
|
||||
product_name: currentProduct?.name ?? '',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
) : usedCard.script ? (
|
||||
<p className="mt-1.5 text-xs leading-relaxed whitespace-pre-line text-foreground/85">
|
||||
{usedCard.script}
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
{/* 와일드카드 부가 정보: 사용 조건 / 메모 */}
|
||||
{isWildCard && (usedCard.condition || usedCard.memo) && (
|
||||
<div className="mt-1.5 pt-1.5 border-t border-amber-200/60 dark:border-amber-900/40 space-y-0.5 text-[10px] text-muted-foreground">
|
||||
{usedCard.condition && (
|
||||
<div>
|
||||
<span className="font-semibold">조건:</span> {usedCard.condition}
|
||||
</div>
|
||||
)}
|
||||
{usedCard.memo && (
|
||||
<div>
|
||||
<span className="font-semibold">메모:</span> {usedCard.memo}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Eye, StopCircle, Clock, Building2 } from 'lucide-react';
|
||||
import { Clock, Building2 } from 'lucide-react';
|
||||
import { DataTable } from '@/components/ui/data-table';
|
||||
import { type Estimate, type Product, normalizeQuotationStatus } from '../types';
|
||||
|
||||
@@ -6,7 +6,6 @@ type QuotationTableProps = {
|
||||
data: Estimate[];
|
||||
products: Product[];
|
||||
onOpenDetail: (id: string) => void;
|
||||
onStop: (id: string, title: string) => void;
|
||||
};
|
||||
|
||||
const statusBadgeClass = (status?: string | null) => {
|
||||
@@ -24,7 +23,7 @@ const statusBadgeClass = (status?: string | null) => {
|
||||
}
|
||||
};
|
||||
|
||||
export function QuotationTable({ data, products, onOpenDetail, onStop }: QuotationTableProps) {
|
||||
export function QuotationTable({ data, products, onOpenDetail }: QuotationTableProps) {
|
||||
return (
|
||||
<DataTable
|
||||
data={data}
|
||||
@@ -102,37 +101,6 @@ export function QuotationTable({ data, products, onOpenDetail, onStop }: Quotati
|
||||
cellClassName: 'font-mono font-bold text-foreground',
|
||||
cell: (est) => `${est.participationCount}개사`,
|
||||
},
|
||||
{
|
||||
header: '관리',
|
||||
align: 'center',
|
||||
cell: (est) => (
|
||||
<div className="flex items-center justify-center gap-2">
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onOpenDetail(est.id ?? '');
|
||||
}}
|
||||
className="flex items-center gap-1 px-2.5 py-1 bg-muted hover:bg-muted-foreground/10 text-[11px] font-semibold border border-border rounded cursor-pointer transition-all"
|
||||
>
|
||||
<Eye size={12} />
|
||||
<span>상세 정보</span>
|
||||
</button>
|
||||
|
||||
{normalizeQuotationStatus(est.status) === '견적진행중' && (
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onStop(est.id ?? '', est.title ?? '');
|
||||
}}
|
||||
className="p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-950/20 rounded cursor-pointer"
|
||||
title="협상 절차 조기 강제중단"
|
||||
>
|
||||
<StopCircle size={14} />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -17,6 +17,7 @@ import type { QuotationSettingData } from '@/api/generated/model/quotationSettin
|
||||
import type { QuotationData } from '@/api/generated/model/quotationData';
|
||||
import type { CardData } from '@/api/generated/model/cardData';
|
||||
import { showToast } from '@/lib/notify';
|
||||
import { confirm } from '@/lib/confirm';
|
||||
import type { Estimate, ChatSession, Product } from '@/types';
|
||||
import { unwrap, mapItem, mapSupplier, mapSetting, mapQuotation } from '../types';
|
||||
|
||||
@@ -68,8 +69,8 @@ export function useQuotations() {
|
||||
const [chatSessions, setChatSessions] = useState<Record<string, ChatSession[]>>({});
|
||||
|
||||
// 협상 강제중단 → '협상보류'.
|
||||
const stopNegotiation = (id: string, name: string) => {
|
||||
if (!confirm(`현재 입찰 중인 [${name}] 단가 협상 절차를 즉시 조기 중단(강제종료)하시겠습니까?`)) return;
|
||||
const stopNegotiation = async (id: string, name: string) => {
|
||||
if (!(await confirm({ title: '협상 강제중단', description: `현재 입찰 중인 [${name}] 단가 협상 절차를 즉시 조기 중단(강제종료)하시겠습니까?`, confirmText: '중단', destructive: true }))) return;
|
||||
setQuotations((prev) => prev.map((e) => (e.id === id ? { ...e, status: '협상보류' } : e)));
|
||||
showToast("해당 협상이 관리자에 의하여 '협상보류' 상태로 지정되었습니다.", 'info');
|
||||
};
|
||||
@@ -101,12 +102,12 @@ export function useQuotations() {
|
||||
};
|
||||
|
||||
// 견적 세팅 삭제(서버 soft-delete, 최소 1개 유지).
|
||||
const deleteSetting = (id: string) => {
|
||||
const deleteSetting = async (id: string) => {
|
||||
if (quotationSettings.length <= 1) {
|
||||
showToast('최소 한 개의 세팅은 유지되어야 합니다.', 'error');
|
||||
return;
|
||||
}
|
||||
if (!confirm('선택한 견적 세팅을 삭제하시겠습니까?')) return;
|
||||
if (!(await confirm({ title: '견적 세팅 삭제', description: '선택한 견적 세팅을 삭제하시겠습니까?', confirmText: '삭제', destructive: true }))) return;
|
||||
deleteSettingMutation.mutate(
|
||||
{ qtSettingId: id },
|
||||
{
|
||||
|
||||
@@ -70,7 +70,7 @@ export function mapQuotation(q: QuotationData): Estimate {
|
||||
status: normalizeQuotationStatus(q.status) || String(q.status ?? ''),
|
||||
settingApplied: q.qt_setting_id, // 드로어 견적세팅 카드가 qt_setting_id 로 매칭
|
||||
dueDate: formatDueDate(q.end_time),
|
||||
participationCount: 0,
|
||||
participationCount: q.participation_count ?? 0,
|
||||
winnerPartnerId: q.preferred_sp_id ?? q.preferred_sp_name ?? null,
|
||||
isEqualPrice: !!q.equal_bid_yn,
|
||||
partnerIds: [],
|
||||
@@ -160,6 +160,7 @@ export type SessionView = {
|
||||
|
||||
export type QuotationCardView = {
|
||||
session_card_id: string;
|
||||
card_id: string | null; // 실제 카드 id(협상=nego_card_id, 와일드=wild_card_id) — /cards?edit= 링크용
|
||||
card_name: string;
|
||||
type: string;
|
||||
};
|
||||
@@ -295,6 +296,7 @@ export function mapServerSessionView(sd: SessionData, partners: Partner[], produ
|
||||
export function mapServerCardView(c: QuotationCardData): QuotationCardView {
|
||||
return {
|
||||
session_card_id: c.session_card_id,
|
||||
card_id: c.nego_card_id ?? c.wild_card_id ?? null,
|
||||
card_name: c.name || '-',
|
||||
type: c.type === 2 ? '와일드 카드' : '협상 카드',
|
||||
};
|
||||
@@ -306,6 +308,7 @@ export function buildQuotationCards(est: Estimate, cards: NegotiationCard[]): Qu
|
||||
const matchedCard = cards.find((c) => c.id === cId);
|
||||
return {
|
||||
session_card_id: `scard-${est.id}-${cId}`,
|
||||
card_id: cId,
|
||||
card_name: matchedCard?.title || '-',
|
||||
type: matchedCard?.isWildcard ? '와일드 카드' : '협상 카드',
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user