fix archived folder
This commit is contained in:
parent
0f5aa4cc6d
commit
be8279dfa9
@ -3,9 +3,11 @@ import classes from "./classes.module.scss";
|
|||||||
import { OfficeFolder } from "le-coffre-resources/dist/Notary";
|
import { OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||||
import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Typography";
|
import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Typography";
|
||||||
import UserFolder from "@Front/Components/DesignSystem/UserFolder";
|
import UserFolder from "@Front/Components/DesignSystem/UserFolder";
|
||||||
|
import { AnchorStatus } from "@Front/Components/Layouts/Folder/FolderInformation";
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
folder: OfficeFolder;
|
folder: OfficeFolder;
|
||||||
|
anchorStatus: AnchorStatus;
|
||||||
};
|
};
|
||||||
type IState = {
|
type IState = {
|
||||||
openedCustomer: string;
|
openedCustomer: string;
|
||||||
@ -49,6 +51,7 @@ export default class ClientSection extends React.Component<IProps, IState> {
|
|||||||
key={customer.uid}
|
key={customer.uid}
|
||||||
isOpened={this.state.openedCustomer === customer.uid}
|
isOpened={this.state.openedCustomer === customer.uid}
|
||||||
onChange={this.changeUserFolder}
|
onChange={this.changeUserFolder}
|
||||||
|
anchorStatus={this.props.anchorStatus}
|
||||||
isArchived
|
isArchived
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -86,4 +86,16 @@
|
|||||||
.modal-title {
|
.modal-title {
|
||||||
margin-bottom: 24px;
|
margin-bottom: 24px;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.loader-container {
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100%;
|
||||||
|
.loader {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
}
|
||||||
}
|
}
|
@ -13,12 +13,18 @@ import BasePage from "../../Base";
|
|||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
import ClientSection from "./ClientSection";
|
import ClientSection from "./ClientSection";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { AnchorStatus } from "../../Folder/FolderInformation";
|
||||||
|
import { useCallback, useEffect, useState } from "react";
|
||||||
|
import OfficeFolderAnchors from "@Front/Api/LeCoffreApi/Notary/OfficeFolderAnchors/OfficeFolderAnchors";
|
||||||
|
import Loader from "@Front/Components/DesignSystem/Loader";
|
||||||
|
|
||||||
type IProps = {};
|
type IProps = {};
|
||||||
|
|
||||||
type IPropsClass = IProps & {
|
type IPropsClass = IProps & {
|
||||||
router: NextRouter;
|
router: NextRouter;
|
||||||
selectedFolderUid: string;
|
selectedFolderUid: string;
|
||||||
|
isLoading: boolean;
|
||||||
|
isAnchored: AnchorStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
type IState = {
|
type IState = {
|
||||||
@ -46,6 +52,7 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
|
|||||||
.modules.pages.Folder.pages.EditCollaborators.props.path.replace("[folderUid]", this.props.selectedFolderUid);
|
.modules.pages.Folder.pages.EditCollaborators.props.path.replace("[folderUid]", this.props.selectedFolderUid);
|
||||||
return (
|
return (
|
||||||
<DefaultNotaryDashboard title={"Dossier"} onSelectedFolder={this.onSelectedFolder} isArchived={true}>
|
<DefaultNotaryDashboard title={"Dossier"} onSelectedFolder={this.onSelectedFolder} isArchived={true}>
|
||||||
|
{!this.props.isLoading && (
|
||||||
<div className={classes["root"]}>
|
<div className={classes["root"]}>
|
||||||
{this.state.selectedFolder ? (
|
{this.state.selectedFolder ? (
|
||||||
<div className={classes["folder-informations"]}>
|
<div className={classes["folder-informations"]}>
|
||||||
@ -61,12 +68,14 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
|
|||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
<FolderBoxInformation
|
<FolderBoxInformation
|
||||||
|
anchorStatus={this.props.isAnchored}
|
||||||
folder={this.state.selectedFolder}
|
folder={this.state.selectedFolder}
|
||||||
isArchived
|
isArchived
|
||||||
type={EFolderBoxInformationType.INFORMATIONS}
|
type={EFolderBoxInformationType.INFORMATIONS}
|
||||||
/>
|
/>
|
||||||
<div className={classes["second-box"]}>
|
<div className={classes["second-box"]}>
|
||||||
<FolderBoxInformation
|
<FolderBoxInformation
|
||||||
|
anchorStatus={this.props.isAnchored}
|
||||||
folder={this.state.selectedFolder}
|
folder={this.state.selectedFolder}
|
||||||
isArchived
|
isArchived
|
||||||
type={EFolderBoxInformationType.DESCRIPTION}
|
type={EFolderBoxInformationType.DESCRIPTION}
|
||||||
@ -74,6 +83,7 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
|
|||||||
</div>
|
</div>
|
||||||
<div className={classes["second-box"]}>
|
<div className={classes["second-box"]}>
|
||||||
<FolderBoxInformation
|
<FolderBoxInformation
|
||||||
|
anchorStatus={this.props.isAnchored}
|
||||||
folder={this.state.selectedFolder}
|
folder={this.state.selectedFolder}
|
||||||
isArchived
|
isArchived
|
||||||
type={EFolderBoxInformationType.ARCHIVED_DESCRIPTION}
|
type={EFolderBoxInformationType.ARCHIVED_DESCRIPTION}
|
||||||
@ -83,10 +93,10 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
|
|||||||
<div className={classes["progress-bar"]}>
|
<div className={classes["progress-bar"]}>
|
||||||
<QuantityProgressBar title="Complétion du dossier" total={100} currentNumber={0} />
|
<QuantityProgressBar title="Complétion du dossier" total={100} currentNumber={0} />
|
||||||
</div>
|
</div>
|
||||||
{this.doesFolderHaveCustomer() && <ClientSection folder={this.state.selectedFolder} />}
|
{this.doesFolderHaveCustomer() && <ClientSection folder={this.state.selectedFolder} anchorStatus={this.props.isAnchored} />}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!this.doesFolderHaveCustomer() && <ClientSection folder={this.state.selectedFolder} />}
|
{!this.doesFolderHaveCustomer() && <ClientSection folder={this.state.selectedFolder} anchorStatus={this.props.isAnchored} />}
|
||||||
|
|
||||||
<div className={classes["button-container"]}>
|
<div className={classes["button-container"]}>
|
||||||
<Button variant={EButtonVariant.GHOST} onClick={this.restoreFolder}>
|
<Button variant={EButtonVariant.GHOST} onClick={this.restoreFolder}>
|
||||||
@ -105,6 +115,14 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
{this.props.isLoading && (
|
||||||
|
<div className={classes["loader-container"]}>
|
||||||
|
<div className={classes["loader"]}>
|
||||||
|
<Loader />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</DefaultNotaryDashboard>
|
</DefaultNotaryDashboard>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -154,7 +172,69 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
|
|||||||
|
|
||||||
export default function FolderInformation(props: IProps) {
|
export default function FolderInformation(props: IProps) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const [isAnchored, setIsAnchored] = useState<AnchorStatus>(AnchorStatus.NOT_ANCHORED);
|
||||||
|
const [isLoading, setIsLoading] = useState<boolean>(true);
|
||||||
|
const [selectedFolder, setSelectedFolder] = useState<OfficeFolder | null>(null);
|
||||||
|
|
||||||
let { folderUid } = router.query;
|
let { folderUid } = router.query;
|
||||||
folderUid = folderUid as string;
|
folderUid = folderUid as string;
|
||||||
return <FolderInformationClass {...props} selectedFolderUid={folderUid} router={router} />;
|
|
||||||
|
const getAnchoringStatus = useCallback(async () => {
|
||||||
|
if(!folderUid) return;
|
||||||
|
setIsLoading(true);
|
||||||
|
try {
|
||||||
|
const anchorStatus = await OfficeFolderAnchors.getInstance().getByUid(folderUid as string);
|
||||||
|
setIsAnchored(anchorStatus.status === "VERIFIED_ON_CHAIN" ? AnchorStatus.VERIFIED_ON_CHAIN : AnchorStatus.ANCHORING);
|
||||||
|
} catch (e) {
|
||||||
|
setIsAnchored(AnchorStatus.NOT_ANCHORED);
|
||||||
|
}
|
||||||
|
setIsLoading(false);
|
||||||
|
}, [folderUid]);
|
||||||
|
|
||||||
|
const getFolder = useCallback(async () => {
|
||||||
|
if (!folderUid) return;
|
||||||
|
setIsLoading(true);
|
||||||
|
const query = {
|
||||||
|
q: {
|
||||||
|
deed: { include: { deed_type: true } },
|
||||||
|
office: true,
|
||||||
|
customers: {
|
||||||
|
include: {
|
||||||
|
contact: true,
|
||||||
|
documents: {
|
||||||
|
include: {
|
||||||
|
folder: true,
|
||||||
|
document_type: true,
|
||||||
|
files: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
documents: {
|
||||||
|
include: {
|
||||||
|
depositor: {
|
||||||
|
include: {
|
||||||
|
contact: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
folder_anchor: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const folder = await Folders.getInstance().getByUid(folderUid as string, query);
|
||||||
|
if (folder) {
|
||||||
|
setSelectedFolder(folder);
|
||||||
|
getAnchoringStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsLoading(false);
|
||||||
|
}, [folderUid, getAnchoringStatus]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setIsLoading(true);
|
||||||
|
getFolder();
|
||||||
|
}, [getFolder]);
|
||||||
|
|
||||||
|
return <FolderInformationClass {...props} selectedFolderUid={folderUid} router={router} isLoading={isLoading} isAnchored={isAnchored} />;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user