diff --git a/frontend/src/pages/account/Teams/Teams.vue b/frontend/src/pages/account/Teams/Teams.vue index 5be22b74d8..12f6b576ec 100644 --- a/frontend/src/pages/account/Teams/Teams.vue +++ b/frontend/src/pages/account/Teams/Teams.vue @@ -36,6 +36,7 @@ export default { }, computed: { ...mapState('account', ['user', 'teams', 'settings']), + ...mapState('account', ['teamMembership', 'team']), teamCount () { return this.teams ? this.teams.length : 0 } @@ -64,7 +65,10 @@ export default { try { await teamApi.removeTeamMember(row.id, this.user.id) alerts.emit(`${this.user.username} successfully removed from ${row.name}`, 'confirmation') - this.$store.dispatch('account/refreshTeams') + await this.$store.dispatch('account/refreshTeams') + if (!this.teamCount) { + await this.$store.dispatch('account/setTeam', null) + } } catch (err) { alerts.emit(`Failed to remove ${this.user.username} from ${row.name}: ${err.response.data.error}`, 'warning') console.warn(err) diff --git a/frontend/src/store/account.js b/frontend/src/store/account.js index 530060bcd7..c175d5a395 100644 --- a/frontend/src/store/account.js +++ b/frontend/src/store/account.js @@ -326,12 +326,12 @@ const actions = { return } } else { - if (!currentTeam || currentTeam.id === team.id) { + if (!currentTeam || currentTeam.id === team?.id) { state.commit('clearPendingTeamChange') return } } - if (team.id) { + if (team?.id) { teamMembership = await teamApi.getTeamUserMembership(team.id) } state.commit('setTeam', team)