Skip to content

Commit

Permalink
Still trying to get the list of rejected files to refresh automatically
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 a4f11cf commit 91b960c
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions client/src/components/_common/Form/FileInputDropZone.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* FP-993: Allow use by DataFilesUploadModal */
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import { useDropzone } from 'react-dropzone';
import { Button, InlineMessage } from '_common';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -45,9 +45,28 @@ 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(previous => rejectedFiles);
setRejectedFiles(rejectedFiles);
}
// useEffect(refreshRejectedFiles, [rejectedFiles]);

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

const showFileList = (files && files.length > 0) || rejectedFiles.length > 0;

Expand Down Expand Up @@ -81,14 +100,16 @@ 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]);
// removeRejectedFile(i);
// console.log('click');
// console.log(rejectedFiles[i]);
rejectedFiles.splice(i, 1);
setRejectedFiles(rejectedFiles);
refreshRejectedFiles();
// refreshRejectedFiles();
// handleClick(i);
handleClick();
console.log('Remaining Rejected Files: ', rejectedFiles);
// console.log(rejectedFiles.fileIndex);
// setRejectedFiles([]);
}}
Expand Down

0 comments on commit 91b960c

Please sign in to comment.