import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; import Form from "@Front/Components/DesignSystem/Form"; import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField"; import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography"; import BackArrow from "@Front/Components/Elements/BackArrow"; import DefaultNotaryDashboard from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard"; import Module from "@Front/Config/Module"; import { OfficeFolder } from "le-coffre-resources/dist/Customer"; import Link from "next/link"; import { NextRouter, useRouter } from "next/router"; import BasePage from "../../Base"; import classes from "./classes.module.scss"; import Customer from "le-coffre-resources/dist/Customer"; import Note from "le-coffre-resources/dist/Customer/Note"; import Folders from "@Front/Api/LeCoffreApi/Customer/Folders/Folders"; import Notes from "@Front/Api/LeCoffreApi/Customer/Notes/Notes"; import Customers from "@Front/Api/LeCoffreApi/Notary/Customers/Customers"; type IProps = {}; type IPropsClass = IProps & { folderUid: string; customerUid: string; router: NextRouter; }; type IState = { folder: OfficeFolder | null; customer: Customer | null; note: Note | null; }; class CreateCustomerNoteClass extends BasePage { private backwardPath = Module.getInstance() .get() .modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", this.props.folderUid!); constructor(props: IPropsClass) { super(props); this.state = { folder: null, customer: null, note: null, }; this.onFormSubmit = this.onFormSubmit.bind(this); } public override render(): JSX.Element { return (
Modifier la note du client
); } public override async componentDidMount() { // const note = await Notes.getInstance().getByUid(this.props.noteUid, query); const folder = await Folders.getInstance().getByUid(this.props.folderUid, { note: true }); const customer = await Customers.getInstance().getByUid(this.props.customerUid); //get the note of the folder that has customer_uid = this.props.customer.uid // const folderNote = folder.notes?.find((note) => note.customer?.uid === this.props.customerUid); // this.setState({ note, folder: note.office_folder || null, customer: note.customer || null }); this.setState({ note: null, folder: folder, customer: customer }); } private async onFormSubmit(e: React.FormEvent | null, values: { [key: string]: string }) { try { if (!this.state.folder || !this.state.customer) { throw new Error("Folder or customer not found"); } const note = { content: values["content"], office_folder: this.state.folder, customer: this.state.customer, }; await Notes.getInstance().post(note); this.props.router.push(this.backwardPath); } catch (error) { console.error(error); } } } export default function UpdateCustomerNote(props: IProps) { const router = useRouter(); let { folderUid, customerUid } = router.query; folderUid = folderUid as string; customerUid = customerUid as string; return ; }