diff --git a/src/front/Components/Layouts/Folder/AddClientToFolder/index.tsx b/src/front/Components/Layouts/Folder/AddClientToFolder/index.tsx index da0e9378..b9449f9f 100644 --- a/src/front/Components/Layouts/Folder/AddClientToFolder/index.tsx +++ b/src/front/Components/Layouts/Folder/AddClientToFolder/index.tsx @@ -10,7 +10,7 @@ import RadioBox from "@Front/Components/DesignSystem/RadioBox"; import { IOption } from "@Front/Components/DesignSystem/Select"; import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography"; import BackArrow from "@Front/Components/Elements/BackArrow"; -import DefaultNotaryDashboard, { IDashBoardFolder } from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard"; +import DefaultNotaryDashboard from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard"; import Module from "@Front/Config/Module"; import { ECivility } from "le-coffre-resources/dist/Customer/Contact"; import { Customer } from "le-coffre-resources/dist/Notary"; @@ -20,17 +20,18 @@ import { NextRouter, useRouter } from "next/router"; import BasePage from "../../Base"; import classes from "./classes.module.scss"; + enum ESelectedOption { EXISTING_CUSTOMER = "existing_customer", NEW_CUSTOMER = "new_customer", -} +} type IProps = {}; type IState = { - selectedFolder: IDashBoardFolder | null; selectedOption: ESelectedOption; availableCustomers: Customer[]; selectedCustomers: readonly IOption[]; existingCustomers: IOption[]; + isLoaded: boolean; }; type IPropsClass = IProps & { @@ -41,13 +42,12 @@ class AddClientToFolderClass extends BasePage { constructor(props: IPropsClass) { super(props); this.state = { - selectedFolder: null, selectedOption: ESelectedOption.EXISTING_CUSTOMER, availableCustomers: [], selectedCustomers: [], existingCustomers: [], + isLoaded: false, }; - this.onSelectedFolder = this.onSelectedFolder.bind(this); this.onExistingClientSelected = this.onExistingClientSelected.bind(this); this.onNewClientSelected = this.onNewClientSelected.bind(this); this.onMutiSelectChange = this.onMutiSelectChange.bind(this); @@ -60,65 +60,74 @@ class AddClientToFolderClass extends BasePage { .get() .modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", this.props.selectedFolderUid); return ( - +
Associer un ou plusieurs client(s) -
- {this.state.availableCustomers.length !== 0 && ( - - Client existant - - )} + {this.state.isLoaded && ( + <> +
+ {this.state.availableCustomers.length !== 0 && ( + + Client existant + + )} - - Nouveau client - -
- -
- {this.state.selectedOption === "existing_customer" && ( -
- -
- - - - -
+ + Nouveau client +
- )} - {this.state.selectedOption === "new_customer" && ( -
- - - - -
- - - - -
-
- )} -
+
+ {this.state.selectedOption === "existing_customer" && ( +
+ +
+ + + + +
+
+ )} + + {this.state.selectedOption === "new_customer" && ( +
+ + + + +
+ + + + +
+
+ )} +
+ + )}
); @@ -135,13 +144,12 @@ class AddClientToFolderClass extends BasePage { if (index !== -1) availableCustomers.splice(index, 1); }); + let selectedOption = ESelectedOption.EXISTING_CUSTOMER; if (availableCustomers.length === 0) { - this.setState({ - selectedOption: ESelectedOption.NEW_CUSTOMER, - }); + selectedOption = ESelectedOption.NEW_CUSTOMER; } - this.setState({ availableCustomers, existingCustomers }); + this.setState({ availableCustomers, existingCustomers, isLoaded: true, selectedOption }); } private async getFolderPreSelectedCustomers(folderUid: string): Promise { @@ -189,10 +197,6 @@ class AddClientToFolderClass extends BasePage { this.setState({ selectedCustomers }); } - private onSelectedFolder(folder: IDashBoardFolder): void { - this.setState({ selectedFolder: folder }); - } - private onExistingClientSelected(): void { this.setState({ selectedOption: ESelectedOption.EXISTING_CUSTOMER }); }