From 6dba349c94065fc2a5bd621d65fc8cc77fcd6d52 Mon Sep 17 00:00:00 2001 From: Vins Date: Fri, 31 May 2024 15:16:05 +0200 Subject: [PATCH] Mooved delete customer icon --- .../UserFolder/UserFolderHeader/index.tsx | 34 +++++++++++++++++++ .../DesignSystem/UserFolder/index.tsx | 24 ------------- 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/front/Components/DesignSystem/UserFolder/UserFolderHeader/index.tsx b/src/front/Components/DesignSystem/UserFolder/UserFolderHeader/index.tsx index 6824c99d..1feab63f 100644 --- a/src/front/Components/DesignSystem/UserFolder/UserFolderHeader/index.tsx +++ b/src/front/Components/DesignSystem/UserFolder/UserFolderHeader/index.tsx @@ -1,4 +1,6 @@ import PenIcon from "@Assets/Icons/pen.svg"; +import Trash from "@Assets/Icons/trash.svg"; + import { OfficeFolder } from "le-coffre-resources/dist/Notary"; import Module from "@Front/Config/Module"; import { Customer } from "le-coffre-resources/dist/Notary"; @@ -10,6 +12,7 @@ import Typography, { ITypo } from "../../Typography"; import WarningBadge from "../../WarningBadge"; import classes from "./classes.module.scss"; import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document"; +import Folders from "@Front/Api/LeCoffreApi/Notary/Folders/Folders"; type IProps = { customer: Customer; @@ -23,6 +26,9 @@ export default class UserFolderHeader extends React.Component { isArchived: false, }; public override render(): JSX.Element | null { + const redirectCurrent = Module.getInstance() + .get() + .modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", this.props.folder.uid ?? ""); const redirectPath = Module.getInstance() .get() .modules.pages.Folder.pages.EditClient.props.path.replace("[folderUid]", this.props.folder.uid ?? "") @@ -60,6 +66,14 @@ export default class UserFolderHeader extends React.Component { edit + + delete this.removeCustomer(this.props.customer.uid!)} + /> + )} @@ -73,6 +87,26 @@ export default class UserFolderHeader extends React.Component { return notAskedDocuments.length > 0; } + private async removeCustomer(uid: string) { + try { + //use folder put to remove customer from folder + const query = { + q: { + customers: "true", + }, + }; + const folder = await Folders.getInstance().getByUid(this.props.folder.uid!, query); + if (!folder.customers) return; + const customers = folder.customers.filter((customer) => customer.uid !== uid); + folder.customers = customers; + await Folders.getInstance().put(this.props.folder.uid!, folder); + //redirect on the same page + window.location.reload(); + } catch (e) { + console.error(e); + } + } + private formatPhoneNumber(phoneNumber: string): string { if (!phoneNumber) return ""; phoneNumber = phoneNumber.replace(/ /g, ""); diff --git a/src/front/Components/DesignSystem/UserFolder/index.tsx b/src/front/Components/DesignSystem/UserFolder/index.tsx index 6e2b3b3c..790da0c5 100644 --- a/src/front/Components/DesignSystem/UserFolder/index.tsx +++ b/src/front/Components/DesignSystem/UserFolder/index.tsx @@ -18,9 +18,6 @@ import DocumentList from "./DocumentList"; import UserFolderHeader from "./UserFolderHeader"; import { AnchorStatus } from "@Front/Components/Layouts/Folder/FolderInformation"; -import Trash from "@Assets/Icons/trash.svg"; -import Folders from "@Front/Api/LeCoffreApi/Notary/Folders/Folders"; - type IProps = { customer: Customer; animationDelay?: number; @@ -78,7 +75,6 @@ export default class UserFolder extends React.Component { } return (
-