forked from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
68 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,38 @@ | ||
import React, { useState } from 'react'; | ||
import Authenticate from './pages/Authenticate/Authenticate.js'; | ||
import Home from './pages/Home/Home.js'; | ||
import Clasico from './pages/Clasico/Clasico.js'; | ||
import WrongRoute from './pages/WrongRoute/WrongRoute.js'; | ||
import './App.css'; | ||
import Register from './components/Register/Register'; | ||
import Login from './components/Login/Login'; | ||
import CssBaseline from '@mui/material/CssBaseline'; | ||
import Container from '@mui/material/Container'; | ||
import Typography from '@mui/material/Typography'; | ||
import Link from '@mui/material/Link'; | ||
|
||
import {BrowserRouter, Routes, Route} from "react-router-dom"; | ||
import AuthProvider from 'react-auth-kit'; | ||
import AuthOutlet from '@auth-kit/react-router/AuthOutlet'; | ||
import createStore from 'react-auth-kit/createStore'; | ||
function App() { | ||
const [showLogin, setShowLogin] = useState(true); | ||
|
||
const store = createStore({ | ||
authName:'_auth', | ||
authType:'cookie', | ||
cookieDomain: window.location.hostname, | ||
cookieSecure: window.location.protocol === 'https:' | ||
}) | ||
|
||
const App = () => { | ||
return ( | ||
<AuthProvider store={store}> | ||
<BrowserRouter> | ||
<Routes> | ||
{/** Rutas públicas */} | ||
<Route path={'/'} element={<Authenticate />}/> | ||
|
||
{/** Rutas privadas */} | ||
<Route element={<AuthOutlet fallbackPath='/' />}> | ||
<Route path='/home' element={<Home />} /> | ||
<Route path='/home/clasico' element={<Clasico />} /> | ||
</Route> | ||
const handleToggleView = () => { | ||
setShowLogin(!showLogin); | ||
}; | ||
|
||
<Route path='*' element={<WrongRoute />} /> | ||
</Routes> | ||
</BrowserRouter> | ||
</AuthProvider> | ||
); | ||
}; | ||
return ( | ||
<Container component="main" maxWidth="xs"> | ||
<CssBaseline /> | ||
<Typography component="h1" variant="h5" align="center" sx={{ marginTop: 2 }}> | ||
Welcome to wiq_es1a | ||
</Typography> | ||
{showLogin ? <Login /> : <Register />} | ||
<Typography component="div" align="center" sx={{ marginTop: 2 }}> | ||
{showLogin ? ( | ||
<Link name="gotoregister" component="button" variant="body2" onClick={handleToggleView}> | ||
Don't have an account? Register here. | ||
</Link> | ||
) : ( | ||
<Link component="button" variant="body2" onClick={handleToggleView}> | ||
Already have an account? Login here. | ||
</Link> | ||
)} | ||
</Typography> | ||
</Container> | ||
); | ||
} | ||
|
||
export default App; | ||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters