Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
Girgetto committed Sep 27, 2019
1 parent 232c947 commit e8a9775
Show file tree
Hide file tree
Showing 33 changed files with 1,771 additions and 129 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/serviceWorker.js
43 changes: 43 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"env": {
"jest": true,
"browser": true
},
"parser": "babel-eslint",
"extends": ["airbnb", "plugin:import/errors"],
"rules": {
"linebreak-style": 0,
"react/prop-types": 0,
"react/jsx-filename-extension": 0,
"react/no-did-mount-set-state": 0,
"global-require": 0,
"id-length": 0,
"max-len": 0,
"jsx-a11y/anchor-is-valid": 0,
"jsx-a11y/label-has-for": 0,
"import/default": 0,
"no-param-reassign": [
2,
{
"props": false
}
],
"consistent-return": 0,
"arrow-parens": 0,
"no-underscore-dangle": 0,
"import/no-dynamic-require": 0,
"import/prefer-default-export": 0,
"newline-per-chained-call": 0,
"object-curly-newline": [
"error",
{
"ObjectPattern": {
"multiline": false
}
}
],
"jsx-a11y/no-noninteractive-element-interactions": 0,
"jsx-a11y/no-static-element-interactions": 0,
"jsx-a11y/click-events-have-key-events": 0,
}
}
35 changes: 33 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,40 @@
"dependencies": {
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-scripts": "3.1.2"
"react-scripts": "3.1.2",
"axios": "^0.19.0",
"classnames": "^2.2.6",
"connected-react-router": "^4.3.0",
"draft-js": "^0.11.0",
"draft-js-plugins-editor": "^3.0.0",
"draft-js-side-toolbar-plugin": "^3.0.2",
"draft-js-static-toolbar-plugin": "^3.0.1",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"eslint": "^6.2.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.14.3",
"expect.js": "^0.3.1",
"history": "^4.7.2",
"husky": "^3.0.4",
"react-redux": "^5.0.7",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
"redux": "^3.7.2",
"redux-actions": "^2.6.5",
"redux-persist": "^5.10.0",
"redux-saga": "^1.0.5",
"rxjs": "5.5.2",
"styled-components": "^4.3.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"lint": "node_modules/.bin/eslint ."
},
"eslintConfig": {
"extends": "react-app"
Expand All @@ -27,5 +54,9 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"babel-eslint": "^10.0.2",
"node-sass": "^4.12.0"
}
}
22 changes: 0 additions & 22 deletions src/App.css

This file was deleted.

26 changes: 0 additions & 26 deletions src/App.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/App.test.js

This file was deleted.

Empty file added src/components/commons/index.js
Empty file.
Empty file added src/components/layout/inde.js
Empty file.
11 changes: 11 additions & 0 deletions src/components/pages/Login/Login.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react'

const Login = () => {
return (
<div>
Login
</div>
)
}

export default Login
11 changes: 11 additions & 0 deletions src/components/pages/Login/Login.container.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { connect } from 'react-redux';
import Login from './Login.styled';

const mapStateToProps = state => ({});

const mapDispatchToProps = dispatch => ({});

export default connect(
mapStateToProps,
mapDispatchToProps,
)(Login);
11 changes: 11 additions & 0 deletions src/components/pages/Login/Login.styled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react'

const Login = () => {
return (
<div>
Login
</div>
)
}

export default Login
5 changes: 5 additions & 0 deletions src/components/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Login from './Login/Login.container';

export {
Login
}
13 changes: 0 additions & 13 deletions src/index.css

This file was deleted.

21 changes: 17 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
import { PersistGate } from 'redux-persist/integration/react';
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import { Provider } from 'react-redux';
import { ConnectedRouter } from 'connected-react-router';
import { store, persistor, history } from './state';
import * as serviceWorker from './serviceWorker';
import Routes from './routes';
import './style.scss';

ReactDOM.render(<App />, document.getElementById('root'));
ReactDOM.render(
<Provider store={store}>
<PersistGate persistor={persistor}>
<ConnectedRouter history={history}>
{Routes}
</ConnectedRouter>
</PersistGate>
</Provider>,
document.getElementById('root'),
);

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
serviceWorker.unregister();
1 change: 0 additions & 1 deletion src/logo.svg

