Skip to content

Commit

Permalink
Finally got to filter rejectedFiles correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff McMillen authored and Jeff McMillen committed Dec 10, 2024
1 parent 91b960c commit 3be734f
Showing 1 changed file with 6 additions and 33 deletions.
39 changes: 6 additions & 33 deletions client/src/components/_common/Form/FileInputDropZone.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,11 @@ function FileInputDropZone({
}
};

const handleClick = (index) => {
// rejectedFiles.splice(index, 1);
// setRejectedFiles(rejectedFiles);
// useState(setRejectedFiles(rejectedFiles));
setRejectedFiles(rejectedFiles.splice(index, 1));
setRejectedFiles(rejectedFiles);
};

// useEffect(() => {
// setRejectedFiles(rejectedFiles);
// console.log('useEffect');
// }, [rejectedFiles]);

const refreshRejectedFiles = () => {
setRejectedFiles(rejectedFiles);
}
// useEffect(refreshRejectedFiles, [rejectedFiles]);

const removeRejectedFile = (index) => {
rejectedFiles.splice(index, 1);
// setRejectedFiles(rejectedFiles);
const removeRejectedFile = (i) => {
const newRejectedFiles = rejectedFiles.filter(
(file) => file !== rejectedFiles[i]
);
setRejectedFiles(newRejectedFiles);
};

const showFileList = (files && files.length > 0) || rejectedFiles.length > 0;
Expand Down Expand Up @@ -100,18 +84,7 @@ function FileInputDropZone({
<Button
type="link"
onClick={() => {
// console.log('click');
console.log('To be removed: ', rejectedFiles[i]);
// removeRejectedFile(i);
// rejectedFiles.splice(i, 1);
// setRejectedFiles(rejectedFiles);
// setRejectedFiles([rejectedFiles]);
// refreshRejectedFiles();
// handleClick(i);
handleClick();
console.log('Remaining Rejected Files: ', rejectedFiles);
// console.log(rejectedFiles.fileIndex);
// setRejectedFiles([]);
removeRejectedFile(i);
}}
>
Remove
Expand Down

0 comments on commit 3be734f

Please sign in to comment.