From 456fd1d9c25293ef2dca9f02b1b564481c3dce5a Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 19 Sep 2023 15:34:49 +0200 Subject: [PATCH 1/3] :bug: Fix pre selected users --- .../UpdateFolderCollaborators/index.tsx | 108 +++++++++++------- 1 file changed, 65 insertions(+), 43 deletions(-) diff --git a/src/front/Components/Layouts/Folder/UpdateFolderCollaborators/index.tsx b/src/front/Components/Layouts/Folder/UpdateFolderCollaborators/index.tsx index 4c3ea3ea..02245906 100644 --- a/src/front/Components/Layouts/Folder/UpdateFolderCollaborators/index.tsx +++ b/src/front/Components/Layouts/Folder/UpdateFolderCollaborators/index.tsx @@ -24,7 +24,9 @@ type IState = { selectedFolder: OfficeFolder | null; selectedOption?: ERadioBoxValue; availableCollaborators: User[]; + defaultCheckedAllOffice: boolean; selectedCollaborators: readonly IOption[]; + loading: boolean; }; enum ERadioBoxValue { @@ -39,6 +41,9 @@ class UpdateFolderCollaboratorsClass extends BasePage { selectedFolder: null, availableCollaborators: [], selectedCollaborators: [], + defaultCheckedAllOffice: false, + selectedOption: ERadioBoxValue.SELECTION, + loading: true, }; this.onSelectedFolder = this.onSelectedFolder.bind(this); this.onSelectedOptionAllOffice = this.onSelectedOptionAllOffice.bind(this); @@ -55,6 +60,7 @@ class UpdateFolderCollaboratorsClass extends BasePage { value: collaborator.uid, }; }); + return (
@@ -63,34 +69,44 @@ class UpdateFolderCollaboratorsClass extends BasePage {
Modifier les collaborateurs -
-
- - Tout l'office - - - Sélectionner des collaborateurs - -
- - {this.state.selectedOption === ERadioBoxValue.SELECTION && ( -
- + {!this.state.loading && ( + +
+ + Tout l'office + + + Sélectionner des collaborateurs +
- )} -
- - - - -
- + {this.state.selectedOption === ERadioBoxValue.SELECTION && ( +
+ +
+ )} + +
+ + + + +
+ + )}
); @@ -121,27 +137,33 @@ class UpdateFolderCollaboratorsClass extends BasePage { value: collaborator.uid, }; }); - this.setState({ selectedCollaborators: preSelectedCollaborators }); + + // no need to pass query 'where' param here, default query for notaries include only users which are in the same office as the caller + const userQuery: IGetUsersParams = { + include: { + contact: { + select: { + first_name: true, + last_name: true, + }, + }, + }, + }; + + const availableCollaborators = await Users.getInstance().get(userQuery); + + this.setState({ + loading: false, + availableCollaborators, + selectedCollaborators: preSelectedCollaborators, + defaultCheckedAllOffice: preSelectedCollaborators.length === availableCollaborators.length, + selectedOption: + preSelectedCollaborators.length === availableCollaborators.length ? ERadioBoxValue.ALL : ERadioBoxValue.SELECTION, + }); } catch (error) { this.props.router.push(Module.getInstance().get().modules.pages["404"].props.path); return; } - - // no need to pass query 'where' param here, default query for notaries include only users which are in the same office as the caller - const userQuery: IGetUsersParams = { - include: { - contact: { - select: { - first_name: true, - last_name: true, - }, - }, - }, - }; - - const availableCollaborators = await Users.getInstance().get(userQuery); - console.log(availableCollaborators) - this.setState({ availableCollaborators }); } private onSelectedOptionAllOffice(event: React.ChangeEvent) { From 5f1f9d3d00f4e02efe9b25ca073fecdc4ad031af Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 19 Sep 2023 15:37:00 +0200 Subject: [PATCH 2/3] :bug: Folder not too long to render --- .../DesignSystem/FolderBoxInformation/classes.module.scss | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/front/Components/DesignSystem/FolderBoxInformation/classes.module.scss b/src/front/Components/DesignSystem/FolderBoxInformation/classes.module.scss index 37c7ee45..0d828c7d 100644 --- a/src/front/Components/DesignSystem/FolderBoxInformation/classes.module.scss +++ b/src/front/Components/DesignSystem/FolderBoxInformation/classes.module.scss @@ -23,13 +23,13 @@ .text-container { display: flex; flex-direction: column; + overflow-wrap: anywhere; > :first-child { margin-bottom: 12px; } } - @media (max-width: $screen-ls) { grid-template-columns: 1fr 1fr; } @@ -37,8 +37,6 @@ @media (max-width: $screen-s) { grid-template-columns: 1fr; } - - } .edit-icon-container { @@ -54,5 +52,4 @@ margin-top: 24px; } } - -} \ No newline at end of file +} From bd38dd6a8d7f664eda12bbd137ce19eee37762c3 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 19 Sep 2023 15:52:23 +0200 Subject: [PATCH 3/3] :bug: Fixing search --- .../DesignSystem/BlockList/classes.module.scss | 2 +- .../DesignSystem/FolderListContainer/index.tsx | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/front/Components/DesignSystem/BlockList/classes.module.scss b/src/front/Components/DesignSystem/BlockList/classes.module.scss index 2e542b94..ca2072d0 100644 --- a/src/front/Components/DesignSystem/BlockList/classes.module.scss +++ b/src/front/Components/DesignSystem/BlockList/classes.module.scss @@ -21,7 +21,7 @@ display: inline-flex; justify-content: space-between; align-items: center; - + overflow-wrap: anywhere; .warning { margin-left: 32px; } diff --git a/src/front/Components/DesignSystem/FolderListContainer/index.tsx b/src/front/Components/DesignSystem/FolderListContainer/index.tsx index 7c730e6e..abfeb50a 100644 --- a/src/front/Components/DesignSystem/FolderListContainer/index.tsx +++ b/src/front/Components/DesignSystem/FolderListContainer/index.tsx @@ -26,6 +26,7 @@ type IPropsClass = IProps & { type IState = { filteredFolders: OfficeFolder[]; + blocks: IBlock[]; }; class FolderListContainerClass extends React.Component { @@ -36,6 +37,7 @@ class FolderListContainerClass extends React.Component { super(props); this.state = { filteredFolders: this.props.folders, + blocks: this.getBlocks(this.props.folders), }; this.filterFolders = this.filterFolders.bind(this); this.onSelectedFolder = this.onSelectedFolder.bind(this); @@ -50,7 +52,7 @@ class FolderListContainerClass extends React.Component {
- +
{!this.props.isArchived && ( @@ -73,8 +75,8 @@ class FolderListContainerClass extends React.Component { ); } - private getBlocks(): IBlock[] { - const pendingFolders = this.props.folders + private getBlocks(folders: OfficeFolder[]): IBlock[] { + const pendingFolders = folders .filter((folder) => { const pendingDocuments = (folder.documents ?? []).filter( (document) => document.document_status === EDocumentStatus.DEPOSITED, @@ -85,7 +87,7 @@ class FolderListContainerClass extends React.Component { return folder1.created_at! > folder2.created_at! ? -1 : 1; }); - const otherFolders = this.props.folders + const otherFolders = folders .filter((folder) => { const pendingDocuments = (folder.documents ?? []).filter( (document) => document.document_status === EDocumentStatus.DEPOSITED, @@ -104,6 +106,7 @@ class FolderListContainerClass extends React.Component { }; }); } + private onSelectedFolder(block: IBlock) { const folder = this.props.folders.find((folder) => folder.uid === block.id); if (!folder) return; @@ -116,19 +119,21 @@ class FolderListContainerClass extends React.Component { const filteredFolders: OfficeFolder[] = this.props.folders.filter((folder) => { const name = folder.name.toLowerCase(); const number = folder.folder_number.toLowerCase(); - + value = value.toLowerCase(); if (folder.customers) { const customerNames = folder.customers .map((customer) => { return `${customer.contact?.first_name.toLowerCase()} ${customer.contact?.last_name.toLowerCase()}`; }) .join(", "); + return name.includes(value) || number.includes(value) || customerNames.includes(value); } return name.includes(value) || number.includes(value); }); - this.setState({ filteredFolders }); + + this.setState({ filteredFolders, blocks: this.getBlocks(filteredFolders) }); } }