[feat] negodata: 견적 목표가 산정 개편 + 협상 초청메일 + 카드 사용구분
[견적·목표가] - 목표가 산정 KTC 기준 정비(MD 우선, 없으면 인터넷최저가·매입가·판매가 중 최저 / 신규는 인터넷최저가만) - 인터넷 평균 수수료 0.078 상수화(견적설정 컬럼 제거) - 앵커링가 세션 저장 + 목표가 클릭 시 산정내역 모달 - 재생성 시 목표가·앵커링가 재계산 없이 직전 값 상속(KTC) - MD 제시가·협력사 유형(유통·제조·총판·기타) 입력 [협상카드] - 사용 구분(공통/신규견적전용/재견적전용) [협상 진행] - 협력사 초청 메일 발송(일괄/개별·재발송, 발송상태 표시) [기타] - 견적상세 창 닫기 버그 수정, 불필요한 컬럼 주석 정리 - DB: 기존 DB는 postgres-init/04-alter.sql 적용 필요(자동 마이그레이션 없음) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
b42d084063
commit
019f3dbeac
51 files changed
+1263
-163
No files matched your search
@@ -1,9 +1,10 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { X, PlusSquare, ArrowRight, Loader2 } from 'lucide-react';
|
||||
import { useNavigate } from 'react-router';
|
||||
import { useGetSupplierLastType } from '@/api/generated/quotation/quotation';
|
||||
import { updateItem } from '@/api/generated/item/item';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
import { Typography, typographyVariants } from '@/components/ui/typography';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
import type { Product, Partner, QuotationSetting, NegotiationCard } from '../types';
|
||||
@@ -47,9 +48,7 @@ export function QuotationCreateModal({
|
||||
const [settingId, setSettingId] = useState(quotationSettings[0]?.qt_setting_id ?? '');
|
||||
const [selectedCardIds, setSelectedCardIds] = useState<string[]>([]);
|
||||
const [memo, setMemo] = useState('');
|
||||
const [mdPrice, setMdPrice] = useState(''); // MD 제시가(원). 비우면 미전송 → 서버가 마진식으로 목표가 산정
|
||||
const [purchaseInput, setPurchaseInput] = useState(''); // 재견적·재협상 매입가(상품 저장값 디폴트, 필수)
|
||||
const [sellingInput, setSellingInput] = useState(''); // 재견적·재협상 판매가(상품 저장값 디폴트, 선택)
|
||||
const [mdPrice, setMdPrice] = useState(''); // MD 제시가(원). 비우면 미전송 → 서버가 상품값으로 목표가 산정
|
||||
const [supplierType, setSupplierType] = useState(''); // 협력사 유형(SupplierType). 재견적 1:1 → 견적에 기록
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const typeOptions = QUOTATION_TYPE_OPTIONS;
|
||||
@@ -66,17 +65,19 @@ export function QuotationCreateModal({
|
||||
setSupplierType(prevSupplierType != null ? String(prevSupplierType) : '');
|
||||
}, [renegoSupplierId, prevSupplierType]);
|
||||
|
||||
// 재견적·재협상(RE)에서만 매입가/판매가 입력을 노출한다. 상품이 정해지면 그 상품 저장값으로 디폴트.
|
||||
const navigate = useNavigate();
|
||||
// 인터넷최저가·매입가·판매가는 상품 속성 — 모달에선 읽기전용으로만 보여주고, 수정은 상품 상세에서 한다.
|
||||
const selectedProduct = products.find((p) => p.id === productId);
|
||||
const isReType = type === QuotationType.RENEGO || type === QuotationType.REQUOTE;
|
||||
const showPrices = isReType && !!productId;
|
||||
// 상품/유형이 바뀌면 그 상품의 저장된 매입가·판매가로 입력칸을 채운다(이후 사용자가 고치면 유지).
|
||||
useEffect(() => {
|
||||
if (!isReType || !selectedProduct) return;
|
||||
setPurchaseInput(selectedProduct.purchase_price != null ? String(selectedProduct.purchase_price) : '');
|
||||
setSellingInput(selectedProduct.selling_price != null ? String(selectedProduct.selling_price) : '');
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [productId, isReType]);
|
||||
const internetLowest = selectedProduct?.internet_lowest_price ?? null;
|
||||
const purchase = selectedProduct?.purchase_price ?? null;
|
||||
const selling = selectedProduct?.selling_price ?? null;
|
||||
// 상품에 산정 후보가 있는지(인터넷=공통, 매입·판매=재 한정). 없으면 MD가가 유일한 후보 → 필수가 된다.
|
||||
const mdNum = Number(mdPrice) || 0;
|
||||
const hasItemCandidate = internetLowest != null || (isReType && (purchase != null || selling != null));
|
||||
const mdRequired = !!productId && !hasItemCandidate;
|
||||
// 목표가 산정 가능 여부: MD가가 있으면 무조건 OK. 없으면 상품 후보 중 하나라도 있어야.
|
||||
const targetReady = mdNum > 0 || hasItemCandidate;
|
||||
|
||||
if (!open) return null;
|
||||
|
||||
@@ -95,16 +96,10 @@ export function QuotationCreateModal({
|
||||
if (submitting) return;
|
||||
setSubmitting(true);
|
||||
try {
|
||||
// 재견적·재협상은 매입가 필수 — 입력된 매입가/판매가를 상품에 저장한 뒤 진행한다.
|
||||
if (showPrices) {
|
||||
if (!purchaseInput) {
|
||||
showToast('재견적·재협상은 매입가가 필수입니다.', 'error');
|
||||
return; // finally 에서 submitting 해제
|
||||
}
|
||||
await updateItem(productId, {
|
||||
purchase_price: Number(purchaseInput),
|
||||
selling_price: sellingInput ? Number(sellingInput) : undefined,
|
||||
});
|
||||
// 목표가 산정에 쓸 값이 없으면(MD가·상품 후보 전무) 생성 차단 — 서버 산정불가 에러 선제 방어.
|
||||
if (productId && !targetReady) {
|
||||
showToast('목표가 산정에 쓸 값이 없습니다 — MD 제시가를 입력하거나, 상품 상세에서 인터넷최저가·매입가를 채워주세요.', 'error');
|
||||
return; // finally 에서 submitting 해제
|
||||
}
|
||||
// 서버가 견적+세션 생성을 끝내고 응답할 때까지 기다린 뒤에 완료(닫기) 처리한다.
|
||||
const ok = await onCreate({
|
||||
@@ -235,9 +230,11 @@ export function QuotationCreateModal({
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{/* MD 제시가 — 신규·재 공통(입력 시 목표가로 사용) */}
|
||||
{/* MD 제시가 — 입력 시 목표가로 사용. 상품에 다른 후보가 없으면 유일 후보라 필수. */}
|
||||
<div className="space-y-1">
|
||||
<Typography as="label" variant="label">MD 제시가 (선택)</Typography>
|
||||
<Typography as="label" variant="label" className={mdRequired ? 'text-rose-500' : undefined}>
|
||||
MD 제시가 {mdRequired ? '(필수 — 다른 후보 없음)' : '(선택)'}
|
||||
</Typography>
|
||||
<Input
|
||||
id="wizard-md-price"
|
||||
type="number"
|
||||
@@ -245,37 +242,46 @@ export function QuotationCreateModal({
|
||||
className="text-xs"
|
||||
value={mdPrice}
|
||||
onChange={(e) => setMdPrice(e.target.value)}
|
||||
placeholder="입력 시 목표가로 사용 · 미입력 시 자동 산정"
|
||||
placeholder={mdRequired ? '상품에 산정값이 없어 MD가 입력이 필요합니다' : '입력 시 목표가로 사용 · 미입력 시 자동 산정'}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 재견적·재협상 — 매입가(필수)·판매가, 선택 상품의 저장값으로 디폴트 */}
|
||||
{showPrices && (
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<div className="space-y-1">
|
||||
<Typography as="label" variant="label" className="text-amber-600">매입가 (필수)</Typography>
|
||||
<Input
|
||||
id="wizard-purchase-price"
|
||||
type="number"
|
||||
min={0}
|
||||
className="text-xs"
|
||||
value={purchaseInput}
|
||||
onChange={(e) => setPurchaseInput(e.target.value)}
|
||||
placeholder="상품 저장값 · 비우면 진행 불가"
|
||||
/>
|
||||
{/* 목표가 산정 후보 — 상품 값(읽기전용). 신규=인터넷최저가, 재=+매입가·판매가. 수정은 상품 상세에서. */}
|
||||
{productId && (
|
||||
<div className="rounded border border-border bg-muted/20 p-3 space-y-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<Typography as="span" variant="label">
|
||||
목표가 산정 후보 <span className="text-muted-foreground font-normal">({isReType ? '재' : '신규'})</span>
|
||||
</Typography>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => navigate(`/products?detail=${productId}`)}
|
||||
className={cn(typographyVariants({ variant: 'link' }), 'text-[10px]')}
|
||||
>
|
||||
상품 상세에서 수정
|
||||
</button>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Typography as="label" variant="label">판매가 (선택)</Typography>
|
||||
<Input
|
||||
id="wizard-selling-price"
|
||||
type="number"
|
||||
min={0}
|
||||
className="text-xs"
|
||||
value={sellingInput}
|
||||
onChange={(e) => setSellingInput(e.target.value)}
|
||||
placeholder="상품 저장값 · 마진 상한 산정에 사용"
|
||||
/>
|
||||
<div className={`grid ${isReType ? 'grid-cols-3' : 'grid-cols-1'} gap-2`}>
|
||||
{[
|
||||
{ label: '인터넷 최저가', value: internetLowest, show: true },
|
||||
{ label: '매입가', value: purchase, show: isReType },
|
||||
{ label: '판매가', value: selling, show: isReType },
|
||||
]
|
||||
.filter((r) => r.show)
|
||||
.map((r) => (
|
||||
<div key={r.label} className="space-y-0.5">
|
||||
<Typography as="span" variant="label" className="text-muted-foreground">{r.label}</Typography>
|
||||
<Typography as="span" variant="small" className="font-mono block">
|
||||
{r.value != null ? `₩${Number(r.value).toLocaleString()}` : '-'}
|
||||
</Typography>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{!targetReady && (
|
||||
<Typography as="p" variant="small" className="text-rose-600 leading-snug">
|
||||
⚠ MD 제시가도 없고 상품에 산정할 값도 없습니다 — MD가를 입력하거나 위 ‘상품 상세에서 수정’으로 값을 채워야 목표가가 나옵니다.
|
||||
</Typography>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -438,8 +444,8 @@ export function QuotationCreateModal({
|
||||
type="button"
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
if (step === 1 && showPrices && !purchaseInput) {
|
||||
showToast('재견적·재협상은 매입가가 필수입니다.', 'error');
|
||||
if (step === 1 && productId && !targetReady) {
|
||||
showToast('목표가 산정에 쓸 값이 없습니다 — MD 제시가를 입력하거나 상품 상세에서 값을 채워주세요.', 'error');
|
||||
return;
|
||||
}
|
||||
setStep((prev) => prev + 1);
|
||||
|
||||
+7
-3
@@ -2,6 +2,8 @@ import type { ReactNode } from 'react';
|
||||
import { Link } from 'react-router';
|
||||
import { Package } from 'lucide-react';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { typographyVariants } from '@/components/ui/typography';
|
||||
import { InfoField } from './InfoField';
|
||||
import { QuotationStatusBadge } from './StatusPill';
|
||||
import type { QuotationData } from '@/api/generated/model/quotationData';
|
||||
@@ -62,7 +64,10 @@ export function DrawerHeaderCards({
|
||||
const productSpecRows = currentProduct
|
||||
? [
|
||||
{ label: '상품코드', value: currentProduct.code || '-' },
|
||||
{ label: '단가', value: currentProduct.price != null ? `₩${Number(currentProduct.price).toLocaleString()}` : '-' },
|
||||
{ label: '상품단가', value: currentProduct.price != null ? `₩${Number(currentProduct.price).toLocaleString()}` : '-' },
|
||||
{ label: '매입가', value: currentProduct.purchase_price != null ? `₩${Number(currentProduct.purchase_price).toLocaleString()}` : '-' },
|
||||
{ label: '판매가', value: currentProduct.selling_price != null ? `₩${Number(currentProduct.selling_price).toLocaleString()}` : '-' },
|
||||
{ label: '인터넷 최저가', value: currentProduct.internet_lowest_price != null ? `₩${Number(currentProduct.internet_lowest_price).toLocaleString()}` : '-' },
|
||||
{ label: '모델명', value: currentProduct.model_name || '-' },
|
||||
{ label: '규격', value: currentProduct.spec || '-' },
|
||||
{ label: '제조사', value: currentProduct.manufacturer || '-' },
|
||||
@@ -146,7 +151,7 @@ export function DrawerHeaderCards({
|
||||
<div className="flex-1 min-w-0">
|
||||
<Link
|
||||
to={`/products?detail=${currentProduct.id}`}
|
||||
className="text-foreground font-bold font-sans text-[12px] mb-2 truncate block hover:text-primary hover:underline"
|
||||
className={cn(typographyVariants({ variant: 'link' }), 'font-bold font-sans text-[12px] mb-2 truncate block')}
|
||||
title={`${currentProduct.name || ''} — 상품 상세로 이동`}
|
||||
>
|
||||
{currentProduct.name || '-'}
|
||||
@@ -182,7 +187,6 @@ export function DrawerHeaderCards({
|
||||
<InfoField
|
||||
label="카드 사용 횟수"
|
||||
value={selectedSettingObj.card_use_count}
|
||||
className="col-span-2 col-start-1"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
import { Link } from 'react-router';
|
||||
import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell } from '@/components/ui/table';
|
||||
import { typographyVariants } from '@/components/ui/typography';
|
||||
import { StatusPill } from './StatusPill';
|
||||
import { mapServerCardView } from '../../types';
|
||||
|
||||
@@ -26,7 +27,7 @@ export function QuotationCardsTab({ quotationCardViews }: { quotationCardViews:
|
||||
{qc.card_id ? (
|
||||
<Link
|
||||
to={`/cards?detail=${qc.card_id}`}
|
||||
className="hover:text-primary hover:underline"
|
||||
className={typographyVariants({ variant: 'link' })}
|
||||
title={`${qc.card_name} — 협상카드 상세로 이동`}
|
||||
>
|
||||
{qc.card_name}
|
||||
|
||||
+133
-26
@@ -1,6 +1,10 @@
|
||||
import { MessageSquare, ExternalLink, Copy } from 'lucide-react';
|
||||
import { useState } from 'react';
|
||||
import { MessageSquare, Copy, Mail, MailCheck, Send } from 'lucide-react';
|
||||
import { showToast } from '@/lib/notify';
|
||||
import { confirm } from '@/lib/confirm';
|
||||
import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell } from '@/components/ui/table';
|
||||
import { typographyVariants } from '@/components/ui/typography';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { StatusPill, sessionStatusTone } from './StatusPill';
|
||||
import { mapServerSessionView, sessionStatusLabel } from '../../types';
|
||||
|
||||
@@ -8,20 +12,95 @@ type SessionView = ReturnType<typeof mapServerSessionView>;
|
||||
|
||||
export function SessionsStatusTab({
|
||||
sessionViews,
|
||||
canNotify,
|
||||
onOpenChat,
|
||||
onShowTarget,
|
||||
onNotifyAll,
|
||||
onNotifyOne,
|
||||
}: {
|
||||
sessionViews: SessionView[];
|
||||
/** 초청 메일 발송 권한(견적 소유자만). false 면 발송 버튼 비활성. */
|
||||
canNotify: boolean;
|
||||
onOpenChat: (sessionId: string) => void;
|
||||
/** 목표가 셀 클릭 → 산정내역 모달. */
|
||||
onShowTarget: (sessionId: string) => void;
|
||||
/** 미발송 세션 전체에 초청 메일 발송. */
|
||||
onNotifyAll: () => Promise<void>;
|
||||
/** 한 세션(공급사)에 초청 메일 발송/재발송. */
|
||||
onNotifyOne: (sessionId: string) => Promise<void>;
|
||||
}) {
|
||||
const [sendingAll, setSendingAll] = useState(false);
|
||||
const [sendingId, setSendingId] = useState<string | null>(null);
|
||||
const unsentCount = sessionViews.filter((s) => !s.email_sent_at).length;
|
||||
|
||||
const handleAll = async () => {
|
||||
if (
|
||||
!(await confirm({
|
||||
title: '초청 메일 발송',
|
||||
description: `미발송 ${unsentCount}곳의 협력사에게 협상 초청 메일을 발송하시겠습니까?`,
|
||||
confirmText: '발송',
|
||||
}))
|
||||
)
|
||||
return;
|
||||
setSendingAll(true);
|
||||
try {
|
||||
await onNotifyAll();
|
||||
} finally {
|
||||
setSendingAll(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleOne = async (sessionId: string, supplierName: string, alreadySent: boolean) => {
|
||||
if (
|
||||
!(await confirm({
|
||||
title: alreadySent ? '초청 메일 재발송' : '초청 메일 발송',
|
||||
description: alreadySent
|
||||
? `[${supplierName}]에 협상 초청 메일을 재발송하시겠습니까?`
|
||||
: `[${supplierName}]에 협상 초청 메일을 발송하시겠습니까?`,
|
||||
confirmText: alreadySent ? '재발송' : '발송',
|
||||
}))
|
||||
)
|
||||
return;
|
||||
setSendingId(sessionId);
|
||||
try {
|
||||
await onNotifyOne(sessionId);
|
||||
} finally {
|
||||
setSendingId(null);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
{/* 초청 메일 발송 툴바 — 미발송분 일괄 발송. 개별 재발송은 행의 버튼으로. */}
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-xs text-muted-foreground">
|
||||
{unsentCount > 0 ? `미발송 ${unsentCount}건` : '모든 협력사에 초청 메일 발송 완료'}
|
||||
</span>
|
||||
<button
|
||||
onClick={handleAll}
|
||||
disabled={!canNotify || sendingAll || unsentCount === 0}
|
||||
title={
|
||||
!canNotify
|
||||
? '본인이 생성한 견적만 초청 메일을 발송할 수 있습니다.'
|
||||
: unsentCount === 0
|
||||
? '발송할 미발송 세션이 없습니다.'
|
||||
: '미발송 세션 전체에 초청 메일을 발송합니다.'
|
||||
}
|
||||
className="flex items-center gap-2 px-3 py-2 bg-primary text-primary-foreground text-xs font-bold rounded hover:opacity-95 cursor-pointer transition-colors disabled:opacity-30 disabled:cursor-not-allowed"
|
||||
>
|
||||
<Mail size={14} />
|
||||
<span>{sendingAll ? '발송 중…' : `초청 메일 발송${unsentCount > 0 ? ` (${unsentCount})` : ''}`}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="border border-border rounded-lg bg-card overflow-x-auto">
|
||||
<Table className="w-full text-left text-xs border-collapse font-mono min-w-[1250px]">
|
||||
<Table className="w-full text-left text-xs border-collapse font-mono min-w-[1350px]">
|
||||
<TableHeader className="bg-muted text-muted-foreground text-[10px] border-b border-border">
|
||||
<TableRow>
|
||||
<TableHead className="p-3 font-semibold">세션 ID</TableHead>
|
||||
<TableHead className="p-3 font-semibold font-sans">협력사</TableHead>
|
||||
<TableHead className="p-3 font-semibold font-sans">협상 URL</TableHead>
|
||||
<TableHead className="p-3 font-semibold text-center font-sans">초청메일</TableHead>
|
||||
<TableHead className="p-3 font-semibold font-sans">상품</TableHead>
|
||||
<TableHead className="p-3 font-semibold text-center font-sans">협상상태</TableHead>
|
||||
<TableHead className="p-3 font-semibold text-right">목표가</TableHead>
|
||||
@@ -36,7 +115,7 @@ export function SessionsStatusTab({
|
||||
<TableBody className="divide-y divide-border">
|
||||
{sessionViews.length === 0 && (
|
||||
<TableRow>
|
||||
<TableCell colSpan={12} className="p-12 text-center text-muted-foreground">
|
||||
<TableCell colSpan={13} className="p-12 text-center text-muted-foreground">
|
||||
참여 중인 협상 세션이 없습니다. (리스트가 비어 있습니다)
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
@@ -58,37 +137,65 @@ export function SessionsStatusTab({
|
||||
</TableCell>
|
||||
<TableCell className="p-3 font-mono">
|
||||
{sess.url ? (
|
||||
<div className="flex items-center gap-1.5">
|
||||
<a
|
||||
href={sess.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
title={sess.url}
|
||||
className="inline-flex items-center gap-1 px-2 py-0.5 rounded bg-primary/10 text-primary hover:bg-primary/20 transition-colors text-[10px] font-semibold"
|
||||
>
|
||||
<ExternalLink size={11} /> 세션 열기
|
||||
</a>
|
||||
<button
|
||||
onClick={() => {
|
||||
void navigator.clipboard?.writeText(sess.url);
|
||||
showToast('협상 URL을 복사했습니다.', 'success');
|
||||
}}
|
||||
title="협상 URL 복사"
|
||||
className="p-1 hover:bg-muted rounded text-muted-foreground hover:text-foreground transition-colors cursor-pointer"
|
||||
>
|
||||
<Copy size={12} />
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => {
|
||||
void navigator.clipboard?.writeText(sess.url);
|
||||
showToast('협상 URL을 복사했습니다.', 'success');
|
||||
}}
|
||||
title="협상 URL 복사"
|
||||
className="p-1 hover:bg-muted rounded text-muted-foreground hover:text-foreground transition-colors cursor-pointer"
|
||||
>
|
||||
<Copy size={12} />
|
||||
</button>
|
||||
) : (
|
||||
<span className="text-muted-foreground">-</span>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell className="p-3 text-center font-sans">
|
||||
<div className="flex flex-col items-center gap-1">
|
||||
<div className="flex items-center gap-1.5">
|
||||
{sess.email_sent_at ? (
|
||||
<span className="inline-flex items-center gap-1 text-emerald-600 text-[10px] font-semibold">
|
||||
<MailCheck size={11} /> 발송됨
|
||||
</span>
|
||||
) : (
|
||||
<span className="inline-flex items-center gap-1 text-muted-foreground text-[10px] font-semibold">
|
||||
<Mail size={11} /> 미발송
|
||||
</span>
|
||||
)}
|
||||
<button
|
||||
onClick={() => handleOne(sess.session_id, sess.supplier_name, !!sess.email_sent_at)}
|
||||
disabled={!canNotify || sendingId === sess.session_id}
|
||||
title={
|
||||
!canNotify
|
||||
? '본인이 생성한 견적만 초청 메일을 발송할 수 있습니다.'
|
||||
: sess.email_sent_at
|
||||
? '이 협력사에게 초청 메일 재발송'
|
||||
: '이 협력사에게 초청 메일 발송'
|
||||
}
|
||||
className="p-1 rounded text-primary hover:bg-primary/10 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed"
|
||||
>
|
||||
<Send size={12} />
|
||||
</button>
|
||||
</div>
|
||||
{sess.email_sent_at && (
|
||||
<span className="text-muted-foreground text-[10px] font-mono">{sess.email_sent_at}</span>
|
||||
)}
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell className="p-3 font-semibold font-sans">{sess.item_name}</TableCell>
|
||||
<TableCell className="p-3 text-center">
|
||||
<StatusPill tone={sessionStatusTone(sess.status)}>{sessionStatusLabel(sess.status)}</StatusPill>
|
||||
</TableCell>
|
||||
<TableCell className="p-3 text-right font-bold text-muted-foreground">
|
||||
₩{sess.target_price?.toLocaleString() || '-'}
|
||||
<TableCell className="p-3 text-right">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onShowTarget(sess.session_id)}
|
||||
title="목표가 산정 내역 보기"
|
||||
className={cn(typographyVariants({ variant: 'link' }), 'font-bold')}
|
||||
>
|
||||
₩{sess.target_price?.toLocaleString() || '-'}
|
||||
</button>
|
||||
</TableCell>
|
||||
<TableCell className="p-3 text-right font-bold text-foreground">
|
||||
{sess.bid_price ? `₩${sess.bid_price.toLocaleString()}` : '-'}
|
||||
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
import { X, Check } from 'lucide-react';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
|
||||
// 세션 목표가 산정내역 모달. backend _calc_target_price 로직을 그대로 재구성해 후보·채택을 보여준다.
|
||||
// (신규견적은 인터넷최저가만 후보, 재는 매입가·판매가까지 / md 입력가 최우선. 앵커링은 설정 anchoring_value 고정율.)
|
||||
type TargetPriceModalProps = {
|
||||
onClose: () => void;
|
||||
qtNumber: string;
|
||||
itemName: string;
|
||||
vatYn?: boolean | null;
|
||||
deliveryFeeYn?: boolean | null;
|
||||
category?: string | null;
|
||||
supplierTypeLabel: string;
|
||||
targetPrice: number;
|
||||
anchoringPrice: number;
|
||||
mdPrice?: number | null;
|
||||
internetLowest?: number | null;
|
||||
purchase?: number | null;
|
||||
selling?: number | null;
|
||||
fee: number;
|
||||
margin: number;
|
||||
anchoringValue: number;
|
||||
isNew: boolean;
|
||||
};
|
||||
|
||||
const won = (n: number | null) => (n != null ? `₩${n.toLocaleString()}` : '-');
|
||||
|
||||
type CandKey = 'md' | 'net' | 'sell' | 'buy';
|
||||
|
||||
export function TargetPriceModal({
|
||||
onClose,
|
||||
qtNumber,
|
||||
itemName,
|
||||
vatYn,
|
||||
deliveryFeeYn,
|
||||
category,
|
||||
supplierTypeLabel,
|
||||
targetPrice,
|
||||
anchoringPrice,
|
||||
mdPrice,
|
||||
internetLowest,
|
||||
purchase,
|
||||
selling,
|
||||
fee,
|
||||
margin,
|
||||
anchoringValue,
|
||||
isNew,
|
||||
}: TargetPriceModalProps) {
|
||||
// 후보값 계산 (신규는 인터넷최저가만, 재는 매입가·판매가까지)
|
||||
const md = mdPrice && mdPrice > 0 ? Math.round(mdPrice) : null;
|
||||
const net = internetLowest && internetLowest > 0 ? Math.round(internetLowest * (1 - fee)) : null;
|
||||
const sell = !isNew && selling && selling > 0 ? Math.round(selling * (1 - margin)) : null;
|
||||
const buy = !isNew && purchase && purchase > 0 ? Math.round(purchase) : null;
|
||||
|
||||
// 채택 후보: md 최우선, 없으면 유효 후보 중 최소값
|
||||
let applied: CandKey | null = null;
|
||||
if (md != null) {
|
||||
applied = 'md';
|
||||
} else {
|
||||
const pool = ([['net', net], ['sell', sell], ['buy', buy]] as [CandKey, number | null][]).filter(
|
||||
(c): c is [CandKey, number] => c[1] != null,
|
||||
);
|
||||
if (pool.length) applied = pool.reduce((m, c) => (c[1] < m[1] ? c : m))[0];
|
||||
}
|
||||
|
||||
const rows: { key: CandKey; label: string; sub?: string; value: number | null }[] = [
|
||||
{ key: 'md', label: 'MD 입력가', value: md },
|
||||
{ key: 'net', label: '인터넷 최저가', sub: '인터넷 평균 수수료 적용', value: net },
|
||||
{ key: 'sell', label: '판매가', sub: '목표 마진율 적용', value: sell },
|
||||
{ key: 'buy', label: '매입가', value: buy },
|
||||
];
|
||||
|
||||
return (
|
||||
<div
|
||||
className="fixed inset-0 z-[60] flex items-center justify-center bg-black/40 backdrop-blur-xs"
|
||||
onClick={onClose}
|
||||
>
|
||||
<div
|
||||
className="w-full max-w-md bg-card border border-border rounded-lg shadow-2xl p-6 font-mono text-xs animate-scale-up"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{/* 헤더 */}
|
||||
<div className="flex items-center justify-between pb-3 border-b border-border">
|
||||
<Typography variant="h3">목표가</Typography>
|
||||
<button onClick={onClose} className="p-1 rounded text-muted-foreground hover:bg-muted cursor-pointer">
|
||||
<X size={18} />
|
||||
</button>
|
||||
</div>
|
||||
<Typography as="p" variant="small" className="text-[11px] text-muted-foreground mt-3">
|
||||
견적번호: {qtNumber} · 상품: {itemName}
|
||||
</Typography>
|
||||
<Typography as="p" variant="small" className="text-[11px] font-semibold text-rose-500 mt-1">
|
||||
배송비: {deliveryFeeYn ? '배송비포함' : '배송비별도'} · 부가세: {vatYn ? 'VAT포함' : 'VAT별도'}
|
||||
</Typography>
|
||||
|
||||
{/* 목표가 */}
|
||||
<div className="flex items-center justify-between gap-3 mt-5">
|
||||
<Typography variant="label" className="font-bold">목표가</Typography>
|
||||
<div className="flex-1 text-right bg-muted/50 border border-border rounded px-3 py-2 font-bold text-base text-foreground">
|
||||
{won(targetPrice)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 선정방식 */}
|
||||
<div className="mt-4 bg-muted/40 border border-border rounded p-3 space-y-1">
|
||||
<Typography as="p" variant="small" className="font-bold text-foreground text-[11px]">목표가 선정방식</Typography>
|
||||
<Typography as="p" variant="small" className="text-[11px] text-muted-foreground">1. MD 입력값 존재 시, 최우선 적용</Typography>
|
||||
<Typography as="p" variant="small" className="text-[11px] text-muted-foreground">2. 다음 중 가장 작은 값 — 인터넷최저가×(1−수수료) | 매입가 | 판매가×(1−목표 마진율)</Typography>
|
||||
<Typography as="p" variant="small" className="text-[10px] text-muted-foreground">
|
||||
* 인터넷 평균 수수료: {fee} · 목표 마진율: {margin}{isNew ? ' · 신규견적이라 인터넷최저가만 적용' : ''}
|
||||
</Typography>
|
||||
</div>
|
||||
|
||||
{/* 후보 */}
|
||||
<div className="mt-4 space-y-2">
|
||||
{rows.map((r) => {
|
||||
const on = r.key === applied;
|
||||
return (
|
||||
<div key={r.key} className="flex items-center gap-2">
|
||||
<span className={`w-4 shrink-0 ${on ? 'text-emerald-600' : 'text-transparent'}`}>
|
||||
{on ? <Check size={14} /> : null}
|
||||
</span>
|
||||
<div className="flex-1">
|
||||
<Typography as="span" variant="small" className={`text-[11px] ${on ? 'font-bold text-foreground' : 'text-muted-foreground'}`}>
|
||||
{r.label}
|
||||
</Typography>
|
||||
{r.sub && (
|
||||
<Typography as="span" variant="small" className="text-[10px] text-muted-foreground ml-1">
|
||||
({r.sub})
|
||||
</Typography>
|
||||
)}
|
||||
</div>
|
||||
<div
|
||||
className={`text-right min-w-[96px] px-2 py-1 rounded border ${
|
||||
on
|
||||
? 'border-emerald-300 bg-emerald-50 dark:bg-emerald-950/20 font-bold text-foreground'
|
||||
: 'border-border bg-muted/30 text-muted-foreground'
|
||||
}`}
|
||||
>
|
||||
{won(r.value)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{/* 앵커링 (negodata: 설정 anchoring_value 고정율) */}
|
||||
<div className="mt-4 bg-muted/40 border border-border rounded p-3 space-y-1">
|
||||
<Typography as="p" variant="small" className="font-bold text-foreground text-[11px]">앵커링</Typography>
|
||||
{category && (
|
||||
<Typography as="p" variant="small" className="text-[11px] text-muted-foreground">서비스 카테고리: {category}</Typography>
|
||||
)}
|
||||
<Typography as="p" variant="small" className="text-[11px] text-muted-foreground">공급 업체 유형: {supplierTypeLabel}</Typography>
|
||||
<Typography as="p" variant="small" className="text-[11px] text-muted-foreground">앵커링 값: {anchoringValue}</Typography>
|
||||
<Typography as="p" variant="small" className="text-[11px] font-bold text-foreground">
|
||||
앵커링가: {won(anchoringPrice)} <span className="font-normal text-[10px] text-muted-foreground">= 목표가×(1−{anchoringValue})</span>
|
||||
</Typography>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import { useListSuppliers } from '@/api/generated/supplier/supplier';
|
||||
import { useListSettings } from '@/api/generated/quotation-setting/quotation-setting';
|
||||
import { useQuotationChain } from '../../hooks/useQuotationChain';
|
||||
import { useScrollLock } from '@/lib/useScrollLock';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import type { QuotationData } from '@/api/generated/model/quotationData';
|
||||
import {
|
||||
mapItem,
|
||||
@@ -18,12 +19,14 @@ import {
|
||||
mapSetting,
|
||||
mapServerSessionView,
|
||||
mapServerCardView,
|
||||
supplierTypeOptions,
|
||||
} from '../../types';
|
||||
import { QuotationStatus } from '@/api/generated/model';
|
||||
import { QuotationStatus, QuotationType } from '@/api/generated/model';
|
||||
import { DrawerHeaderCards } from './DrawerHeaderCards';
|
||||
import { RoundTimeline } from './RoundTimeline';
|
||||
import { RegenerateModal } from './RegenerateModal';
|
||||
import { SessionsStatusTab } from './SessionsStatusTab';
|
||||
import { TargetPriceModal } from './TargetPriceModal';
|
||||
import { QuotationCardsTab } from './QuotationCardsTab';
|
||||
import { ChatTab } from './ChatTab';
|
||||
|
||||
@@ -36,6 +39,10 @@ type QuotationDetailSheetProps = {
|
||||
onSwitchRound: (qtId: string) => void;
|
||||
/** 마감된 견적의 다음 라운드를 수동 생성(공급사 선택). 성공 시 새 qt_id 반환. */
|
||||
onRegenerate: (qtId: string, supplierIds: string[]) => Promise<string | null>;
|
||||
/** 협상 초청 메일 — 견적 단위(미발송 세션 전체) 발송. */
|
||||
onNotify: (qtId: string) => Promise<void>;
|
||||
/** 협상 초청 메일 — 세션(공급사) 단위 재발송. */
|
||||
onNotifySession: (sessionId: string, qtId: string) => Promise<void>;
|
||||
onClose: () => void;
|
||||
};
|
||||
|
||||
@@ -44,11 +51,14 @@ export function QuotationDetailSheet({
|
||||
onCloseQuotation,
|
||||
onSwitchRound,
|
||||
onRegenerate,
|
||||
onNotify,
|
||||
onNotifySession,
|
||||
onClose,
|
||||
}: QuotationDetailSheetProps) {
|
||||
const [activeTab, setActiveTab] = useState<DrawerTab>('status');
|
||||
const [showHeaderCards, setShowHeaderCards] = useState(true);
|
||||
const [regenOpen, setRegenOpen] = useState(false);
|
||||
const [targetSessionId, setTargetSessionId] = useState<string | null>(null);
|
||||
// 시트 열린 동안 뒤 견적 리스트(<main>) 스크롤 잠금 — 옆에 배경 스크롤바가 같이 뜨는 것 방지.
|
||||
useScrollLock();
|
||||
|
||||
@@ -60,6 +70,9 @@ export function QuotationDetailSheet({
|
||||
).map(mapSetting);
|
||||
|
||||
const qtId = quotation.qt_id ?? '';
|
||||
// 초청 메일 발송은 견적 소유자만. (백엔드 스코프 도입 전까지의 1차 차단 — 본인 견적 아니면 버튼 비활성)
|
||||
const myUserId = useAuthStore((s) => s.user?.userId);
|
||||
const canNotify = !!myUserId && quotation.user_id === myUserId;
|
||||
// 협상 세션·사용 카드는 견적 단위, 채팅은 선택 세션 단위로 서버에서 읽는다.
|
||||
// 세션은 협상 진행으로 계속 바뀌므로 탭 복귀 시 재조회한다. 카드는 생성 후 불변이라 끄둔다.
|
||||
const sessionsQuery = useGetQuotationSessions(qtId, {
|
||||
@@ -231,7 +244,14 @@ export function QuotationDetailSheet({
|
||||
{/* Tab content */}
|
||||
<div style={{ flex: '1 1 0%' }} className="min-h-0 p-6 overflow-y-auto bg-background/50">
|
||||
{activeTab === 'status' && (
|
||||
<SessionsStatusTab sessionViews={sessionViews} onOpenChat={goToChat} />
|
||||
<SessionsStatusTab
|
||||
sessionViews={sessionViews}
|
||||
canNotify={canNotify}
|
||||
onOpenChat={goToChat}
|
||||
onShowTarget={setTargetSessionId}
|
||||
onNotifyAll={() => onNotify(qtId)}
|
||||
onNotifyOne={(sessionId) => onNotifySession(sessionId, qtId)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{activeTab === 'cards' && <QuotationCardsTab quotationCardViews={quotationCardViews} />}
|
||||
@@ -251,6 +271,33 @@ export function QuotationDetailSheet({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{targetSessionId && currentItem && (() => {
|
||||
const ts = sessionViews.find((s) => s.session_id === targetSessionId);
|
||||
if (!ts) return null;
|
||||
const rawSetting = settingsQuery.data?.settings?.find((s) => s.qt_setting_id === quotation.qt_setting_id);
|
||||
return (
|
||||
<TargetPriceModal
|
||||
onClose={() => setTargetSessionId(null)}
|
||||
qtNumber={quotation.number ?? '-'}
|
||||
itemName={currentItem.name ?? ts.item_name ?? '-'}
|
||||
vatYn={currentItem.vat_yn}
|
||||
deliveryFeeYn={currentItem.delivery_fee_yn}
|
||||
category={currentItem.category}
|
||||
supplierTypeLabel={supplierTypeOptions.find((o) => o.value === quotation.supplier_type)?.label ?? '-'}
|
||||
targetPrice={ts.target_price}
|
||||
anchoringPrice={ts.target_anchoring_price}
|
||||
mdPrice={quotation.md_price}
|
||||
internetLowest={currentItem.internet_lowest_price}
|
||||
purchase={currentItem.purchase_price}
|
||||
selling={currentItem.selling_price}
|
||||
fee={0.078}
|
||||
margin={rawSetting?.target_margin_rate ?? 0}
|
||||
anchoringValue={rawSetting?.anchoring_value ?? 0}
|
||||
isNew={quotation.type === QuotationType.NEW_NEGO || quotation.type === QuotationType.NEW_QUOTE}
|
||||
/>
|
||||
);
|
||||
})()}
|
||||
|
||||
{regenOpen && (
|
||||
<RegenerateModal
|
||||
open
|
||||
|
||||
@@ -24,18 +24,16 @@ export function QuotationSettingsModal({
|
||||
}: QuotationSettingsModalProps) {
|
||||
const [targetMargin, setTargetMargin] = useState('');
|
||||
const [anchoringValue, setAnchoringValue] = useState('');
|
||||
const [internetFee, setInternetFee] = useState('7.8');
|
||||
const [cardUseCount, setCardUseCount] = useState('');
|
||||
|
||||
if (!open) return null;
|
||||
|
||||
const handleAdd = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
const ok = onAdd({ targetMargin, anchoringValue, internetFee, cardUseCount });
|
||||
const ok = onAdd({ targetMargin, anchoringValue, cardUseCount });
|
||||
if (ok) {
|
||||
setTargetMargin('');
|
||||
setAnchoringValue('');
|
||||
setInternetFee('7.8');
|
||||
setCardUseCount('');
|
||||
}
|
||||
};
|
||||
@@ -110,10 +108,6 @@ export function QuotationSettingsModal({
|
||||
<Typography as="label" variant="muted" className="text-[10px] font-semibold">앵커링 값</Typography>
|
||||
<Input type="number" step="0.01" value={anchoringValue} onChange={(e) => setAnchoringValue(e.target.value)} placeholder="예: 0.01" />
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Typography as="label" variant="muted" className="text-[10px] font-semibold">인터넷 수수료율 (%)</Typography>
|
||||
<Input type="number" step="0.1" value={internetFee} onChange={(e) => setInternetFee(e.target.value)} placeholder="예: 7.8" />
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Typography as="label" variant="muted" className="text-[10px] font-semibold">카드 사용 횟수</Typography>
|
||||
<Input type="number" step="1" value={cardUseCount} onChange={(e) => setCardUseCount(e.target.value)} placeholder="예: 3" />
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { type ReactNode } from 'react';
|
||||
import { Clock, Building2, Link2, CornerDownRight } from 'lucide-react';
|
||||
import { DataTable } from '@/components/ui/data-table';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
import { Typography, typographyVariants } from '@/components/ui/typography';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { useQuotationChain } from '../hooks/useQuotationChain';
|
||||
import {
|
||||
type Estimate,
|
||||
@@ -52,7 +53,7 @@ export function QuotationTable({ data, products, onOpenDetail, onFilterChain, fo
|
||||
const productName = product?.name ?? est.productName; // 목록에 없으면 서버 조인 상품명으로 폴백
|
||||
return (
|
||||
<div>
|
||||
<Typography as="span" variant="small" className="block text-sm font-bold text-foreground hover:underline cursor-pointer">
|
||||
<Typography as="span" variant="link" className="block text-sm font-bold">
|
||||
{est.title}
|
||||
</Typography>
|
||||
<Typography as="span" variant="small" className="mt-0.5 flex items-center gap-1.5 text-[10px] font-mono text-muted-foreground">
|
||||
@@ -77,7 +78,7 @@ export function QuotationTable({ data, products, onOpenDetail, onFilterChain, fo
|
||||
onFilterChain(est.number!);
|
||||
}}
|
||||
title="이 견적번호의 모든 차수만 보기"
|
||||
className="inline-flex items-center gap-1 hover:text-primary hover:underline cursor-pointer"
|
||||
className={cn(typographyVariants({ variant: 'link' }), 'inline-flex items-center gap-1')}
|
||||
>
|
||||
<Link2 size={11} className="opacity-60" />
|
||||
<Typography as="span" variant="small" className="text-xs text-inherit">{est.number}</Typography>
|
||||
|
||||
@@ -15,6 +15,8 @@ import {
|
||||
useCreateQuotation,
|
||||
useStopQuotation,
|
||||
useRegenerateQuotation,
|
||||
useNotifyQuotation,
|
||||
useNotifySession,
|
||||
getGetQuotationQueryKey,
|
||||
getGetQuotationSessionsQueryKey,
|
||||
} from '@/api/generated/quotation/quotation';
|
||||
@@ -43,7 +45,6 @@ export type CreateQuotationInput = {
|
||||
export type SettingInput = {
|
||||
targetMargin: string;
|
||||
anchoringValue: string;
|
||||
internetFee: string;
|
||||
cardUseCount: string;
|
||||
};
|
||||
|
||||
@@ -63,6 +64,8 @@ export function useQuotations(params: ListQuotationsParams) {
|
||||
const createQuotationMutation = useCreateQuotation();
|
||||
const stopQuotationMutation = useStopQuotation();
|
||||
const regenerateQuotationMutation = useRegenerateQuotation();
|
||||
const notifyQuotationMutation = useNotifyQuotation();
|
||||
const notifySessionMutation = useNotifySession();
|
||||
|
||||
// 파라미터별 목록 쿼리 키 전부 재조회(prefix 무효화).
|
||||
const invalidateQuotations = () =>
|
||||
@@ -119,14 +122,13 @@ export function useQuotations(params: ListQuotationsParams) {
|
||||
const addSetting = (input: SettingInput): boolean => {
|
||||
const marginPct = Number(String(input.targetMargin).replace('%', '').trim());
|
||||
const anchoring = Number(String(input.anchoringValue).trim());
|
||||
const feePct = Number(String(input.internetFee).replace('%', '').trim());
|
||||
const cardCount = parseInt(String(input.cardUseCount).replace(/[^0-9-]/g, ''), 10);
|
||||
if (!Number.isFinite(marginPct) || !Number.isFinite(anchoring) || !Number.isFinite(feePct) || !Number.isInteger(cardCount)) {
|
||||
showToast('목표 마진율·앵커링 값·수수료율·카드 사용 횟수를 숫자로 입력해야 합니다.', 'error');
|
||||
if (!Number.isFinite(marginPct) || !Number.isFinite(anchoring) || !Number.isInteger(cardCount)) {
|
||||
showToast('목표 마진율·앵커링 값·카드 사용 횟수를 숫자로 입력해야 합니다.', 'error');
|
||||
return false;
|
||||
}
|
||||
createSettingMutation.mutate(
|
||||
{ data: { target_margin_rate: marginPct / 100, anchoring_value: anchoring, internet_average_fee: feePct / 100, card_count: cardCount } },
|
||||
{ data: { target_margin_rate: marginPct / 100, anchoring_value: anchoring, card_count: cardCount } },
|
||||
{
|
||||
onSuccess: () => {
|
||||
invalidateSettings();
|
||||
@@ -236,6 +238,48 @@ export function useQuotations(params: ListQuotationsParams) {
|
||||
}
|
||||
};
|
||||
|
||||
// 협상 초청 메일 — 견적 단위(미발송 세션 전체) 발송. 발송 후 세션 재조회로 발송배지 갱신.
|
||||
const notifyQuotation = async (qtId: string): Promise<void> => {
|
||||
try {
|
||||
const res = await notifyQuotationMutation.mutateAsync({ qtId });
|
||||
if (!res?.result?.success) {
|
||||
const reason = res?.msg ?? res?.result?.desc ?? '서버 오류';
|
||||
showToast(`초청 메일 발송 실패: ${reason}`, 'error');
|
||||
return;
|
||||
}
|
||||
const sent = res.sent ?? 0;
|
||||
const parts = [`${sent}건 발송`];
|
||||
if (res.failed) parts.push(`${res.failed}건 실패`);
|
||||
if (res.skipped) parts.push(`${res.skipped}건 이메일없음`);
|
||||
showToast(`초청 메일 — ${parts.join(' · ')}`, sent > 0 ? 'success' : 'info');
|
||||
} catch {
|
||||
showToast('초청 메일 발송에 실패했습니다.', 'error');
|
||||
} finally {
|
||||
queryClient.invalidateQueries({ queryKey: getGetQuotationSessionsQueryKey(qtId) });
|
||||
}
|
||||
};
|
||||
|
||||
// 협상 초청 메일 — 세션(공급사) 단위 재발송. qtId 는 세션 목록 재조회용.
|
||||
const notifySession = async (sessionId: string, qtId: string): Promise<void> => {
|
||||
try {
|
||||
const res = await notifySessionMutation.mutateAsync({ sessionId });
|
||||
if (!res?.result?.success) {
|
||||
const reason = res?.msg ?? res?.result?.desc ?? '서버 오류';
|
||||
showToast(`재발송 실패: ${reason}`, 'error');
|
||||
} else if (res.skipped) {
|
||||
showToast('담당자 이메일이 없어 발송하지 못했습니다.', 'info');
|
||||
} else if (res.sent) {
|
||||
showToast('초청 메일을 재발송했습니다.', 'success');
|
||||
} else {
|
||||
showToast('초청 메일 발송에 실패했습니다.', 'error');
|
||||
}
|
||||
} catch {
|
||||
showToast('재발송에 실패했습니다.', 'error');
|
||||
} finally {
|
||||
queryClient.invalidateQueries({ queryKey: getGetQuotationSessionsQueryKey(qtId) });
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
products,
|
||||
partners,
|
||||
@@ -248,5 +292,7 @@ export function useQuotations(params: ListQuotationsParams) {
|
||||
deleteSetting,
|
||||
createQuotation,
|
||||
regenerateQuotation,
|
||||
notifyQuotation,
|
||||
notifySession,
|
||||
};
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import type { SessionData } from '@/api/generated/model/sessionData';
|
||||
import type { QuotationCardData } from '@/api/generated/model/quotationCardData';
|
||||
import { QuotationType, QuotationStatus, SessionStatus, CardType, SupplierType } from '@/api/generated/model';
|
||||
import { DELIVERY_TYPE_LABEL } from '@/lib/enumLabels';
|
||||
import { toMinPrice } from '@/features/products/types';
|
||||
import type { Product, Partner, NegotiationCard } from '@/types';
|
||||
|
||||
export type { Product, Partner, NegotiationCard } from '@/types';
|
||||
@@ -41,7 +40,7 @@ export interface QuotationSetting {
|
||||
// ── 서버 응답 → UI 모델 매퍼 ─────────────────────────────────────────────
|
||||
|
||||
export function mapItem(it: ItemData): Product {
|
||||
return { ...it, id: it.item_id, minPrice: toMinPrice(it.price), status: 'ACTIVE' } as Product;
|
||||
return { ...it, id: it.item_id, minPrice: it.internet_lowest_price ?? 0, status: 'ACTIVE' } as Product;
|
||||
}
|
||||
|
||||
export function mapSupplier(sp: SupplierData): Partner {
|
||||
@@ -156,7 +155,7 @@ export const supplierTypeOptions: { value: number; label: string }[] = [
|
||||
{ value: SupplierType.DISTRIBUTION, label: '유통' },
|
||||
{ value: SupplierType.MANUFACTURE, label: '제조' },
|
||||
{ value: SupplierType.SOLE_AGENCY, label: '총판' },
|
||||
{ value: SupplierType.ETC, label: '없음' },
|
||||
{ value: SupplierType.NONE, label: '없음' },
|
||||
];
|
||||
|
||||
// ── 라운드 체인(같은 견적번호) ───────────────────────────────────────────
|
||||
@@ -198,6 +197,7 @@ export type SessionView = {
|
||||
item_name: string;
|
||||
status: number;
|
||||
target_price: number;
|
||||
target_anchoring_price: number;
|
||||
bid_price: number | null;
|
||||
bid_at: string;
|
||||
reject_reason: string | null;
|
||||
@@ -205,6 +205,7 @@ export type SessionView = {
|
||||
reject_delivery_type: string | null;
|
||||
end_time: string;
|
||||
url: string; // 세션 chat 실행 URL(공급사 협상 프론트)
|
||||
email_sent_at: string | null; // 초청 메일 발송 시각(KST). null=미발송 → 발송배지/재발송 판단
|
||||
};
|
||||
|
||||
export type QuotationCardView = {
|
||||
@@ -262,6 +263,7 @@ export function mapServerSessionView(sd: SessionData, partners: Partner[], produ
|
||||
item_name: product?.name || '-',
|
||||
status: sd.status,
|
||||
target_price: sd.target_price ?? 0,
|
||||
target_anchoring_price: sd.target_anchoring_price ?? 0,
|
||||
bid_price: sd.bid_price ?? null,
|
||||
bid_at: sd.bid_at ? fmtDateTime(sd.bid_at) : '-',
|
||||
reject_reason: sd.reject_reason ?? null,
|
||||
@@ -271,6 +273,7 @@ export function mapServerSessionView(sd: SessionData, partners: Partner[], produ
|
||||
: null,
|
||||
end_time: fmtDateTime(sd.end_time),
|
||||
url: sd.url || '',
|
||||
email_sent_at: sd.email_sent_at ? fmtDateTime(sd.email_sent_at) : null,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user