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 bolded text for Existing Owners Error #4261

Merged
merged 2 commits into from
Jul 29, 2021
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: 4 additions & 10 deletions src/libs/actions/BankAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,18 +618,12 @@ function setupWithdrawalAccount(data) {
// Show warning if another account already set up this bank account and promote share
if (response.existingOwners) {
console.error('Cannot set up withdrawal account due to existing owners', response);
const existingOwnersList = response.existingOwners.reduce((ownersStr, owner, i, ownersArr) => {
let separator = ',\n';
if (i === 0) {
separator = '\n';
} else if (i === ownersArr.length - 1) {
separator = ' and\n';
}
return `${ownersStr}${separator}${owner}`;
}, '');
Onyx.merge(
ONYXKEYS.REIMBURSEMENT_ACCOUNT,
{existingOwnersList, error: CONST.BANK_ACCOUNT.ERROR.EXISTING_OWNERS},
{
existingOwners: response.existingOwners,
error: CONST.BANK_ACCOUNT.ERROR.EXISTING_OWNERS,
},
);
return;
}
Expand Down
27 changes: 20 additions & 7 deletions src/pages/ReimbursementAccount/BankAccountStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const propTypes = {
/** Error set when handling the API response */
error: PropTypes.string,

/** A list of existing owners, set if the bank account being added is already owned */
existingOwnersList: PropTypes.string,
/** The existing owners for if the bank account is already owned */
existingOwners: PropTypes.arrayOf(PropTypes.string),
}).isRequired,

...withLocalizePropTypes,
Expand Down Expand Up @@ -129,8 +129,9 @@ class BankAccountStep extends React.Component {
// Disable bank account fields once they've been added in db so they can't be changed
const isFromPlaid = this.props.achData.setupType === CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID;
const shouldDisableInputs = Boolean(this.props.achData.bankAccountID) || isFromPlaid;
const existingOwners = this.props.reimbursementAccount.existingOwners;
const isExistingOwnersErrorVisible = Boolean(this.props.reimbursementAccount.error
&& this.props.reimbursementAccount.existingOwnersList);
&& existingOwners);
return (
<View style={[styles.flex1, styles.justifyContentBetween]}>
<HeaderWithCloseButton
Expand Down Expand Up @@ -252,14 +253,26 @@ class BankAccountStep extends React.Component {
onConfirm={hideExistingOwnersError}
shouldShowCancelButton={false}
prompt={(
<View style={[styles.flex1]}>
<View>
<Text style={[styles.mb4]}>
<Text>
{this.props.translate('bankAccount.error.existingOwners.alreadyInUse')}
</Text>
<Text style={styles.textStrong}>
{this.props.reimbursementAccount.existingOwnersList}
</Text>
{existingOwners && existingOwners.map((existingOwner, i) => {
let separator = ', ';
if (i === 0) {
separator = '';
} else if (i === existingOwners.length - 1) {
separator = ` ${this.props.translate('common.and')} `;
}
return (
<>
<Text>{separator}</Text>
<Text style={styles.textStrong}>{existingOwner}</Text>
{i === existingOwners.length - 1 && <Text>.</Text>}
</>
);
})}
</Text>
<Text style={[styles.mb4]}>
{this.props.translate('bankAccount.error.existingOwners.pleaseAskThemToShare')}
Expand Down