Skip to content

Commit

Permalink
chore: if image doesn't exist, show value
Browse files Browse the repository at this point in the history
  • Loading branch information
luizakp committed Aug 19, 2024
1 parent 434ef9b commit c04d9fc
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/components/DataTable/SWRDataTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,18 @@ 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")}
/>
);
const image = row.getValue("image") || value;

Check failure on line 118 in src/components/DataTable/SWRDataTable/index.tsx

View workflow job for this annotation

GitHub Actions / Run Type Check & Linters

Unexpected lexical declaration in case block
if (image?.url){

Check failure on line 119 in src/components/DataTable/SWRDataTable/index.tsx

View workflow job for this annotation

GitHub Actions / Run Type Check & Linters

Insert `·`
return (
<img
className="aspect-ratio-1 size-16 rounded-sm object-contain"
src={image.url}
alt={image.alt_text}
/>
);
} else {

Check failure on line 127 in src/components/DataTable/SWRDataTable/index.tsx

View workflow job for this annotation

GitHub Actions / Run Type Check & Linters

Unnecessary 'else' after 'return'
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 c04d9fc

Please sign in to comment.