From c9c91231f74a22c72627cd0e300e1d4595e534cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com>
Date: Thu, 26 Sep 2024 22:00:18 +0200
Subject: [PATCH] make hdl configurable

---
 pages/fdo/show/[prefix]/[suffix].tsx | 3 ++-
 pages/fdo/show/[prefix]/sandbox.tsx  | 3 ++-
 src/components/profiles/list.tsx     | 3 ++-
 src/constants.js                     | 1 +
 4 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/pages/fdo/show/[prefix]/[suffix].tsx b/pages/fdo/show/[prefix]/[suffix].tsx
index 8412158..e6adb3d 100644
--- a/pages/fdo/show/[prefix]/[suffix].tsx
+++ b/pages/fdo/show/[prefix]/[suffix].tsx
@@ -1,5 +1,6 @@
 import React from 'react'
 
+import { HDL_URL } from '../../../../src/constants'
 import { ErrorComponent } from '../../../../src/components/ErrorComponent'
 import { GetServerSideProps } from 'next'
 import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
@@ -24,7 +25,7 @@ import Cloud from '@mui/icons-material/Cloud'
 import VerifiedIcon from '@mui/icons-material/Verified'
 import ReportIcon from '@mui/icons-material/Report'
 
-const resolvePid = (pid: string) => `https://hdl.handle.net/${pid}`
+const resolvePid = (pid: string) => HDL_URL + `/${pid}`
 
 const ShowFDO = () => {
   const { params } = useParsed()
diff --git a/pages/fdo/show/[prefix]/sandbox.tsx b/pages/fdo/show/[prefix]/sandbox.tsx
index 6b66b8c..cf6d200 100644
--- a/pages/fdo/show/[prefix]/sandbox.tsx
+++ b/pages/fdo/show/[prefix]/sandbox.tsx
@@ -1,6 +1,7 @@
 import React from 'react'
 import { ErrorComponent } from '../../../../src/components/ErrorComponent'
 import { GetServerSideProps } from 'next'
+import { HDL_URL } from '../../../../src/constants'
 import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
 import { useShow, useTranslate, useParsed, useCustom, useApiUrl } from '@refinedev/core'
 import { Show } from '@refinedev/mui'
@@ -26,7 +27,7 @@ import ReportIcon from '@mui/icons-material/Report'
 import { styled, ThemeProvider } from '@mui/material/styles'
 import Details from '../../../../src/components/fdos/details'
 
-const resolvePid = (pid: string) => `https://hdl.handle.net/${pid}`
+const resolvePid = (pid: string) => HDL_URL + `/${pid}`
 
 const ShowFDO = () => {
   const { params } = useParsed()
diff --git a/src/components/profiles/list.tsx b/src/components/profiles/list.tsx
index 1793d6f..3e4d06f 100644
--- a/src/components/profiles/list.tsx
+++ b/src/components/profiles/list.tsx
@@ -1,4 +1,5 @@
 import { IResourceComponentsProps } from '@refinedev/core'
+import { HDL_URL } from '../../constants'
 import Link from '@mui/material/Link'
 
 import { List, useDataGrid } from '@refinedev/mui'
@@ -33,7 +34,7 @@ const columns: Array<GridColDef<IProfile>> = [
     width: 300,
     renderCell: (params) => {
       const pid = params?.row.attributes.pid
-      return <Link href={'https://hdl.handle.net/' + pid}>{pid}</Link>
+      return <Link href={HDL_URL + '/' + pid}>{pid}</Link>
     }
   }
 ]
diff --git a/src/constants.js b/src/constants.js
index c891c2a..9b56450 100644
--- a/src/constants.js
+++ b/src/constants.js
@@ -1,3 +1,4 @@
 import { version } from './version'
 export const API_URL = process.env.NEXT_PUBLIC_API_URL || '/api'
+export const HDL_URL = process.env.NEXT_PUBLIC_HDL_URL || 'https://hdl.handle.net'
 export const FDO_MANAGER_WEBUI_VERSION = version
-- 
GitLab