Moved Admin and LoginForm to admin folder and deleted app and main in replacement for root.
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
./app/components/App.jsx
|
||||
|
||||
<FetchData url={"https://apollo.kevinmidboe.com/api/v1/plex/playing"} />
|
||||
*/
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router-dom'
|
||||
|
||||
import FetchData from './FetchData.js';
|
||||
import ListStrays from './ListStrays.jsx';
|
||||
|
||||
import FetchRequested from './FetchRequested.jsx';
|
||||
|
||||
import LoginForm from './LoginForm/LoginForm.jsx';
|
||||
import { Provider } from 'react-redux';
|
||||
import store from './redux/store.jsx';
|
||||
|
||||
import { getCookie } from './Cookie.jsx';
|
||||
|
||||
|
||||
function getLoginStatus() {
|
||||
const logged_in = getCookie('logged_in');
|
||||
if (logged_in) {
|
||||
return <FetchRequested />
|
||||
}
|
||||
return <LoginForm />
|
||||
}
|
||||
|
||||
const Admin = () => (
|
||||
<Provider store={store}>
|
||||
{ getLoginStatus() }
|
||||
</Provider>
|
||||
)
|
||||
|
||||
export default Admin
|
||||
@@ -1,12 +0,0 @@
|
||||
import React, { Component } from "react";
|
||||
import Header from './Header.jsx';
|
||||
import Main from './Main.jsx';
|
||||
|
||||
const App = () => (
|
||||
<div>
|
||||
<Header />
|
||||
<Main />
|
||||
</div>
|
||||
)
|
||||
|
||||
export default App
|
||||
@@ -1,66 +0,0 @@
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { login } from '../redux/reducer.jsx';
|
||||
|
||||
class LoginForm extends Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {};
|
||||
this.onSubmit = this.onSubmit.bind(this);
|
||||
}
|
||||
|
||||
render() {
|
||||
let {email, password} = this.state;
|
||||
let {isLoginPending, isLoginSuccess, loginError} = this.props;
|
||||
return (
|
||||
<form name="loginForm" onSubmit={this.onSubmit}>
|
||||
<div className="form-group-collection">
|
||||
<div className="form-group">
|
||||
<label>Email:</label>
|
||||
<input type="" name="email" onChange={e => this.setState({email: e.target.value})} value={email}/>
|
||||
</div>
|
||||
|
||||
<div className="form-group">
|
||||
<label>Password:</label>
|
||||
<input type="password" name="password" onChange={e => this.setState({password: e.target.value})} value={password}/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="submit" value="Login" />
|
||||
|
||||
<div className="message">
|
||||
{ isLoginPending && <div>Please wait...</div> }
|
||||
{ isLoginSuccess && <div>Success.</div> }
|
||||
{ loginError && <div>{loginError.message}</div> }
|
||||
</div>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
|
||||
onSubmit(e) {
|
||||
e.preventDefault();
|
||||
let { email, password } = this.state;
|
||||
this.props.login(email, password);
|
||||
this.setState({
|
||||
email: '',
|
||||
password: ''
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
isLoginPending: state.isLoginPending,
|
||||
isLoginSuccess: state.isLoginSuccess,
|
||||
loginError: state.loginError
|
||||
};
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
login: (email, password) => dispatch(login(email, password))
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(LoginForm);
|
||||
@@ -1,21 +0,0 @@
|
||||
import React from 'react';
|
||||
import { HashRouter as Router, Route, Switch} from 'react-router-dom';
|
||||
import { createBrowserHistory } from 'history';
|
||||
|
||||
import SearchRequest from './SearchRequest.jsx';
|
||||
import Admin from './Admin.jsx';
|
||||
import NotFound from './NotFound.js';
|
||||
|
||||
export const history = createBrowserHistory();
|
||||
|
||||
const Main = () => (
|
||||
<Router>
|
||||
<Switch>
|
||||
<Route exact path='/' component={SearchRequest} />
|
||||
<Route path='/admin' component={Admin} />
|
||||
<Route component={NotFound} />
|
||||
</Switch>
|
||||
</Router>
|
||||
)
|
||||
|
||||
export default Main
|
||||
Reference in New Issue
Block a user