From 2cdd13eceb7bf831e7f7d98813f42c5be35589d1 Mon Sep 17 00:00:00 2001 From: Max S Date: Tue, 23 Jul 2024 10:30:23 +0200 Subject: [PATCH 1/4] ClientBox retours --- .../ClientView/ClientBox/classes.module.scss | 6 +++- .../ClientView/ClientBox/index.tsx | 28 +++++++++++++------ .../FolderInformation/ClientView/index.tsx | 2 +- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/classes.module.scss b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/classes.module.scss index 2aebed14..5e75f6fa 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/classes.module.scss +++ b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/classes.module.scss @@ -9,10 +9,14 @@ background: var(--primary-weak-higlight, #e5eefa); min-width: 300px; - .header{ + .header { display: flex; justify-content: space-between; align-items: center; width: 100%; } + + .delete-button { + margin: auto; + } } 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 5de56af7..63908f68 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/index.tsx @@ -1,4 +1,4 @@ -import Button, { EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button"; +import Button, { EButtonSize, EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button"; import IconButton, { EIconButtonVariant } from "@Front/Components/DesignSystem/IconButton"; import Typography, { ETypo, ETypoColor } from "@Front/Components/DesignSystem/Typography"; import useOpenable from "@Front/Hooks/useOpenable"; @@ -8,33 +8,44 @@ import { ICustomer } from ".."; import { AnchorStatus } from "../.."; import classes from "./classes.module.scss"; import DeleteCustomerModal from "./DeleteCustomerModal"; +import Link from "next/link"; +import Module from "@Front/Config/Module"; type IProps = { customer: ICustomer; anchorStatus: AnchorStatus; + folderUid: string | undefined; }; export default function ClientBox(props: IProps) { - const { customer, anchorStatus } = props; + const { customer, anchorStatus, folderUid } = props; const { isOpen, open, close } = useOpenable(); + console.log("customer", customer); + return (
- {customer.contact?.last_name} + {customer.contact?.first_name} {customer.contact?.last_name} {anchorStatus === AnchorStatus.NOT_ANCHORED && ( - } /> + + } /> + )}
- + Numéro de téléphone - - {customer.contact?.phone_number} + + {customer.contact?.cell_phone_number ?? customer.contact?.phone_number ?? "_"}
@@ -42,7 +53,7 @@ export default function ClientBox(props: IProps) { E-mail - {customer.contact?.email} + {customer.contact?.email ?? "_"}
@@ -58,6 +69,7 @@ export default function ClientBox(props: IProps) { <>
- + {anchorStatus === AnchorStatus.NOT_ANCHORED && ( Date: Tue, 23 Jul 2024 10:37:27 +0200 Subject: [PATCH 2/4] :sparkles: firstname on folder page --- src/front/Components/Layouts/Folder/index.tsx | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/front/Components/Layouts/Folder/index.tsx b/src/front/Components/Layouts/Folder/index.tsx index 844893de..1225922a 100644 --- a/src/front/Components/Layouts/Folder/index.tsx +++ b/src/front/Components/Layouts/Folder/index.tsx @@ -3,22 +3,39 @@ import Button, { EButtonVariant, EButtonstyletype } from "@Front/Components/Desi import Typography, { ETypo, ETypoColor } from "@Front/Components/DesignSystem/Typography"; import DefaultNotaryDashboard from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard"; import { DocumentIcon } from "@heroicons/react/24/outline"; -import { OfficeFolder } from "le-coffre-resources/dist/Notary"; -import { useCallback, useState } from "react"; +import User, { OfficeFolder } from "le-coffre-resources/dist/Notary"; +import { useCallback, useEffect, useState } from "react"; import Image from "next/image"; import classes from "./classes.module.scss"; import Link from "next/link"; import Module from "@Front/Config/Module"; +import JwtService from "@Front/Services/JwtService/JwtService"; +import Users from "@Front/Api/LeCoffreApi/Notary/Users/Users"; 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 (
@@ -26,9 +43,17 @@ export default function Folder() {
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{" "} From e77a7b262fe71f2f61e2d130bc2e22b6abedfb75 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 23 Jul 2024 10:38:57 +0200 Subject: [PATCH 3/4] :sparkles: folder note working --- .../Folder/FolderInformation/InformationSection/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/front/Components/Layouts/Folder/FolderInformation/InformationSection/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/InformationSection/index.tsx index 925a1b3f..606a5109 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/InformationSection/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/InformationSection/index.tsx @@ -80,7 +80,7 @@ export default function InformationSection(props: IProps) { Notre dossier - Travaux de rénovation en cours. + {folder?.description}
From 0767d164910c86b58d0ba689762d38283a0c0d73 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 23 Jul 2024 10:56:25 +0200 Subject: [PATCH 4/4] :sparkles: Delete client working --- .../ClientBox/DeleteCustomerModal/index.tsx | 18 +++++---------- .../ClientView/ClientBox/index.tsx | 11 ++++++++-- .../FolderInformation/ClientView/index.tsx | 22 ++++++++++++++++--- 3 files changed, 34 insertions(+), 17 deletions(-) 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/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/index.tsx index 8f771e32..3cce0e55 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,6 +48,21 @@ 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 (
@@ -68,7 +84,7 @@ export default function ClientView(props: IProps) {
- + {anchorStatus === AnchorStatus.NOT_ANCHORED && ( )}
- {doesCustomerHaveDocument ? : } + {doesCustomerHaveDocument ? : }
);