archived note (#24)

This commit is contained in:
Maxime Lalo 2023-05-03 17:16:02 +02:00 committed by GitHub
commit 756dab774c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -17,6 +17,7 @@ import ClientSection from "./ClientSection";
import { EDocumentStatus } from "le-coffre-resources/dist/Notary/Document"; import { EDocumentStatus } from "le-coffre-resources/dist/Notary/Document";
import Folders from "@Front/Api/LeCoffreApi/SuperAdmin/Folders/Folders"; import Folders from "@Front/Api/LeCoffreApi/SuperAdmin/Folders/Folders";
import { OfficeFolder } from "le-coffre-resources/dist/Customer"; import { OfficeFolder } from "le-coffre-resources/dist/Customer";
import { ChangeEvent } from "react";
type IProps = {}; type IProps = {};
@ -28,6 +29,7 @@ type IPropsClass = IProps & {
type IState = { type IState = {
selectedFolder: IDashBoardFolder | null; selectedFolder: IDashBoardFolder | null;
isArchivedModalOpen: boolean; isArchivedModalOpen: boolean;
inputArchivedDescripton: string;
}; };
class FolderInformationClass extends BasePage<IPropsClass, IState> { class FolderInformationClass extends BasePage<IPropsClass, IState> {
public constructor(props: IPropsClass) { public constructor(props: IPropsClass) {
@ -35,12 +37,14 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
this.state = { this.state = {
selectedFolder: null, selectedFolder: null,
isArchivedModalOpen: false, isArchivedModalOpen: false,
inputArchivedDescripton: "",
}; };
this.onSelectedFolder = this.onSelectedFolder.bind(this); this.onSelectedFolder = this.onSelectedFolder.bind(this);
this.openArchivedModal = this.openArchivedModal.bind(this); this.openArchivedModal = this.openArchivedModal.bind(this);
this.closeArchivedModal = this.closeArchivedModal.bind(this); this.closeArchivedModal = this.closeArchivedModal.bind(this);
this.onArchivedModalAccepted = this.onArchivedModalAccepted.bind(this); this.onArchivedModalAccepted = this.onArchivedModalAccepted.bind(this);
this.getCompletionNumber = this.getCompletionNumber.bind(this); this.getCompletionNumber = this.getCompletionNumber.bind(this);
this.onArchivedDescriptionInputChange = this.onArchivedDescriptionInputChange.bind(this);
} }
// TODO: Message if the user has not created any folder yet // TODO: Message if the user has not created any folder yet
@ -98,7 +102,7 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
<div className={classes["modal-title"]}> <div className={classes["modal-title"]}>
<Typography typo={ITypo.P_16}>Souhaitez-vous vraiment archiver le dossier ?</Typography> <Typography typo={ITypo.P_16}>Souhaitez-vous vraiment archiver le dossier ?</Typography>
</div> </div>
<InputField name="input field" fakeplaceholder="Description" textarea /> <InputField name="archived_description" fakeplaceholder="Description" textarea onChange={this.onArchivedDescriptionInputChange}/>
</Confirm> </Confirm>
</div> </div>
) : ( ) : (
@ -148,9 +152,15 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
this.setState({ isArchivedModalOpen: false }); this.setState({ isArchivedModalOpen: false });
} }
private onArchivedDescriptionInputChange(e: ChangeEvent<HTMLInputElement>){
this.setState({inputArchivedDescripton: e.target.value})
}
private async onArchivedModalAccepted() { private async onArchivedModalAccepted() {
if (!this.state.selectedFolder) return; if (!this.state.selectedFolder) return;
await Folders.getInstance().archive(this.state.selectedFolder.uid ?? "", this.state.selectedFolder); const folder = this.state.selectedFolder;
folder.archived_description = this.state.inputArchivedDescripton;
await Folders.getInstance().archive(this.state.selectedFolder.uid ?? "", folder);
this.closeArchivedModal(); this.closeArchivedModal();
this.props.router.push(Module.getInstance().get().modules.pages.Folder.props.path); this.props.router.push(Module.getInstance().get().modules.pages.Folder.props.path);
} }

View File

@ -119,7 +119,9 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
private async restoreFolder() { private async restoreFolder() {
if (!this.state.selectedFolder) return; if (!this.state.selectedFolder) return;
await Folders.getInstance().restore(this.state.selectedFolder.uid ?? "", this.state.selectedFolder); const folder = this.state.selectedFolder;
folder.archived_description = null;
await Folders.getInstance().restore(this.state.selectedFolder.uid ?? "", folder);
this.props.router.push(Module.getInstance().get().modules.pages.Folder.pages.FolderArchived.props.path); this.props.router.push(Module.getInstance().get().modules.pages.Folder.pages.FolderArchived.props.path);
} }