This file was deleted.

16 changes: 16 additions & 0 deletions src/routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import { Switch, Route } from 'react-router-dom';
import {
Login,
} from './components/pages';


const Routes = (
<div>
<Switch>
<Route path="/" exact component={() => <Login />} />
</Switch>
</div>
);

export default Routes;
6 changes: 6 additions & 0 deletions src/state/UI/actionCreators.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

import { createAction } from 'redux-actions';
import * as actionTypes from './actionTypes';

export const setLoading = createAction(actionTypes.SET_LOADING, isLoading => ({ isLoading }));
export const setError = createAction(actionTypes.SET_ERROR, error => ({ error }));
3 changes: 3 additions & 0 deletions src/state/UI/actionTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

export const SET_LOADING = 'SET_LOADING';
export const SET_ERROR = 'SET_ERROR';
4 changes: 4 additions & 0 deletions src/state/UI/initial.state.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
isLoading: false,
error: false,
};
Empty file added src/state/UI/reducer.js
Empty file.
Empty file added src/state/UI/sagas.js
Empty file.
10 changes: 10 additions & 0 deletions src/state/UI/selectors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { handleActions } from 'redux-actions';
import initialState from './initial.state';
import * as actions from './actionCreators';

const ui = handleActions(
{},
initialState,
);

export default ui;
5 changes: 5 additions & 0 deletions src/state/User/actionCreators.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

import { createAction } from 'redux-actions';
import * as actionTypes from './actionTypes';

export const login = createAction(actionTypes.LOGIN, user => ({ user }));
2 changes: 2 additions & 0 deletions src/state/User/actionTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const LOGIN = 'LOGIN';
export const SET_USER = 'SET_USER';
5 changes: 5 additions & 0 deletions src/state/User/initial.state.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
id: null,
email: null,
role: null,
};
9 changes: 9 additions & 0 deletions src/state/User/reducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { handleActions } from 'redux-actions';
import initialState from './initial.state';

const user = handleActions(
{},
initialState,
);

export default user;
Empty file added src/state/User/sagas.js
Empty file.
Empty file added src/state/User/selectors.js
Empty file.
12 changes: 12 additions & 0 deletions src/state/index-reducers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { combineReducers } from 'redux';
import ui from './UI/reducer';
import user from './User/reducer';

const AppReducer = combineReducers({ ui, user });

const rootReducer = (state, action) => {
if (action.type === 'LOGOUT') return AppReducer({}, action);
return AppReducer(state, action);
};

export default rootReducer;
39 changes: 39 additions & 0 deletions src/state/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { createStore, applyMiddleware, compose } from 'redux';
import { persistStore, persistReducer } from 'redux-persist';
import autoMergeLevel2 from 'redux-persist/lib/stateReconciler/autoMergeLevel2';
import storage from 'redux-persist/lib/storage';
import createSagaMiddleware from 'redux-saga';
import { createBrowserHistory } from 'history';
import { connectRouter, routerMiddleware } from 'connected-react-router';

import rootReducer from './index-reducers';
import rootSagas from './sagas-registration';

const sagaMiddleware = createSagaMiddleware();

const history = createBrowserHistory();

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; // eslint-disable-line no-undef
const enhancer = composeEnhancers(applyMiddleware(routerMiddleware(history), sagaMiddleware));

const persistConfig = {
key: 'root',
storage,
blacklist: ['ui'],
stateReconciler: autoMergeLevel2,
};
const persistedReducer = persistReducer(persistConfig, rootReducer);

const configureStore = (initialState = {}) => {
const store = createStore(connectRouter(history)(persistedReducer), initialState, enhancer);
const persistor = persistStore(store);
sagaMiddleware.run(rootSagas);
routerMiddleware(history);
persistStore(store);

return { store, persistor };
};

const { store, persistor } = configureStore();

export { store, persistor, history };
5 changes: 5 additions & 0 deletions src/state/sagas-registration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { all } from 'redux-saga/effects';

export default function* root() {
yield all([]);
}
Loading

0 comments on commit e8a9775

Please sign in to comment.