Skip to content

Commit

Permalink
refactor(sb): price movement type
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip London committed Jul 15, 2020
1 parent c2ba940 commit 96f8041
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
@@ -1,7 +1,7 @@
import { actions } from 'data'
import { bindActionCreators, Dispatch } from 'redux'
import { connect, ConnectedProps } from 'react-redux'
import { FiatType, SBPairType } from 'core/types'
import { FiatType, PriceMovementDirType, SBPairType } from 'core/types'
import { getCoinFromPair } from 'data/components/simpleBuy/model'
import { RootState } from 'data/rootReducer'
import React, { PureComponent } from 'react'
Expand All @@ -18,7 +18,7 @@ const Change = styled.span<{ color: keyof DefaultTheme }>`
color: ${props => props.theme[props.color]};
`

const getSignFromMovement = (movement: 'none' | 'up' | 'down') => {
const getSignFromMovement = (movement: PriceMovementDirType) => {
switch (movement) {
case 'down':
return '-'
Expand All @@ -29,7 +29,7 @@ const getSignFromMovement = (movement: 'none' | 'up' | 'down') => {
}
}

const getColorFromMovement = (movement: 'none' | 'up' | 'down') => {
const getColorFromMovement = (movement: PriceMovementDirType) => {
switch (movement) {
case 'down':
return 'red600'
Expand Down
9 changes: 7 additions & 2 deletions packages/blockchain-wallet-v4/src/redux/data/misc/actions.ts
@@ -1,5 +1,10 @@
import * as AT from './actionTypes'
import { CoinType, FiatType, MiscActionTypes } from 'core/types'
import {
CoinType,
FiatType,
MiscActionTypes,
PriceMovementDirType
} from 'core/types'

// FETCH_CAPTCHA
export const fetchCaptcha = () => ({ type: AT.FETCH_CAPTCHA })
Expand All @@ -25,7 +30,7 @@ export const fetchPrice24HLoading = (base: CoinType): MiscActionTypes => ({
export const fetchPrice24HSuccess = (
base: CoinType,
change: string,
movement: 'none' | 'up' | 'down'
movement: PriceMovementDirType
): MiscActionTypes => ({
type: AT.FETCH_PRICE_24H_SUCCESS,
payload: {
Expand Down
6 changes: 4 additions & 2 deletions packages/blockchain-wallet-v4/src/redux/data/misc/types.ts
Expand Up @@ -14,6 +14,8 @@ export type RatesType = {
[key in FiatType]: RateType
}

export type PriceMovementDirType = 'none' | 'up' | 'down'

// state
export type MiscStateType = {
authorize_login: RemoteDataType<any, any>
Expand All @@ -24,7 +26,7 @@ export type MiscStateType = {
price_24h: {
[key in CoinType]: RemoteDataType<
string,
{ change: string; movement: 'none' | 'up' | 'down' }
{ change: string; movement: PriceMovementDirType }
>
}
price_index_series: RemoteDataType<any, any>
Expand Down Expand Up @@ -89,7 +91,7 @@ interface FetchPrice24HSuccessActionType {
payload: {
base: CoinType
change: string
movement: 'none' | 'up' | 'down'
movement: PriceMovementDirType
}
type: typeof AT.FETCH_PRICE_24H_SUCCESS
}
Expand Down

0 comments on commit 96f8041

Please sign in to comment.