Skip to content

Commit

Permalink
fix: Cannot read property 'amount_inquired' of null bunqCommunity#585
Browse files Browse the repository at this point in the history
  • Loading branch information
sKiLdUsT committed Oct 28, 2020
1 parent 74fc2b1 commit 92ed8b3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
28 changes: 20 additions & 8 deletions src/react/Components/ListItems/BunqMeTabListItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,20 @@ class BunqMeTabListItem extends React.Component {
}, 0);

// format the amounts
const formattedInquiredAmount = formatMoney(bunqMeTab.bunqme_tab_entry.amount_inquired.value);
const formattedTotalPaid = formatMoney(totalPaidAmount);

const merchantList = bunqMeTab.bunqme_tab_entry.merchant_available
.filter(merchant => merchant.available)
.map(merchant => merchant.merchant_type)
.join(", ");
// fill with empty values first
let formattedInquiredAmount = formatMoney(0.00);
let formattedTotalPaid = formatMoney(0.00);
let merchantList = [];

// only fill real values if tab isn't canceled, will crash otherwise
if (bunqMeTab.status !== 'CANCELLED' && bunqMeTab.bunqme_tab_entry !== null) {
formattedInquiredAmount = formatMoney(bunqMeTab.bunqme_tab_entry.amount_inquired.value);
formattedTotalPaid = formatMoney(totalPaidAmount);
merchantList = bunqMeTab.bunqme_tab_entry.merchant_available
.filter(merchant => merchant.available)
.map(merchant => merchant.merchant_type)
.join(", ");
}

const avatarStandalone = (
<Avatar style={styles.smallAvatar}>
Expand All @@ -126,6 +133,11 @@ class BunqMeTabListItem extends React.Component {
</Badge>
);

const primaryText =
bunqMeTab.bunqme_tab_entry !== null
? bunqMeTab.bunqme_tab_entry.description
: t("Cancelled payment request")

const secondaryText =
bunqMeTabPayments.length > 0
? `${t("Received")}: ${formattedTotalPaid}`
Expand All @@ -134,7 +146,7 @@ class BunqMeTabListItem extends React.Component {
return [
<ListItem button onClick={this.toggleExtraInfo}>
{itemAvatar}
<ListItemText primary={bunqMeTab.bunqme_tab_entry.description} secondary={secondaryText} />
<ListItemText primary={primaryText} secondary={secondaryText} />
<ListItemSecondaryAction style={{ marginTop: -16 }}>
<AccountQRFullscreen mode="HIDDEN" text={shareUrl} />
<CopyToClipboardWrap text={shareUrl} onCopy={this.props.copiedValue("the bunq tab url")}>
Expand Down
3 changes: 2 additions & 1 deletion src/react/Locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"Cancel editing": "Bearbeitung abbrechen",
"Cancel request": "Anfrage abbrechen",
"Cancelled": "Abgebrochen",
"Cancelled payment request": "Abgebrochene Zahlungsanfrage",
"Capslock active": "Feststelltaste aktiviert",
"Card": "Karte",
"Card filter": "Kartenfilter",
Expand Down Expand Up @@ -695,4 +696,4 @@
"weeks": "Wochen",
"year": "Jahr",
"years": "Jahre"
}
}
3 changes: 2 additions & 1 deletion src/react/Locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"Cancel editing": "Cancel editing",
"Cancel request": "Cancel request",
"Cancelled": "Cancelled",
"Cancelled payment request": "Cancelled payment request",
"Capslock active": "Capslock active",
"Card": "Card",
"Card filter": "Card filter",
Expand Down Expand Up @@ -698,4 +699,4 @@
"weeks": "weeks",
"year": "year",
"years": "years"
}
}
3 changes: 2 additions & 1 deletion src/react/Locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"Cancel editing": "Bewerken annuleren",
"Cancel request": "Verzoek annuleren",
"Cancelled": "Geannuleerd",
"Cancelled payment request": "Geannuleerd Betalingsverzoek",
"Capslock active": "Capslock actief",
"Card": "Pas",
"Card filter": "Passen",
Expand Down Expand Up @@ -687,4 +688,4 @@
"weeks": "weken",
"year": "jaar",
"years": "jaren"
}
}

0 comments on commit 92ed8b3

Please sign in to comment.