Skip to content

Commit

Permalink
Update dropzone
Browse files Browse the repository at this point in the history
  • Loading branch information
Lehats committed Dec 19, 2024
1 parent a5814b4 commit d912a92
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions src/client/src/pages/detail/attachments/fileDropzone.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,14 @@ export const FileDropzone = props => {
setDropZoneTextColor(defaultDropzoneTextColor);
setDropZoneText(t(defaultText));
setFiles(prevFiles => [...prevFiles, ...acceptedFiles]);
// set filetype depending on acceptedFileTypes. if contains csv
if (acceptedFileTypes.includes("text/csv")) {
setFileType("csv");
}
if (acceptedFileTypes.includes("application/json")) {
setFileType("json");

if (setFileType) {
if (acceptedFileTypes.includes("text/csv")) {
setFileType("csv");
}
if (acceptedFileTypes.includes("application/json")) {
setFileType("json");
}
}
}
},
Expand All @@ -112,7 +114,9 @@ export const FileDropzone = props => {
// Is called when an accepted file is removed.
const removeFile = fileToRemove => {
setFiles(prevFiles => prevFiles.filter(file => file !== fileToRemove));
setFileType(null);
if (setFileType) {
setFileType(null);
}
};

// Is called when the selected/dropped files are rejected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const GeometryImport = ({ boreholeId }) => {
<FileDropzone
onHandleFileChange={field.onChange}
defaultText={"dropZoneGeometryText"}
restrictAcceptedFileTypeToCsv={true}
acceptedFileTypes={["text/csv"]}
maxFilesToSelectAtOnce={1}
maxFilesToUpload={1}
isDisabled={false}
Expand Down

0 comments on commit d912a92

Please sign in to comment.