From b54b5a7b7edc38dbae819c6613ea2905c731141d Mon Sep 17 00:00:00 2001 From: Max S Date: Tue, 23 Jul 2024 14:22:57 +0200 Subject: [PATCH] restore archive --- .../DesignSystem/Alert/classes.module.scss | 4 ++ .../Components/DesignSystem/Alert/index.tsx | 5 +- .../elements/AnchoringAlertInfo/index.tsx | 1 + .../elements/AnchoringAlertSuccess/index.tsx | 1 + .../elements/ArchiveAlertWarning/index.tsx | 48 +++++++++++++++++++ .../elements/ArchiveModal/index.tsx | 1 - .../Folder/FolderInformation/index.tsx | 16 ++++--- 7 files changed, 67 insertions(+), 9 deletions(-) create mode 100644 src/front/Components/Layouts/Folder/FolderInformation/elements/ArchiveAlertWarning/index.tsx diff --git a/src/front/Components/DesignSystem/Alert/classes.module.scss b/src/front/Components/DesignSystem/Alert/classes.module.scss index b230faf6..96e78746 100644 --- a/src/front/Components/DesignSystem/Alert/classes.module.scss +++ b/src/front/Components/DesignSystem/Alert/classes.module.scss @@ -83,4 +83,8 @@ stroke: var(--alerts-badge-contrast-neutral); } } + + &.fullwidth { + width: 100%; + } } diff --git a/src/front/Components/DesignSystem/Alert/index.tsx b/src/front/Components/DesignSystem/Alert/index.tsx index 4605961f..a00022bc 100644 --- a/src/front/Components/DesignSystem/Alert/index.tsx +++ b/src/front/Components/DesignSystem/Alert/index.tsx @@ -16,6 +16,7 @@ type IProps = { firstButton?: IButtonProps; secondButton?: IButtonProps; closeButton?: boolean; + fullWidth?: boolean; }; export enum EAlertVariant { @@ -36,12 +37,12 @@ const variantButtonMap: Record = { export default function Alert(props: IProps) { const { isOpen, close } = useOpenable({ defaultOpen: true }); - const { variant = EAlertVariant.INFO, title, description, firstButton, secondButton, closeButton, icon } = props; + const { variant = EAlertVariant.INFO, title, description, firstButton, secondButton, closeButton, icon, fullWidth } = props; if (!isOpen) return null; return ( -
+
{icon ?? }
diff --git a/src/front/Components/Layouts/Folder/FolderInformation/elements/AnchoringAlertInfo/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/elements/AnchoringAlertInfo/index.tsx index b8d243ed..bbdf1378 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/elements/AnchoringAlertInfo/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/elements/AnchoringAlertInfo/index.tsx @@ -19,6 +19,7 @@ export default function AnchoringAlertInfo(props: IProps) { onClick: onAnchor, }} variant={EAlertVariant.INFO} + fullWidth /> ); } diff --git a/src/front/Components/Layouts/Folder/FolderInformation/elements/AnchoringAlertSuccess/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/elements/AnchoringAlertSuccess/index.tsx index 3cef33fb..0c5ae96f 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/elements/AnchoringAlertSuccess/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/elements/AnchoringAlertSuccess/index.tsx @@ -30,6 +30,7 @@ export default function AnchoringAlertSuccess(props: IProps) { } variant={EAlertVariant.SUCCESS} icon={} + fullWidth /> ); } diff --git a/src/front/Components/Layouts/Folder/FolderInformation/elements/ArchiveAlertWarning/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/elements/ArchiveAlertWarning/index.tsx new file mode 100644 index 00000000..89828c08 --- /dev/null +++ b/src/front/Components/Layouts/Folder/FolderInformation/elements/ArchiveAlertWarning/index.tsx @@ -0,0 +1,48 @@ +import Folders from "@Front/Api/LeCoffreApi/Notary/Folders/Folders"; +import Alert, { EAlertVariant } from "@Front/Components/DesignSystem/Alert"; +import { EButtonstyletype } from "@Front/Components/DesignSystem/Button"; +import Module from "@Front/Config/Module"; +import { ArchiveBoxArrowDownIcon, ArchiveBoxIcon, ArrowDownOnSquareIcon } from "@heroicons/react/24/outline"; +import { useRouter } from "next/router"; +import { useCallback } from "react"; + +type IProps = { + onDownloadAnchoringProof: () => void; + folderUid: string; +}; + +export default function ArchiveAlertWarning(props: IProps) { + const { onDownloadAnchoringProof, folderUid } = props; + + const router = useRouter(); + + const restoreArchive = useCallback(() => { + Folders.getInstance() + .restore(folderUid) + .then(() => router.push(Module.getInstance().get().modules.pages.Folder.props.path)) + .catch((e) => { + console.warn(e); + }); + }, [folderUid, router]); + + return ( + , + onClick: onDownloadAnchoringProof, + }} + secondButton={{ + children: "Restaurer le dossier", + onClick: restoreArchive, + rightIcon: , + }} + variant={EAlertVariant.WARNING} + icon={} + fullWidth + /> + ); +} diff --git a/src/front/Components/Layouts/Folder/FolderInformation/elements/ArchiveModal/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/elements/ArchiveModal/index.tsx index 441b71b3..177ddf8e 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/elements/ArchiveModal/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/elements/ArchiveModal/index.tsx @@ -18,7 +18,6 @@ export default function ArchiveModal(props: IProps) { const router = useRouter(); const archive = useCallback(() => { - if (!folderUid) return; const description = (document.querySelector("textarea[name='archived_description']") as HTMLTextAreaElement).value ?? ""; Folders.getInstance() diff --git a/src/front/Components/Layouts/Folder/FolderInformation/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/index.tsx index c9770a16..2f1b37a0 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/index.tsx @@ -2,6 +2,7 @@ import Folders from "@Front/Api/LeCoffreApi/Notary/Folders/Folders"; import OfficeFolderAnchors from "@Front/Api/LeCoffreApi/Notary/OfficeFolderAnchors/OfficeFolderAnchors"; import Loader from "@Front/Components/DesignSystem/Loader"; import DefaultNotaryDashboard from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard"; +import useOpenable from "@Front/Hooks/useOpenable"; import { OfficeFolder } from "le-coffre-resources/dist/Notary"; import { EDocumentStatus } from "le-coffre-resources/dist/Notary/Document"; import { useParams } from "next/navigation"; @@ -9,15 +10,15 @@ import { useCallback, useEffect, useMemo, useState } from "react"; import classes from "./classes.module.scss"; import ClientView from "./ClientView"; -import InformationSection from "./InformationSection"; -import NoClientView from "./NoClientView"; import AnchoringAlertInfo from "./elements/AnchoringAlertInfo"; -import AnchoringModal from "./elements/AnchoringModal"; -import useOpenable from "@Front/Hooks/useOpenable"; import AnchoringAlertSuccess from "./elements/AnchoringAlertSuccess"; +import AnchoringModal from "./elements/AnchoringModal"; +import ArchiveAlertWarning from "./elements/ArchiveAlertWarning"; +import ArchiveModal from "./elements/ArchiveModal"; import DownloadAnchoringProofModal from "./elements/DownloadAnchoringProofModal"; import RequireAnchoringModal from "./elements/RequireAnchoringModal"; -import ArchiveModal from "./elements/ArchiveModal"; +import InformationSection from "./InformationSection"; +import NoClientView from "./NoClientView"; export enum AnchorStatus { "VERIFIED_ON_CHAIN" = "VERIFIED_ON_CHAIN", @@ -138,13 +139,16 @@ export default function FolderInformation(props: IProps) { {progress === 100 && anchorStatus === AnchorStatus.NOT_ANCHORED && ( )} - {anchorStatus === AnchorStatus.VERIFIED_ON_CHAIN && ( + {!isArchived && anchorStatus === AnchorStatus.VERIFIED_ON_CHAIN && ( )} + {isArchived && folderUid && ( + + )} {folder && !doesFolderHaveClient && } {folder && doesFolderHaveClient && } {folderUid && anchorStatus === AnchorStatus.NOT_ANCHORED && (