Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
feat(statistics): add defaulrCurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
dmorenogogoleva committed Apr 10, 2019
1 parent 83bda11 commit 205b8d3
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions front/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class CheckmoneyWeb extends App<WithReduxProps> {
if (token.nonEmpty()) {
ctx.reduxStore.dispatch(dataActions.setToken(token.get()))
await ctx.reduxStore.dispatch(getUserProfile() as any)
console.log('app.tsx')
}

const isSecure = !!(appContext.Component as any).isSecure
Expand Down
8 changes: 5 additions & 3 deletions front/src/domain/user/reducer/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { UserProfile } from '../actions/UserProfile'
import { Option } from 'tsoption'

interface State extends FetchingState {
profile: { defaultCurrency: Currency }
data: { profile: { defaultCurrency: Currency } }
}
interface Actions {
setCurrency: ClearAction<[Currency]>
Expand All @@ -31,8 +31,10 @@ const { reducer, actions } = createClearReduxWithFetching<State, Actions>(
},
},
{
profile: {
defaultCurrency: Currency.USD,
data: {
profile: {
defaultCurrency: Currency.USD,
},
},
error: Option.of(null),
loading: false,
Expand Down
4 changes: 0 additions & 4 deletions front/src/domain/user/selectors/getCurrency.ts

This file was deleted.

4 changes: 4 additions & 0 deletions front/src/domain/user/selectors/getDefaultCurrency.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { State } from '@front/domain/store'

export const getDefaultCurrency = (state: State) =>
state.user.user.data.profile.defaultCurrency
6 changes: 4 additions & 2 deletions front/src/features/statistics/Statistics.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useCallback } from 'react'
import { useMappedState } from 'redux-react-hook'

import { Currency } from '@shared/enum/Currency'
import { CurrencySwitch } from '@front/ui/components/controls/currency-switch'
import { Container } from '@front/ui/components/layout/container'
import { Tabs, Tab } from '@front/ui/components/layout/tabs'
Expand All @@ -14,12 +14,14 @@ import { Sources } from './features/sources'
import * as styles from './Statistics.css'
import { PageHeader } from '@front/ui/components/layout/page-header'
import { pushRoute } from '../routing'
import { getDefaultCurrency } from '@front/domain/user/selectors/getDefaultCurrency'

const columnWidthPercent = 40
const maxLength = 5

export const Statistics = () => {
const [currency, setCurrency] = useState(Currency.USD)
const defaultCurrency = useMappedState(getDefaultCurrency)
const [currency, setCurrency] = useState(defaultCurrency)

const renderContent = useCallback(
(title: string, group: GroupBy.Month | GroupBy.Year) => (
Expand Down

0 comments on commit 205b8d3

Please sign in to comment.