-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from ShahandFahad/usermgmt
Usermgmt
- Loading branch information
Showing
24 changed files
with
3,084 additions
and
78 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
import Admin from "./admin/Admin"; | ||
import Login from "./components/Auth/Login"; | ||
import Signup from "./components/Auth/Signup"; | ||
import MainLayout from "./layouts/MainLayout"; | ||
import { BrowserRouter as Router, Routes, Route } from "react-router-dom"; | ||
import AuthProvider from "./provider/authProvider"; | ||
import Routes from "./routes"; | ||
|
||
function App() { | ||
return ( | ||
<> | ||
<Router> | ||
<Routes> | ||
{/* Login Page */} | ||
<Route path="/login" element={<Login />} /> | ||
{/* Registeration Page */} | ||
<Route path="/signup" element={<Signup />} /> | ||
{/* Client Side */} | ||
<Route path="/*" element={<MainLayout />} /> | ||
{/* Admin Panel */} | ||
<Route path="/admin/*" element={<Admin />} /> | ||
</Routes> | ||
</Router> | ||
</> | ||
<AuthProvider> | ||
<Routes /> | ||
</AuthProvider> | ||
); | ||
} | ||
|
||
export default App; | ||
|
||
// The Routing Strategy Without Authentication | ||
// <> | ||
// <Router> | ||
// <Routes> | ||
// {/* Login Page */} | ||
// <Route path="/login" element={<Login />} /> | ||
// {/* Registeration Page */} | ||
// <Route path="/signup" element={<Signup />} /> | ||
// {/* Client Side */} | ||
// <Route path="/*" element={<MainLayout />} /> | ||
// {/* Admin Panel */} | ||
// <Route path="/admin/*" element={<Admin />} /> | ||
// </Routes> | ||
// </Router> | ||
// </> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from "react"; | ||
import axios from "axios"; | ||
import { useAuth } from "../../provider/authProvider"; | ||
import { useNavigate } from "react-router-dom"; | ||
import styled from "styled-components"; | ||
// Custom loader | ||
const Spinner = styled.div` | ||
width: 80px; | ||
height: 80px; | ||
border: 10px solid #f76b1c; | ||
border-bottom-color: transparent; | ||
border-radius: 50%; | ||
display: inline-block; | ||
box-sizing: border-box; | ||
animation: rotation 1s linear infinite; | ||
@keyframes rotation { | ||
0% { | ||
transform: rotate(0deg); | ||
} | ||
100% { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
`; | ||
|
||
const LogOut = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 5px; | ||
width: 100%; | ||
height: 100vh; | ||
justify-content: center; | ||
align-items: center; | ||
`; | ||
|
||
const Logout = () => { | ||
const { setToken } = useAuth(); | ||
const navigate = useNavigate(); | ||
|
||
// Just remove the token from local storage and navigate back to login page | ||
const handleLogout = () => { | ||
setToken(); | ||
navigate("/login", { replace: true }); | ||
}; | ||
|
||
// Wait for 5 sec | ||
setTimeout(() => { | ||
handleLogout(); | ||
console.log("User Logged Out."); | ||
}, 1500); | ||
|
||
return ( | ||
<LogOut> | ||
<Spinner /> | ||
<h1>LOGGING OUT...</h1> | ||
</LogOut> | ||
); | ||
}; | ||
|
||
export default Logout; |
Oops, something went wrong.