Skip to content

Commit 1dfeeeb

Browse files
committed
refactored redux modules
1 parent 2289d9a commit 1dfeeeb

File tree

5 files changed

+15
-24
lines changed

5 files changed

+15
-24
lines changed

src/containers/currency-converter-container/index.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as React from 'react';
33
import { bindActionCreators } from 'redux';
44
import { connect } from 'react-redux';
55
// components imports
6-
import { updateBaseCurrency, updateTargetCurrency, updateBaseValue, updateTargetValue } from '../../reducers/currency-converter-reducer';
6+
import * as currencyConverterActions from '../../reducers/currency-converter-reducer';
77
import { CurrencyConverter } from './components/currency-converter';
88

99
interface IProps {
@@ -43,14 +43,8 @@ function mapStateToProps(state) {
4343
};
4444
}
4545

46+
const actions = Object.assign({}, currencyConverterActions);
4647
function mapDispatchToProps(dispatch) {
47-
const actions = {
48-
updateBaseCurrency,
49-
updateTargetCurrency,
50-
updateBaseValue,
51-
updateTargetValue
52-
};
53-
5448
return {
5549
actions: bindActionCreators(actions, dispatch)
5650
};

src/reducers/currency-converter-reducer.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { createAction } from 'redux-actions';
22
import Immutable from 'seamless-immutable';
33

44
// Action Types - LOAD, CREATE, UPDATE, REMOVE
5-
export const UPDATE_BASE_CURRENCY = 'currencyConverter/UPDATE_BASE_CURRENCY';
6-
export const UPDATE_TARGET_CURRENCY = 'currencyConverter/UPDATE_TARGET_CURRENCY';
7-
export const UPDATE_BASE_VALUE = 'currencyConverter/UPDATE_BASE_VALUE';
8-
export const UPDATE_TARGET_VALUE = 'currencyConverter/UPDATE_TARGET_VALUE';
5+
const UPDATE_BASE_CURRENCY = 'currencyConverter/UPDATE_BASE_CURRENCY';
6+
const UPDATE_TARGET_CURRENCY = 'currencyConverter/UPDATE_TARGET_CURRENCY';
7+
const UPDATE_BASE_VALUE = 'currencyConverter/UPDATE_BASE_VALUE';
8+
const UPDATE_TARGET_VALUE = 'currencyConverter/UPDATE_TARGET_VALUE';
99

1010
// Action Creators
1111
export const updateBaseCurrency = createAction(UPDATE_BASE_CURRENCY, (event) => {

src/reducers/currency-rates-reducer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import Immutable from 'seamless-immutable';
44
const RATES_MOCK = { 'PLN': 1, 'SEK': 2.1919 };
55

66
// Action Types - LOAD, CREATE, UPDATE, REMOVE
7-
export const LOAD_CURRENCY_RATES = 'currencyRates/LOAD';
8-
export const LOAD_CURRENCY_RATES_SUCCESS = 'currencyRates/LOAD_SUCCESS';
9-
export const LOAD_CURRENCY_RATES_ERROR = 'currencyRates/LOAD_ERROR';
7+
const LOAD_CURRENCY_RATES = 'currencyRates/LOAD';
8+
const LOAD_CURRENCY_RATES_SUCCESS = 'currencyRates/LOAD_SUCCESS';
9+
const LOAD_CURRENCY_RATES_ERROR = 'currencyRates/LOAD_ERROR';
1010

1111
// Action Creators
1212
export const loadCurrencyRates = createAction(LOAD_CURRENCY_RATES);

src/reducers/tests/currency-rates-reducer.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'blue-tape';
2-
import * as reducerModule from '../currency-rates-reducer';
2+
import * as currencyRatesActions from '../currency-rates-reducer';
33

44
// testing action creators
55

@@ -16,9 +16,9 @@ test('testing action creator currencyRatesFetchSuccess', function(t) {
1616
// tslint:enable
1717

1818
// act
19-
const actual = reducerModule.loadCurrencyRatesSuccess(results);
19+
const actual = currencyRatesActions.loadCurrencyRatesSuccess(results);
2020
const expected = {
21-
type: reducerModule.LOAD_CURRENCY_RATES_SUCCESS,
21+
type: 'currencyRates/LOAD_SUCCESS',
2222
payload: results
2323
};
2424

@@ -33,9 +33,9 @@ test('testing action creator currencyRatesFetchError', function(t) {
3333
const errorMessage = 'Error Message';
3434

3535
// act
36-
const actual = reducerModule.loadCurrencyRatesError(errorMessage);
36+
const actual = currencyRatesActions.loadCurrencyRatesError(errorMessage);
3737
const expected = {
38-
type: reducerModule.LOAD_CURRENCY_RATES_ERROR,
38+
type: 'currencyRates/LOAD_ERROR',
3939
payload: errorMessage
4040
};
4141

src/tsconfig.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@
3737
],
3838
"exclude": [
3939
"node_modules/**/",
40-
"jspm_packages/**/",
41-
"test-runner.tsx",
42-
"**/*.spec.*",
43-
"**/*.test.*"
40+
"jspm_packages/**/"
4441
],
4542
"vscode": {
4643
"rewriteTsconfig": true

0 commit comments

Comments
 (0)