[feat] 공급사 포털: 협상완료 부가정보(select·종료 동의폼)·상태 라벨 통일·예아니오 Enter=예·목록 결과열·재협상 요청/철회 API·테스트

This commit is contained in:
minaChoi committed 2026-07-24 14:18:52 +09:00
1 parent cfee6e89d0
commit d7c4e86f30
46 files changed
+1715 -270

No files matched your search

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