1+ import { useEffect , useState } from 'react' ;
12import Image from 'next/image' ;
23import Link from 'next/link' ;
34import { Button , Divider , Icon , Text , Tooltip } from 'opub-ui' ;
45
5- import { formatDate } from '@/lib/utils' ;
6+ import { formatDate , getWebsiteTitle } from '@/lib/utils' ;
67import { Icons } from '@/components/icons' ;
78
89const Metadata = ( { data, setOpen } : { data : any ; setOpen ?: any } ) => {
10+ const [ platformTitle , setPlatformTitle ] = useState < string | null > ( null ) ;
11+
12+ useEffect ( ( ) => {
13+ const fetchTitle = async ( ) => {
14+ try {
15+ const urlItem = data . useCase . platformUrl ;
16+
17+ if ( urlItem && urlItem . value ) {
18+ const title = await getWebsiteTitle ( urlItem . value ) ;
19+ setPlatformTitle ( title ) ;
20+ }
21+ } catch ( error ) {
22+ console . error ( 'Error fetching website title:' , error ) ;
23+ }
24+ } ;
25+
26+ if ( data . useCase . platformUrl === null ) {
27+ setPlatformTitle ( 'N/A' ) ;
28+ } else {
29+ fetchTitle ( ) ;
30+ }
31+ } , [ data . useCase . platformUrl ] ) ;
932 const metadata = [
1033 {
1134 label : data . useCase . isIndividualUsecase ? 'Publisher' : 'Organization' ,
@@ -27,18 +50,39 @@ const Metadata = ({ data, setOpen }: { data: any; setOpen?: any }) => {
2750 { data . useCase . isIndividualUsecase ? 'Publisher' : 'Organization' }
2851 </ Link >
2952 ) ,
53+
54+ } ,
55+ {
56+ label : 'Platform URL' ,
57+ value :
58+ data . useCase . platformUrl === null ? (
59+ 'N/A'
60+ ) : (
61+ < Link
62+ className = "text-primaryBlue underline"
63+ href = { data . useCase . platformUrl }
64+ >
65+ < Text className = "underline" color = "highlight" variant = "bodyLg" >
66+ { platformTitle ?. trim ( ) ? platformTitle : 'Visit Platform' }
67+ </ Text >
68+ </ Link >
69+ ) ,
70+ tooltipContent : data . useCase . platformUrl === null ? 'N/A' : platformTitle ,
3071 } ,
3172 {
3273 label : 'Started On' ,
3374 value : formatDate ( data . useCase . created ) || 'N/A' ,
75+ tooltipContent : formatDate ( data . useCase . created ) || 'N/A' ,
3476 } ,
3577 {
3678 label : 'Status' ,
3779 value : data . useCase . runningStatus . split ( '_' ) . join ( '' ) || 'N/A' ,
80+ tooltipContent : data . useCase . runningStatus . split ( '_' ) . join ( '' ) || 'N/A' ,
3881 } ,
3982 {
4083 label : 'Last Updated' ,
4184 value : formatDate ( data . useCase . modified ) || 'N/A' ,
85+ tooltipContent : formatDate ( data . useCase . modified ) || 'N/A' ,
4286 } ,
4387 {
4488 label : 'Sectors' ,
@@ -142,14 +186,14 @@ const Metadata = ({ data, setOpen }: { data: any; setOpen?: any }) => {
142186 { item . label }
143187 </ Text >
144188 < Tooltip content = { item ?. tooltipContent } >
145- < Text
146- className = "max-w-xs truncate"
147- variant = "bodyLg"
148- fontWeight = "medium"
149- // title={item?.tooltipContent}
150- >
151- { typeof item . value === 'string' ? item . value : item . value }
152- </ Text >
189+ < Text
190+ className = "max-w-xs truncate"
191+ variant = "bodyLg"
192+ fontWeight = "medium"
193+ // title={item?.tooltipContent}
194+ >
195+ { typeof item . value === 'string' ? item . value : item . value }
196+ </ Text >
153197 </ Tooltip >
154198 </ div >
155199 ) ) }
0 commit comments