Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

changes for #359 #596

Merged
merged 1 commit into from
Jul 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion client/src/components/Upload/Initial/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ export default function Initial({ onError, onUpload, templateId }) {

const [invalidFileExtension, setInvalidFileExtension] = React.useState(false);

const [isDisabledDownload, disableDownload] = React.useState(false);
const downloadTemplate = async () => {
disableDownload(true);
const url = `${config.API_PREFIX}/templates/${templateId}`;
try {
const { data } = await apiClient.get(url);
window.location = data.url;
} catch (error) {
if (onError) onError(error);
}
disableDownload(false);
};

const upload = (files) => {
Expand Down Expand Up @@ -96,7 +99,7 @@ export default function Initial({ onError, onUpload, templateId }) {
</span>
</div>
<div className={style.label2}>Supports XLS, XLSX or CSV file</div>
<div className={style.label3} onClick={downloadTemplate}>
<div className={style.label3} onClick={downloadTemplate} disabled={isDisabledDownload}>
Download Import Template (.XLSX)
</div>
</>
Expand Down
6 changes: 6 additions & 0 deletions client/src/components/Upload/Initial/style.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
text-underline-position: under;
}

.label3[disabled]
{
pointer-events: none;
opacity: 0.7;
}

.message {
position: absolute;
top: 0;
Expand Down