From deaec05e57ec9067d1f244e22e8c83c5b4264eb4 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 15 May 2023 14:41:03 +0700 Subject: [PATCH 1/4] Fix remove button remains enabled when removing a user in other device --- src/pages/workspace/WorkspaceMembersPage.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pages/workspace/WorkspaceMembersPage.js b/src/pages/workspace/WorkspaceMembersPage.js index 2d439efc9ef4..7044cbf96451 100644 --- a/src/pages/workspace/WorkspaceMembersPage.js +++ b/src/pages/workspace/WorkspaceMembersPage.js @@ -96,6 +96,13 @@ class WorkspaceMembersPage extends React.Component { this.validate(); } + if (!_.isEqual(prevProps.policyMemberList, this.props.policyMemberList)) { + const selectedEmployees = _.filter(this.state.selectedEmployees, (selectedEmployee) => { + return _.has(this.props.policyMemberList, selectedEmployee); + }); + this.setState({selectedEmployees}); + } + const isReconnecting = prevProps.network.isOffline && !this.props.network.isOffline; if (!isReconnecting) { return; @@ -363,6 +370,7 @@ class WorkspaceMembersPage extends React.Component { } render() { + console.log(this.state.selectedEmployees); const policyMemberList = lodashGet(this.props, 'policyMemberList', {}); const policyOwner = lodashGet(this.props.policy, 'owner'); const currentUserLogin = lodashGet(this.props.currentUserPersonalDetails, 'login'); From 3cfd6443da1aa8cf5234420e86a0d562c1f1c3de Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 15 May 2023 15:03:13 +0700 Subject: [PATCH 2/4] format code --- src/pages/workspace/WorkspaceMembersPage.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/WorkspaceMembersPage.js b/src/pages/workspace/WorkspaceMembersPage.js index 7044cbf96451..a2e9740803ba 100644 --- a/src/pages/workspace/WorkspaceMembersPage.js +++ b/src/pages/workspace/WorkspaceMembersPage.js @@ -97,10 +97,12 @@ class WorkspaceMembersPage extends React.Component { } if (!_.isEqual(prevProps.policyMemberList, this.props.policyMemberList)) { - const selectedEmployees = _.filter(this.state.selectedEmployees, (selectedEmployee) => { - return _.has(this.props.policyMemberList, selectedEmployee); + this.setState((prevState) => { + const selectedEmployees = _.filter(prevState.selectedEmployees, (selectedEmployee) => _.has(this.props.policyMemberList, selectedEmployee)); + return { + selectedEmployees, + }; }); - this.setState({selectedEmployees}); } const isReconnecting = prevProps.network.isOffline && !this.props.network.isOffline; @@ -370,7 +372,6 @@ class WorkspaceMembersPage extends React.Component { } render() { - console.log(this.state.selectedEmployees); const policyMemberList = lodashGet(this.props, 'policyMemberList', {}); const policyOwner = lodashGet(this.props.policy, 'owner'); const currentUserLogin = lodashGet(this.props.currentUserPersonalDetails, 'login'); From fbdc92708cc527606da58032c0b4a16a73212024 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 15 May 2023 20:51:04 +0700 Subject: [PATCH 3/4] update check change --- src/pages/workspace/WorkspaceMembersPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceMembersPage.js b/src/pages/workspace/WorkspaceMembersPage.js index a2e9740803ba..d1da8bcf9708 100644 --- a/src/pages/workspace/WorkspaceMembersPage.js +++ b/src/pages/workspace/WorkspaceMembersPage.js @@ -96,7 +96,7 @@ class WorkspaceMembersPage extends React.Component { this.validate(); } - if (!_.isEqual(prevProps.policyMemberList, this.props.policyMemberList)) { + if (prevProps.policyMemberList !== this.props.policyMemberList) { this.setState((prevState) => { const selectedEmployees = _.filter(prevState.selectedEmployees, (selectedEmployee) => _.has(this.props.policyMemberList, selectedEmployee)); return { From 20ae49832c7f0774b0d5a15ea93a63cba48a98b6 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 15 May 2023 23:28:26 +0700 Subject: [PATCH 4/4] change method update selectedEmplyees --- src/pages/workspace/WorkspaceMembersPage.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/pages/workspace/WorkspaceMembersPage.js b/src/pages/workspace/WorkspaceMembersPage.js index d1da8bcf9708..1ba01ddeae34 100644 --- a/src/pages/workspace/WorkspaceMembersPage.js +++ b/src/pages/workspace/WorkspaceMembersPage.js @@ -97,12 +97,9 @@ class WorkspaceMembersPage extends React.Component { } if (prevProps.policyMemberList !== this.props.policyMemberList) { - this.setState((prevState) => { - const selectedEmployees = _.filter(prevState.selectedEmployees, (selectedEmployee) => _.has(this.props.policyMemberList, selectedEmployee)); - return { - selectedEmployees, - }; - }); + this.setState((prevState) => ({ + selectedEmployees: _.intersection(prevState.selectedEmployees, _.keys(this.props.policyMemberList)), + })); } const isReconnecting = prevProps.network.isOffline && !this.props.network.isOffline;