♻️ (tableComponent): remove toTitleCase utility function to simplify headerName assignment
💡 (utils.ts): remove unnecessary commas and improve code readability
This commit is contained in:
parent
3ea0c7b03a
commit
30cd13a7da
2 changed files with 9 additions and 9 deletions
|
|
@ -8,7 +8,7 @@ import {
|
|||
} from "../../constants/constants";
|
||||
import { useDarkStore } from "../../stores/darkStore";
|
||||
import "../../style/ag-theme-shadcn.css"; // Custom CSS applied to the grid
|
||||
import { cn, toTitleCase } from "../../utils/utils";
|
||||
import { cn } from "../../utils/utils";
|
||||
import ForwardedIconComponent from "../genericIconComponent";
|
||||
import { Alert, AlertDescription, AlertTitle } from "../ui/alert";
|
||||
import TableOptions from "./components/TableOptions";
|
||||
|
|
@ -35,12 +35,12 @@ const TableComponent = forwardRef<
|
|||
alertDescription = DEFAULT_TABLE_ALERT_MSG,
|
||||
...props
|
||||
},
|
||||
ref
|
||||
ref,
|
||||
) => {
|
||||
let colDef = props.columnDefs.map((col, index) => {
|
||||
let newCol = {
|
||||
...col,
|
||||
headerName: toTitleCase(col.headerName),
|
||||
headerName: col.headerName,
|
||||
};
|
||||
if (index === props.columnDefs.length - 1) {
|
||||
newCol = {
|
||||
|
|
@ -111,7 +111,7 @@ const TableComponent = forwardRef<
|
|||
};
|
||||
const onColumnMoved = (params) => {
|
||||
const updatedColumnDefs = makeLastColumnNonResizable(
|
||||
params.columnApi.getAllGridColumns().map((col) => col.getColDef())
|
||||
params.columnApi.getAllGridColumns().map((col) => col.getColDef()),
|
||||
);
|
||||
params.api.setGridOption("columnDefs", updatedColumnDefs);
|
||||
if (props.onColumnMoved) props.onColumnMoved(params);
|
||||
|
|
@ -135,7 +135,7 @@ const TableComponent = forwardRef<
|
|||
className={cn(
|
||||
dark ? "ag-theme-quartz-dark" : "ag-theme-quartz",
|
||||
"ag-theme-shadcn flex h-full flex-col",
|
||||
"relative"
|
||||
"relative",
|
||||
)} // applying the grid theme
|
||||
>
|
||||
<AgGridReact
|
||||
|
|
@ -153,7 +153,7 @@ const TableComponent = forwardRef<
|
|||
if (e.sources.some((source) => source.includes("column"))) {
|
||||
localStorage.setItem(
|
||||
storeReference,
|
||||
JSON.stringify(realRef.current?.api?.getColumnState())
|
||||
JSON.stringify(realRef.current?.api?.getColumnState()),
|
||||
);
|
||||
setColumnStateChange(true);
|
||||
}
|
||||
|
|
@ -176,7 +176,7 @@ const TableComponent = forwardRef<
|
|||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
export default TableComponent;
|
||||
|
|
|
|||
|
|
@ -364,7 +364,7 @@ export function extractColumnsFromRows(
|
|||
function intersection() {
|
||||
for (const key in rows[0]) {
|
||||
columnsKeys[key] = {
|
||||
headerName: toTitleCase(key),
|
||||
headerName: key,
|
||||
field: key,
|
||||
cellRenderer: TableAutoCellRender,
|
||||
filter: true,
|
||||
|
|
@ -382,7 +382,7 @@ export function extractColumnsFromRows(
|
|||
for (const row of rows) {
|
||||
for (const key in row) {
|
||||
columnsKeys[key] = {
|
||||
headerName: toTitleCase(key),
|
||||
headerName: key,
|
||||
field: key,
|
||||
filter: true,
|
||||
cellRenderer: TableAutoCellRender,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue