-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
187 lines (173 loc) · 4.81 KB
/
App.tsx
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
import React, { useMemo } from 'react';
import { Routes, BrowserRouter, Route } from "react-router-dom"
import { CssBaseline, gridClasses, Typography } from "@mui/material";
import { createTheme, ThemeProvider } from "@mui/material/styles";
import { blue, purple } from '@mui/material/colors';
import { useRecoilValue } from 'recoil';
import { withErrorBoundary, useErrorBoundary } from "react-use-error-boundary";
import MainLayout from "layouts/MainLayout"
import Companies from 'views/Companies';
import Company from 'views/Company';
import Dashboard from "views/Dashboard"
import Job from 'views/Job';
import Jobs from 'views/Jobs';
import Searches from 'views/Searches';
import PageChanges from 'views/PageChanges';
import FeedbackBackdrop from 'components/FeedbackBackdrop';
import { themeState } from 'state';
import Grid from 'components/Grid';
import { ErrorOutline } from '@mui/icons-material';
const App = withErrorBoundary(() => {
const themeMode = useRecoilValue(themeState);
const [error] = useErrorBoundary(
(error, errorInfo) => {
console.error(`Error thrown: - ${error}`, errorInfo);
}
);
const theme = useMemo(() => {
const theme = createTheme({
palette: {
mode: themeMode,
primary: {
main: blue[500],
dark: blue[700]
},
secondary: {
main: purple[500]
},
background: {
default: themeMode === "dark" ? "#303030" : "#fafafa",
paper: themeMode === "dark" ? "#424242" : "#fff"
}
},
components: {
MuiLink: {
styleOverrides: {
root: {
color: "inherit",
textDecoration: "none",
"&:hover": {
textDecoration: "underline"
}
}
}
},
MuiGrid: {
styleOverrides: {
root: {
[`& .${gridClasses.item}:empty`]: {
padding: "0 !important"
}
}
}
},
MuiPaper: {
styleOverrides: {
root: {
backgroundImage: "none"
}
}
}
},
breakpoints: {
values: {
xs: 0,
sm: 600,
md: 960,
lg: 1280,
xl: 1920,
xxl: 2500
}
}
});
if (theme?.components) {
theme.components.MuiContainer = {
styleOverrides: {
root: {
[theme.breakpoints.down("sm")]: {
padding: 0
}
}
}
}
}
return theme;
}, [themeMode]);
if (error) {
return (
<ThemeProvider theme={theme}>
<CssBaseline />
<Grid container alignItems="center" justifyContent="center" direction="column" sx={{ height: "100vh" }}>
<Grid item>
<ErrorOutline color="error" sx={{ fontSize: "10em" }} />
</Grid>
<Grid item container direction="column" alignItems="center">
<Typography variant="h1">Fatal Error</Typography>
<Typography variant="body1">A fatal error has occurred. Please reload and try again, or report this issue if it persists.</Typography>
</Grid>
</Grid>
</ThemeProvider>
)
}
return (
<ThemeProvider theme={theme}>
<CssBaseline />
<FeedbackBackdrop />
<BrowserRouter>
<Routes>
<Route path="/" element={
<MainLayout pageTitle="Dashboard">
<Dashboard />
</MainLayout>
} />
<Route path="/jobs" element={
<MainLayout pageTitle="Saved Jobs">
<Jobs />
</MainLayout>
} />
<Route path="/job/:id" element={
<MainLayout>
<Job />
</MainLayout>
} />
<Route path="/companies" element={
<MainLayout pageTitle="Saved Companies">
<Companies />
</MainLayout>
} />
<Route path="/company/:id" element={
<MainLayout>
<Company />
</MainLayout>
} />
<Route path="/searches" element={
<MainLayout>
<Searches />
</MainLayout>
} />
<Route path="/page-changes/:id" element={
<MainLayout pageTitle="Page Changes">
<PageChanges />
</MainLayout>
} />
<Route path="/page-changes/:id/:change" element={
<MainLayout pageTitle="Page Changes">
<PageChanges />
</MainLayout>
} />
</Routes>
</BrowserRouter>
</ThemeProvider>
);
});
export default App;
declare module "@mui/material/styles" {
interface BreakpointOverrides {
xs: true;
sm: true;
md: true;
lg: true;
xl: true;
xxl: true;
}
}