Skip to content

Commit

Permalink
Show dataset name when multiple of same title
Browse files Browse the repository at this point in the history
  • Loading branch information
Elson9 committed Jan 29, 2025
1 parent 9792096 commit 4b54f55
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/nextapp/components/products-list/dataset-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ const DatasetInput: React.FC<DatasetInputProps> = ({ dataset }) => {

const isInvalid = search.length > 0 && !selected;

const titleCounts = (results || []).reduce((acc, d) => {
acc[d.title] = (acc[d.title] || 0) + 1;
return acc;
}, {} as Record<string, number>);

return (
<>
<FormControl id="dataset" position="relative" isInvalid={isInvalid}>
Expand Down Expand Up @@ -158,7 +163,9 @@ const DatasetInput: React.FC<DatasetInputProps> = ({ dataset }) => {
},
})}
>
<Text fontSize="md">{d.title}</Text>
<Text fontSize="md">
{d.title} {titleCounts[d.title] > 1 ? `(${d.name})` : ''}
</Text>
</Box>
))}
{isOpen && isSuccess && !results.length && (
Expand Down

0 comments on commit 4b54f55

Please sign in to comment.