Initial commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import React from 'react';
|
||||
import { Route, Redirect } from 'react-router-dom';
|
||||
|
||||
const PrivateRoute = ({ component: Component, ...rest }) => {
|
||||
return (
|
||||
<Route
|
||||
{...rest}
|
||||
render={props => {
|
||||
return JSON.parse(localStorage.getItem('auth')).userType ==
|
||||
rest.userType ? (
|
||||
<Component {...props} />
|
||||
) : (
|
||||
<Redirect
|
||||
to={{ pathname: rest.rejectPath, state: { from: props.location } }}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
authentication: state.authentication
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
login: (email, password) => dispatch(authActions.login(email, password))
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(PrivateRoute);
|
||||
@@ -0,0 +1,28 @@
|
||||
import React from 'react';
|
||||
import { Switch, Route } from 'react-router-dom';
|
||||
import styles from './root.less';
|
||||
|
||||
import PrivateRoute from './PrivateRoute';
|
||||
|
||||
import backgroundImage from '../assets/images/mainbg.jpg';
|
||||
|
||||
const Root = props => {
|
||||
return (
|
||||
<React.Fragment>
|
||||
{/* Toast for notifications */}
|
||||
|
||||
<div className={styles.mainCont}>
|
||||
<input
|
||||
className={styles.searchBar}
|
||||
placeholder="Do Everything You Want"
|
||||
/>
|
||||
|
||||
<img className={styles.backgroundImage} src={backgroundImage} />
|
||||
</div>
|
||||
|
||||
<Switch />
|
||||
</React.Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
export default Root;
|
||||
@@ -0,0 +1,38 @@
|
||||
.mainCont {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
.searchBar {
|
||||
display: block;
|
||||
margin: 0;
|
||||
padding: var(--inputPaddingV) var(--inputPaddingH);
|
||||
color: inherit;
|
||||
font-family: inherit;
|
||||
font-size: var(--inputFontSize);
|
||||
font-weight: inherit;
|
||||
line-height: var(--inputLineHeight);
|
||||
border: none;
|
||||
border-radius: 0.4rem;
|
||||
transition: box-shadow var(--transitionDuration);
|
||||
padding: 1em;
|
||||
box-shadow: 0 0 8px #666;
|
||||
width: 400px;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
|
||||
Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||
}
|
||||
|
||||
.backgroundImage {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
opacity: 0.7;
|
||||
|
||||
z-index: -1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user