feat: use field label in table headers if possible

This commit is contained in:
Daniel Lautzenheiser 2023-04-12 18:21:13 -04:00
parent 9e16956663
commit 8be6117861

View File

@ -120,11 +120,21 @@ const EntryListing = ({
});
}, [entries, inferFields, isSingleCollectionInList, otherProps, summaryFields, viewStyle]);
const summaryFieldHeaders = useMemo(() => {
if ('collection' in otherProps) {
return selectFields(otherProps.collection).map(f => f.label ?? f.name);
}
return [];
}, [otherProps]);
if (viewStyle === 'VIEW_STYLE_LIST') {
return (
<>
<Table
columns={!isSingleCollectionInList ? ['Collection', ...summaryFields] : summaryFields}
columns={
!isSingleCollectionInList ? ['Collection', ...summaryFieldHeaders] : summaryFields
}
>
{renderedCards}
</Table>