forked from processing/p5.js-web-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutes.jsx
92 lines (84 loc) · 3.51 KB
/
routes.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import PropTypes from 'prop-types';
import React, { useEffect } from 'react';
import { useDispatch } from 'react-redux';
import { Route as RouterRoute, Switch } from 'react-router-dom';
import App from './modules/App/App';
import IDEView from './modules/IDE/pages/IDEView';
import FullView from './modules/IDE/pages/FullView';
import CodeOfConduct from './modules/Legal/pages/CodeOfConduct';
import PrivacyPolicy from './modules/Legal/pages/PrivacyPolicy';
import TermsOfUse from './modules/Legal/pages/TermsOfUse';
import LoginView from './modules/User/pages/LoginView';
import SignupView from './modules/User/pages/SignupView';
import ResetPasswordView from './modules/User/pages/ResetPasswordView';
import EmailVerificationView from './modules/User/pages/EmailVerificationView';
import NewPasswordView from './modules/User/pages/NewPasswordView';
import AccountView from './modules/User/pages/AccountView';
import CollectionView from './modules/User/pages/CollectionView';
import DashboardView from './modules/User/pages/DashboardView';
import { getUser } from './modules/User/actions';
/**
* `params` is no longer a top-level route component prop in v4.
* It is a nested property of `match`.
* Use an HOC to lift it up to top-level.
*/
const withParams = (Component) => (props) => (
// eslint-disable-next-line react/prop-types
<Component {...props} params={props.match.params} />
);
/**
* Instead of updating all individual components, use this plug-in Route replacement.
* It passes the `params` as a top-level property
* and fixes prop-types errors in react-router package
* (Warning: Failed prop type: Invalid prop `component` of type `object` supplied to `Route`, expected `function`.)
*/
const Route = ({ component, ...props }) => (
<RouterRoute component={withParams(component)} {...props} />
);
Route.propTypes = {
...RouterRoute.propTypes,
component: PropTypes.elementType.isRequired
};
const routes = (
<Switch>
<Route exact path="/" component={IDEView} />
<Route path="/login" component={LoginView} />
<Route path="/signup" component={SignupView} />
<Route
path="/reset-password/:reset_password_token"
component={NewPasswordView}
/>
<Route path="/reset-password" component={ResetPasswordView} />
<Route path="/verify" component={EmailVerificationView} />
<Route path="/projects/:project_id" component={IDEView} />
<Route path="/:username/full/:project_id" component={FullView} />
<Route path="/full/:project_id" component={FullView} />
<Route path="/:username/assets" component={DashboardView} />
<Route
path="/:username/sketches/:project_id/add-to-collection"
component={IDEView}
/>
<Route path="/:username/sketches/:project_id" component={IDEView} />
<Route path="/:username/sketches" component={DashboardView} />
<Route
path="/:username/collections/:collection_id"
component={CollectionView}
/>
<Route path="/:username/collections" component={DashboardView} />
<Route path="/sketches" component={DashboardView} />
<Route path="/assets" component={DashboardView} />
<Route path="/account" component={AccountView} />
<Route path="/about" component={IDEView} />
<Route path="/privacy-policy" component={PrivacyPolicy} />
<Route path="/terms-of-use" component={TermsOfUse} />
<Route path="/code-of-conduct" component={CodeOfConduct} />
</Switch>
);
function Routing() {
const dispatch = useDispatch();
useEffect(() => {
dispatch(getUser());
}, []);
return <App>{routes}</App>;
}
export default Routing;