[as] feat: 결재선 검증 로직 수정

This commit is contained in:
2026-08-06 16:17:44 +09:00
parent 6e2ebe9025
commit 999fd610af
4 changed files with 48 additions and 7 deletions
@@ -3,13 +3,15 @@
import { useMemo, useState } from "react";
import { useConfirm } from "@frontend-opensource/use-react-hooks";
import { useQueryClient } from "@tanstack/react-query";
import { getCoreRowModel, type RowSelectionState } from "@tanstack/react-table";
import { useDataTable } from "@/shared/lib";
import { ENDPOINT } from "@/shared/config";
import { useDataTable, useMutationWrapper } from "@/shared/lib";
import {
type ElaprTmplt,
elaprTmpltService,
useCreateElaprTmplt,
useDeleteElaprTmplt,
useElaprTmpltPage,
useUpdateElaprTmplt,
} from "@/entities/elapr";
@@ -26,6 +28,7 @@ interface ElaprTmpltListProps {
function ElaprTmpltList({ selectedTmpltId, onSelectTmplt }: ElaprTmpltListProps) {
const { confirm } = useConfirm();
const queryClient = useQueryClient();
const [dialogMode, setDialogMode] = useState<"create" | "edit" | null>(null);
const [editingTmplt, setEditingTmplt] = useState<ElaprTmplt | null>(null);
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
@@ -38,7 +41,14 @@ function ElaprTmpltList({ selectedTmpltId, onSelectTmplt }: ElaprTmpltListProps)
const createMutation = useCreateElaprTmplt();
const updateMutation = useUpdateElaprTmplt();
const deleteMutation = useDeleteElaprTmplt();
const { mutateAsync: deleteTmplt } = useMutationWrapper({
mutationFn: (elaprTmpltId: string) => elaprTmpltService.remove(elaprTmpltId),
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: [ENDPOINT.AS_ELAPR_SERVICE.ELAPR_TMPLT],
});
},
});
const columns = useMemo(
() =>
@@ -49,13 +59,13 @@ function ElaprTmpltList({ selectedTmpltId, onSelectTmplt }: ElaprTmpltListProps)
},
onDelete: async (row) => {
if (!(await confirm("선택한 결재서식을 삭제하시겠습니까?"))) return;
await deleteMutation.mutateAsync(row.elaprTmpltId);
await deleteTmplt(row.elaprTmpltId);
if (selectedTmpltId === row.elaprTmpltId) {
onSelectTmplt(null);
}
},
}),
[confirm, deleteMutation, onSelectTmplt, selectedTmpltId],
[confirm, deleteTmplt, onSelectTmplt, selectedTmpltId],
);
const { tableComponent } = useDataTable({