@@ -88,7 +88,6 @@ function renderNode(nodes: any[], depth = 0) {
8888}
8989
9090export default function BiorepoCollectionsContent ( ) {
91- const [ config , setConfig ] = useState ( null ) ;
9291 const [ value , setValue ] = React . useState ( 0 ) ;
9392 const [ taxonomicNodesData , setTaxonomicNodes ] = useState ( [ ] ) ;
9493 const [ sampletypeNodesData , setSampletypeNodes ] = useState ( [ ] ) ;
@@ -99,68 +98,31 @@ export default function BiorepoCollectionsContent() {
9998 } ;
10099
101100 useEffect ( ( ) => {
102- // Fetch configuration from getSymbiniConfig.php
103- const fetchConfig = async ( ) => {
104- const basePath = window . location . origin ;
105- const currentPath = window . location . pathname . split ( '/' ) . slice ( 0 , - 1 ) . join ( '/' ) ;
106- const pathSegments = currentPath . split ( '/' ) . filter ( Boolean ) ;
107- let clientRootPath = '/' ;
108- for ( let i = 1 ; i <= pathSegments . length ; i += 1 ) {
109- const candidatePath = `/${ pathSegments . slice ( 0 , i ) . join ( '/' ) } /neon-react` ;
110- // Check if the resource exists (use HEAD request to test for existence)
111- const xhr = new XMLHttpRequest ( ) ;
112- xhr . open ( 'HEAD' , `${ basePath } ${ candidatePath } ` , false ) ;
113- xhr . send ( ) ;
114- if ( xhr . status === 200 ) {
115- clientRootPath = `/${ pathSegments . slice ( 0 , i ) . join ( '/' ) } ` ;
116- break ;
117- }
118- }
119- const fetchUrl = `${ basePath } ${ clientRootPath } /neon-react/biorepo_lib/getSymbiniConfig.php` ;
120- try {
121- const response = await fetch ( fetchUrl ) ;
122- if ( ! response . ok ) {
123- throw new Error ( 'Failed to fetch configuration' ) ;
124- }
125- const data = await response . json ( ) ;
126- setConfig ( data ) ;
127- } catch ( error ) {
128- console . error ( 'Error fetching configuration:' , error ) ;
129- }
130- } ;
131-
132- fetchConfig ( ) ;
133- } , [ ] ) ;
134-
135- useEffect ( ( ) => {
136- if ( ! config ) return ;
137- fetch ( `${ config . CLIENT_ROOT } /neon-react/biorepo_lib/collections-taxonomic.json` )
101+ fetch ( '../../neon-react/biorepo_lib/collections-taxonomic.json' )
138102 . then ( ( response ) => response . json ( ) )
139103 . then ( ( data ) => {
140104 setTaxonomicNodes ( data ) ;
141105 } )
142106 . catch ( ( error ) => console . error ( 'Error loading nodes data:' , error ) ) ;
143- } , [ config ] ) ;
107+ } , [ ] ) ;
144108
145109 useEffect ( ( ) => {
146- if ( ! config ) return ;
147- fetch ( `${ config . CLIENT_ROOT } /neon-react/biorepo_lib/collections-sampletype.json` )
110+ fetch ( '../../neon-react/biorepo_lib/collections-sampletype.json' )
148111 . then ( ( response ) => response . json ( ) )
149112 . then ( ( data ) => {
150113 setSampletypeNodes ( data ) ;
151114 } )
152115 . catch ( ( error ) => console . error ( 'Error loading nodes data:' , error ) ) ;
153- } , [ config ] ) ;
116+ } , [ ] ) ;
154117
155118 useEffect ( ( ) => {
156- if ( ! config ) return ;
157- fetch ( `${ config . CLIENT_ROOT } /neon-react/biorepo_lib/collections-protocol.json` )
119+ fetch ( '../../neon-react/biorepo_lib/collections-protocol.json' )
158120 . then ( ( response ) => response . json ( ) )
159121 . then ( ( data ) => {
160122 setProtocolNodes ( data ) ;
161123 } )
162124 . catch ( ( error ) => console . error ( 'Error loading nodes data:' , error ) ) ;
163- } , [ config ] ) ;
125+ } , [ ] ) ;
164126
165127 return (
166128 < div >
0 commit comments