From f12a5eef73431d73b5a3b7d6c2e8c53dba86cbf5 Mon Sep 17 00:00:00 2001 From: Maks <41080668+Maks19@users.noreply.github.com> Date: Thu, 27 Jun 2024 17:46:40 +0300 Subject: [PATCH] add charts to mobile view (#1154) --- .../MobileEarningSummaryContainer.tsx | 3 + .../components/MobileEarningSummary.tsx | 172 +++++++++++++----- 2 files changed, 126 insertions(+), 49 deletions(-) diff --git a/packages/web-app/src/modules/earn-views-mobile/MobileEarningSummaryContainer.tsx b/packages/web-app/src/modules/earn-views-mobile/MobileEarningSummaryContainer.tsx index a7813654e..adaff75c7 100644 --- a/packages/web-app/src/modules/earn-views-mobile/MobileEarningSummaryContainer.tsx +++ b/packages/web-app/src/modules/earn-views-mobile/MobileEarningSummaryContainer.tsx @@ -11,6 +11,9 @@ const mapStoreToProps = (store: RootStore): any => ({ last7DayEarnings: store.balance.lastWeekEarnings, last30DayEarnings: store.balance.lastMonthEarnings, earningHistory: store.balance.earningsHistory, + viewLast24Hours: store.balance.viewLast24Hours, + viewLast7Days: store.balance.viewLast7Days, + viewLast30Days: store.balance.viewLast30Days, }) export const MobileEarningSummaryContainer = connect(mapStoreToProps, withLogin(MobileEarningSummary)) diff --git a/packages/web-app/src/modules/earn-views-mobile/components/MobileEarningSummary.tsx b/packages/web-app/src/modules/earn-views-mobile/components/MobileEarningSummary.tsx index 06f055f07..60f9c4fe5 100644 --- a/packages/web-app/src/modules/earn-views-mobile/components/MobileEarningSummary.tsx +++ b/packages/web-app/src/modules/earn-views-mobile/components/MobileEarningSummary.tsx @@ -1,14 +1,46 @@ +import { Switch, Text } from '@saladtechnologies/garden-components' +import { useState } from 'react' import type { WithStyles } from 'react-jss' import withStyles from 'react-jss' +import type { SaladTheme } from '../../../SaladTheme' import { Divider, SectionHeader, StatElement } from '../../../components' +import { Segments } from '../../../components/elements/Segments' import { formatBalance } from '../../../utils' import { EarningChartContainer } from '../../earn-views' +import { EarningLineChartContainer } from '../../earn-views/EarningLineChartContainer' -const styles = () => ({ - container: {}, +const styles = (theme: SaladTheme) => ({ item: { paddingTop: 10, }, + chartContainer: { + display: 'flex', + height: 250, + width: '100%', + position: 'relative', + flexDirection: 'column', + }, + chartHeader: { + display: 'flex', + justifyContent: 'flex-start', + alignItems: 'flex-end', + flexDirection: 'row', + }, + segmentsContainer: { + '&>label:first-child': { + borderRadius: '2px 0px 0px 2px', + }, + '&>label:last-child': { + borderRadius: '0px 2px 2px 0px', + }, + }, + earningPerMachineSwitchWrapper: { + marginLeft: 32, + }, + descriptionWrapper: { + paddingLeft: '70px', + color: theme.lightGreen, + }, }) interface Props extends WithStyles { @@ -18,6 +50,9 @@ interface Props extends WithStyles { last30DayEarnings: number lifetimeBalance?: number totalXp?: number + viewLast24Hours: () => void + viewLast7Days: () => void + viewLast30Days: () => void } const _MobileEarningSummary = ({ @@ -28,52 +63,91 @@ const _MobileEarningSummary = ({ last30DayEarnings, lifetimeBalance, totalXp, -}: Props) => ( -
- Summary -
- -
-
- -
-
- -
-
- -
-
- -
-
- -
- - Earning History - - -
-) + viewLast24Hours, + viewLast7Days, + viewLast30Days, +}: Props) => { + const [isEarningsPerMachineEnabled, setIsEarningsPerMachineEnabled] = useState(false) + const segmentOptions = [ + { name: '24 Hours', action: viewLast24Hours }, + { name: '7 Days', action: viewLast7Days }, + { name: '30 Days', action: viewLast30Days }, + ] + + return ( + <> + Summary +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ + Earning History +
+
+ +
+
+ +
+
+
+ {isEarningsPerMachineEnabled ? : } +
+ {isEarningsPerMachineEnabled && ( +
+ + *Per machine earnings don’t include referral earnings, earning rate multipliers or any other kind of bonus + earnings. + +
+ )} + + + ) +} export const MobileEarningSummary = withStyles(styles)(_MobileEarningSummary)