diff --git a/package-lock.json b/package-lock.json index bd84bff8..9f6985c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,7 +24,7 @@ "eslint-config-next": "13.2.4", "form-data": "^4.0.0", "jwt-decode": "^3.1.2", - "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.139", + "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.151", "next": "^14.2.3", "prettier": "^2.8.7", "react": "18.2.0", @@ -331,9 +331,9 @@ } }, "node_modules/@eslint-community/regexpp": { - "version": "4.10.0", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", - "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.1.tgz", + "integrity": "sha512-Zm2NGpWELsQAD1xsJzGQpYfvICSsFkEpU0jxBjfdC6uNEWXcHnfs9hScFWtXVDVl+rBQJGrl4g1vcKIejpH9dA==", "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } @@ -1250,15 +1250,18 @@ } }, "node_modules/array.prototype.tosorted": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/array.prototype.tosorted/-/array.prototype.tosorted-1.1.3.tgz", - "integrity": "sha512-/DdH4TiTmOKzyQbp/eadcCVexiCb36xJg7HshYOYJnNZFDj33GEv0P7GxsynpShhq4OLYJzbGcBDkLsDt7MnNg==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/array.prototype.tosorted/-/array.prototype.tosorted-1.1.4.tgz", + "integrity": "sha512-p6Fx8B7b7ZhL/gmUsAy0D15WhvDccw3mnGNbZpi3pmeJdxtWsj2jEaI4Y6oo3XiHfzuSgPwKc04MYt6KgvC/wA==", "dependencies": { - "call-bind": "^1.0.5", + "call-bind": "^1.0.7", "define-properties": "^1.2.1", - "es-abstract": "^1.22.3", - "es-errors": "^1.1.0", + "es-abstract": "^1.23.3", + "es-errors": "^1.3.0", "es-shim-unscopables": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" } }, "node_modules/arraybuffer.prototype.slice": { @@ -1353,14 +1356,14 @@ "optional": true }, "node_modules/bare-fs": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-2.3.0.tgz", - "integrity": "sha512-TNFqa1B4N99pds2a5NYHR15o0ZpdNKbAeKTE/+G6ED/UeOavv8RY3dr/Fu99HW3zU3pXpo2kDNO8Sjsm2esfOw==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-2.3.1.tgz", + "integrity": "sha512-W/Hfxc/6VehXlsgFtbB5B4xFcsCl+pAh30cYhoFyXErf6oGrwjh8SwiPAdHgpmWonKuYpZgGywN0SXt7dgsADA==", "optional": true, "dependencies": { "bare-events": "^2.0.0", "bare-path": "^2.0.0", - "bare-stream": "^1.0.0" + "bare-stream": "^2.0.0" } }, "node_modules/bare-os": { @@ -1379,12 +1382,12 @@ } }, "node_modules/bare-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/bare-stream/-/bare-stream-1.0.0.tgz", - "integrity": "sha512-KhNUoDL40iP4gFaLSsoGE479t0jHijfYdIcxRn/XtezA2BaUD0NRf/JGRpsMq6dMNM+SrCrB0YSSo/5wBY4rOQ==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/bare-stream/-/bare-stream-2.0.1.tgz", + "integrity": "sha512-ubLyoDqPnUf5o0kSFp709HC0WRZuxVuh4pbte5eY95Xvx5bdvz07c2JFmXBfqqe60q+9PJ8S4X5GRvmcNSKMxg==", "optional": true, "dependencies": { - "streamx": "^2.16.1" + "streamx": "^2.18.0" } }, "node_modules/base64-js": { @@ -1508,9 +1511,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001625", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001625.tgz", - "integrity": "sha512-4KE9N2gcRH+HQhpeiRZXd+1niLB/XNLAhSy4z7fI8EzcbcPoAqjNInxVHTiTwWfTIV4w096XG8OtCOCQQKPv3w==", + "version": "1.0.30001628", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001628.tgz", + "integrity": "sha512-S3BnR4Kh26TBxbi5t5kpbcUlLJb9lhtDXISDPwOfI+JoC+ik0QksvkZtUVyikw3hjnkgkMPSJ8oIM9yMm9vflA==", "funding": [ { "type": "opencollective", @@ -1772,9 +1775,9 @@ } }, "node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", + "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", "dependencies": { "ms": "2.1.2" }, @@ -1926,9 +1929,9 @@ } }, "node_modules/enhanced-resolve": { - "version": "5.16.1", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.16.1.tgz", - "integrity": "sha512-4U5pNsuDl0EhuZpq46M5xPslstkviJuhrdobaRDBk2Jy2KO37FDAJl4lb2KlNabxT0m4MTK2UHNrsAcphE8nyw==", + "version": "5.17.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.0.tgz", + "integrity": "sha512-dwDPwZL0dmye8Txp2gzFmA6sxALaSvdRDjPH0viLcKrtlOL3tw62nWWweVD1SdILDTJrbrL6tdWVN58Wo6U3eA==", "dependencies": { "graceful-fs": "^4.2.4", "tapable": "^2.2.0" @@ -3489,7 +3492,7 @@ } }, "node_modules/le-coffre-resources": { - "resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#f45dc562f3eabfa91e11d56b870e2e053c486135", + "resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#67348c776c8319ed8707ade406a2ce454e7adc2e", "license": "MIT", "dependencies": { "class-transformer": "^0.5.1", @@ -4674,12 +4677,13 @@ } }, "node_modules/streamx": { - "version": "2.17.0", - "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.17.0.tgz", - "integrity": "sha512-mzRXEeafEA0skX5XLiDht/zdIqEVs4kgayUTFHDoMjiaZ2kC7DoFsQDJVXRILI2Qme/kWXxLpuU6P0B+xcXpFA==", + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.18.0.tgz", + "integrity": "sha512-LLUC1TWdjVdn1weXGcSxyTR3T4+acB6tVGXT95y0nGbca4t4o/ng1wKAGTljm9VicuCVLvRlqFYXYy5GwgM7sQ==", "dependencies": { - "fast-fifo": "^1.1.0", - "queue-tick": "^1.0.1" + "fast-fifo": "^1.3.2", + "queue-tick": "^1.0.1", + "text-decoder": "^1.1.0" }, "optionalDependencies": { "bare-events": "^2.2.0" @@ -4874,6 +4878,14 @@ "streamx": "^2.15.0" } }, + "node_modules/text-decoder": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.1.0.tgz", + "integrity": "sha512-TmLJNj6UgX8xcUZo4UDStGQtDiTzF7BzWlzn9g7UWrjkpHr5uJTK1ld16wZ3LXb2vb6jH8qU89dW5whuMdXYdw==", + "dependencies": { + "b4a": "^1.6.4" + } + }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -4915,9 +4927,9 @@ } }, "node_modules/tslib": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", - "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" }, "node_modules/tsutils": { "version": "3.21.0", diff --git a/package.json b/package.json index 146d5210..dac22059 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "eslint-config-next": "13.2.4", "form-data": "^4.0.0", "jwt-decode": "^3.1.2", - "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.139", + "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.151", "next": "^14.2.3", "prettier": "^2.8.7", "react": "18.2.0", diff --git a/src/front/Api/LeCoffreApi/Customer/Notes/Notes.ts b/src/front/Api/LeCoffreApi/Customer/Notes/Notes.ts new file mode 100644 index 00000000..464d0501 --- /dev/null +++ b/src/front/Api/LeCoffreApi/Customer/Notes/Notes.ts @@ -0,0 +1,69 @@ +import BaseCustomer from "../BaseCustomer"; +import Note from "le-coffre-resources/dist/Customer/Note"; + +// TODO Type get query params -> Where + inclue + orderby +export interface IGetFoldersParams { + q?: { + select?: {}; + where?: {}; + orderBy?: {}[]; + include?: {}; + }; +} + +export default class Notes extends BaseCustomer { + private static instance: Notes; + private readonly baseURl = this.namespaceUrl.concat("/notes"); + + private constructor() { + super(); + } + + public static getInstance() { + if (!this.instance) { + return new this(); + } else { + return this.instance; + } + } + + /** + * @description : Get a note by uid + */ + public async getByUid(uid: string, q?: any): Promise { + const url = new URL(this.baseURl.concat(`/${uid}`)); + if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value))); + try { + return await this.getRequest(url); + } catch (err) { + this.onError(err); + return Promise.reject(err); + } + } + + /** + * @description : Create a note + */ + public async post(note: Partial): Promise { + const url = new URL(this.baseURl); + try { + return await this.postRequest(url, note); + } catch (err) { + this.onError(err); + return Promise.reject(err); + } + } + + /** + * @description : Update the note + */ + public async put(uid: string, body: Partial): Promise { + const url = new URL(this.baseURl.concat(`/${uid}`)); + try { + return await this.putRequest(url, body); + } catch (err) { + this.onError(err); + return Promise.reject(err); + } + } +} diff --git a/src/front/Components/DesignSystem/FolderBoxInformation/index.tsx b/src/front/Components/DesignSystem/FolderBoxInformation/index.tsx index 48529ede..7048b425 100644 --- a/src/front/Components/DesignSystem/FolderBoxInformation/index.tsx +++ b/src/front/Components/DesignSystem/FolderBoxInformation/index.tsx @@ -9,18 +9,22 @@ import React from "react"; import Typography, { ITypo } from "../Typography"; import classes from "./classes.module.scss"; import { AnchorStatus } from "@Front/Components/Layouts/Folder/FolderInformation"; +import Note from "le-coffre-resources/dist/Customer/Note"; type IProps = { folder: OfficeFolder; type: EFolderBoxInformationType; isArchived?: boolean; anchorStatus: AnchorStatus; + customerUid?: string; + note?: Note | null; }; export enum EFolderBoxInformationType { INFORMATIONS = "informations", DESCRIPTION = "description", ARCHIVED_DESCRIPTION = "archivedDescription", + NOTE = "note", } export default function FolderBoxInformation(props: IProps) { @@ -32,10 +36,27 @@ export default function FolderBoxInformation(props: IProps) { .get() .modules.pages.Folder.pages.EditInformations.props.path.replace("[folderUid]", props.folder.uid ?? ""); - const path = type === EFolderBoxInformationType.DESCRIPTION ? editDescriptionPath : editInformationsPath; + let createOrUpdateNotePath = Module.getInstance() + .get() + .modules.pages.Notes.pages.EditNote.props.path.replace("[noteUid]", props.note?.uid ?? ""); + if (!props.note) { + createOrUpdateNotePath = Module.getInstance() + .get() + .modules.pages.Notes.pages.CreateNote.props.path.replace("[folderUid]", props.folder.uid ?? ""); + createOrUpdateNotePath = createOrUpdateNotePath.replace("[customerUid]", props.customerUid ?? ""); + } + + let path = editInformationsPath; + + if (type === EFolderBoxInformationType.DESCRIPTION) { + path = editDescriptionPath; + } else if (type === EFolderBoxInformationType.NOTE) { + path = createOrUpdateNotePath; + } + return (
-
{renderContentByType(props.folder, type)}
+
{renderContentByType(props.folder, type, props.note)}
{!isArchived && props.anchorStatus === AnchorStatus.NOT_ANCHORED && ( edit informations @@ -44,7 +65,7 @@ export default function FolderBoxInformation(props: IProps) {
); - function renderContentByType(folder: OfficeFolder, type: EFolderBoxInformationType) { + function renderContentByType(folder: OfficeFolder, type: EFolderBoxInformationType, note?: Note | null) { switch (type) { case EFolderBoxInformationType.DESCRIPTION: return ( @@ -53,6 +74,13 @@ export default function FolderBoxInformation(props: IProps) { {folder.description ?? ""} ); + case EFolderBoxInformationType.NOTE: + return ( +
+ Note client + {note?.content ?? ""} +
+ ); case EFolderBoxInformationType.ARCHIVED_DESCRIPTION: return (
diff --git a/src/front/Components/DesignSystem/UserFolder/classes.module.scss b/src/front/Components/DesignSystem/UserFolder/classes.module.scss index 453861ac..2b965a52 100644 --- a/src/front/Components/DesignSystem/UserFolder/classes.module.scss +++ b/src/front/Components/DesignSystem/UserFolder/classes.module.scss @@ -79,5 +79,10 @@ } } } + + .notes { + margin-top: 15px; + width: 50%; + } } } diff --git a/src/front/Components/DesignSystem/UserFolder/index.tsx b/src/front/Components/DesignSystem/UserFolder/index.tsx index 790da0c5..7d2705e2 100644 --- a/src/front/Components/DesignSystem/UserFolder/index.tsx +++ b/src/front/Components/DesignSystem/UserFolder/index.tsx @@ -17,6 +17,7 @@ import classes from "./classes.module.scss"; import DocumentList from "./DocumentList"; import UserFolderHeader from "./UserFolderHeader"; import { AnchorStatus } from "@Front/Components/Layouts/Folder/FolderInformation"; +import FolderBoxInformation, { EFolderBoxInformationType } from "../FolderBoxInformation"; type IProps = { customer: Customer; @@ -73,6 +74,9 @@ export default class UserFolder extends React.Component { documentAskedSubtitle = "Aucun document en attente"; } } + //get the note of the folder that has customer_uid = this.props.customer.uid + const folderNote = this.props.folder.notes?.find((note) => note.customer?.uid === this.props.customer.uid); + return (
{
)}
+
+ +
)} diff --git a/src/front/Components/Layouts/ClientDashboard/classes.module.scss b/src/front/Components/Layouts/ClientDashboard/classes.module.scss index 34bc07c1..da2801a1 100644 --- a/src/front/Components/Layouts/ClientDashboard/classes.module.scss +++ b/src/front/Components/Layouts/ClientDashboard/classes.module.scss @@ -59,6 +59,16 @@ background-color: gray; margin: 0 20px; /* Adjust the margin as needed */ } + + .note-box { + border: 1px solid #e0e0e0; /* Light grey border */ + margin-top: 25px; + padding: 10px; + width: 100%; + height: 100px; /* Adjust height as needed */ + box-sizing: border-box; + position: relative; + } } .sub-container { diff --git a/src/front/Components/Layouts/ClientDashboard/index.tsx b/src/front/Components/Layouts/ClientDashboard/index.tsx index 0d308385..186e40da 100644 --- a/src/front/Components/Layouts/ClientDashboard/index.tsx +++ b/src/front/Components/Layouts/ClientDashboard/index.tsx @@ -4,7 +4,7 @@ import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; import DepositDocument from "@Front/Components/DesignSystem/DepositDocument"; import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Typography"; import DefaultTemplate from "@Front/Components/LayoutTemplates/DefaultTemplate"; -import Customer, { Document, DocumentType, OfficeFolder } from "le-coffre-resources/dist/Customer"; +import Customer, { Document, DocumentType, Note, OfficeFolder } from "le-coffre-resources/dist/Customer"; import React, { useCallback, useEffect, useState } from "react"; import classes from "./classes.module.scss"; @@ -24,6 +24,7 @@ export default function ClientDashboard(props: IProps) { const [customer, setCustomer] = useState(null); const [contact, setContact] = useState(null); const [folder, setFolder] = useState(null); + const [note, setNote] = useState(null); const [isAddDocumentModalVisible, setIsAddDocumentModalVisible] = useState(false); const getDocuments = useCallback(async () => { @@ -36,6 +37,11 @@ export default function ClientDashboard(props: IProps) { q: { office: true, customers: true, + notes: { + include: { + customer: true, + }, + }, stakeholders: { include: { contact: true, @@ -44,7 +50,6 @@ export default function ClientDashboard(props: IProps) { }, }, }); - //Loop through the folder stakeholders, if there is at least one stakeholder that role is "Collaborateur" set contact to this stakeholders.contact, else, take the first stakeholders of the list const contact = folder.stakeholders!.find((stakeholder) => stakeholder.office_role?.name === "Collaborateur")?.contact; setContact(contact ?? folder.stakeholders![0]!.contact); @@ -52,6 +57,9 @@ export default function ClientDashboard(props: IProps) { const actualCustomer = folder?.customers?.find((customer) => customer.contact?.email === jwt?.email); if (!actualCustomer) throw new Error("Customer not found"); + const note = folder.notes?.find((note) => note.customer?.uid === actualCustomer.uid); + if (!note) throw new Error("Note not found"); + const query: IGetDocumentsparams = { where: { depositor: { uid: actualCustomer.uid }, folder_uid: folderUid as string }, include: { @@ -78,6 +86,7 @@ export default function ClientDashboard(props: IProps) { setFolder(folder); setDocuments(documentList); setCustomer(actualCustomer); + setNote(note); }, [folderUid]); const onCloseModalAddDocument = useCallback(() => { @@ -136,7 +145,13 @@ export default function ClientDashboard(props: IProps) { sélectionnez le document correspondant.
En déposant un document, celui-ci est automatiquement enregistré et transmis à votre notaire. +
+ + {note?.content} + +
+

diff --git a/src/front/Components/Layouts/Folder/CreateCustomerNote/classes.module.scss b/src/front/Components/Layouts/Folder/CreateCustomerNote/classes.module.scss new file mode 100644 index 00000000..cd3ceba2 --- /dev/null +++ b/src/front/Components/Layouts/Folder/CreateCustomerNote/classes.module.scss @@ -0,0 +1,56 @@ +@import "@Themes/constants.scss"; + +.root { + display: flex; + flex-direction: column; + min-height: 100%; + align-items: flex-start; + width: fit-content; + + .back-arrow { + margin-bottom: 24px; + } + + .form { + width: 100%; + + .content { + margin-top: 32px; + + >:not(:last-child) { + margin-bottom: 24px; + } + + } + + .button-container { + width: 100%; + display: flex; + text-align: center; + margin-top: 24px; + + .cancel-button { + display: flex; + margin-right: 32px; + } + + @media (max-width: $screen-m) { + display: flex; + flex-direction: column-reverse; + + .cancel-button { + margin-left: 0; + margin-top: 12px; + + >* { + flex: 1; + } + } + + >* { + width: 100%; + } + } + } + } +} \ No newline at end of file diff --git a/src/front/Components/Layouts/Folder/CreateCustomerNote/index.tsx b/src/front/Components/Layouts/Folder/CreateCustomerNote/index.tsx new file mode 100644 index 00000000..5ef9d77d --- /dev/null +++ b/src/front/Components/Layouts/Folder/CreateCustomerNote/index.tsx @@ -0,0 +1,114 @@ +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 ; +} diff --git a/src/front/Components/Layouts/Folder/FolderInformation/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/index.tsx index 86b5d635..097f2d11 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/index.tsx @@ -489,6 +489,11 @@ export default function FolderInformation(props: IProps) { }, }, folder_anchor: true, + notes: { + include: { + customer: true, + }, + }, }, }; diff --git a/src/front/Components/Layouts/Folder/UpdateCustomerNote/classes.module.scss b/src/front/Components/Layouts/Folder/UpdateCustomerNote/classes.module.scss new file mode 100644 index 00000000..cd3ceba2 --- /dev/null +++ b/src/front/Components/Layouts/Folder/UpdateCustomerNote/classes.module.scss @@ -0,0 +1,56 @@ +@import "@Themes/constants.scss"; + +.root { + display: flex; + flex-direction: column; + min-height: 100%; + align-items: flex-start; + width: fit-content; + + .back-arrow { + margin-bottom: 24px; + } + + .form { + width: 100%; + + .content { + margin-top: 32px; + + >:not(:last-child) { + margin-bottom: 24px; + } + + } + + .button-container { + width: 100%; + display: flex; + text-align: center; + margin-top: 24px; + + .cancel-button { + display: flex; + margin-right: 32px; + } + + @media (max-width: $screen-m) { + display: flex; + flex-direction: column-reverse; + + .cancel-button { + margin-left: 0; + margin-top: 12px; + + >* { + flex: 1; + } + } + + >* { + width: 100%; + } + } + } + } +} \ No newline at end of file diff --git a/src/front/Components/Layouts/Folder/UpdateCustomerNote/index.tsx b/src/front/Components/Layouts/Folder/UpdateCustomerNote/index.tsx new file mode 100644 index 00000000..dde3dabc --- /dev/null +++ b/src/front/Components/Layouts/Folder/UpdateCustomerNote/index.tsx @@ -0,0 +1,109 @@ +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 Link from "next/link"; +import { NextRouter, useRouter } from "next/router"; + +import BasePage from "../../Base"; +import classes from "./classes.module.scss"; +import Note from "le-coffre-resources/dist/Customer/Note"; +import Notes from "@Front/Api/LeCoffreApi/Customer/Notes/Notes"; + +type IProps = {}; + +type IPropsClass = IProps & { + noteUid: string; + router: NextRouter; +}; + +type IState = { + note: Note | null; + backwardPath: string; +}; +class UpdateCustomerNoteClass extends BasePage { + constructor(props: IPropsClass) { + super(props); + this.state = { + note: null, + backwardPath: "", + }; + this.onFormSubmit = this.onFormSubmit.bind(this); + } + public override render(): JSX.Element { + return ( + +
+
+ +
+ Modifier la note du client + +
+
+ +
+ +
+ + + + +
+
+
+
+ ); + } + + public override async componentDidMount() { + const query = { + q: { + customer: "true", + folder: "true", + }, + }; + const note = await Notes.getInstance().getByUid(this.props.noteUid, query); + // const folder = await Folders.getInstance().getByUid(this.props.folderUid, { note: true }); + //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, + backwardPath: Module.getInstance() + .get() + .modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", note.folder?.uid!), + }); + } + + private async onFormSubmit(e: React.FormEvent | null, values: { [key: string]: string }) { + try { + const note = { + content: values["content"], + }; + + await Notes.getInstance().put(this.props.noteUid, note); + this.props.router.push(this.state.backwardPath); + + // await Folders.getInstance().put(this.props.folderUid, values); + // this.props.router.push(this.backwardPath); + } catch (error) { + console.error(error); + } + } +} + +export default function UpdateCustomerNote(props: IProps) { + const router = useRouter(); + let { noteUid } = router.query; + + noteUid = noteUid as string; + + return ; +} diff --git a/src/front/Components/Layouts/FolderArchived/FolderInformation/index.tsx b/src/front/Components/Layouts/FolderArchived/FolderInformation/index.tsx index 9e06a63c..ef018df8 100644 --- a/src/front/Components/Layouts/FolderArchived/FolderInformation/index.tsx +++ b/src/front/Components/Layouts/FolderArchived/FolderInformation/index.tsx @@ -215,6 +215,7 @@ class FolderInformationClass extends BasePage { deed: { include: { deed_type: "true" } }, office: "true", customers: { include: { contact: true } }, + notes: "true", }, }; const folder = await Folders.getInstance().getByUid(this.props.selectedFolderUid, query); diff --git a/src/front/Config/Module/development.json b/src/front/Config/Module/development.json index 224c6033..2e7e5c5c 100644 --- a/src/front/Config/Module/development.json +++ b/src/front/Config/Module/development.json @@ -360,6 +360,29 @@ } } } + }, + "Notes": { + "enabled": true, + "props": { + "path": "/notes", + "labelKey": "notes" + }, + "pages": { + "EditNote": { + "enabled": true, + "props": { + "path": "/notes/[noteUid]/edit", + "labelKey": "edit_note" + } + }, + "CreateNote": { + "enabled": true, + "props": { + "path": "/notes/folder/[folderUid]/customer/[customerUid]/create", + "labelKey": "create_note" + } + } + } } } } diff --git a/src/pages/notes/[noteUid]/edit.tsx b/src/pages/notes/[noteUid]/edit.tsx new file mode 100644 index 00000000..26f5c657 --- /dev/null +++ b/src/pages/notes/[noteUid]/edit.tsx @@ -0,0 +1,5 @@ +import UpdateCustomerNote from "@Front/Components/Layouts/Folder/UpdateCustomerNote"; + +export default function Route() { + return ; +} diff --git a/src/pages/notes/folder/[folderUid]/customer/[customerUid]/create.tsx b/src/pages/notes/folder/[folderUid]/customer/[customerUid]/create.tsx new file mode 100644 index 00000000..9765dea1 --- /dev/null +++ b/src/pages/notes/folder/[folderUid]/customer/[customerUid]/create.tsx @@ -0,0 +1,5 @@ +import CreateCustomerNote from "@Front/Components/Layouts/Folder/CreateCustomerNote"; + +export default function Route() { + return ; +}