diff --git a/src/components/Utilities/index.js b/src/components/Utilities/index.js index 393b8133be3f8bbc09bbe01627285e580d2567b1..1cfbd244f20bd899e4be5cb3b65538c9e7eb4e5e 100644 --- a/src/components/Utilities/index.js +++ b/src/components/Utilities/index.js @@ -37,15 +37,15 @@ class Utilities extends Component { && (!billsRes.err)) { const boxBuildingList = billsRes.data.box_building_list; const allAccounts = accountRes.data.utilities.map((account) => { - let urlDownload = ''; - // Loop through and connect a box URL with this account - for (let i = 0; i < boxBuildingList.length; i += 1) { - const boxFile = boxBuildingList[i]; - if (boxFile.tags === account.account_number) { - urlDownload = boxFile.url_download; - break; + const urlDownload = boxBuildingList.reduce((url, boxFile) => { + if (!url) { + if (boxFile.tags === account.account_number) { + return boxFile.url_download; + } } - } + return url; + }, ''); + return this.createUtilityComponent({ building_address: address, utility: account.type,