Add createTypes function
This commit is contained in:
@ -1,4 +1,6 @@
|
|||||||
const types = [
|
import createTypes from '../utils/create-types';
|
||||||
|
|
||||||
|
export default createTypes([
|
||||||
'updateTitle',
|
'updateTitle',
|
||||||
|
|
||||||
'fetchUser',
|
'fetchUser',
|
||||||
@ -9,8 +11,4 @@ const types = [
|
|||||||
'handleError',
|
'handleError',
|
||||||
// used to hit the server
|
// used to hit the server
|
||||||
'hardGoTo'
|
'hardGoTo'
|
||||||
];
|
], 'app');
|
||||||
|
|
||||||
export default types
|
|
||||||
// make into object with signature { type: nameSpace[type] };
|
|
||||||
.reduce((types, type) => ({ ...types, [type]: `app.${type}` }), {});
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
const types = [
|
import createTypes from '../../../utils/create-types';
|
||||||
|
|
||||||
|
export default createTypes([
|
||||||
'fetchHikes',
|
'fetchHikes',
|
||||||
'fetchHikesCompleted',
|
'fetchHikesCompleted',
|
||||||
'resetHike',
|
'resetHike',
|
||||||
@ -19,9 +21,4 @@ const types = [
|
|||||||
|
|
||||||
'hikeCompleted',
|
'hikeCompleted',
|
||||||
'goToNextHike'
|
'goToNextHike'
|
||||||
];
|
], 'videos');
|
||||||
|
|
||||||
export default types.reduce((types, type) => {
|
|
||||||
types[type] = `videos.${type}`;
|
|
||||||
return types;
|
|
||||||
}, {});
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
const types = [
|
import createTypes from '../../../utils/create-types';
|
||||||
|
|
||||||
|
export default createTypes([
|
||||||
'fetchJobs',
|
'fetchJobs',
|
||||||
'fetchJobsCompleted',
|
'fetchJobsCompleted',
|
||||||
|
|
||||||
@ -17,9 +19,4 @@ const types = [
|
|||||||
'updatePromo',
|
'updatePromo',
|
||||||
'applyPromo',
|
'applyPromo',
|
||||||
'applyPromoCompleted'
|
'applyPromoCompleted'
|
||||||
];
|
], 'jobs');
|
||||||
|
|
||||||
export default types.reduce((types, type) => {
|
|
||||||
types[type] = `jobs.${type}`;
|
|
||||||
return types;
|
|
||||||
}, {});
|
|
||||||
|
10
common/app/utils/create-types.js
Normal file
10
common/app/utils/create-types.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// createTypes(types: String[], prefix: String) => Object
|
||||||
|
export default function createTypes(types = [], prefix = '') {
|
||||||
|
if (!Array.isArray(types) || typeof prefix !== 'string') {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return types.reduce((types, type) => {
|
||||||
|
types[type] = prefix + '.' + type;
|
||||||
|
return types;
|
||||||
|
}, {});
|
||||||
|
}
|
Reference in New Issue
Block a user