aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2017-12-10 11:10:05 +0100
committerNoah Loomans <noahloomans@gmail.com>2017-12-10 11:10:05 +0100
commit7bd3b6766536e33146bb55506c79619a1ab7d3b3 (patch)
treee5e53fa944d2c86143d1924b82de504c9dc76224
parentb7fab958633456346d67c9cdd68eef05572882ab (diff)
Move reducers and actions into seperate folders
-rw-r--r--.eslintrc.js3
-rw-r--r--.vscode/settings.json3
-rw-r--r--src/client/react/App.jsx (renamed from src/client/react/App.js)0
-rw-r--r--src/client/react/actions/search.js (renamed from src/client/react/actions.js)2
-rw-r--r--src/client/react/components/container/Search.js6
-rw-r--r--src/client/react/components/presentational/Search.jsx (renamed from src/client/react/components/presentational/Search.js)2
-rw-r--r--src/client/react/index.jsx (renamed from src/client/react/index.js)0
-rw-r--r--src/client/react/reducers.js25
-rw-r--r--src/client/react/reducers/search.js21
-rw-r--r--src/server/routes/getSchedule.js7
-rw-r--r--webpack.config.js7
11 files changed, 46 insertions, 30 deletions
diff --git a/.eslintrc.js b/.eslintrc.js
index cd88221..2090205 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -4,7 +4,4 @@ module.exports = {
"browser": true,
"node": true,
},
- "rules": {
- "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }]
- },
};
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..4718ffd
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+ "eslint.enable": true
+} \ No newline at end of file
diff --git a/src/client/react/App.js b/src/client/react/App.jsx
index d79826e..d79826e 100644
--- a/src/client/react/App.js
+++ b/src/client/react/App.jsx
diff --git a/src/client/react/actions.js b/src/client/react/actions/search.js
index a754943..82db383 100644
--- a/src/client/react/actions.js
+++ b/src/client/react/actions/search.js
@@ -1,5 +1,5 @@
// eslint-disable-next-line import/prefer-default-export
export const type = typedValue => ({
- type: 'TYPE',
+ type: 'SEARCH/TYPE',
typedValue,
});
diff --git a/src/client/react/components/container/Search.js b/src/client/react/components/container/Search.js
index 0722128..ddfb0a6 100644
--- a/src/client/react/components/container/Search.js
+++ b/src/client/react/components/container/Search.js
@@ -1,10 +1,10 @@
import { connect } from 'react-redux';
-import { type } from '../../actions';
+import { type } from '../../actions/search';
import PresentationalSearch from '../presentational/Search';
const mapStateToProps = state => ({
- results: state.searchResults,
- value: state.searchInput,
+ results: state.search.searchResults,
+ value: state.search.searchInput,
});
const mapDispatchToProps = dispatch => ({
diff --git a/src/client/react/components/presentational/Search.js b/src/client/react/components/presentational/Search.jsx
index f75e612..1e00192 100644
--- a/src/client/react/components/presentational/Search.js
+++ b/src/client/react/components/presentational/Search.jsx
@@ -16,7 +16,7 @@ const Search = ({ onType, value, results }) => (
Search.propTypes = {
onType: PropTypes.func.isRequired,
- value: PropTypes.func.isRequired,
+ value: PropTypes.string.isRequired,
results: PropTypes.arrayOf(PropTypes.shape({
name: PropTypes.string.require,
type: PropTypes.string.require,
diff --git a/src/client/react/index.js b/src/client/react/index.jsx
index e1bae3c..e1bae3c 100644
--- a/src/client/react/index.js
+++ b/src/client/react/index.jsx
diff --git a/src/client/react/reducers.js b/src/client/react/reducers.js
index 3fb884b..9fdf2c4 100644
--- a/src/client/react/reducers.js
+++ b/src/client/react/reducers.js
@@ -1,21 +1,8 @@
-const DEFAULT_STATE = {
- searchInput: '',
- searchResults: [],
-};
+import { combineReducers } from 'redux';
+import search from './reducers/search';
-const reducer = (state = DEFAULT_STATE, action) => {
- switch (action.type) {
- case 'TYPE':
- return {
- ...state,
- searchInput: action.typedValue,
- searchResults: [
- { type: 's', name: '18561' },
- ],
- };
- default:
- return state;
- }
-};
+const rootReducer = combineReducers({
+ search,
+});
-export default reducer;
+export default rootReducer;
diff --git a/src/client/react/reducers/search.js b/src/client/react/reducers/search.js
new file mode 100644
index 0000000..05926c9
--- /dev/null
+++ b/src/client/react/reducers/search.js
@@ -0,0 +1,21 @@
+const DEFAULT_STATE = {
+ searchInput: '',
+ searchResults: [],
+};
+
+const search = (state = DEFAULT_STATE, action) => {
+ switch (action.type) {
+ case 'SEARCH/TYPE':
+ return {
+ ...state,
+ searchInput: action.typedValue,
+ searchResults: [
+ { type: 's', name: '18561' },
+ ],
+ };
+ default:
+ return state;
+ }
+};
+
+export default search;
diff --git a/src/server/routes/getSchedule.js b/src/server/routes/getSchedule.js
index 7850918..9c31d66 100644
--- a/src/server/routes/getSchedule.js
+++ b/src/server/routes/getSchedule.js
@@ -67,7 +67,12 @@ router.get('/:type/:value', function (req, res, next) {
return
}
- const utf8Body = iconv.decode(data.body, 'ISO-8859-1')
+ let utf8Body = iconv.decode(data.body, 'ISO-8859-1')
+
+ users.forEach(function (user) {
+ let utf8Body = utf8Body.replace(/oko/g, "test")
+ })
+
res.status(data.statusCode).end(utf8Body)
})
})
diff --git a/webpack.config.js b/webpack.config.js
index baba614..482f8db 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -1,7 +1,7 @@
const path = require('path');
module.exports = {
- entry: './src/client/react/index.js',
+ entry: './src/client/react/index.jsx',
output: {
path: path.resolve(__dirname, 'src/client/static'),
filename: 'bundle.js',
@@ -9,11 +9,14 @@ module.exports = {
module: {
rules: [
{
- test: [/\.js$/],
+ test: [/\.js$/, /\.jsx$/],
exclude: [/node_modules/],
loader: 'babel-loader',
options: { presets: ['es2015', 'react', 'stage-2'] },
},
],
},
+ resolve: {
+ extensions: ['.js', '.jsx'],
+ }
};