diff --git a/src/app/components/portfolio/UploadCsvModal.tsx b/src/app/components/portfolio/UploadCsvModal.tsx index cf5410ec..dc812e9f 100644 --- a/src/app/components/portfolio/UploadCsvModal.tsx +++ b/src/app/components/portfolio/UploadCsvModal.tsx @@ -90,18 +90,29 @@ export function InputFile({ fundingScheme: string; goalValue: string; }) { + function handleOnChange(e: React.ChangeEvent) { + if (e.target.files) { + // Check if files is not null + const file = e.target.files[0]; + if (file.type !== "text/csv") { + // Show an error message + console.error("File is not a CSV"); + return; + } + setCsvFile(file); // Assuming you have a state to keep the file + handleButtonDisabled(selectedGoal, fundingScheme, goalValue, file); + } + } + return (
{ - const file = event.target.files[0]; - setCsvFile(file); // Assuming you have a state to keep the file - handleButtonDisabled(selectedGoal, fundingScheme, goalValue, file); - }} + onChange={handleOnChange} />
);