Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
612c2c8
feat(frontend): added Protection to Frontend
SHREESHANTH99 Jul 4, 2025
082a576
feat(frontend): add Protection to frontend
SHREESHANTH99 Jul 5, 2025
0672064
feat(frontend): add profile page
PixelKnightDev Jun 17, 2025
2e84642
style(frontend): fix profile page styling and layout consistency
PixelKnightDev Jun 27, 2025
be5524b
style(frontend): fix profil page styling and layout consistency
PixelKnightDev Jun 27, 2025
ccca68e
style(frontend): make a few fixes in css
PixelKnightDev Jun 29, 2025
6be4e94
style(frontend): fix tag remove button position
PixelKnightDev Jul 4, 2025
581b7ad
feat(frontend): added Protection to Frontend
SHREESHANTH99 Jul 6, 2025
b4d9a50
feat(frontend): added Protection to Frontend
SHREESHANTH99 Jul 10, 2025
71eb705
Fix #24 (feat) : added the preloader (#30)
ShirshenduR Jul 9, 2025
7bcc66a
feat(frontend): added Protection to Frontend Made changes according t…
SHREESHANTH99 Jul 9, 2025
5775fea
Merge remote-tracking branch 'origin/main' into feature/protected-routes
SHREESHANTH99 Jul 10, 2025
0f4d1f9
feat(frontend): added Protection to Frontend
SHREESHANTH99 Jul 10, 2025
7173bb1
feat(frontend): added Protection to Frontend
SHREESHANTH99 Jul 10, 2025
849070d
feat(frontend): resolve merge conflicts
SHREESHANTH99 Jul 10, 2025
90d16e3
feat(frontend): added route protection
SHREESHANTH99 Jul 10, 2025
a6b0cbb
Merge branches 'feature/protected-routes' and 'main' of https://githu…
SHREESHANTH99 Jul 11, 2025
0aae707
feat(frontend): added preloader into privateroute
SHREESHANTH99 Jul 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,31 @@ import Login from "./pages/Login/Login";
import { Routes, Route, Navigate } from "react-router-dom";
import Home from "./pages/Home/Home.jsx";
import Callback from "./pages/Callback/Callback";
import NotFound from "./pages/404/404";
import MainLayout from "./layouts/MainLayout.jsx";
import Preloader from "./pages/Preloader/Preloader";
import NotFound from './pages/404/404'
import ProfilePage from "./pages/Profile/ProfilePage.jsx";
import PrivateRoutesWrapper from "./components/ProtectedRoutes/PrivateRoutesWrapper.jsx";

function App() {
return (
<Routes>
<Route path="/" element={<Landingpage />} />
<Route path="/home" element={<Home />} />
<Route path="/login" element={<Login />} />
<Route path="/callback" element={<Callback />} />
<Route path="/preloader" element={<Preloader />} />
<Route path="/profile" element={<ProfilePage />} />
<Route element={<MainLayout />}>
<Route path="/" element={<Landingpage />} />
<Route path="/login" element={<Login />} />
<Route element={<PrivateRoutesWrapper />}>
<Route path="/home" element={<Home />} />
<Route path="/profile" element={<ProfilePage />} />
<Route path="/preloader" element={<Preloader />} />
{/* Add more protected routes here */}
</Route>
<Route path="/callback" element={<Callback />} />
</Route>


<Route path="*" element={<NotFound />} />
</Routes>
)
</Routes>
);
}

export default App;
1 change: 1 addition & 0 deletions src/components/Navbar/Navbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
background-color: transparent;
border: none;
margin-bottom: 2px;
z-index: 9999;
}
.nav-middle{
flex: 1;
Expand Down
2 changes: 0 additions & 2 deletions src/components/Navbar/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import YDO from '../../assets/navbar-images/YDO-logo.png'
import notification from '../../assets/navbar-images/notification-YDO.png'
import Account from '../../assets/navbar-images/Account-YDO.png'
import Settings from '../../assets/navbar-images/Settings-YDO.png'

function Navbar() {

return (
<>
<svg width="0" height="0">
Expand Down
25 changes: 25 additions & 0 deletions src/components/ProtectedRoutes/PrivateRoutesWrapper.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { useEffect, useState } from "react";
import { Outlet, Navigate } from "react-router-dom";
import { checkLoginStatus } from "../../utils/checkLoginStatus";
import Preloader from "../../pages/Preloader/Preloader";

const API_BASE_URL = import.meta.env.VITE_API_URL || "";

const PrivateRoutesWrapper = () => {
const [isAuthenticated, setIsAuthenticated] = useState(null);

useEffect(() => {
const checkAuth = async () => {
const loggedIn = await checkLoginStatus(API_BASE_URL);
setIsAuthenticated(loggedIn);
};
checkAuth();
}, []);

if (isAuthenticated === null) return <Preloader />;
if (!isAuthenticated) return <Navigate to="/login" replace />;

return <Outlet />;
};

export default PrivateRoutesWrapper;
16 changes: 16 additions & 0 deletions src/layouts/MainLayout.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {Outlet, useLocation } from "react-router-dom";
import Navbar from "../components/Navbar/Navbar";

const MainLayout=()=>{
const location=useLocation();
const hideNavBarRoutes=["/","/login"];
const showNavBar= !hideNavBarRoutes.includes(location.pathname)
return(
<>
{showNavBar && <Navbar/>}
<Outlet/>
</>
);
};

export default MainLayout;
10 changes: 7 additions & 3 deletions src/pages/Login/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ const Login = ({ onLogin }) => {
window.location = `${API_BASE_URL}/auth/signin/google`;
};

if (loggedIn) {
window.location.href = "/";
}
useEffect(() => {
if (loggedIn) {
window.location.href = "/home";
}
}, [loggedIn]);
return (
<>
<div className="container" style={{backgroundImage:`url(${backgroundImage})`}}>
Expand All @@ -53,4 +55,6 @@ const Login = ({ onLogin }) => {
);
};



export default Login;
Loading