fix: [stocks] 재고생산 품목추가 버튼 제거
- ItemAddDialog 모달이 수주용 형식이라 재고생산과 불일치 - 품목은 재고생산 저장 시 자동으로 추가되므로 수동 추가 불필요 - 관련 import, state, handler 정리
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* 재고생산 등록/수정 폼
|
||||
*
|
||||
* - 생산사유, 목표재고수량, 메모, 비고
|
||||
* - 품목 내역 (ItemAddDialog 사용)
|
||||
* - 품목 내역 (자동 추가, 수동 추가 불가)
|
||||
* - IntegratedDetailTemplate + renderForm 패턴
|
||||
*/
|
||||
|
||||
@@ -24,11 +24,11 @@ import {
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from '@/components/ui/table';
|
||||
import { Package, Plus, Trash2, MessageSquare, ClipboardList } from 'lucide-react';
|
||||
import { Package, Trash2, MessageSquare, ClipboardList } from 'lucide-react';
|
||||
import { toast } from 'sonner';
|
||||
import { IntegratedDetailTemplate } from '@/components/templates/IntegratedDetailTemplate';
|
||||
import { FormSection } from '@/components/organisms/FormSection';
|
||||
import { ItemAddDialog, type OrderItem } from '@/components/orders/ItemAddDialog';
|
||||
import type { OrderItem } from '@/components/orders/ItemAddDialog';
|
||||
import { formatAmount } from '@/lib/utils/amount';
|
||||
import {
|
||||
createStockOrder,
|
||||
@@ -139,7 +139,6 @@ export function StockProductionForm({
|
||||
return INITIAL_FORM;
|
||||
});
|
||||
|
||||
const [isItemDialogOpen, setIsItemDialogOpen] = useState(false);
|
||||
const [fieldErrors, setFieldErrors] = useState<Record<string, string>>({});
|
||||
|
||||
// 필드 에러 초기화
|
||||
@@ -153,16 +152,6 @@ export function StockProductionForm({
|
||||
});
|
||||
}, []);
|
||||
|
||||
// 품목 추가
|
||||
const handleAddItem = useCallback((item: OrderItem) => {
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
items: [...prev.items, item],
|
||||
}));
|
||||
clearFieldError('items');
|
||||
toast.success('품목이 추가되었습니다.');
|
||||
}, [clearFieldError]);
|
||||
|
||||
// 품목 삭제
|
||||
const handleRemoveItem = useCallback((itemId: string) => {
|
||||
setForm((prev) => ({
|
||||
@@ -311,16 +300,6 @@ export function StockProductionForm({
|
||||
<FormSection
|
||||
title="품목 내역"
|
||||
icon={Package}
|
||||
headerAction={
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => setIsItemDialogOpen(true)}
|
||||
>
|
||||
<Plus className="h-4 w-4 mr-1" />
|
||||
품목 추가
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
{fieldErrors.items && (
|
||||
<p className="text-sm text-red-500 mb-3">{fieldErrors.items}</p>
|
||||
@@ -329,16 +308,7 @@ export function StockProductionForm({
|
||||
{form.items.length === 0 ? (
|
||||
<div className="text-center py-12 text-muted-foreground">
|
||||
<Package className="h-12 w-12 mx-auto mb-3 opacity-30" />
|
||||
<p>품목을 추가해주세요</p>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="mt-3"
|
||||
onClick={() => setIsItemDialogOpen(true)}
|
||||
>
|
||||
<Plus className="h-4 w-4 mr-1" />
|
||||
품목 추가
|
||||
</Button>
|
||||
<p>품목이 없습니다. 재고생산 저장 시 자동으로 추가됩니다.</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="overflow-x-auto">
|
||||
@@ -403,21 +373,13 @@ export function StockProductionForm({
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<IntegratedDetailTemplate
|
||||
config={config}
|
||||
mode={isEditMode ? 'edit' : 'create'}
|
||||
isLoading={false}
|
||||
onCancel={handleCancel}
|
||||
onSubmit={() => handleSave()}
|
||||
renderForm={renderFormContent}
|
||||
/>
|
||||
|
||||
<ItemAddDialog
|
||||
open={isItemDialogOpen}
|
||||
onOpenChange={setIsItemDialogOpen}
|
||||
onAdd={handleAddItem}
|
||||
/>
|
||||
</>
|
||||
<IntegratedDetailTemplate
|
||||
config={config}
|
||||
mode={isEditMode ? 'edit' : 'create'}
|
||||
isLoading={false}
|
||||
onCancel={handleCancel}
|
||||
onSubmit={() => handleSave()}
|
||||
renderForm={renderFormContent}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user