From 96f8041db27ae0d738237662a9e1ddbd69cb98ce Mon Sep 17 00:00:00 2001 From: Philip London Date: Wed, 15 Jul 2020 13:01:16 +0200 Subject: [PATCH] refactor(sb): price movement type --- .../CryptoSelector/PriceMovement/index.tsx | 6 +++--- .../blockchain-wallet-v4/src/redux/data/misc/actions.ts | 9 +++++++-- .../blockchain-wallet-v4/src/redux/data/misc/types.ts | 6 ++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/packages/blockchain-wallet-v4-frontend/src/modals/SimpleBuy/CryptoSelection/CryptoSelector/PriceMovement/index.tsx b/packages/blockchain-wallet-v4-frontend/src/modals/SimpleBuy/CryptoSelection/CryptoSelector/PriceMovement/index.tsx index 0be91a6e4e7..22412ba3cd8 100644 --- a/packages/blockchain-wallet-v4-frontend/src/modals/SimpleBuy/CryptoSelection/CryptoSelector/PriceMovement/index.tsx +++ b/packages/blockchain-wallet-v4-frontend/src/modals/SimpleBuy/CryptoSelection/CryptoSelector/PriceMovement/index.tsx @@ -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' @@ -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 '-' @@ -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' diff --git a/packages/blockchain-wallet-v4/src/redux/data/misc/actions.ts b/packages/blockchain-wallet-v4/src/redux/data/misc/actions.ts index 5cecc5de5c1..2812c7bd4f4 100755 --- a/packages/blockchain-wallet-v4/src/redux/data/misc/actions.ts +++ b/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 }) @@ -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: { diff --git a/packages/blockchain-wallet-v4/src/redux/data/misc/types.ts b/packages/blockchain-wallet-v4/src/redux/data/misc/types.ts index a3cc816c609..8bc406599d9 100644 --- a/packages/blockchain-wallet-v4/src/redux/data/misc/types.ts +++ b/packages/blockchain-wallet-v4/src/redux/data/misc/types.ts @@ -14,6 +14,8 @@ export type RatesType = { [key in FiatType]: RateType } +export type PriceMovementDirType = 'none' | 'up' | 'down' + // state export type MiscStateType = { authorize_login: RemoteDataType @@ -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 @@ -89,7 +91,7 @@ interface FetchPrice24HSuccessActionType { payload: { base: CoinType change: string - movement: 'none' | 'up' | 'down' + movement: PriceMovementDirType } type: typeof AT.FETCH_PRICE_24H_SUCCESS }