Skip to content

Commit 2a38275

Browse files
committed
refactor(ListingComponent): streamline metadata and footer content structure for improved readability
1 parent bad8f40 commit 2a38275

File tree

2 files changed

+67
-24
lines changed

2 files changed

+67
-24
lines changed

app/[locale]/(user)/components/ListingComponent.tsx

Lines changed: 54 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -478,35 +478,65 @@ const ListingComponent: React.FC<ListingProps> = ({
478478
? `${process.env.NEXT_PUBLIC_BACKEND_URL}/${item.organization.logo}`
479479
: '/org.png';
480480

481+
const MetadataContent = [
482+
{
483+
icon: Icons.calendar,
484+
label: 'Date',
485+
value: formatDate(item.modified),
486+
tooltip: 'Date',
487+
},
488+
{
489+
icon: Icons.download,
490+
label: 'Download',
491+
value: item.download_count.toString(),
492+
tooltip: 'Download',
493+
},
494+
{
495+
icon: Icons.globe,
496+
label: 'Geography',
497+
value: 'India',
498+
tooltip: 'Geography',
499+
},
500+
];
501+
502+
if (item.has_charts && view === 'expanded') {
503+
MetadataContent.push({
504+
icon: Icons.chart,
505+
label: '',
506+
value: 'With Charts',
507+
tooltip: 'Charts',
508+
});
509+
}
510+
511+
const FooterContent = [
512+
{
513+
icon: `/Sectors/${item.sectors[0]}.svg`,
514+
label: 'Sectors',
515+
tooltip: `${item.sectors[0]}`,
516+
},
517+
...(item.has_charts && view !== 'expanded'
518+
? [
519+
{
520+
icon: `/chart-bar.svg`,
521+
label: 'Charts',
522+
tooltip: 'Charts',
523+
},
524+
]
525+
: []),
526+
{
527+
icon: image,
528+
label: 'Published by',
529+
tooltip: `${item.is_individual_dataset ? item.user?.name : item.organization?.name}`,
530+
},
531+
];
532+
481533
const commonProps = {
482534
title: item.title,
483535
description: item.description,
484-
metadataContent: [
485-
{
486-
icon: Icons.calendar,
487-
label: 'Date',
488-
value: formatDate(item.modified),
489-
},
490-
{
491-
icon: Icons.download,
492-
label: 'Download',
493-
value: item.download_count.toString(),
494-
},
495-
{
496-
icon: Icons.globe,
497-
label: 'Geography',
498-
value: 'India',
499-
},
500-
],
536+
metadataContent: MetadataContent,
501537
tag: item.tags,
502538
formats: item.formats,
503-
footerContent: [
504-
{
505-
icon: `/Sectors/${item.sectors[0]}.svg`,
506-
label: 'Sectors',
507-
},
508-
{ icon: image, label: 'Published by' },
509-
],
539+
footerContent: FooterContent,
510540
};
511541

512542
return (

public/chart-bar.svg

Lines changed: 13 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)