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

Add an error Growl for failed IOU payments #3809

Merged
merged 8 commits into from
Jul 1, 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
2 changes: 2 additions & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export default {
paid: ({owner, manager}) => `${manager} paid ${owner}`,
split: ({amount}) => `Split ${amount}`,
choosePaymentMethod: 'Choose payment method:',
noReimbursableExpenses: 'This report has an invalid amount',
},
reportDetailsPage: {
notificationPreferencesDescription: 'How often should we notify you when there are new messages to catch up on in this room?',
Expand Down Expand Up @@ -319,6 +320,7 @@ export default {
address: 'Please enter a valid address',
dob: 'Please enter a valid date of birth',
ssnLast4: 'Please enter valid last 4 digits of SSN',
noDefaultDepositAccountOrDebitCardAvailable: 'Please add a default deposit bank account or debit card',
},
},
addPersonalBankAccountPage: {
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export default {
paid: ({owner, manager}) => `${manager} pagó a ${owner}`,
split: ({amount}) => `Dividir ${amount}`,
choosePaymentMethod: 'Elige el método de pago:',
noReimbursableExpenses: 'El monto de este informe es inválido',
},
reportDetailsPage: {
notificationPreferencesDescription: 'Cada cuanto tiempo quieres que te avisemos que hay nuevos mensajes en este canal?',
Expand Down Expand Up @@ -312,6 +313,7 @@ export default {
address: 'Ingrese una dirección válida',
dob: 'Ingrese una fecha de nacimiento válida',
ssnLast4: 'Ingrese los últimos 4 dígitos del número de seguro social',
noDefaultDepositAccountOrDebitCardAvailable: 'Por favor agregue una cuenta bancaria para depósitos o una tarjeta de débito',
},
},
addPersonalBankAccountPage: {
Expand Down
14 changes: 13 additions & 1 deletion src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import ROUTES from '../../ROUTES';
import * as API from '../API';
import {getSimplifiedIOUReport, fetchChatReportsByIDs, fetchIOUReportByIDAndUpdateChatReport} from './Report';
import Navigation from '../Navigation/Navigation';
import Growl from '../Growl';
import {translateLocal} from '../translate';
import asyncOpenURL from '../asyncOpenURL';

/**
Expand Down Expand Up @@ -222,7 +224,17 @@ function payIOUReport({
fetchIOUReportByIDAndUpdateChatReport(reportID, chatReportID);
})
.catch((error) => {
console.error(`Error Paying iouReport: ${error}`);
switch (error.message) {
// eslint-disable-next-line max-len
case 'You cannot pay via Expensify Wallet until you have either a verified deposit bank account or debit card.':
Growl.error(translateLocal('bankAccount.error.noDefaultDepositAccountOrDebitCardAvailable'), 5000);
break;
case 'This report doesn\'t have reimbursable expenses.':
Growl.error(translateLocal('iou.noReimbursableExpenses'), 5000);
break;
default:
Growl.error(error.message, 5000);
}
Onyx.merge(ONYXKEYS.IOU, {error: true});
})
.finally(() => Onyx.merge(ONYXKEYS.IOU, {loading: false})),
Expand Down