@@ -113,59 +113,76 @@ const SimilarDatasets: React.FC = () => {
113113 < CarouselContent className = "p-4" >
114114 { SimilatDatasetdetails ?. data ?. getDataset &&
115115 SimilatDatasetdetails ?. data ?. getDataset . similarDatasets . map (
116- ( item : any ) => (
117- < CarouselItem
118- key = { item . id }
119- className = { cn (
120- 'h-2/4 basis-full pl-4 sm:basis-1/2 lg:basis-1/2' ,
121- Styles . List
122- ) }
123- >
124- { ' ' }
125- < Card
126- title = { item . title }
127- description = { stripMarkdown ( item . description || '' ) }
128- metadataContent = { [
129- {
130- icon : Icons . calendar as any ,
131- label : 'Date' ,
132- value : '19 July 2024' ,
133- } ,
134- {
135- icon : Icons . download as any ,
136- label : 'Download' ,
137- value : item . downloadCount . toString ( ) ,
138- } ,
139- {
140- icon : Icons . globe as any ,
141- label : 'Geography' ,
142- value : item . geographies . join ( ', ' ) ,
143- } ,
144- ] }
145- tag = { item . tags }
146- formats = { item . formats }
147- footerContent = { [
148- {
149- icon : `/Sectors/${ item . sectors [ 0 ] ?. name } .svg` as any ,
150- label : 'Sectors' ,
151- } ,
152- {
153- icon : item . isIndividualDataset
154- ? ( item ?. user ?. profilePicture as any )
155- ? `${ process . env . NEXT_PUBLIC_BACKEND_URL } /${ item . user . profilePicture . url } `
156- : ( '/profile.png' as any )
157- : ( item ?. organization ?. logo as any )
158- ? `${ process . env . NEXT_PUBLIC_BACKEND_URL } /${ item . organization . logo . url } `
159- : ( '/org.png' as any ) ,
160- label : 'Published by' ,
161- } ,
162- ] }
163- variation = { 'collapsed' }
164- iconColor = "warning"
165- href = { `/datasets/${ item . id } ` }
166- />
167- </ CarouselItem >
168- )
116+ ( item : any ) => {
117+ const geographies =
118+ Array . isArray ( item . geographies ) &&
119+ item . geographies . length > 0
120+ ? item . geographies
121+ . map ( ( geo : any ) =>
122+ typeof geo === 'string' ? geo : geo ?. name
123+ )
124+ . filter ( Boolean )
125+ : null ;
126+
127+ const metadataContent : any [ ] = [
128+ {
129+ icon : Icons . calendar as any ,
130+ label : 'Date' ,
131+ value : '19 July 2024' ,
132+ } ,
133+ {
134+ icon : Icons . download as any ,
135+ label : 'Download' ,
136+ value : item . downloadCount . toString ( ) ,
137+ } ,
138+ ] ;
139+
140+ if ( geographies && geographies . length > 0 ) {
141+ metadataContent . push ( {
142+ icon : Icons . globe as any ,
143+ label : 'Geography' ,
144+ value : geographies . join ( ', ' ) ,
145+ } ) ;
146+ }
147+
148+ return (
149+ < CarouselItem
150+ key = { item . id }
151+ className = { cn (
152+ 'h-2/4 basis-full pl-4 sm:basis-1/2 lg:basis-1/2' ,
153+ Styles . List
154+ ) }
155+ >
156+ { ' ' }
157+ < Card
158+ title = { item . title }
159+ description = { stripMarkdown ( item . description || '' ) }
160+ metadataContent = { metadataContent }
161+ tag = { item . tags }
162+ formats = { item . formats }
163+ footerContent = { [
164+ {
165+ icon : `/Sectors/${ item . sectors [ 0 ] ?. name } .svg` as any ,
166+ label : 'Sectors' ,
167+ } ,
168+ {
169+ icon : item . isIndividualDataset
170+ ? ( item ?. user ?. profilePicture as any )
171+ ? `${ process . env . NEXT_PUBLIC_BACKEND_URL } /${ item . user . profilePicture . url } `
172+ : ( '/profile.png' as any )
173+ : ( item ?. organization ?. logo as any )
174+ ? `${ process . env . NEXT_PUBLIC_BACKEND_URL } /${ item . organization . logo . url } `
175+ : ( '/org.png' as any ) ,
176+ label : 'Published by' ,
177+ } ,
178+ ] }
179+ variation = { 'collapsed' }
180+ iconColor = "warning"
181+ href = { `/datasets/${ item . id } ` }
182+ />
183+ </ CarouselItem >
184+ ) ;
185+ }
169186 ) }
170187 </ CarouselContent >
171188 < CarouselNext />
0 commit comments