forked from dunky11/react-saas-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRouting.js
More file actions
131 lines (127 loc) · 3.78 KB
/
Routing.js
File metadata and controls
131 lines (127 loc) · 3.78 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import React, { memo } from "react";
import PropTypes from "prop-types";
import { Switch } from "react-router-dom";
import { withStyles } from "@material-ui/core";
import Dashboard from "./dashboard/Dashboard";
import Posts from "./posts/Posts";
import Subscription from "./subscription/Subscription";
import PropsRoute from "../../shared/components/PropsRoute";
import useLocationBlocker from "../../shared/functions/useLocationBlocker";
const styles = (theme) => ({
wrapper: {
margin: theme.spacing(1),
width: "auto",
[theme.breakpoints.up("xs")]: {
width: "95%",
marginLeft: "auto",
marginRight: "auto",
marginTop: theme.spacing(4),
marginBottom: theme.spacing(4),
},
[theme.breakpoints.up("sm")]: {
marginTop: theme.spacing(6),
marginBottom: theme.spacing(6),
width: "90%",
marginLeft: "auto",
marginRight: "auto",
},
[theme.breakpoints.up("md")]: {
marginTop: theme.spacing(6),
marginBottom: theme.spacing(6),
width: "82.5%",
marginLeft: "auto",
marginRight: "auto",
},
[theme.breakpoints.up("lg")]: {
marginTop: theme.spacing(6),
marginBottom: theme.spacing(6),
width: "70%",
marginLeft: "auto",
marginRight: "auto",
},
},
});
function Routing(props) {
const {
classes,
EmojiTextArea,
ImageCropper,
Dropzone,
DateTimePicker,
pushMessageToSnackbar,
posts,
transactions,
toggleAccountActivation,
CardChart,
statistics,
targets,
setTargets,
setPosts,
isAccountActivated,
selectDashboard,
selectPosts,
selectSubscription,
openAddBalanceDialog,
} = props;
useLocationBlocker();
return (
<div className={classes.wrapper}>
<Switch>
<PropsRoute
path="/c/posts"
component={Posts}
EmojiTextArea={EmojiTextArea}
ImageCropper={ImageCropper}
Dropzone={Dropzone}
DateTimePicker={DateTimePicker}
pushMessageToSnackbar={pushMessageToSnackbar}
posts={posts}
setPosts={setPosts}
selectPosts={selectPosts}
/>
<PropsRoute
path="/c/subscription"
component={Subscription}
transactions={transactions}
pushMessageToSnackbar={pushMessageToSnackbar}
selectSubscription={selectSubscription}
openAddBalanceDialog={openAddBalanceDialog}
/>
<PropsRoute
path=""
component={Dashboard}
toggleAccountActivation={toggleAccountActivation}
pushMessageToSnackbar={pushMessageToSnackbar}
CardChart={CardChart}
statistics={statistics}
targets={targets}
setTargets={setTargets}
isAccountActivated={isAccountActivated}
selectDashboard={selectDashboard}
/>
</Switch>
</div>
);
}
Routing.propTypes = {
classes: PropTypes.object.isRequired,
EmojiTextArea: PropTypes.elementType,
ImageCropper: PropTypes.elementType,
Dropzone: PropTypes.elementType,
DateTimePicker: PropTypes.elementType,
pushMessageToSnackbar: PropTypes.func,
setTargets: PropTypes.func.isRequired,
setPosts: PropTypes.func.isRequired,
posts: PropTypes.arrayOf(PropTypes.object).isRequired,
transactions: PropTypes.arrayOf(PropTypes.object).isRequired,
toggleAccountActivation: PropTypes.func,
CardChart: PropTypes.elementType,
statistics: PropTypes.object.isRequired,
targets: PropTypes.arrayOf(PropTypes.object).isRequired,
isAccountActivated: PropTypes.bool.isRequired,
selectDashboard: PropTypes.func.isRequired,
selectPosts: PropTypes.func.isRequired,
selectSubscription: PropTypes.func.isRequired,
openAddBalanceDialog: PropTypes.func.isRequired,
};
export default withStyles(styles, { withTheme: true })(memo(Routing));