Mooved delete customer icon
This commit is contained in:
parent
5f51fd07a9
commit
6dba349c94
@ -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<IProps, IState> {
|
||||
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<IProps, IState> {
|
||||
<Link href={redirectPath}>
|
||||
<Image src={PenIcon} alt="edit" className={classes["edit-icon"]} onClick={this.onEditClick} />
|
||||
</Link>
|
||||
<Link href={redirectCurrent}>
|
||||
<Image
|
||||
src={Trash}
|
||||
alt="delete"
|
||||
className={classes["edit-icon"]}
|
||||
onClick={() => this.removeCustomer(this.props.customer.uid!)}
|
||||
/>
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@ -73,6 +87,26 @@ export default class UserFolderHeader extends React.Component<IProps, IState> {
|
||||
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, "");
|
||||
|
@ -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<IProps, IState> {
|
||||
}
|
||||
return (
|
||||
<div className={classes["root"]} data-opened={this.props.isOpened.toString()}>
|
||||
<Button variant={EButtonVariant.LINE} icon={Trash} onClick={() => this.removeCustomer(this.props.customer.uid!)} />{" "}
|
||||
<Confirm
|
||||
isOpen={this.state.isOpenDeletionModal}
|
||||
onClose={this.closeDeletionModal}
|
||||
@ -219,24 +215,4 @@ export default class UserFolder extends React.Component<IProps, IState> {
|
||||
isOpenDeletionModal: false,
|
||||
});
|
||||
}
|
||||
|
||||
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
|
||||
await this.props.getFolderCallback();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user