@@ -20,7 +20,10 @@ export const MyOpenCRE = () => {
2020
2121 const downloadCreCsv = async ( ) => {
2222 try {
23- const response = await fetch ( `${ apiUrl } /cre_csv` , {
23+ const baseUrl = apiUrl || window . location . origin ;
24+ const backendUrl = baseUrl . includes ( 'localhost' ) ? 'http://127.0.0.1:5000' : baseUrl ;
25+
26+ const response = await fetch ( `${ backendUrl } /cre_csv` , {
2427 method : 'GET' ,
2528 headers : { Accept : 'text/csv' } ,
2629 } ) ;
@@ -46,25 +49,6 @@ export const MyOpenCRE = () => {
4649 }
4750 } ;
4851
49- const downloadTemplate = ( ) => {
50- const headers = [ 'standard_name' , 'standard_section' , 'cre_id' , 'notes' ] ;
51-
52- const csvContent = headers . join ( ',' ) + '\n' ;
53-
54- const blob = new Blob ( [ csvContent ] , {
55- type : 'text/csv;charset=utf-8;' ,
56- } ) ;
57-
58- const url = URL . createObjectURL ( blob ) ;
59- const link = document . createElement ( 'a' ) ;
60-
61- link . href = url ;
62- link . setAttribute ( 'download' , 'myopencre_mapping_template.csv' ) ;
63- document . body . appendChild ( link ) ;
64- link . click ( ) ;
65- document . body . removeChild ( link ) ;
66- } ;
67-
6852 /* ------------------ FILE SELECTION ------------------ */
6953
7054 const onFileChange = ( e : React . ChangeEvent < HTMLInputElement > ) => {
@@ -144,9 +128,6 @@ export const MyOpenCRE = () => {
144128 < Button primary onClick = { downloadCreCsv } >
145129 Download CRE Catalogue (CSV)
146130 </ Button >
147- < Button secondary onClick = { downloadTemplate } style = { { marginLeft : '1rem' } } >
148- Download Mapping Template (CSV)
149- </ Button >
150131 </ div >
151132
152133 < div className = "myopencre-section myopencre-upload" >
0 commit comments