Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) Staled master account #577

Merged
merged 2 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/components/Auth/RegisterSubAccounts/RegisterSubAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
import _filter from 'lodash/filter'
import _isEmpty from 'lodash/isEmpty'
import { Classes, Dialog } from '@blueprintjs/core'

import Icon from 'icons'
Expand Down Expand Up @@ -43,12 +44,25 @@ class RegisterSubAccounts extends PureComponent {
}
}

componentDidUpdate() {
const { users } = this.props
if (_isEmpty(users)) {
this.clearMasterAccEmail()
}
}

onEmailChange = (email) => {
this.setState({
masterAccEmail: email,
})
}

clearMasterAccEmail = () => {
this.setState({
masterAccEmail: undefined,
})
}

render() {
const {
t,
Expand Down
4 changes: 3 additions & 1 deletion src/components/SubAccounts/SubAccount/SubAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'
import { Button, Intent } from '@blueprintjs/core'
import _get from 'lodash/get'
import _isEmpty from 'lodash/isEmpty'
import _differenceBy from 'lodash/differenceBy'

import Loading from 'ui/Loading'

Expand Down Expand Up @@ -113,6 +114,7 @@ class SubAccount extends PureComponent {
const subUsers = _get(subAccountData, 'subUsers', [])
const hasFilledAccounts = getFilledAccounts(accounts).length > 0
const hasSubAccount = !!users.find(user => user.email === masterAccountEmail && user.isSubAccount)
const preparedUsers = _differenceBy(users, subUsers, 'email')
let showContent
if (isSubAccountsLoading) {
showContent = <Loading />
Expand All @@ -134,9 +136,9 @@ class SubAccount extends PureComponent {
{(masterAccount || (isSubAccount || !hasSubAccount)) && (
<>
<SubUsersAdd
users={users}
accounts={accounts}
authData={authData}
users={preparedUsers}
onChange={this.onSubUsersChange}
masterAccount={masterAccount}
addMultipleAccsEnabled={addMultipleAccsEnabled}
Expand Down