diff options
Diffstat (limited to 'frontend/src/routes/AuthenticatedRoute.tsx')
-rw-r--r-- | frontend/src/routes/AuthenticatedRoute.tsx | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/frontend/src/routes/AuthenticatedRoute.tsx b/frontend/src/routes/AuthenticatedRoute.tsx deleted file mode 100644 index b53f9850..00000000 --- a/frontend/src/routes/AuthenticatedRoute.tsx +++ /dev/null @@ -1,66 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -/* eslint-disable @typescript-eslint/no-explicit-any */ -import * as React from 'react'; -import { connect } from 'react-redux'; -import { Route } from 'react-router-dom'; -import history from '../history'; -import { Store } from '../types'; - -import './Layout.less'; -import NavBar from '../components/navbar/Index'; -import Footer from '../components/footer/Index'; - -interface Props { - exact?: boolean; - isAuthenticated: boolean | null; - path: string; - component: React.ComponentType<any>; -} - -const AuthenticatedRoute = ({ - component: Component, - isAuthenticated, - ...otherProps -}: Props) => { - if (isAuthenticated === false) { - history.push('/login'); - } - - return ( - <> - <div className="container"> - <NavBar /> - <Route - render={() => ( - <> - <Component {...otherProps} /> - </> - )} - /> - </div> - <Footer /> - </> - ); -}; - -const mapStateToProps = (state: Store) => ({ - ...state, - isAuthenticated: state.isAuthenticated, -}); - -export default connect(mapStateToProps)(AuthenticatedRoute); |