Skip to content

Commit 3c2e860

Browse files
fix(myopencre): remove extra download button, fix downloadCreCsv URL, improve section spacing
1 parent 3729b8a commit 3c2e860

2 files changed

Lines changed: 5 additions & 24 deletions

File tree

application/frontend/src/pages/MyOpenCRE/MyOpenCRE.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
}
44

55
.myopencre-upload {
6-
margin-top: 1.5rem;
6+
margin-top: 3rem;
77
}
88

99
.myopencre-disabled {

application/frontend/src/pages/MyOpenCRE/MyOpenCRE.tsx

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)