diff --git a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/DeleteCustomerModal/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/DeleteCustomerModal/index.tsx index 559ba8ca..bdf407d9 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/DeleteCustomerModal/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/DeleteCustomerModal/index.tsx @@ -7,21 +7,15 @@ type IProps = { isOpen: boolean; onClose?: () => void; - onDeleteSuccess: (uid: string) => void; + onDelete: (customerUid: string) => void; }; export default function DeleteCustomerModal(props: IProps) { - const { isOpen, onClose, customerUid, onDeleteSuccess } = props; + const { isOpen, onClose, onDelete } = props; - const onDelete = useCallback( - () => onDeleteSuccess(customerUid), - // Documents.getInstance() - // .delete(documentUid) - // .then(() => onDeleteSuccess(documentUid)) - // .then(onClose) - // .catch((error) => console.warn(error)), - [customerUid, onDeleteSuccess], - ); + const handleDelete = useCallback(() => { + onDelete(props.customerUid); + }, [onDelete, props.customerUid]); return ( + secondButton={{ children: "Supprimer le client", onClick: handleDelete }}> Cette action retirera le client de ce dossier. Vous ne pourrez plus récupérer les informations associées à ce client dans ce dossier une fois supprimées. diff --git a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/index.tsx index 63908f68..6d9c01f8 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/index.tsx @@ -10,11 +10,13 @@ import classes from "./classes.module.scss"; import DeleteCustomerModal from "./DeleteCustomerModal"; import Link from "next/link"; import Module from "@Front/Config/Module"; +import { useCallback } from "react"; type IProps = { customer: ICustomer; anchorStatus: AnchorStatus; folderUid: string | undefined; + onDelete: (customerUid: string) => void; }; export default function ClientBox(props: IProps) { @@ -22,7 +24,12 @@ export default function ClientBox(props: IProps) { const { isOpen, open, close } = useOpenable(); - console.log("customer", customer); + const handleDelete = useCallback( + (customerUid: string) => { + props.onDelete(customerUid); + }, + [props], + ); return (
@@ -76,7 +83,7 @@ export default function ClientBox(props: IProps) { onClick={open}> Supprimer le client - {}} /> + )}
diff --git a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/classes.module.scss b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/classes.module.scss index b55462e7..673d2297 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/classes.module.scss +++ b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/classes.module.scss @@ -10,6 +10,10 @@ gap: var(--spacing-md, 16px); justify-content: space-between; align-items: center; + + .tabs { + width: calc(100% - 210px); + } } .content { diff --git a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/index.tsx index 8f771e32..d36aca2b 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/index.tsx @@ -2,7 +2,7 @@ import Tabs from "@Front/Components/Elements/Tabs"; import Customer from "le-coffre-resources/dist/Customer"; import { OfficeFolder } from "le-coffre-resources/dist/Notary"; -import { useMemo, useState } from "react"; +import { useCallback, useMemo, useState } from "react"; import { AnchorStatus } from ".."; import classes from "./classes.module.scss"; @@ -13,6 +13,7 @@ import Module from "@Front/Config/Module"; import Link from "next/link"; import NoDocument from "./NoDocument"; import DocumentTables from "./DocumentTables"; +import Folders from "@Front/Api/LeCoffreApi/Notary/Folders/Folders"; type IProps = { folder: OfficeFolder; @@ -47,10 +48,26 @@ export default function ClientView(props: IProps) { const doesCustomerHaveDocument = useMemo(() => customer.documents && customer.documents.length > 0, [customer]); + const handleClientDelete = useCallback( + (customerUid: string) => { + if (!folder.uid) return; + Folders.getInstance().put( + folder.uid, + OfficeFolder.hydrate({ + ...folder, + customers: folder.customers?.filter((customer) => customer.uid !== customerUid), + }), + ); + window.location.reload(); + }, + [folder], + ); + return (
- {tabs && tabs={tabs} onSelect={setCustomer} />} +
{tabs && tabs={tabs} onSelect={setCustomer} />}
+ {anchorStatus === AnchorStatus.NOT_ANCHORED && (
- + {anchorStatus === AnchorStatus.NOT_ANCHORED && ( )}
- {doesCustomerHaveDocument ? : } + {doesCustomerHaveDocument ? : }
); diff --git a/src/front/Components/Layouts/Folder/FolderInformation/InformationSection/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/InformationSection/index.tsx index 925a1b3f..cfd93afe 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/InformationSection/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/InformationSection/index.tsx @@ -78,9 +78,9 @@ export default function InformationSection(props: IProps) {
- Notre dossier + Note du dossier - Travaux de rénovation en cours. + {folder?.description}
diff --git a/src/front/Components/Layouts/Folder/index.tsx b/src/front/Components/Layouts/Folder/index.tsx index ff0df471..d9f7b1d9 100644 --- a/src/front/Components/Layouts/Folder/index.tsx +++ b/src/front/Components/Layouts/Folder/index.tsx @@ -1,14 +1,16 @@ import backgroundImage from "@Assets/images/background_refonte_reverse.svg"; import LogoIcon from "@Assets/logo_small_blue.svg"; +import Users from "@Front/Api/LeCoffreApi/Notary/Users/Users"; import Button, { EButtonSize, EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button"; import Typography, { ETypo, ETypoColor } from "@Front/Components/DesignSystem/Typography"; import DefaultNotaryDashboard from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard"; import Module from "@Front/Config/Module"; +import JwtService from "@Front/Services/JwtService/JwtService"; import { DocumentIcon } from "@heroicons/react/24/outline"; -import { OfficeFolder } from "le-coffre-resources/dist/Notary"; +import User, { OfficeFolder } from "le-coffre-resources/dist/Notary"; import Image from "next/image"; import Link from "next/link"; -import { useCallback, useState } from "react"; +import { useCallback, useEffect, useState } from "react"; import classes from "./classes.module.scss"; @@ -16,10 +18,25 @@ export default function Folder() { const [_folder, setFolder] = useState(null); const [_isArchivedModalOpen, _setIsArchivedModalOpen] = useState(true); + const [activeUser, setActiveUser] = useState(); const onSelectedFolder = useCallback((folder: OfficeFolder): void => { setFolder(folder); }, []); + useEffect(() => { + const decodedJwt = JwtService.getInstance().decodeJwt(); + if (!decodedJwt) return; + Users.getInstance() + .getByUid(decodedJwt.userId, { + q: { + contact: true, + }, + }) + .then((user) => { + setActiveUser(user); + }); + }, []); + return ( logo - - Bonjour John, bienvenue sur LeCoffre.io - + {activeUser && activeUser.contact && ( + + Bonjour {activeUser.contact.first_name}, bienvenue sur LeCoffre.io + + )} + {!activeUser || + (!activeUser.contact && ( + + Bonjour, bienvenue sur LeCoffre.io + + ))} Commencez par créer votre{" "}