Refuse documents (#30)

This commit is contained in:
Maxime Lalo 2023-05-09 16:58:57 +02:00 committed by GitHub
commit 5f083e1b6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions

View File

@ -13,7 +13,8 @@ export interface IGetDocumentsparams {
// TODO Type getbyuid query params
export type IPutDocumentsParams = {
document_status?: EDocumentStatus
document_status?: EDocumentStatus;
refused_reason?: string;
};
export interface IPostDocumentsParams {}

View File

@ -66,6 +66,7 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
this.hasPrevious = this.hasPrevious.bind(this);
this.hasNext = this.hasNext.bind(this);
this.refuseDocument = this.refuseDocument.bind(this);
}
public override render(): JSX.Element | null {
@ -156,7 +157,7 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
<Confirm
isOpen={this.state.isRefuseModalVisible}
onClose={this.closeModals}
onAccept={this.closeModals}
onAccept={this.refuseDocument}
closeBtn
header={"Refuser le document ?"}
cancelText={"Annuler"}
@ -244,6 +245,23 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
return index < this.state.document!.files!.length;
}
private async refuseDocument(){
try{
await Documents.getInstance().put(this.props.documentUid, {
document_status: EDocumentStatus.REFUSED,
refused_reason: this.state.refuseText
});
this.props.router.push(
Module.getInstance()
.get()
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", this.props.folderUid),
);
}catch(e){
console.error(e);
}
}
private async validateAnchoring() {
this.setState({
hasValidateAnchoring: true,