fix: update column handling in TableList to support function-based column definitions

This commit is contained in:
faisolavolut 2025-04-28 11:46:57 +07:00
parent c04631519f
commit 246b1a80fe
1 changed files with 6 additions and 4 deletions

View File

@ -323,13 +323,14 @@ export const TableList = <T extends object>({
};
useEffect(() => {
try {
if (Array.isArray(column) && column?.length) {
const dateIndices = Array.isArray(column)
? column
const col = typeof column === "function" ? column() : column;
if (Array.isArray(col) && col?.length) {
const dateIndices = Array.isArray(col)
? col
.map((e, index) => (e.type === "date" ? index : -1))
.filter((index) => index !== -1)
: [];
const result: FieldFilterProps[] = column
const result: FieldFilterProps[] = col
.filter(
(e, index) =>
e.filter !== false &&
@ -362,6 +363,7 @@ export const TableList = <T extends object>({
pagination: e?.pagination,
search: e?.search,
}));
console.log({ result });
local.fieldFilter = result;
local.render();
}