I have a component inside a modal where I can upload multiple files, It has to be closed when all files are already uploaded or give me a message if one of them failed to upload .eg(file too large)
Component - ModalUploadFile.jsx
this.state =  {
  files: [file1, file2, file2]
}
Following codes will be called when submit button clicked
uploadFile = () => {
    this.refs.btn.setAttribute("disabled", "disabled");
    this.state.files.map( function(file) {
        this.props.saveFile(this.props.selected_candidate.id, file)
      }, this
    ) 
}
Sagas.js
function* saveFile(action) {
  try {
    let file = action.file
    let formData = new FormData()
    formData.append("file", file)
    let result = yield fetch(URL, {
      method: "POST",
      credentials: "same-origin",
      body: formData
    }).then(response => response.json()).then(data => {
      return data
    })
    yield put({
      type: actionTypes.FILE_UPLOADED,
      ci: result
    })
    yield put({
      type: actionTypes.CLOSE_MODAL
    })
  } catch (ex) {
    console.log(ex)
  }
}
Currently, The Upload Modal will be closed when one of the files successfully uploaded.
 
    