Skip to content

Commit

Permalink
Merge pull request #92 from bleu/image
Browse files Browse the repository at this point in the history
If image doesn't exist, show value
  • Loading branch information
luizakp authored Aug 20, 2024
2 parents aa43f41 + 6e5e41b commit 0bd6ab7
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/components/DataTable/SWRDataTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,19 @@ export const renderDataTableCell = ({ filters, column, row, selectedRows }) => {
case "actions":
return <DataTableRowActions row={row} column={column} />;
case "image":
if (!row.getValue("image")?.url) return null;
return (
<img
className="aspect-ratio-1 size-16 rounded-sm object-contain"
src={row.getValue("image").url}
alt={row.getValue("name")}
/>
);
// eslint-disable-next-line no-case-declarations
const image = row.getValue("image") || value;
if (image?.url) {
return (
<img
className="aspect-ratio-1 size-16 rounded-sm object-contain"
src={image.url}
alt={image.alt_text}
/>
);
}
return <div className="max-w-[400px] truncate">{value}</div>;

case "link":
// eslint-disable-next-line no-case-declarations
const url = row.getValue("details_url");
Expand Down

0 comments on commit 0bd6ab7

Please sign in to comment.