diff --git a/src/front/Components/Layouts/Folder/FolderInformation/elements/AnchoringModal/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/elements/AnchoringModal/index.tsx index 6710946a..071ddc34 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/elements/AnchoringModal/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/elements/AnchoringModal/index.tsx @@ -11,7 +11,7 @@ type IProps = { isOpen: boolean; onClose?: () => void; folderUid: string; - onAnchorSuccess?: () => void; + onAnchorSuccess: () => void; }; export default function AnchoringModal(props: IProps) { @@ -19,12 +19,22 @@ export default function AnchoringModal(props: IProps) { const [isAnchoring, setIsAnchoring] = useState(false); const anchor = useCallback(() => { + const timeoutDelay = 9800; + const timeoutPromise = new Promise((resolve) => { + setTimeout(resolve, timeoutDelay); + }); setIsAnchoring(true); - OfficeFolderAnchors.getInstance() + return OfficeFolderAnchors.getInstance() .post(folderUid) + .then(() => timeoutPromise) + .then(() => setIsAnchoring(false)) .then(onAnchorSuccess) - .catch((e) => console.warn(e)) - }, [folderUid, onAnchorSuccess]); + .then(onClose) + .catch((e) => { + console.warn(e); + setIsAnchoring(false); + }); + }, [folderUid, onAnchorSuccess, onClose]); return ( + ); +} diff --git a/src/front/Components/Layouts/Folder/FolderInformation/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/index.tsx index d7528a68..8ec5ceaf 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/index.tsx @@ -13,6 +13,7 @@ import ClientView from "./ClientView"; import AnchoringAlertInfo from "./elements/AnchoringAlertInfo"; import AnchoringAlertSuccess from "./elements/AnchoringAlertSuccess"; import AnchoringModal from "./elements/AnchoringModal"; +import AnchoringProcessingNeutral from "./elements/AnchoringProcessingNeutral"; import ArchiveAlertWarning from "./elements/ArchiveAlertWarning"; import ArchiveModal from "./elements/ArchiveModal"; import DownloadAnchoringProofModal from "./elements/DownloadAnchoringProofModal"; @@ -121,8 +122,6 @@ export default function FolderInformation(props: IProps) { fetchData(); }, [fetchData]); - const onAnchorSuccess = useCallback(() => fetchData().then(downloadAnchoringProofModal.open), [fetchData, downloadAnchoringProofModal]); - const onArchive = useCallback(() => { if (anchorStatus === AnchorStatus.NOT_ANCHORED) return requireAnchoringModal.open(); archiveModal.open(); @@ -149,17 +148,18 @@ export default function FolderInformation(props: IProps) { isArchived={isArchived} /> )} + {!isArchived && anchorStatus === AnchorStatus.ANCHORING && } {isArchived && folderUid && ( )} {folder && !doesFolderHaveClient && } {folder && doesFolderHaveClient && } - {folderUid && anchorStatus === AnchorStatus.NOT_ANCHORED && ( + {folderUid && ( )} {folder && anchorStatus === AnchorStatus.VERIFIED_ON_CHAIN && (