Remove default content

This commit is contained in:
GHOSCHT 2020-08-01 15:41:43 +02:00
parent e492618b06
commit dd6fe1251f
8 changed files with 0 additions and 176 deletions

View file

@ -1,6 +0,0 @@
import { createAction } from 'redux-actions';
export default {
login: createAction('USER_LOGIN'),
logout: createAction('USER_LOGOUT'),
};

View file

@ -1,24 +0,0 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
export default class LoggedIn extends Component {
static propTypes = {
onLogout: PropTypes.func.isRequired,
};
handleLogout = () => {
this.props.onLogout({
username: '',
loggedIn: false,
});
};
render() {
return (
<div>
<h2>Logged in as {this.props.user.username}</h2>
<button onClick={this.handleLogout}>Logout</button>
</div>
);
}
}

View file

@ -1,42 +0,0 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import SerialPort from 'serialport';
export default class Login extends Component {
static propTypes = {
onLogin: PropTypes.func.isRequired,
};
state = {
username: '',
};
handleLogin = () => {
this.props.onLogin({
username: this.state.username,
loggedIn: true,
});
};
handleChange = (e) => {
this.setState({
username: e.target.value,
});
};
render() {
const port = new SerialPort('COM3');
const triggerOn = () => {
port.write('on');
};
const triggerOff = () => {
port.write('off');
};
return (
<div>
<button onClick={triggerOn}>ON</button>
<button onClick={triggerOff}>OFF</button>
</div>
);
}
}

View file

@ -1,21 +0,0 @@
import { connect } from 'react-redux';
import { push } from 'connected-react-router';
import { bindActionCreators } from 'redux';
import LoggedIn from '../components/LoggedIn';
import userActions from '../actions/user';
const mapStateToProps = (state) => {
return state;
};
const mapDispatchToProps = (dispatch) => {
const user = bindActionCreators(userActions, dispatch);
return {
onLogout: (data) => {
user.logout(data);
dispatch(push('/'));
},
};
};
export default connect(mapStateToProps, mapDispatchToProps)(LoggedIn);

View file

@ -1,21 +0,0 @@
import { connect } from 'react-redux';
import { push } from 'connected-react-router';
import { bindActionCreators } from 'redux';
import Login from '../components/Login';
import userActions from '../actions/user';
const mapStateToProps = (state) => {
return state;
};
const mapDispatchToProps = (dispatch) => {
const user = bindActionCreators(userActions, dispatch);
return {
onLogin: (data) => {
user.login(data);
dispatch(push('/loggedin'));
},
};
};
export default connect(mapStateToProps, mapDispatchToProps)(Login);

View file

@ -1,14 +0,0 @@
import { handleActions } from 'redux-actions';
import actions from '../actions/user';
export default handleActions(
{
[actions.login]: (state, action) => {
return { ...state, ...action.payload };
},
[actions.logout]: (state, action) => {
return { ...state, ...action.payload };
},
},
{},
);

View file

@ -1,12 +0,0 @@
import React from 'react';
import { Switch, Route } from 'react-router';
import LoginPage from './containers/LoginPage';
import LoggedInPage from './containers/LoggedInPage';
export default (
<Switch>
<Route exact path="/" component={LoginPage} />
<Route exact path="/loggedin" component={LoggedInPage} />
</Switch>
);

View file

@ -1,36 +0,0 @@
import { createStore, applyMiddleware, combineReducers, compose } from 'redux';
import { connectRouter, routerMiddleware, push } from 'connected-react-router';
import persistState from 'redux-localstorage';
import thunk from 'redux-thunk';
import user from './reducers/user';
import userActions from './actions/user';
export default function configureStore(initialState, routerHistory) {
const router = routerMiddleware(routerHistory);
const actionCreators = {
...userActions,
push,
};
const reducers = {
router: connectRouter(routerHistory),
user,
};
const middlewares = [thunk, router];
const composeEnhancers = (() => {
const compose_ = window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
if (process.env.NODE_ENV === 'development' && compose_) {
return compose_({ actionCreators });
}
return compose;
})();
const enhancer = composeEnhancers(applyMiddleware(...middlewares), persistState());
const rootReducer = combineReducers(reducers);
return createStore(rootReducer, initialState, enhancer);
}