diff --git a/apps/cs/src/pages/role/model/table-columns.tsx b/apps/cs/src/pages/role/model/table-columns.tsx index f1e586043..71da16cfe 100644 --- a/apps/cs/src/pages/role/model/table-columns.tsx +++ b/apps/cs/src/pages/role/model/table-columns.tsx @@ -3,8 +3,13 @@ import { useState } from "react"; import type { Role } from "@/entities/role"; import type { ColumnDef } from "@tanstack/react-table"; import { MappingRoleDialog } from "../ui/mapping-role-dialog"; +import { Button } from "@common/components"; -export const columns: ColumnDef[] = [ +export const createColumns = ({ + deleteRole, +}: { + deleteRole: (roleId: string) => void; +}): ColumnDef[] => [ { id: "no", header: "NO", @@ -39,7 +44,18 @@ export const columns: ColumnDef[] = [ { id: "action", header: "관리", - cell: ({ row }) => , + cell: ({ row }) => ( +
+ + +
+ ), }, ]; diff --git a/apps/cs/src/pages/role/ui/role-page.tsx b/apps/cs/src/pages/role/ui/role-page.tsx index 7d5453895..97c3d615b 100644 --- a/apps/cs/src/pages/role/ui/role-page.tsx +++ b/apps/cs/src/pages/role/ui/role-page.tsx @@ -7,11 +7,12 @@ import { getCoreRowModel, type PaginationState } from "@tanstack/react-table"; import { Button, Input, Label } from "@common/components"; import { RoleApi, type Role, type RoleParams } from "@/entities/role"; import { ENDPOINT } from "@/shared/config"; -import { useDataTable } from "@/shared/lib"; -import { columns } from "../model/table-columns"; +import { useAlertStore, useDataTable, useMutationWrapper } from "@/shared/lib"; +import { createColumns } from "../model/table-columns"; function RolePage() { const router = useRouter(); + const alert = useAlertStore((state) => state.setMessage); const [keyword, setKeyword] = useState(""); const [searchParams, setSearchParams] = useState({ @@ -33,6 +34,13 @@ function RolePage() { }), }); + const { mutateAsync: deleteRole } = useMutationWrapper({ + mutationFn: (roleId: string) => RoleApi.deleteRole(roleId), + onSuccess: () => { + alert("삭제되었습니다.", query.refetch); + }, + }); + const handleRowClick = (row: Role) => { router.push(`/role/register/${row.roleId}`); }; @@ -40,7 +48,9 @@ function RolePage() { const { tableComponent } = useDataTable({ query, tableOptions: { - columns, + columns: createColumns({ + deleteRole, + }), state: { pagination, },