mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-30 12:55:02 +00:00
restrict input to just csv file
This commit is contained in:
parent
3b66371bb1
commit
7aa3c930da
1 changed files with 16 additions and 5 deletions
|
|
@ -90,18 +90,29 @@ export function InputFile({
|
|||
fundingScheme: string;
|
||||
goalValue: string;
|
||||
}) {
|
||||
function handleOnChange(e: React.ChangeEvent<HTMLInputElement>) {
|
||||
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 (
|
||||
<div className="grid w-full max-w-sm items-center gap-1.5 text-sm font-semibold text-gray-600">
|
||||
<Label htmlFor="csv-uploader">Upload your csv</Label>
|
||||
<Input
|
||||
id="csv-uploader"
|
||||
type="file"
|
||||
accept=".csv, text/csv"
|
||||
className="cursor-pointer"
|
||||
onChange={(event) => {
|
||||
const file = event.target.files[0];
|
||||
setCsvFile(file); // Assuming you have a state to keep the file
|
||||
handleButtonDisabled(selectedGoal, fundingScheme, goalValue, file);
|
||||
}}
|
||||
onChange={handleOnChange}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue