better not found

This commit is contained in:
James
2020-01-19 20:39:03 -05:00
parent 519330e20e
commit 7019a4db09
3 changed files with 29 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ import { useUser } from './data/User';
import Dashboard from './views/Dashboard';
import Login from './views/Login';
import Logout from './views/Logout';
import NotFound from './views/NotFound';
import CreateFirstUser from './views/CreateFirstUser';
import MediaLibrary from './views/MediaLibrary';
import Edit from './views/collections/Edit';
@@ -110,7 +111,7 @@ const Routes = () => {
}}
/>
<Route>
<h1>Not Found</h1>
<NotFound />
</Route>
</Switch>
);

View File

@@ -9,8 +9,10 @@ const cookies = new Cookies();
const Context = createContext({});
const UserProvider = ({ children }) => {
const cookieToken = cookies.get('token');
const [token, setToken] = useState('');
const [user, setUser] = useState(null);
const [user, setUser] = useState(cookieToken ? jwtDecode(cookieToken) : null);
useEffect(() => {
if (token) {

View File

@@ -0,0 +1,24 @@
import React from 'react';
import getSanitizedConfig from '../../../config/getSanitizedConfig';
import Button from '../../controls/Button';
import DefaultTemplate from '../../layout/DefaultTemplate';
const { routes: { admin } } = getSanitizedConfig();
const NotFound = () => {
return (
<DefaultTemplate className="not-found">
<h1>Nothing found</h1>
<p>Sorry&mdash;there is nothing to correspond with your request.</p>
<br />
<Button
el="link"
to={`${admin}`}
>
Back to Dashboard
</Button>
</DefaultTemplate>
);
};
export default NotFound;