diff --git a/src/components/Table/index.tsx b/src/components/Table/index.tsx index 4a6cd37..6c9d938 100644 --- a/src/components/Table/index.tsx +++ b/src/components/Table/index.tsx @@ -39,6 +39,7 @@ type ActionButton = { type GenericTableProps = { data: T[]; columns: ColumnDef[]; + onRowClick?: (item: T) => void; actions?: ActionButton[]; bulkActions?: ActionButton[]; globalActions?: ActionButton[]; @@ -51,6 +52,7 @@ function GenericTable({ actions, bulkActions, globalActions, + onRowClick, idKey, }: GenericTableProps) { const [selectedRows, setSelectedRows] = useState>( @@ -175,11 +177,18 @@ function GenericTable({ {paginatedData?.map((item, rowIndex) => ( - + onRowClick?.(item)} + className="cursor-pointer" + > toggleRow(item[idKey])} + onClick={(e) => { + e.stopPropagation(); + toggleRow(item[idKey]); + }} /> {columns.map((column, colIndex) => ( @@ -193,7 +202,9 @@ function GenericTable({
{actions.map((action, index) => ( -
{action.button(item)}
+
e.stopPropagation()}> + {action.button(item)} +
))}
diff --git a/src/pages/ui/services/components/ServicesList/index.tsx b/src/pages/ui/services/components/ServicesList/index.tsx index 117d938..c4dfd96 100644 --- a/src/pages/ui/services/components/ServicesList/index.tsx +++ b/src/pages/ui/services/components/ServicesList/index.tsx @@ -95,6 +95,10 @@ function ServicesList() { data={filteredServices} idKey="name" + onRowClick={(item) => { + setFormService(item); + navigate(`/ui/services/${item.name}/settings`); + }} columns={[ { header: "Name", accessor: "name" }, { header: "Image", accessor: "image" },