fix: [process] 품목 전체 삭제 confirm() → DeleteConfirmDialog 전환
This commit is contained in:
@@ -87,8 +87,8 @@ export function ProcessDetail({ process, onProcessUpdate }: ProcessDetailProps)
|
||||
};
|
||||
|
||||
// 품목 전체 삭제
|
||||
const [showRemoveAllDialog, setShowRemoveAllDialog] = useState(false);
|
||||
const handleRemoveAllItems = async () => {
|
||||
if (!confirm(`등록된 품목 ${itemCount}개를 모두 삭제하시겠습니까?`)) return;
|
||||
const result = await removeProcessItem(process.id, []);
|
||||
if (result.success && result.data) {
|
||||
toast.success('품목이 모두 제거되었습니다.');
|
||||
@@ -96,6 +96,7 @@ export function ProcessDetail({ process, onProcessUpdate }: ProcessDetailProps)
|
||||
} else {
|
||||
toast.error(result.error || '품목 전체 제거에 실패했습니다.');
|
||||
}
|
||||
setShowRemoveAllDialog(false);
|
||||
};
|
||||
|
||||
const [isDuplicating, setIsDuplicating] = useState(false);
|
||||
@@ -294,7 +295,7 @@ export function ProcessDetail({ process, onProcessUpdate }: ProcessDetailProps)
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={handleRemoveAllItems}
|
||||
onClick={() => setShowRemoveAllDialog(true)}
|
||||
className="shrink-0 text-destructive hover:text-destructive"
|
||||
>
|
||||
<Trash2 className="h-3.5 w-3.5 mr-1" />
|
||||
@@ -511,6 +512,14 @@ export function ProcessDetail({ process, onProcessUpdate }: ProcessDetailProps)
|
||||
loading={deleteDialog.isPending}
|
||||
description="이 공정을 삭제하시겠습니까? 이 작업은 되돌릴 수 없습니다."
|
||||
/>
|
||||
|
||||
{/* 품목 전체 삭제 확인 다이얼로그 */}
|
||||
<DeleteConfirmDialog
|
||||
open={showRemoveAllDialog}
|
||||
onOpenChange={setShowRemoveAllDialog}
|
||||
onConfirm={handleRemoveAllItems}
|
||||
description={`등록된 품목 ${itemCount}개를 모두 삭제하시겠습니까?`}
|
||||
/>
|
||||
</PageLayout>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
} from '@/components/ui/select';
|
||||
import { RuleModal } from './RuleModal';
|
||||
import { toast } from 'sonner';
|
||||
import { DeleteConfirmDialog } from '@/components/ui/confirm-dialog';
|
||||
import type { Process, ClassificationRule, ProcessType, ProcessStep } from '@/types/process';
|
||||
import { PROCESS_CATEGORY_OPTIONS } from '@/types/process';
|
||||
import {
|
||||
@@ -143,12 +144,13 @@ export function ProcessForm({ mode, initialData }: ProcessFormProps) {
|
||||
}, []);
|
||||
|
||||
// 품목 전체 삭제
|
||||
const [showRemoveAllDialog, setShowRemoveAllDialog] = useState(false);
|
||||
const handleRemoveAllItems = useCallback(() => {
|
||||
if (!confirm(`등록된 품목 ${itemCount}개를 모두 삭제하시겠습니까?`)) return;
|
||||
setClassificationRules((prev) =>
|
||||
prev.filter((rule) => rule.registrationType !== 'individual')
|
||||
);
|
||||
}, [itemCount]);
|
||||
setShowRemoveAllDialog(false);
|
||||
}, []);
|
||||
|
||||
// 부서 목록 + 문서양식 목록 로드
|
||||
useEffect(() => {
|
||||
@@ -611,7 +613,7 @@ export function ProcessForm({ mode, initialData }: ProcessFormProps) {
|
||||
type="button"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={handleRemoveAllItems}
|
||||
onClick={() => setShowRemoveAllDialog(true)}
|
||||
className="shrink-0 text-destructive hover:text-destructive"
|
||||
>
|
||||
<Trash2 className="h-3.5 w-3.5 mr-1" />
|
||||
@@ -867,13 +869,23 @@ export function ProcessForm({ mode, initialData }: ProcessFormProps) {
|
||||
const config = isEdit ? processEditConfig : processCreateConfig;
|
||||
|
||||
return (
|
||||
<IntegratedDetailTemplate
|
||||
config={config}
|
||||
mode={isEdit ? 'edit' : 'create'}
|
||||
isLoading={isDepartmentsLoading}
|
||||
onCancel={handleCancel}
|
||||
onSubmit={handleSubmit}
|
||||
renderForm={renderFormContent}
|
||||
/>
|
||||
<>
|
||||
<IntegratedDetailTemplate
|
||||
config={config}
|
||||
mode={isEdit ? 'edit' : 'create'}
|
||||
isLoading={isDepartmentsLoading}
|
||||
onCancel={handleCancel}
|
||||
onSubmit={handleSubmit}
|
||||
renderForm={renderFormContent}
|
||||
/>
|
||||
|
||||
{/* 품목 전체 삭제 확인 다이얼로그 */}
|
||||
<DeleteConfirmDialog
|
||||
open={showRemoveAllDialog}
|
||||
onOpenChange={setShowRemoveAllDialog}
|
||||
onConfirm={handleRemoveAllItems}
|
||||
description={`등록된 품목 ${itemCount}개를 모두 삭제하시겠습니까?`}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user