🐛 Loading for first file uploaded

This commit is contained in:
Maxime Lalo 2023-12-14 16:22:55 +01:00
parent d27bebecb3
commit e493d7e3a3

View File

@ -86,6 +86,7 @@ export default class DepositDocument extends React.Component<IProps, IState> {
this.addDocument = this.addDocument.bind(this); this.addDocument = this.addDocument.bind(this);
this.onFileChange = this.onFileChange.bind(this); this.onFileChange = this.onFileChange.bind(this);
this.addFile = this.addFile.bind(this);
this.removeFile = this.removeFile.bind(this); this.removeFile = this.removeFile.bind(this);
this.onDragOver = this.onDragOver.bind(this); this.onDragOver = this.onDragOver.bind(this);
this.onDragDrop = this.onDragDrop.bind(this); this.onDragDrop = this.onDragDrop.bind(this);
@ -147,7 +148,6 @@ export default class DepositDocument extends React.Component<IProps, IState> {
))} ))}
</div> </div>
</div> </div>
{this.props.document.document_status !== EDocumentStatus.VALIDATED && this.state.files.length > 0 && (
<div className={classes["documents-container"]}> <div className={classes["documents-container"]}>
{this.state.files.map((file) => { {this.state.files.map((file) => {
const fileObj = file.file; const fileObj = file.file;
@ -184,7 +184,6 @@ export default class DepositDocument extends React.Component<IProps, IState> {
</div> </div>
)} )}
</div> </div>
)}
{this.props.document.document_status !== EDocumentStatus.VALIDATED && ( {this.props.document.document_status !== EDocumentStatus.VALIDATED && (
<div className={classes["bottom-container"]}> <div className={classes["bottom-container"]}>
<Button variant={EButtonVariant.LINE} className={classes["add-button"]} onClick={this.addDocument}> <Button variant={EButtonVariant.LINE} className={classes["add-button"]} onClick={this.addDocument}>
@ -343,7 +342,6 @@ export default class DepositDocument extends React.Component<IProps, IState> {
alert("Ce fichier est trop volumineux"); alert("Ce fichier est trop volumineux");
return false; return false;
} }
this.setState({ this.setState({
loading: true, loading: true,
}); });
@ -410,8 +408,13 @@ export default class DepositDocument extends React.Component<IProps, IState> {
const file = files[0]; const file = files[0];
try { try {
if (file) this.addFile(file); if (file) {
await this.setState({ loading: true }, () => {
this.addFile(file);
});
}
} catch (e) { } catch (e) {
this.setState({ loading: false });
console.log(e); console.log(e);
} }
} }