diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/DeedTypes/DeedTypes.ts b/src/front/Api/LeCoffreApi/SuperAdmin/DeedTypes/DeedTypes.ts index 548a95ff..c9a05459 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/DeedTypes/DeedTypes.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/DeedTypes/DeedTypes.ts @@ -15,7 +15,7 @@ export type IPutDeedTypesParams = { deed?: DeedType["deed"]; office?: DeedType["office"]; archived_at?: DeedType["archived_at"]; - deed_type_has_document_types?: DeedType["deed_type_has_document_types"]; + document_types?: DeedType["document_types"]; }; export default class DeedTypes extends BaseSuperAdmin { diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/Deeds/Deeds.ts b/src/front/Api/LeCoffreApi/SuperAdmin/Deeds/Deeds.ts index 3953781f..a3360412 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/Deeds/Deeds.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/Deeds/Deeds.ts @@ -15,7 +15,7 @@ export type IPutDeedsParams = { description?: OfficeFolder["description"]; archived_description?: OfficeFolder["archived_description"]; status?: OfficeFolder["status"]; - deed_has_document_types?: Deed["deed_has_document_types"]; + document_types?: Deed["document_types"]; }; export default class Deeds extends BaseSuperAdmin { diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/Users/Users.ts b/src/front/Api/LeCoffreApi/SuperAdmin/Users/Users.ts index 17432643..319a01fd 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/Users/Users.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/Users/Users.ts @@ -15,7 +15,6 @@ export type IPutUsersParams = { idNot?: User["idNot"]; contact?: User["contact"]; office_membership?: User["office_membership"]; - office_folder_has_stakeholders?: User["office_folder_has_stakeholders"]; documents?: User["documents"]; }; diff --git a/src/front/Components/DesignSystem/SearchBar/index.tsx b/src/front/Components/DesignSystem/SearchBar/index.tsx index 3a680722..40590a95 100644 --- a/src/front/Components/DesignSystem/SearchBar/index.tsx +++ b/src/front/Components/DesignSystem/SearchBar/index.tsx @@ -59,10 +59,10 @@ export default class SearchBar extends React.Component { const number = folder.folder_number.toLowerCase(); const value = event.target.value.toLowerCase(); - if (folder.office_folder_has_customers) { - const customerNames = folder.office_folder_has_customers + if (folder.customers) { + const customerNames = folder.customers .map((customer) => { - return `${customer.customer.contact?.first_name.toLowerCase()} ${customer.customer.contact?.last_name.toLowerCase()}`; + return `${customer.contact?.first_name.toLowerCase()} ${customer.contact?.last_name.toLowerCase()}`; }) .join(", "); return name.includes(value) || number.includes(value) || customerNames.includes(value); diff --git a/src/front/Components/LayoutTemplates/DefaultNotaryDashboard/index.tsx b/src/front/Components/LayoutTemplates/DefaultNotaryDashboard/index.tsx index bad6838a..00ec42dc 100644 --- a/src/front/Components/LayoutTemplates/DefaultNotaryDashboard/index.tsx +++ b/src/front/Components/LayoutTemplates/DefaultNotaryDashboard/index.tsx @@ -39,7 +39,7 @@ export type IDashBoardFolder = { description: OfficeFolder["description"]; deed?: OfficeFolder["deed"]; created_at: OfficeFolder["created_at"]; - office_folder_has_customers?: OfficeFolder["office_folder_has_customers"]; + customers?: OfficeFolder["customers"]; archived_description: OfficeFolder["archived_description"]; status: OfficeFolder["status"]; }; diff --git a/src/front/Components/Layouts/ClientDashboard/index.tsx b/src/front/Components/Layouts/ClientDashboard/index.tsx index dd25c1ec..0df97dce 100644 --- a/src/front/Components/Layouts/ClientDashboard/index.tsx +++ b/src/front/Components/Layouts/ClientDashboard/index.tsx @@ -10,7 +10,6 @@ import React from "react"; import classes from "./classes.module.scss"; import Customers from "@Front/Api/LeCoffreApi/SuperAdmin/Customers/Customers"; import Customer, { Document } from "le-coffre-resources/dist/Customer"; -import { document } from "./../../../Components/Layouts/DesignSystem/dummyData"; type IProps = { targetedCustormer: string; // MOCK @@ -69,7 +68,7 @@ export default class ClientDashboard extends Base { Glissez / Déposez votre document dans la zone prévue à cet effet ou cliquez sur la zone puis sélectionnez le document correspondant. - + {/* */} diff --git a/src/front/Components/Layouts/DesignSystem/classes.module.scss b/src/front/Components/Layouts/DesignSystem/classes.module.scss deleted file mode 100644 index 61db99b4..00000000 --- a/src/front/Components/Layouts/DesignSystem/classes.module.scss +++ /dev/null @@ -1,18 +0,0 @@ -.root { - margin-left: 35px; - margin-right: 35px; - .section { - margin-bottom: 32px; - } - .sub-section { - margin-bottom: 24px; - } - - .inline-flex { - display: inline-flex; - } - - .folder-conatainer { - width: 389px; - } -} diff --git a/src/front/Components/Layouts/DesignSystem/dummyData.ts b/src/front/Components/Layouts/DesignSystem/dummyData.ts deleted file mode 100644 index 85af3021..00000000 --- a/src/front/Components/Layouts/DesignSystem/dummyData.ts +++ /dev/null @@ -1,347 +0,0 @@ -import { ECustomerStatus } from "le-coffre-resources/dist/Customer/Customer"; -import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document"; -import EFolderStatus from "le-coffre-resources/dist/Customer/EFolderStatus"; -import { - Address, - Contact, - Customer, - Deed, - DeedType, - Document, - DocumentType, - File, - Office, - OfficeFolder, - OfficeFolderHasCustomer, -} from "le-coffre-resources/dist/Notary"; - -export const address: Address = { - uid: "a&2azedzaa3", - address: "123", - city: "France", - zip_code: 78140, - created_at: new Date(), - updated_at: new Date(), -}; - -export const office: Office = { - uid: "111zdazaefez213", - idNot: "12EE12", - name: "Office 1", - crpcen: "AZezdz", - address: address, - created_at: new Date(), - updated_at: new Date(), - office_status: "ACTIVATED", -}; -export const deedType: DeedType = { - uid: "123azefezgzeg312", - name: "Acte mariage", - description: "dzsdaf", - archived_at: new Date(), - office: office, - created_at: new Date(), - updated_at: new Date(), -}; - -export const deed: Deed = { - uid: "zegefzeferg", - deed_type: deedType, - created_at: new Date(), - updated_at: new Date(), -}; - -export const contact: Contact = { - uid: "contact_1_uid", - first_name: "John", - last_name: "Doe", - email: "johnDoe@gmail.com", - address: address, - created_at: new Date(), - updated_at: new Date(), - cell_phone_number: "0132249865", - phone_number: "0132249865", - civility: "MALE", -}; - -export const contact2: Contact = { - uid: "contact_2_uid", - first_name: "Customer2", - last_name: "Doe", - email: "johnDoe@gmail.com", - address: address, - created_at: new Date(), - updated_at: new Date(), - cell_phone_number: "0132249865", - phone_number: "0132249865", - civility: "MALE", -}; - -export const docType: DocumentType = { - name: "Votre document", - uid: "fezezfazegezrgrezg", - created_at: new Date(), - updated_at: new Date(), - public_description: "", - private_description: "", - archived_at: new Date(), - office: office, -}; - -export const identityDocType: DocumentType = { - name: "Carte d'identité", - uid: "fezezfazegezrgrezg", - created_at: new Date(), - updated_at: new Date(), - public_description: "Carte d'identité public description", - private_description: "Carte d'identité private description", - archived_at: new Date(), - office: office, -}; - -export const customer: Customer = { - uid: "erhtgerfzeare", - contact: contact, - created_at: new Date(), - updated_at: new Date(), - status: ECustomerStatus.VALIDATED, -}; - -export const customer2_mock: Customer = { - uid: "yregrgetergrt", - contact: contact2, - created_at: new Date(), - updated_at: new Date(), - status: ECustomerStatus.VALIDATED, -}; - -export const folder: OfficeFolder = { - uid: "mkovrijvrezviev", - folder_number: "12331", - name: "Mon dossier", - status: EFolderStatus.ARCHIVED, - deed: deed, - office: office, - created_at: new Date(), - updated_at: new Date(), - description: "Description", - archived_description: "Archived description", -}; - -export const document: Document = { - uid: "fzeafergreztyzgrf", - depositor: customer2_mock, - document_status: "ASKED", - folder: folder, - document_type: docType, - updated_at: new Date(), - created_at: new Date(), -}; - -export const fileMock: File = { - uid: "super_file_uid_1", - created_at: new Date(), - updated_at: new Date(), - document: document, - file_name: "file_1", - file_path: - "https://minteed-stg-euwest3-s3.s3.eu-west-3.amazonaws.com/Qmf_Yb_Eh_X9st_F_Srq_Ve_Bj_Yb_Aj56xv_AV_Nj6_Wjypo_B4r5ubce_U_ae3303e7ab.pdf", - archived_at: null, - mimetype: "image/png", - size: 0, -}; - -export const fileMock2: File = { - uid: "super_file_uid_2", - created_at: new Date(), - updated_at: new Date(), - document: document, - file_name: "file_2", - file_path: - "https://minteed-prod-euwest3-s3.s3.eu-west-3.amazonaws.com/Qm_Wq_En1_DCA_8yt_RX_Qx_QFA_9_Fm_ZKZH_Qqb_VH_1_Q_Mnv_G_Jtt1_FS_Xp_2a35a36e19", - archived_at: null, - mimetype: "image/png", - size: 0, -}; - -export const identityFile: File = { - uid: "identity_file_uid", - created_at: new Date(), - updated_at: new Date(), - document: document, - file_name: "file_3", - file_path: "https://minteed-stg-euwest3-s3.s3.eu-west-3.amazonaws.com/cni_fake_c7259d4923.png", - archived_at: null, - mimetype: "image/png", - size: 0, -}; - -export const documentIdentity: Document = { - uid: "ethrthbkjtrbporjbh", - depositor: customer2_mock, - document_status: EDocumentStatus.DEPOSITED, - folder: folder, - document_type: identityDocType, - updated_at: new Date(), - created_at: new Date(), - files: [identityFile], -}; - -export const documentPending: Document = { - uid: "fzefeazdagrtetrury", - depositor: customer2_mock, - document_status: EDocumentStatus.DEPOSITED, - folder: folder, - document_type: docType, - updated_at: new Date(), - created_at: new Date(), - files: [fileMock, fileMock2], -}; - -export const documentDeposited: Document = { - uid: "uè§u§htfgrthytrgr", - depositor: customer2_mock, - document_status: "VALIDATED", - folder: folder, - document_type: docType, - updated_at: new Date(), - created_at: new Date(), - files: [fileMock], -}; - -export const customer2: Customer = { - uid: "yregrgetergrt", - contact: contact2, - created_at: new Date(), - updated_at: new Date(), - status: ECustomerStatus.VALIDATED, - documents: [document, documentPending, documentDeposited, documentIdentity], -}; - -export const folderWithPendingDocument: OfficeFolder = { - uid: "ferzferzfezeefzdd", - folder_number: "00001", - name: "Mon dossier", - status: EFolderStatus.LIVE, - deed: deed, - office: office, - created_at: new Date(), - updated_at: new Date(), - description: "Description", - archived_description: "Archived description", - documents: [], -}; -export const folderWithPendingDocument1: OfficeFolder = { - uid: "gtrtyutyhretgytu", - folder_number: "00002", - name: "Mon dossier", - status: EFolderStatus.LIVE, - deed: deed, - office: office, - created_at: new Date(), - updated_at: new Date(), - description: "Description", - archived_description: "Archived description", - documents: [documentDeposited], -}; -export const folderWithPendingDocument2: OfficeFolder = { - uid: "adzefzefsfrefzrtgtr", - folder_number: "00003", - name: "Mon dossier", - status: EFolderStatus.LIVE, - deed: deed, - office: office, - created_at: new Date(), - updated_at: new Date(), - description: "Description", - archived_description: "Archived description", - documents: [document], -}; - -export const officeFolderHasCustomer1: OfficeFolderHasCustomer = { - uid: "ferzfergrzeyerezrz", - customer: customer, - office_folder: folderWithPendingDocument, - created_at: new Date(), - updated_at: new Date(), -}; - -export const officeFolderHasCustomer2: OfficeFolderHasCustomer = { - uid: "tezrfzdfgrggeerry", - customer: customer2, - office_folder: folderWithPendingDocument, - created_at: new Date(), - updated_at: new Date(), -}; - -export const folderWithPendingDocument3: OfficeFolder = { - uid: "mkovrijvrezviev", - folder_number: "00014", - name: "Mon dossier", - status: EFolderStatus.LIVE, - deed: deed, - office: office, - created_at: new Date(), - updated_at: new Date(), - description: "Description", - archived_description: "Archived description", - documents: [document, documentDeposited, documentPending, documentIdentity], - office_folder_has_customers: [officeFolderHasCustomer1, officeFolderHasCustomer2], -}; - -export const document8: Document = { - uid: "eztreggrgbyunjukhg", - depositor: customer, - document_status: "ASKED", - folder: folderWithPendingDocument, - document_type: docType, - updated_at: new Date(), - created_at: new Date(), -}; - -export const folderWithPendingDocumentArchived1: OfficeFolder = { - uid: "gtrtyutyhrdazafad&éfytu", - folder_number: "00007", - name: "Mon dossier", - status: EFolderStatus.ARCHIVED, - deed: deed, - office: office, - created_at: new Date(), - updated_at: new Date(), - description: "Description", - archived_description: "Archived description", - documents: [documentDeposited], - office_folder_has_customers: [officeFolderHasCustomer1, officeFolderHasCustomer2], -}; -export const folderWithPendingDocumentArchived2: OfficeFolder = { - uid: "adzefdazdaazzrtgtr", - folder_number: "00008", - name: "Mon dossier", - status: EFolderStatus.ARCHIVED, - deed: deed, - office: office, - created_at: new Date(), - updated_at: new Date(), - description: "Description", - archived_description: "Archived description", - documents: [document], -}; - -export const document2: Document = { - uid: "mejfihruehfoire", - depositor: customer, - document_status: "ASKED", - folder: folderWithPendingDocument3, - document_type: docType, - updated_at: new Date(), - created_at: new Date(), -}; - -export const folders: OfficeFolder[] = [ - folderWithPendingDocument, - folderWithPendingDocument1, - folderWithPendingDocument2, - folderWithPendingDocument3, -]; - -export const foldersArchived: OfficeFolder[] = [folderWithPendingDocumentArchived1, folderWithPendingDocumentArchived2]; diff --git a/src/front/Components/Layouts/DesignSystem/index.tsx b/src/front/Components/Layouts/DesignSystem/index.tsx deleted file mode 100644 index 20a6108e..00000000 --- a/src/front/Components/Layouts/DesignSystem/index.tsx +++ /dev/null @@ -1,319 +0,0 @@ -import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; -import CheckBox from "@Front/Components/DesignSystem/CheckBox"; -import DocumentNotary from "@Front/Components/DesignSystem/Document/DocumentNotary"; -import FilePreview from "@Front/Components/DesignSystem/FilePreview"; -import FolderContainer from "@Front/Components/DesignSystem/FolderContainer"; -import FolderList from "@Front/Components/DesignSystem/FolderListContainer"; -import HeaderLink from "@Front/Components/DesignSystem/Header/HeaderLink"; -import Confirm from "@Front/Components/DesignSystem/Modal/Confirm"; -import MultiSelect from "@Front/Components/DesignSystem/MultiSelect"; -import QuantityProgressBar from "@Front/Components/DesignSystem/QuantityProgressBar"; -import RadioBox from "@Front/Components/DesignSystem/RadioBox"; -import SearchBar from "@Front/Components/DesignSystem/SearchBar"; -import ToolTip from "@Front/Components/DesignSystem/ToolTip"; -import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography"; -import UserFolder from "@Front/Components/DesignSystem/UserFolder"; -import BasePage from "@Front/Components/Layouts/Base"; -import DefaultTemplate from "@Front/Components/LayoutTemplates/DefaultTemplate"; -import Toasts, { IToast } from "@Front/Stores/Toasts"; - -import classes from "./classes.module.scss"; -import { customer2, document, documentDeposited, documentPending, folder, folders, folderWithPendingDocument } from "./dummyData"; -import { IDashBoardFolder } from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard"; -import SelectField, { IOption } from "@Front/Components/DesignSystem/Form/SelectField"; -import TextField from "@Front/Components/DesignSystem/Form/TextField"; -import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField"; - -type IState = { - isModalDisplayed: boolean; - selectedOption?: IOption; -}; -type IProps = {}; - -export default class DesignSystem extends BasePage { - constructor(props: IProps) { - super(props); - this.state = { - isModalDisplayed: false, - }; - this.openModal = this.openModal.bind(this); - this.closeModal = this.closeModal.bind(this); - this.onSelectedOption = this.onSelectedOption.bind(this); - } - - public override render(): JSX.Element { - const selectOptions: IOption[] = [ - { value: "1", label: "Divorce" }, - { value: "2", label: "Succession" }, - { value: "3", label: "Vente immobilière" }, - ]; - return ( - -
-
-
- Website design System -
-
- - This page allows to gather all the design system of the site. A Design System is a library of components, - visuals and principles with reusable code. This evolving kit offers a UX and UI repository for designers and - developers of digital products and services. The construction of a design system offers many advantages. - This solution facilitates the work of the teams and reduces the "design debt" and the "technical debt". The - result is a coherent ecosystem and therefore a better experience for users and customers. - -
-
-
-
- Button components -
- - - -
- -
-
- Toaster component -
- -
-
-
- Modal components -
- - - - Lorem ipsum dolor sit amet consectetur. Aliquam nunc lobortis lacus vulputate sagittis sed tempor eget feugiat. - Elementum malesuada at sit elit. - -
- -
-
- HeaderLink components -
-
- - -
-
-
-
- CheckBox component -
- - -
-
-
- RadioBox component -
- - Radio Box 1 - - - Radio Box 2 - -
-
-
- Tool tip component -
- -
-
-
- Input component -
-
- -
-
- -
-
- -
-
- -
-
- Progress bar component -
-
- -
-
- -
-
- -
-
- -
-
- Folder container component -
-
- Folder with no document to validate -
- -
-
-
- Folder with document waiting for being validate -
- -
-
-
- -
-
- Select component -
-
-
- -
-
-
- -
-
- Notary Documents -
-
- Documents ASKED -
- -
-
-
- Documents Depoited -
- -
-
-
- Documents VALIDATED - -
- -
-
-
- -
-
- Notary Documents -
-
- { - return; - }} - /> -
-
- -
-
- MultiSelect -
-
- -
-
- -
-
- Document SearchBar -
-
- -
-
- -
-
- Folder List -
-
- -
-
- -
-
- Preview Image/Pdf -
-
-
- -
- -
-
-
-
- ); - } - private openModal() { - this.setState({ - isModalDisplayed: true, - }); - } - private closeModal() { - this.setState({ - isModalDisplayed: false, - }); - } - private spawnToast() { - const toast: IToast = { - title: "Un collaborateur veut rejoindre votre office", - text: "12:00 - 1 fev 2023", - }; - Toasts.getInstance().open(toast); - } - - private onSelectedOption(option: IOption) { - this.setState({ - selectedOption: option, - }); - } -} diff --git a/src/front/Components/Layouts/Folder/AddClientToFolder/index.tsx b/src/front/Components/Layouts/Folder/AddClientToFolder/index.tsx index 69e613cf..b9acad59 100644 --- a/src/front/Components/Layouts/Folder/AddClientToFolder/index.tsx +++ b/src/front/Components/Layouts/Folder/AddClientToFolder/index.tsx @@ -9,7 +9,7 @@ import BackArrow from "@Front/Components/Elements/BackArrow"; import DefaultNotaryDashboard from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard"; import Module from "@Front/Config/Module"; import { ECivility } from "le-coffre-resources/dist/Customer/Contact"; -import { Customer, OfficeFolder, OfficeFolderHasCustomer } from "le-coffre-resources/dist/Notary"; +import { Customer, OfficeFolder } from "le-coffre-resources/dist/Notary"; import Link from "next/link"; import { NextRouter, useRouter } from "next/router"; @@ -164,10 +164,10 @@ class AddClientToFolderClass extends BasePage { let preExistingCustomers: IOption[] = []; try { const folder = await Folders.getInstance().getByUid(folderUid, query); - preExistingCustomers = folder.office_folder_has_customers!.map((folderHasCustomer) => { + preExistingCustomers = folder.customers!.map((customer) => { return { - label: folderHasCustomer.customer.contact?.first_name + " " + folderHasCustomer.customer.contact?.last_name, - value: folderHasCustomer.customer.uid, + label: customer.contact?.first_name + " " + customer.contact?.last_name, + value: customer.uid, }; }); } catch (error) { @@ -209,23 +209,23 @@ class AddClientToFolderClass extends BasePage { values["civility"] = ECivility.MALE; // TODO: should maybe be deleted later or added to the form const allCustomersToLink = this.state.selectedCustomers.concat(this.state.existingCustomers); - let customersToLink: Partial[] = allCustomersToLink.map((customer) => { + let customersToLink: Partial[] = allCustomersToLink.map((customer) => { return { customer: { uid: customer.value }, }; - }) as Partial[]; + }) as Partial[]; if (this.state.selectedOption === "new_customer") { const customer: Customer = await Customers.getInstance().post({ contact: values, }); if (!customer.uid) return; - customersToLink?.push({ customer: { uid: customer.uid } } as Partial); + customersToLink?.push({ customer: { uid: customer.uid } } as Partial); } if (customersToLink) { - const body = OfficeFolder.hydrate({ office_folder_has_customers: customersToLink.map((customer) => { - return OfficeFolderHasCustomer.hydrate(customer); + const body = OfficeFolder.hydrate({ customers: customersToLink.map((customer) => { + return Customer.hydrate(customer); }) }); await Folders.getInstance().put(this.props.selectedFolderUid, body); diff --git a/src/front/Components/Layouts/Folder/AskDocuments/index.tsx b/src/front/Components/Layouts/Folder/AskDocuments/index.tsx index d360b6f5..eedec845 100644 --- a/src/front/Components/Layouts/Folder/AskDocuments/index.tsx +++ b/src/front/Components/Layouts/Folder/AskDocuments/index.tsx @@ -169,8 +169,8 @@ class AskDocumentsClass extends BasePage { .map((document) => { return document.document_type!.uid!; }); - const documentTypes = folder.deed!.deed_has_document_types!.filter((documentType) => { - if (userDocumentTypesUids.includes(documentType.document_type!.uid!)) return false; + const documentTypes = folder.deed!.document_types!.filter((documentType) => { + if (userDocumentTypesUids.includes(documentType!.uid!)) return false; return true; }); @@ -182,9 +182,9 @@ class AskDocumentsClass extends BasePage { }) .map((documentType) => { return { - label: documentType.document_type!.name!, - value: documentType.document_type!.uid!, - description: documentType.document_type!.private_description!, + label: documentType!.name!, + value: documentType!.uid!, + description: documentType!.private_description!, }; }); @@ -209,13 +209,11 @@ class AskDocumentsClass extends BasePage { public_description: this.state.visibleDescription, }); - const oldDocumentsType = this.state.folder?.deed?.deed_has_document_types!; + const oldDocumentsType = this.state.folder?.deed?.document_types!; await Deeds.getInstance().put(this.state.folder?.deed?.uid!, { - deed_has_document_types: [ + document_types: [ ...oldDocumentsType, - { - document_type: documentType, - }, + documentType, ], }); diff --git a/src/front/Components/Layouts/Folder/CreateFolder/index.tsx b/src/front/Components/Layouts/Folder/CreateFolder/index.tsx index bbae4b7b..5056836a 100644 --- a/src/front/Components/Layouts/Folder/CreateFolder/index.tsx +++ b/src/front/Components/Layouts/Folder/CreateFolder/index.tsx @@ -13,7 +13,7 @@ import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Ty import BackArrow from "@Front/Components/Elements/BackArrow"; import DefaultDoubleSidePage from "@Front/Components/LayoutTemplates/DefaultDoubleSidePage"; import { ValidationError } from "class-validator"; -import { Deed, DeedType, Office, OfficeFolder, OfficeFolderHasStakeholder } from "le-coffre-resources/dist/Notary"; +import { Deed, DeedType, Office, OfficeFolder } from "le-coffre-resources/dist/Notary"; import User from "le-coffre-resources/dist/Notary"; import { NextRouter, useRouter } from "next/router"; import React from "react"; @@ -243,13 +243,14 @@ class CreateFolderClass extends BasePage { const usersMock = await Users.getInstance().get({ include: { office_membership: true } }); const userMock = usersMock[0]; - let stakeholders = this.getStakeholders(); - let testUsers = stakeholders.map((stakeholder) => ({ - user_stakeholder: { - uid: stakeholder.user_stakeholder.uid, - }, - })); - + let stakeholders = this.state.collaborators; + if (this.state.folder_access === "select_collaborators") { + stakeholders = this.state.collaborators.filter((collaborator) => { + return this.state.formValues.collaborators?.some((selectedCollaborator) => { + return selectedCollaborator.value === collaborator.uid; + }); + }); + } const officeFolderForm = OfficeFolder.hydrate({ folder_number: values["folder_number"], name: values["name"], @@ -262,13 +263,8 @@ class CreateFolderClass extends BasePage { office: Office.hydrate({ uid: userMock?.office_membership?.uid, }), - office_folder_has_stakeholder: testUsers.map((user) => { - return OfficeFolderHasStakeholder.hydrate({ - user_stakeholder: User.hydrate({ - uid: user.user_stakeholder.uid, - }), - }); - }), + customers: [], + stakeholders }); try { @@ -313,25 +309,6 @@ class CreateFolderClass extends BasePage { folder_access: e.target.value, }); } - - private getStakeholders() { - let collaborators: User[] = this.state.collaborators; - - let office_folder_has_stakeholders = collaborators.map((collaborator) => { - return OfficeFolderHasStakeholder.hydrate({ - user_stakeholder: collaborator, - }); - }); - - if (this.state.folder_access === "select_collaborators") { - office_folder_has_stakeholders = office_folder_has_stakeholders.filter((collaborator) => { - return this.state.formValues.collaborators?.some((selectedCollaborator) => { - return selectedCollaborator.value === collaborator.user_stakeholder.uid; - }); - }); - } - return office_folder_has_stakeholders; - } } export default function CreateFolder(props: IProps): JSX.Element { diff --git a/src/front/Components/Layouts/Folder/FolderInformation/ClientSection/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/ClientSection/index.tsx index e95817f0..aa5f46b0 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/ClientSection/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/ClientSection/index.tsx @@ -60,14 +60,14 @@ export default class ClientSection extends React.Component { } private renderCustomerFolders() { - const output = this.props.folder.office_folder_has_customers?.map((folderHasCustomer) => { - if (!folderHasCustomer.customer) return null; + const output = this.props.folder.customers?.map((customer) => { + if (!customer) return null; return ( ); @@ -83,7 +83,7 @@ export default class ClientSection extends React.Component { } private doesFolderHaveCustomer(): boolean { - if (!this.props.folder?.office_folder_has_customers) return false; - return this.props.folder?.office_folder_has_customers!.length > 0; + if (!this.props.folder?.customers) return false; + return this.props.folder?.customers!.length > 0; } } diff --git a/src/front/Components/Layouts/Folder/FolderInformation/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/index.tsx index cd91f829..a0fafb0e 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/index.tsx @@ -155,8 +155,8 @@ class FolderInformationClass extends BasePage { } private doesFolderHaveCustomer(): boolean { - if (!this.state.selectedFolder?.office_folder_has_customers) return false; - return this.state.selectedFolder?.office_folder_has_customers!.length > 0; + if (!this.state.selectedFolder?.customers) return false; + return this.state.selectedFolder?.customers!.length > 0; } private onSelectedFolder(folder: IDashBoardFolder): void { diff --git a/src/front/Components/Layouts/Folder/UpdateFolderCollaborators/index.tsx b/src/front/Components/Layouts/Folder/UpdateFolderCollaborators/index.tsx index 25ce20ba..8b99c85e 100644 --- a/src/front/Components/Layouts/Folder/UpdateFolderCollaborators/index.tsx +++ b/src/front/Components/Layouts/Folder/UpdateFolderCollaborators/index.tsx @@ -1,20 +1,20 @@ +import Folders from "@Front/Api/LeCoffreApi/SuperAdmin/Folders/Folders"; +import Users, { IGetUsersparams } from "@Front/Api/LeCoffreApi/SuperAdmin/Users/Users"; import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; import Form from "@Front/Components/DesignSystem/Form"; +import { IOption } from "@Front/Components/DesignSystem/Form/SelectField"; +import MultiSelect from "@Front/Components/DesignSystem/MultiSelect"; +import RadioBox from "@Front/Components/DesignSystem/RadioBox"; import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography"; import BackArrow from "@Front/Components/Elements/BackArrow"; import DefaultNotaryDashboard, { IDashBoardFolder } from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard"; -import BasePage from "../../Base"; -import classes from "./classes.module.scss"; +import Module from "@Front/Config/Module"; +import User from "le-coffre-resources/dist/Notary"; import Link from "next/link"; import { NextRouter, useRouter } from "next/router"; -import RadioBox from "@Front/Components/DesignSystem/RadioBox"; -import MultiSelect from "@Front/Components/DesignSystem/MultiSelect"; -import Module from "@Front/Config/Module"; -import Users, { IGetUsersparams } from "@Front/Api/LeCoffreApi/SuperAdmin/Users/Users"; -import Folders from "@Front/Api/LeCoffreApi/SuperAdmin/Folders/Folders"; -import { OfficeFolderHasStakeholder } from "le-coffre-resources/dist/Customer"; -import { IOption } from "@Front/Components/DesignSystem/Form/SelectField"; -import User from "le-coffre-resources/dist/Notary"; + +import BasePage from "../../Base"; +import classes from "./classes.module.scss"; type IPropsClass = { selectedFolderUid: string; @@ -119,10 +119,10 @@ class UpdateFolderCollaboratorsClass extends BasePage { let folder = null; try { folder = await Folders.getInstance().getByUid(folderUid, query); - const preSelectedCollaborators: IOption[] = folder.office_folder_has_stakeholder!.map((collaborator) => { + const preSelectedCollaborators: IOption[] = folder.stakeholders!.map((collaborator) => { return { - label: collaborator.user_stakeholder.contact?.first_name + " " + collaborator.user_stakeholder.contact?.last_name, - value: collaborator.user_stakeholder.uid, + label: collaborator.contact?.first_name + " " + collaborator.contact?.last_name, + value: collaborator.uid, }; }); this.setState({ selectedCollaborators: preSelectedCollaborators }); @@ -173,17 +173,13 @@ class UpdateFolderCollaboratorsClass extends BasePage { private async onFormSubmit(e: React.FormEvent | null, values: { [key: string]: string }) { try { - let collaboratorsUid: OfficeFolderHasStakeholder[]; + let collaboratorsUid: User[] = this.state.availableCollaborators; if (this.state.selectedOption === ERadioBoxValue.SELECTION) { - collaboratorsUid = this.state.selectedCollaborators.map( - (collaborator) => ({ user_stakeholder: { uid: collaborator.value } } as OfficeFolderHasStakeholder), + collaboratorsUid = this.state.selectedCollaborators.map((collaborator) => + User.hydrate({ uid: collaborator.value as string }), ); - } else { - collaboratorsUid = this.state.availableCollaborators.map( - (collaborator) => ({ user_stakeholder: { uid: collaborator.uid } } as OfficeFolderHasStakeholder), - ); - } - await Folders.getInstance().put(this.props.selectedFolderUid, { office_folder_has_stakeholder: collaboratorsUid }); + } + await Folders.getInstance().put(this.props.selectedFolderUid, { stakeholders: collaboratorsUid }); this.props.router.push( Module.getInstance() .get() diff --git a/src/front/Components/Layouts/FolderArchived/FolderInformation/ClientSection/index.tsx b/src/front/Components/Layouts/FolderArchived/FolderInformation/ClientSection/index.tsx index 84eafba9..33143af1 100644 --- a/src/front/Components/Layouts/FolderArchived/FolderInformation/ClientSection/index.tsx +++ b/src/front/Components/Layouts/FolderArchived/FolderInformation/ClientSection/index.tsx @@ -40,14 +40,14 @@ export default class ClientSection extends React.Component { } private renderCustomerFolders() { - const output = this.props.folder.office_folder_has_customers?.map((folderHasCustomer) => { - if (!folderHasCustomer.customer) return null; + const output = this.props.folder.customers?.map((customer) => { + if (!customer) return null; return ( ); @@ -62,7 +62,7 @@ export default class ClientSection extends React.Component { } private doesFolderHaveCustomer(): boolean { - if (!this.props.folder?.office_folder_has_customers) return false; - return this.props.folder?.office_folder_has_customers!.length > 0; + if (!this.props.folder?.customers) return false; + return this.props.folder?.customers!.length > 0; } } diff --git a/src/front/Components/Layouts/FolderArchived/FolderInformation/index.tsx b/src/front/Components/Layouts/FolderArchived/FolderInformation/index.tsx index 99609888..44fb416c 100644 --- a/src/front/Components/Layouts/FolderArchived/FolderInformation/index.tsx +++ b/src/front/Components/Layouts/FolderArchived/FolderInformation/index.tsx @@ -108,7 +108,7 @@ class FolderInformationClass extends BasePage { } private doesFolderHaveCustomer(): boolean { - return this.state.selectedFolder?.office_folder_has_customers !== undefined; + return this.state.selectedFolder?.customers !== undefined; } private onSelectedFolder(folder: IDashBoardFolder): void { diff --git a/src/pages/design-system.tsx b/src/pages/design-system.tsx deleted file mode 100644 index d3835570..00000000 --- a/src/pages/design-system.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import DesignSystem from "@Front/Components/Layouts/DesignSystem"; - -export default function Route() { - return ; -}