diff --git a/.eslintrc b/.eslintrc
index c7cc78f..7268b93 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -34,10 +34,13 @@
"max-len": [
"error",
{
+ "code": 120,
+ "tabWidth": 2,
"ignoreUrls": true,
"ignoreComments": true,
"ignoreStrings": true,
- "ignorePattern": "
]*>.*?
"
+ "ignorePattern": "]*>.*?
",
+ "ignoreTrailingComments": true
}
]
}
diff --git a/README.md b/README.md
index fe55bdb..747a712 100644
--- a/README.md
+++ b/README.md
@@ -24,9 +24,9 @@ yarn install
To run the application on port 8080
```bash
-yarn dev
+yarn start
```
## License
-© Zcash Foundation 2018
\ No newline at end of file
+© Zcash Foundation 2018
diff --git a/app/actions/add-todo.js b/app/actions/add-todo.js
deleted file mode 100644
index e2410c6..0000000
--- a/app/actions/add-todo.js
+++ /dev/null
@@ -1,15 +0,0 @@
-// @flow
-
-import uuidv4 from 'uuid/v4';
-import { ADD_TODO } from '../constants/actions';
-import { getTimestamp } from '../utils/timestamp';
-
-export const addTodo = (text: string) => ({
- type: ADD_TODO,
- payload: {
- text,
- id: uuidv4(),
- editing: false,
- createdAt: getTimestamp(),
- },
-});
diff --git a/app/actions/cancel-update-todo.js b/app/actions/cancel-update-todo.js
deleted file mode 100644
index afa0aa0..0000000
--- a/app/actions/cancel-update-todo.js
+++ /dev/null
@@ -1,8 +0,0 @@
-// @flow
-
-import { CANCEL_UPDATE_TODO } from '../constants/actions';
-
-export const cancelUpdateTodo = (id: string) => ({
- type: CANCEL_UPDATE_TODO,
- payload: { id },
-});
diff --git a/app/actions/delete-todo.js b/app/actions/delete-todo.js
deleted file mode 100644
index 0378af7..0000000
--- a/app/actions/delete-todo.js
+++ /dev/null
@@ -1,8 +0,0 @@
-// @flow
-
-import { DELETE_TODO } from '../constants/actions';
-
-export const deleteTodo = (id: string) => ({
- type: DELETE_TODO,
- payload: { id },
-});
diff --git a/app/actions/toggle-edit-todo.js b/app/actions/toggle-edit-todo.js
deleted file mode 100644
index fd59481..0000000
--- a/app/actions/toggle-edit-todo.js
+++ /dev/null
@@ -1,8 +0,0 @@
-// @flow
-
-import { TOGGLE_EDIT_TODO } from '../constants/actions';
-
-export const toggleEdit = (id: string) => ({
- type: TOGGLE_EDIT_TODO,
- payload: { id },
-});
diff --git a/app/actions/update-todo.js b/app/actions/update-todo.js
deleted file mode 100644
index 6332fea..0000000
--- a/app/actions/update-todo.js
+++ /dev/null
@@ -1,11 +0,0 @@
-// @flow
-
-import { UPDATE_TODO } from '../constants/actions';
-
-export const updateTodo = (id: string, text: string) => ({
- type: UPDATE_TODO,
- payload: {
- text,
- id,
- },
-});
diff --git a/app/app.js b/app/app.js
index c6dff33..7d632aa 100644
--- a/app/app.js
+++ b/app/app.js
@@ -3,7 +3,7 @@
import React from 'react';
import { Provider } from 'react-redux';
import { ConnectedRouter } from 'connected-react-router';
-import { configureStore, history } from './store/configure';
+import { configureStore, history } from './redux/create';
import { Router } from './router/container';
const store = configureStore({});
diff --git a/app/constants/actions.js b/app/constants/actions.js
deleted file mode 100644
index 84ba2f5..0000000
--- a/app/constants/actions.js
+++ /dev/null
@@ -1,7 +0,0 @@
-// @flow
-
-export const ADD_TODO = 'ADD_TODO';
-export const DELETE_TODO = 'DELETE_TODO';
-export const UPDATE_TODO = 'UPDATE_TODO';
-export const TOGGLE_EDIT_TODO = 'TOGGLE_EDIT_TODO';
-export const CANCEL_UPDATE_TODO = 'CANCEL_UPDATE_TODO';
diff --git a/app/containers/todo.js b/app/containers/todo.js
index fbdb389..6d32347 100644
--- a/app/containers/todo.js
+++ b/app/containers/todo.js
@@ -2,11 +2,10 @@
import { connect } from 'react-redux';
import TodoView from '../views/todo';
-import { addTodo } from '../actions/add-todo';
-import { deleteTodo } from '../actions/delete-todo';
-import { toggleEdit } from '../actions/toggle-edit-todo';
-import { updateTodo } from '../actions/update-todo';
-import { cancelUpdateTodo } from '../actions/cancel-update-todo';
+import {
+ addTodo, deleteTodo, toggleEdit, updateTodo, cancelUpdateTodo,
+} from '../redux/modules/todo';
+
import type { AppState } from '../types/app-state';
import type { Dispatch } from '../types/redux';
diff --git a/app/reducers/todo.js b/app/reducers/todo.js
deleted file mode 100644
index ef1b944..0000000
--- a/app/reducers/todo.js
+++ /dev/null
@@ -1,53 +0,0 @@
-// @flow
-
-import {
- ADD_TODO,
- DELETE_TODO,
- UPDATE_TODO,
- CANCEL_UPDATE_TODO,
- TOGGLE_EDIT_TODO,
-} from '../constants/actions';
-import type { TodoType } from '../types/todo';
-import type { Action } from '../types/redux';
-
-const initialState = [];
-
-export default (state: Array = initialState, action: Action) => {
- switch (action.type) {
- case ADD_TODO:
- return [
- ...state,
- action.payload,
- ];
- case DELETE_TODO:
- // $FlowFixMe
- return state.filter((todo: Object) => todo.id !== action.payload.id);
- case TOGGLE_EDIT_TODO: {
- const { id } = action.payload;
- const todos = [...state];
- const index = todos.map(todo => todo.id).indexOf(id);
- todos[index].editing = true;
-
- return todos;
- }
- case UPDATE_TODO: {
- const { id, text } = action.payload;
- const todos = [...state];
- const index = todos.map(todo => todo.id).indexOf(id);
- todos[index].text = text;
- todos[index].editing = false;
-
- return todos;
- }
- case CANCEL_UPDATE_TODO: {
- const { id } = action.payload;
- const todos = [...state];
- const index = todos.map(todo => todo.id).indexOf(id);
- todos[index].editing = false;
-
- return todos;
- }
- default:
- return state;
- }
-};
diff --git a/app/redux/create.js b/app/redux/create.js
new file mode 100644
index 0000000..c574d10
--- /dev/null
+++ b/app/redux/create.js
@@ -0,0 +1,22 @@
+// @flow
+
+import { createStore, applyMiddleware, compose } from 'redux';
+import { routerMiddleware } from 'connected-react-router';
+import { createBrowserHistory } from 'history';
+import thunk from 'redux-thunk';
+import { createRootReducer } from './modules/reducer';
+
+export const history = createBrowserHistory();
+
+const shouldEnableDevTools = (process.env.NODE_ENV !== 'production' || process.env.NODE_ENV !== 'staging') && window.devToolsExtension;
+
+export const configureStore = (initialState: Object) => {
+ const middleware = applyMiddleware(thunk, routerMiddleware(history));
+
+ const enhancer = compose(
+ middleware,
+ shouldEnableDevTools ? window.devToolsExtension() : f => f,
+ );
+
+ return createStore(createRootReducer(history), initialState, enhancer);
+};
diff --git a/app/reducers/index.js b/app/redux/modules/reducer.js
similarity index 62%
rename from app/reducers/index.js
rename to app/redux/modules/reducer.js
index e91c19d..089bafa 100644
--- a/app/reducers/index.js
+++ b/app/redux/modules/reducer.js
@@ -2,9 +2,11 @@
import { combineReducers } from 'redux';
import { connectRouter } from 'connected-react-router';
+import type { History } from 'react-router-dom';
+
import todoReducer from './todo';
-export const createRootReducer = (history: Object) => combineReducers({
+export const createRootReducer = (history: History) => combineReducers({
todos: todoReducer,
router: connectRouter(history),
});
diff --git a/app/redux/modules/todo.js b/app/redux/modules/todo.js
new file mode 100644
index 0000000..fea3072
--- /dev/null
+++ b/app/redux/modules/todo.js
@@ -0,0 +1,78 @@
+// @flow
+
+import UUID from 'uuid/v4';
+
+import { getTimestamp } from '../../utils/timestamp';
+
+import type { Action } from '../../types/redux';
+import type { TodoType } from '../../types/todo';
+
+// Actions
+export const ADD_TODO = 'ADD_TODO';
+export const DELETE_TODO = 'DELETE_TODO';
+export const UPDATE_TODO = 'UPDATE_TODO';
+export const TOGGLE_EDIT_TODO = 'TOGGLE_EDIT_TODO';
+export const CANCEL_UPDATE_TODO = 'CANCEL_UPDATE_TODO';
+
+// Actions Creators
+export const addTodo = (text: string) => ({
+ type: ADD_TODO,
+ payload: {
+ text,
+ id: UUID(),
+ editing: false,
+ createdAt: getTimestamp(),
+ },
+});
+
+export const cancelUpdateTodo = (id: string) => ({
+ type: CANCEL_UPDATE_TODO,
+ payload: { id },
+});
+
+export const deleteTodo = (id: string) => ({
+ type: DELETE_TODO,
+ payload: { id },
+});
+
+export const toggleEdit = (id: string) => ({
+ type: TOGGLE_EDIT_TODO,
+ payload: { id },
+});
+
+export const updateTodo = (id: string, text: string) => ({
+ type: UPDATE_TODO,
+ payload: {
+ text,
+ id,
+ },
+});
+
+// Initial State
+const initialState = [];
+
+// Reducers
+export default (state: Array = initialState, action: Action): Array => {
+ switch (action.type) {
+ case ADD_TODO:
+ return [...state, action.payload];
+ case DELETE_TODO:
+ return state.filter((todo: TodoType) => todo.id !== action.payload.id);
+ case TOGGLE_EDIT_TODO: {
+ const { id } = action.payload;
+ return state.map(todo => (todo.id === id ? { ...todo, editing: true } : todo));
+ }
+ case UPDATE_TODO: {
+ const { id, text } = action.payload;
+ return state.map(todo => (todo.id === id ? { ...todo, editing: false, text } : todo));
+ }
+ case CANCEL_UPDATE_TODO: {
+ const { id } = action.payload;
+ return state.map(todo => (todo.id === id ? { ...todo, editing: false } : todo));
+ }
+ default:
+ return state;
+ }
+};
+
+// SideEffects
diff --git a/app/store/configure.js b/app/store/configure.js
deleted file mode 100644
index 5acf821..0000000
--- a/app/store/configure.js
+++ /dev/null
@@ -1,35 +0,0 @@
-// @flow
-
-import { createStore, applyMiddleware, compose } from 'redux';
-import { routerMiddleware } from 'connected-react-router';
-import { createBrowserHistory } from 'history';
-import thunk from 'redux-thunk';
-import { createRootReducer } from '../reducers';
-
-export const history = createBrowserHistory();
-
-export const configureStore = (initialState: Object) => {
- let enhancer;
- const middleware = applyMiddleware(
- thunk,
- routerMiddleware(history),
- );
-
- if (
- process.env.NODE_ENV !== 'production'
- || process.env.NODE_ENV !== 'staging'
- ) {
- enhancer = compose(
- middleware,
- window.devToolsExtension ? window.devToolsExtension() : f => f,
- );
- } else {
- enhancer = compose(middleware);
- }
-
- return createStore(
- createRootReducer(history),
- initialState,
- enhancer,
- );
-};
diff --git a/package.json b/package.json
index 8a18690..9319bce 100644
--- a/package.json
+++ b/package.json
@@ -113,7 +113,10 @@
"./node_modules/**/*"
],
"linux": {
- "icon": "./build/icons/png"
+ "icon": "./build/icons/png",
+ "target": [
+ "deb"
+ ]
},
"mac": {
"category": "public.app-category.productivity",