@@ -3,6 +3,7 @@ import React, { ChangeEvent, useEffect, useState } from "react";
33import {
44 Box ,
55 Grid ,
6+ Link ,
67 Pagination ,
78 Stack ,
89 Tab ,
@@ -38,6 +39,7 @@ import { ErrorModal } from "../errors/ErrorModal";
3839import { Visualization } from "../visualizations/Visualization" ;
3940import VisibilityIcon from "@mui/icons-material/Visibility" ;
4041import config from "../../app.config" ;
42+ import { fetchPublicStandardLicenseUrl } from "../../utils/licenses" ;
4143
4244export const PublicDataset = ( ) : JSX . Element => {
4345 // path parameter
@@ -79,10 +81,19 @@ export const PublicDataset = (): JSX.Element => {
7981 const about = useSelector (
8082 ( state : RootState ) => state . publicDataset . publicAbout
8183 ) ;
82-
8384 const publicFolderPath = useSelector (
8485 ( state : RootState ) => state . folder . publicFolderPath
8586 ) ;
87+ const license = useSelector ( ( state : RootState ) => state . dataset . license ) ;
88+ const [ standardLicenseUrl , setStandardLicenseUrl ] = useState < string > ( "" ) ;
89+ const fetchStandardLicenseUrlData = async ( license_id : string ) => {
90+ try {
91+ const data = await fetchPublicStandardLicenseUrl ( license_id ) ; // Call your function to fetch licenses
92+ setStandardLicenseUrl ( data ) ; // Update state with the fetched data
93+ } catch ( error ) {
94+ console . error ( "Error fetching license url" , error ) ;
95+ }
96+ } ;
8697
8798 // state
8899 const [ selectedTabIndex , setSelectedTabIndex ] = useState < number > ( 0 ) ;
@@ -111,6 +122,11 @@ export const PublicDataset = (): JSX.Element => {
111122 getMetadatDefinitions ( null , 0 , 100 ) ;
112123 } , [ searchParams ] ) ;
113124
125+ useEffect ( ( ) => {
126+ if ( about && about . license_id !== undefined )
127+ fetchStandardLicenseUrlData ( about . license_id ) ;
128+ } , [ about ] ) ;
129+
114130 // for breadcrumb
115131 useEffect ( ( ) => {
116132 // for breadcrumb
@@ -270,6 +286,35 @@ export const PublicDataset = (): JSX.Element => {
270286 </ TabPanel >
271287 </ Grid >
272288 < Grid item xs = { 12 } sm = { 12 } md = { 2 } lg = { 2 } xl = { 2 } >
289+ < Typography variant = "h5" gutterBottom >
290+ License
291+ </ Typography >
292+ { about . standard_license && about . license_id !== undefined ? (
293+ < Typography >
294+ < Link href = { standardLicenseUrl } target = "_blank" >
295+ < img
296+ className = "logo"
297+ src = { `public/${ about . license_id } .png` }
298+ alt = { about . license_id }
299+ />
300+ </ Link >
301+ </ Typography >
302+ ) : (
303+ < > </ >
304+ ) }
305+ { ! about . standard_license &&
306+ license !== undefined &&
307+ license . name !== undefined ? (
308+ < div >
309+ < Typography >
310+ < Link href = { license . url } target = "_blank" >
311+ { license . name }
312+ </ Link >
313+ </ Typography >
314+ </ div >
315+ ) : (
316+ < > </ >
317+ ) }
273318 < DatasetDetails details = { about } />
274319 </ Grid >
275320 </ Grid >
0 commit comments