Skip to content

Commit

Permalink
Added better way of looping through data
Browse files Browse the repository at this point in the history
  • Loading branch information
Gtonizuka committed Feb 17, 2020
1 parent b247be0 commit c3148e3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
28 changes: 16 additions & 12 deletions src/components/BodyComponent/BodyComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const BodyComponent = () => {
totalAmount: 0,
desktopSales: 0,
mobileSales: 0,
iOSSales: 0,
androidSales: 0,
windowsSales: 0,
macOSSales: 0,
iOS: 0,
android: 0,
windows: 0,
macOS: 0,
paypalSales: 0,
applePaySales: 0,
cardSales: 0
Expand Down Expand Up @@ -74,10 +74,14 @@ const BodyComponent = () => {
{ desktop: 0, mobile: 0, android: 0 }
);

const iOSSales = os.filter(el => el == "iOS").length;
const androidSales = os.filter(el => el == "android").length;
const windowsSales = os.filter(el => el == "windows").length;
const macOSSales = os.filter(el => el == "macOS").length;
const { iOS, android, windows, macOS } = os.reduce(
(r, el) => {
if (el in r) r[el]++;

return r;
},
{ iOS: 0, android: 0, windows: 0, macOS: 0 }
);

const paypalSales = paymentPlatform.filter(el => el == "paypal").length;
const applePaySales = paymentPlatform.filter(el => el == "applePay").length;
Expand All @@ -89,10 +93,10 @@ const BodyComponent = () => {
totalAmount,
desktop,
mobile,
iOSSales,
androidSales,
windowsSales,
macOSSales,
iOS,
android,
windows,
macOS,
paypalSales,
applePaySales,
cardSales
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ const CustomerPlatformComponent = props => {
{
color: "#E38627",
title: "iOS",
value: props.applicationData.iOSSales
value: props.applicationData.iOS
},
{
color: "#1E90FF",
title: "Android",
value: props.applicationData.androidSales
value: props.applicationData.android
}
]}
label
Expand Down Expand Up @@ -96,12 +96,12 @@ const CustomerPlatformComponent = props => {
{
color: "#50B711",
title: "Windows",
value: props.applicationData.windowsSales
value: props.applicationData.windows
},
{
color: "#AAAAAA",
title: "MacOS",
value: props.applicationData.macOSSales
value: props.applicationData.macOS
}
]}
label
Expand Down

0 comments on commit c3148e3

Please sign in to comment.