Skip to content

Commit

Permalink
Merge main into sweep/upgrade-react-query
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Dec 10, 2023
2 parents 5fd301c + 0a4879a commit 80cb773
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export default function SubmissionForms(props) {
if (["redcap", "cdisc"].includes(inputFormat)) {
if (Object.keys(uploadedFiles).length < 3) {
toast.error("Please upload all required files");
console.log(uploadedFiles);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,30 +105,29 @@ export default function InputFilesPond(props) {
*/

const returnedFileName = JSON.parse(file.serverId).tempFilename;
const fileName = file.filename;
const {filename, fileExtension} = file;

if (fileName in uploadedFiles) {
if (filename in uploadedFiles) {
toast.error("File already uploaded");
file.abortProcessing()
file.setMetadata("processingAborted", true)
file.abortProcessing();
return;
}

const extension = fileName.split(".").pop();

let fileType = "input-file";
if (fileName.includes("dictionary") && extension === "csv") {
if (filename.includes("dictionary") && fileExtension === "csv") {
fileType = "redcap-dictionary";
} else if (
fileName.includes("mapping") &&
["yaml", "yml", "json"].includes(extension)
filename.includes("mapping") &&
["yaml", "yml", "json"].includes(fileExtension)
) {
fileType = "mapping-file";
}

setUploadedFiles((prev) => {
return {
...prev,
[fileName]: [fileType, returnedFileName],
[filename]: [fileType, returnedFileName],
};
});
};
Expand Down Expand Up @@ -274,29 +273,25 @@ export default function InputFilesPond(props) {
setFilesUploadFinished(false);
const fileName = file.filename;

// Not sure if below is working as expected
setUploadedFiles((prev) => {
const prevCopy = { ...prev };
delete prevCopy[fileName];
return prevCopy;
});
// only update state if the file processing was finished (status 2 = IDLE)
// for reference see
// github.com/pqina/filepond-docs/blob/master/content/patterns/API/filepond-object.md#filestatus-enum
if (file.status === 2 && file.getMetadata("processingAborted") !== true) {
console.log("onremovefile")
console.log(uploadedFiles)

setUploadedFiles((prev) => {
const prevCopy = { ...prev };
delete prevCopy[fileName];
return prevCopy;
});
}
}}
// option provided by plugins
acceptedFileTypes={acceptedFileTypesMapping[inputFormat]}
fileValidateTypeLabelExpectedTypes={
expectedFileExtensionsMapping[inputFormat]
}
// TODO
// when showing an error message increase the size of the filepond component

// fileValidateTypeDetectType={ ( source, type ) =>
// {
// console.log( source, type );
// resolve( type );
// } }

// better get this from the server

// this should be a prop
// so large file are only expected for OMOP (sqls)
maxFileSize="1000MB"
Expand Down

0 comments on commit 80cb773

Please sign in to comment.