Skip to content

Commit

Permalink
[WebApp] Create earning line chart (#1149)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maks19 authored Jun 21, 2024
1 parent 0a0d3ea commit b1dcaca
Show file tree
Hide file tree
Showing 11 changed files with 1,448 additions and 12 deletions.
8 changes: 4 additions & 4 deletions packages/web-app/src/modules/balance/BalanceStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { AxiosInstance } from 'axios'
import { action, computed, flow, observable } from 'mobx'
import moment from 'moment'
import type { RootStore } from '../../Store'
import type { EarningWindow } from './models'
import type { ChartDaysShowing, EarningWindow } from './models'
import { batchEarningsWindow, getEarningWindowsGroupedByDay } from './utils'

enum EarningChartTimeFilter {
Expand All @@ -22,15 +22,15 @@ export class BalanceStore {
private earningHistory: Map<number, number> = new Map()

@observable
private daysShowingEarnings: 1 | 7 | 30 = 1
private daysShowingEarnings: ChartDaysShowing = 1

@computed
public get earningsHistory(): EarningWindow[] {
return this.getEarningWindows(this.daysShowingEarnings)
}

@computed
public get getDaysShowingEarnings(): 1 | 7 | 30 {
public get getDaysShowingEarnings(): ChartDaysShowing {
return this.daysShowingEarnings
}

Expand Down Expand Up @@ -73,7 +73,7 @@ export class BalanceStore {
@observable
public lastMonthEarnings: number = 0

private getEarningWindows = (numberOfDays: 1 | 7 | 30): EarningWindow[] => {
private getEarningWindows = (numberOfDays: ChartDaysShowing): EarningWindow[] => {
const windows: EarningWindow[] = []

const now = moment.utc()
Expand Down
6 changes: 6 additions & 0 deletions packages/web-app/src/modules/balance/models/EarningWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ export interface EarningWindow {
/** Total earnings during the window */
earnings: number
}

export interface EarningPerMachine {
[key: string]: EarningWindow[]
}

export type ChartDaysShowing = 1 | 7 | 30
Loading

0 comments on commit b1dcaca

Please sign in to comment.