feat(WEB): 견적 상세 item_type 공통코드 표시 개선
- getItemTypeCodes API 호출로 공통코드 조회 - 하드코딩된 RM/SM/CS 대신 코드명 동적 표시
This commit is contained in:
@@ -30,6 +30,7 @@ import {
|
|||||||
} from "@/components/quotes";
|
} from "@/components/quotes";
|
||||||
import { getCompanyInfo } from "@/components/settings/CompanyInfoManagement/actions";
|
import { getCompanyInfo } from "@/components/settings/CompanyInfoManagement/actions";
|
||||||
import type { CompanyFormData } from "@/components/settings/CompanyInfoManagement/types";
|
import type { CompanyFormData } from "@/components/settings/CompanyInfoManagement/types";
|
||||||
|
import { getItemTypeCodes, type CommonCode } from "@/lib/api/common-codes";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
@@ -79,6 +80,9 @@ export default function QuoteDetailPage() {
|
|||||||
// BOM 자재 상세 펼침/접힘 상태
|
// BOM 자재 상세 펼침/접힘 상태
|
||||||
const [isBomExpanded, setIsBomExpanded] = useState(true);
|
const [isBomExpanded, setIsBomExpanded] = useState(true);
|
||||||
|
|
||||||
|
// 공통 코드 (item_type)
|
||||||
|
const [itemTypeCodes, setItemTypeCodes] = useState<CommonCode[]>([]);
|
||||||
|
|
||||||
// 견적 데이터 조회
|
// 견적 데이터 조회
|
||||||
const fetchQuote = useCallback(async () => {
|
const fetchQuote = useCallback(async () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
@@ -137,10 +141,26 @@ export default function QuoteDetailPage() {
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// 공통 코드 조회
|
||||||
|
const fetchItemTypeCodes = useCallback(async () => {
|
||||||
|
const result = await getItemTypeCodes();
|
||||||
|
if (result.success && result.data) {
|
||||||
|
setItemTypeCodes(result.data);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// item_type 코드 → 이름 변환 헬퍼
|
||||||
|
const getItemTypeLabel = useCallback((code: string | undefined | null): string => {
|
||||||
|
if (!code) return '-';
|
||||||
|
const found = itemTypeCodes.find(item => item.code === code);
|
||||||
|
return found?.name || code;
|
||||||
|
}, [itemTypeCodes]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchQuote();
|
fetchQuote();
|
||||||
fetchCompanyInfo();
|
fetchCompanyInfo();
|
||||||
}, [fetchQuote, fetchCompanyInfo]);
|
fetchItemTypeCodes();
|
||||||
|
}, [fetchQuote, fetchCompanyInfo, fetchItemTypeCodes]);
|
||||||
|
|
||||||
const handleBack = () => {
|
const handleBack = () => {
|
||||||
router.push("/sales/quote-management");
|
router.push("/sales/quote-management");
|
||||||
@@ -559,9 +579,7 @@ export default function QuoteDetailPage() {
|
|||||||
<td className="p-2">{material.itemName}</td>
|
<td className="p-2">{material.itemName}</td>
|
||||||
<td className="p-2">
|
<td className="p-2">
|
||||||
<Badge variant="outline" className="text-xs">
|
<Badge variant="outline" className="text-xs">
|
||||||
{material.itemType === 'RM' ? '원자재' :
|
{getItemTypeLabel(material.itemType)}
|
||||||
material.itemType === 'SM' ? '부자재' :
|
|
||||||
material.itemType === 'CS' ? '소모품' : material.itemType}
|
|
||||||
</Badge>
|
</Badge>
|
||||||
</td>
|
</td>
|
||||||
<td className="p-2 text-muted-foreground">{material.specification || '-'}</td>
|
<td className="p-2 text-muted-foreground">{material.specification || '-'}</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user