begins refactoring frontend into src, moves babel-register to src
|
Before Width: | Height: | Size: 200 KiB After Width: | Height: | Size: 200 KiB |
|
Before Width: | Height: | Size: 193 KiB After Width: | Height: | Size: 193 KiB |
|
Before Width: | Height: | Size: 604 KiB After Width: | Height: | Size: 604 KiB |
|
Before Width: | Height: | Size: 859 KiB After Width: | Height: | Size: 859 KiB |
|
Before Width: | Height: | Size: 150 KiB After Width: | Height: | Size: 150 KiB |
13
src/client/components/graphics/Icon/index.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import React from 'react';
|
||||
|
||||
import { PayloadIcon } from 'payload/components';
|
||||
|
||||
const Icon = () => {
|
||||
return (
|
||||
<div className="icon-wrap">
|
||||
<PayloadIcon />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Icon;
|
||||
13
src/client/components/graphics/Logo/index.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import React from 'react';
|
||||
|
||||
import { PayloadLogo } from 'payload/components';
|
||||
|
||||
const Logo = () => {
|
||||
return (
|
||||
<div className="logo-wrap">
|
||||
<PayloadLogo />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Logo;
|
||||
|
Before Width: | Height: | Size: 943 B After Width: | Height: | Size: 943 B |
28
src/client/components/index.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import React from 'react';
|
||||
import { render } from 'react-dom';
|
||||
import { BrowserRouter as Router } from 'react-router-dom';
|
||||
import { Provider } from 'react-redux';
|
||||
import Routes from './routes';
|
||||
import store from '../store';
|
||||
import LoadConfig from './utilities/LoadConfig';
|
||||
import MeasureWindow from './utilities/MeasureWindow';
|
||||
import MeasureScroll from './utilities/MeasureScroll';
|
||||
import SetLocale from './utilities/SetLocale';
|
||||
import SetSearchParams from './utilities/SetSearchParams';
|
||||
|
||||
const Index = () => {
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<Router>
|
||||
<MeasureScroll />
|
||||
<MeasureWindow />
|
||||
<LoadConfig />
|
||||
<SetLocale />
|
||||
<SetSearchParams />
|
||||
<Routes />
|
||||
</Router>
|
||||
</Provider>
|
||||
);
|
||||
};
|
||||
|
||||
render(<Index />, document.getElementById('app'));
|
||||
37
src/client/components/routes/index.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import React from 'react';
|
||||
import Cookies from 'universal-cookie';
|
||||
import { Route, Switch, withRouter, Redirect } from 'react-router-dom';
|
||||
import {
|
||||
CollectionRoutes,
|
||||
DefaultTemplate,
|
||||
Dashboard,
|
||||
Login,
|
||||
CreateUser,
|
||||
MediaLibrary,
|
||||
} from 'payload/components';
|
||||
|
||||
const cookies = new Cookies();
|
||||
|
||||
const Routes = props => {
|
||||
return (
|
||||
<Switch>
|
||||
<Route path="/login" render={routeProps => <Login {...routeProps} />} />
|
||||
<Route path="/forgot" component={() => { return <h1>Forgot Password</h1>; }} />
|
||||
<Route path="/" render={routeProps => {
|
||||
if (cookies.get('token')) {
|
||||
return (
|
||||
<DefaultTemplate {...routeProps}>
|
||||
<Route path="/media-library" component={MediaLibrary} />
|
||||
<Route path="/create-user" component={CreateUser} />
|
||||
<Route path="/" exact component={Dashboard} />
|
||||
<CollectionRoutes views={props.views} />
|
||||
</DefaultTemplate>
|
||||
);
|
||||
}
|
||||
return <Redirect to="/login" />
|
||||
}} />
|
||||
</Switch>
|
||||
);
|
||||
}
|
||||
|
||||
export default withRouter(Routes);
|
||||
20
src/client/components/utilities/LoadConfig/index.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import config from '~local/payload.config.js';
|
||||
|
||||
const mapDispatch = dispatch => ({
|
||||
loadConfig: payload => dispatch({ type: 'LOAD_CONFIG', payload })
|
||||
})
|
||||
|
||||
class LoadConfig extends Component {
|
||||
componentDidMount() {
|
||||
this.props.loadConfig(config);
|
||||
}
|
||||
|
||||
render() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(null, mapDispatch)(LoadConfig);
|
||||