Skip to content
This repository was archived by the owner on Jan 14, 2020. It is now read-only.

Commit 7c5ada0

Browse files
committed
fix: handle undefined stock product
1 parent 3244ee9 commit 7c5ada0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/state-indicators.service.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ class StateIndicatorsService {
7373
let products
7474
let national
7575

76-
const getStockAmount = (stock, product, amount = 0) => {
77-
if (!isNaN(parseInt(stock[product].amount, 10))) {
76+
const getStockAmount = function (stock, product) {
77+
var amount = 0
78+
if (stock[product].amount && typeof stock[product].amount === 'number') {
7879
amount = stock[product].amount
79-
} else if (!isNaN(parseInt(stock[product], 10))) {
80+
} else if (typeof stock[product] === 'number' || !isNaN(parseInt(stock[product], 10))) {
8081
amount = stock[product]
8182
}
8283
return amount

0 commit comments

Comments
 (0)