fix: [stocks] 재고생산 상세 보기에 수정/삭제 버튼 추가

- showEdit: true, showDelete: true 설정
- onDelete prop으로 IntegratedDetailTemplate 내장 삭제 다이얼로그 활용
- 불필요한 DeleteConfirmDialog, isDeleteDialogOpen, handleDelete 제거
This commit is contained in:
김보곤
2026-03-18 21:46:02 +09:00
parent b840ebba35
commit 2d915ee938

View File

@@ -24,7 +24,6 @@ import { toast } from 'sonner';
import { IntegratedDetailTemplate } from '@/components/templates/IntegratedDetailTemplate';
import { FormSection } from '@/components/organisms/FormSection';
import { BadgeSm } from '@/components/atoms/BadgeSm';
import { DeleteConfirmDialog } from '@/components/ui/confirm-dialog';
import {
getStockOrderById,
getBendingCodeMap,
@@ -49,8 +48,8 @@ const stockDetailConfig: DetailConfig = {
fields: [],
actions: {
showBack: true,
showEdit: false,
showDelete: false,
showEdit: true,
showDelete: true,
backLabel: '목록',
},
};
@@ -95,7 +94,6 @@ export function StockProductionDetail({ orderId }: StockProductionDetailProps) {
const [order, setOrder] = useState<StockOrder | null>(null);
const [codeMap, setCodeMap] = useState<BendingCodeMap | null>(null);
const [loading, setLoading] = useState(true);
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
const [isProcessing, setIsProcessing] = useState(false);
// 데이터 로드
@@ -171,28 +169,6 @@ export function StockProductionDetail({ orderId }: StockProductionDetailProps) {
}
}, [order]);
// 삭제
const handleDelete = useCallback(async () => {
if (!order) return;
setIsProcessing(true);
try {
const result = await deleteStockOrder(order.id);
if (result.__authError) {
toast.error('인증이 만료되었습니다.');
return;
}
if (result.success) {
toast.success('재고생산이 삭제되었습니다.');
router.push(basePath);
} else {
toast.error(result.error || '삭제에 실패했습니다.');
}
} finally {
setIsProcessing(false);
setIsDeleteDialogOpen(false);
}
}, [order, router, basePath]);
// 헤더 액션 버튼
const headerActionItems = useMemo((): ActionItem[] => {
if (!order) return [];
@@ -343,18 +319,17 @@ export function StockProductionDetail({ orderId }: StockProductionDetailProps) {
itemId={orderId}
isLoading={loading}
onCancel={() => router.push(basePath)}
onDelete={async (id) => {
const result = await deleteStockOrder(String(id));
if (result.__authError) {
return { success: false, error: '인증이 만료되었습니다.' };
}
return { success: result.success, error: result.error };
}}
headerActions={null}
headerActionItems={headerActionItems}
renderView={(data) => renderViewContent(data as unknown as StockOrder)}
/>
<DeleteConfirmDialog
open={isDeleteDialogOpen}
onOpenChange={setIsDeleteDialogOpen}
onConfirm={handleDelete}
title="재고생산 삭제"
description="이 재고생산을 삭제하시겠습니까? 삭제된 데이터는 복구할 수 없습니다."
/>
</>
);
}