2017-09-25 02:06:28 +00:00
|
|
|
import { FiatSucceededRatesAction, RatesAction } from 'actions/rates';
|
|
|
|
import { TypeKeys } from 'actions/rates/constants';
|
2017-07-13 21:02:39 +00:00
|
|
|
// SYMBOL -> PRICE TO BUY 1 ETH
|
2017-09-25 02:06:28 +00:00
|
|
|
export interface State {
|
|
|
|
[key: string]: number;
|
|
|
|
}
|
2017-07-13 21:02:39 +00:00
|
|
|
|
2017-07-27 17:05:09 +00:00
|
|
|
export const INITIAL_STATE: State = {};
|
2017-07-13 21:02:39 +00:00
|
|
|
|
2017-09-12 22:15:23 +00:00
|
|
|
function fiatSucceededRates(
|
|
|
|
state: State,
|
|
|
|
action: FiatSucceededRatesAction
|
|
|
|
): State {
|
2017-07-13 21:02:39 +00:00
|
|
|
return action.payload;
|
|
|
|
}
|
|
|
|
|
2017-07-27 17:05:09 +00:00
|
|
|
export function rates(
|
|
|
|
state: State = INITIAL_STATE,
|
|
|
|
action: RatesAction
|
|
|
|
): State {
|
2017-07-13 21:02:39 +00:00
|
|
|
switch (action.type) {
|
2017-09-25 02:06:28 +00:00
|
|
|
case TypeKeys.RATES_FIAT_SUCCEEDED:
|
2017-09-12 22:15:23 +00:00
|
|
|
return fiatSucceededRates(state, action);
|
2017-07-13 21:02:39 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|