notes fully working

This commit is contained in:
Maxime Lalo 2024-07-23 16:11:19 +02:00
parent 1d973744c7
commit 706fdc7921

View File

@ -1,17 +1,16 @@
import Button, { EButtonSize, 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 Typography, { ETypo, ETypoColor } from "@Front/Components/DesignSystem/Typography";
import useOpenable from "@Front/Hooks/useOpenable"; import useOpenable from "@Front/Hooks/useOpenable";
import { PencilSquareIcon, TrashIcon } from "@heroicons/react/24/outline"; import { PencilSquareIcon, TrashIcon, UsersIcon } from "@heroicons/react/24/outline";
import { ICustomer } from ".."; import { ICustomer } from "..";
import { AnchorStatus } from "../.."; import { AnchorStatus } from "../..";
import classes from "./classes.module.scss"; import classes from "./classes.module.scss";
import DeleteCustomerModal from "./DeleteCustomerModal"; import DeleteCustomerModal from "./DeleteCustomerModal";
import Link from "next/link";
import Module from "@Front/Config/Module"; import Module from "@Front/Config/Module";
import { useCallback } from "react"; import { useCallback } from "react";
import { Note } from "le-coffre-resources/dist/Customer"; import { Note } from "le-coffre-resources/dist/Customer";
import ButtonWithSubMenu from "@Front/Components/Elements/ButtonWithSubMenu";
type IProps = { type IProps = {
customer: ICustomer; customer: ICustomer;
@ -33,6 +32,16 @@ export default function ClientBox(props: IProps) {
[props], [props],
); );
let createOrUpdateNotePath = Module.getInstance()
.get()
.modules.pages.Notes.pages.EditNote.props.path.replace("[noteUid]", customerNote?.uid ?? "");
if (!customerNote) {
createOrUpdateNotePath = Module.getInstance()
.get()
.modules.pages.Notes.pages.CreateNote.props.path.replace("[folderUid]", folderUid ?? "");
createOrUpdateNotePath = createOrUpdateNotePath.replace("[customerUid]", customer.uid ?? "");
}
return ( return (
<div className={classes["root"]}> <div className={classes["root"]}>
<div className={classes["header"]}> <div className={classes["header"]}>
@ -40,13 +49,30 @@ export default function ClientBox(props: IProps) {
{customer.contact?.first_name} {customer.contact?.last_name} {customer.contact?.first_name} {customer.contact?.last_name}
</Typography> </Typography>
{anchorStatus === AnchorStatus.NOT_ANCHORED && ( {anchorStatus === AnchorStatus.NOT_ANCHORED && (
<Link <ButtonWithSubMenu
href={Module.getInstance() icon={<PencilSquareIcon />}
openingSide="right"
subElements={[
{
icon: <UsersIcon />,
text: "Modifier les informations",
link: Module.getInstance()
.get() .get()
.modules.pages.Folder.pages.EditClient.props.path.replace("[folderUid]", folderUid ?? "") .modules.pages.Folder.pages.EditClient.props.path.replace("[folderUid]", folderUid ?? "")
.replace("[customerUid]", customer.uid ?? "")}> .replace("[customerUid]", customer.uid ?? ""),
<IconButton variant={EIconButtonVariant.NEUTRAL} icon={<PencilSquareIcon />} /> hasSeparator: true,
</Link> },
{
icon: <PencilSquareIcon />,
text: "Modifier la note",
link: createOrUpdateNotePath,
},
]}
/>
// <Link
// href={}>
// <IconButton variant={EIconButtonVariant.NEUTRAL} />
// </Link>
)} )}
</div> </div>
<div> <div>