Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 1 addition & 13 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

170 changes: 92 additions & 78 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BrowserRouter, Routes, Route } from "react-router-dom";
import { BrowserRouter, Routes, Route, useLocation } from "react-router-dom";
import { AuthProvider } from "./context/AuthContext";
import MainLayout from "./layouts/MainLayout";
import LandingPage from "./pages/LandingPage";
Expand All @@ -24,88 +24,102 @@ import GitHubIntelligencePage from "./pages/GitHubIntelligencePage";
import GitHubCallbackPage from "./pages/GitHubCallbackPage";
import ProtectedRoute from "./components/shared/ProtectedRoute";
import PublicRoute from "./components/shared/PublicRoute";
import FAQSection from "./components/explore/FAQSection";

/**
* Inner router shell — lives inside BrowserRouter so it can call useLocation.
* Keys the animation wrapper on location.pathname so the page-fade-in CSS
* keyframe re-runs on actual page changes only (not same-path re-navigations).
*/
function AppRoutes() {
const location = useLocation();

return (
<MainLayout>
<div key={location.pathname} className="page-fade-in w-full flex-1 flex flex-col">
<Routes>
<Route path="/" element={<LandingPage />} />
<Route
path="/login"
element={
<PublicRoute>
<LoginPage />
</PublicRoute>
}
/>
<Route
path="/signup"
element={
<PublicRoute>
<SignupPage />
</PublicRoute>
}
/>
<Route
path="/dashboard"
element={
<ProtectedRoute>
<DashboardPage />
</ProtectedRoute>
}
/>
<Route
path="/account-center"
element={
<ProtectedRoute>
<AccountCenterPage />
</ProtectedRoute>
}
/>
<Route
path="/github-intelligence"
element={
<ProtectedRoute>
<GitHubIntelligencePage />
</ProtectedRoute>
}
/>
<Route
path="/forgot-password"
element={
<PublicRoute>
<ForgotPassword />
</PublicRoute>
}
/>
<Route path="/explore" element={<ExplorePage />} />
{/* GitHub OAuth callback — must be public, no auth required */}
<Route path="/auth/github/callback" element={<GitHubCallbackPage />} />
<Route path="/practice" element={<PracticePage />} />

<Route path="/apex-ai" element={<ApexAIPage />} />
<Route path="/algoverse" element={<AlgoVersePage />} />
<Route path="/contests/codeforces" element={<ContestCodeforcesPage />} />
<Route path="/contests/codechef" element={<ContestCodeChefPage />} />
<Route path="/contests/leetcode" element={<ContestLeetCodePage />} />
<Route path="/contests/atcoder" element={<ContestAtCoderPage />} />
<Route
path="/codeforces"
element={
<ProtectedRoute>
<CodeforcesPage />
</ProtectedRoute>
}
/>
<Route path="/terms" element={<TermsPage />} />
<Route path="/privacy" element={<PrivacyPage />} />
<Route path="*" element={<NotFoundPage />} />
</Routes>
</div>
</MainLayout>
);
}

export default function App() {
return (
<AuthProvider>
<BrowserRouter>
<MainLayout>
<Routes>
<Route path="/" element={<LandingPage />} />
<Route
path="/login"
element={
<PublicRoute>
<LoginPage />
</PublicRoute>
}
/>
<Route
path="/signup"
element={
<PublicRoute>
<SignupPage />
</PublicRoute>
}
/>
<Route
path="/dashboard"
element={
<ProtectedRoute>
<DashboardPage />
</ProtectedRoute>
}
/>
<Route
path="/account-center"
element={
<ProtectedRoute>
<AccountCenterPage />
</ProtectedRoute>
}
/>
<Route
path="/github-intelligence"
element={
<ProtectedRoute>
<GitHubIntelligencePage />
</ProtectedRoute>
}
/>
<Route
path="/forgot-password"
element={
<PublicRoute>
<ForgotPassword />
</PublicRoute>
}
/>
<Route path="/explore" element={<ExplorePage />} />
{/* GitHub OAuth callback — must be public, no auth required */}
<Route path="/auth/github/callback" element={<GitHubCallbackPage />} />
<Route path="/practice" element={<PracticePage />} />

<Route path="/apex-ai" element={<ApexAIPage />} />
<Route path="/algoverse" element={<AlgoVersePage />} />
<Route path="/contests/codeforces" element={<ContestCodeforcesPage />} />
<Route path="/contests/codechef" element={<ContestCodeChefPage />} />
<Route path="/contests/leetcode" element={<ContestLeetCodePage />} />
<Route path="/contests/atcoder" element={<ContestAtCoderPage />} />
<Route
path="/codeforces"
element={
<ProtectedRoute>
<CodeforcesPage />
</ProtectedRoute>
}
/>
<Route path="/terms" element={<TermsPage/>} />
<Route path="/privacy" element={<PrivacyPage/>} />
<Route path="*" element={<NotFoundPage />} />
</Routes>
</MainLayout>
<AppRoutes />
</BrowserRouter>
</AuthProvider>

);
}
1 change: 0 additions & 1 deletion frontend/src/components/codeforces/ConnectBanner.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useState } from "react";
import { Link } from "react-router-dom";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function DashboardExecutiveSummary() {
setSummary(data.data.summary);
setLoading(false);
}
} catch (err) {
} catch {
if (isMounted) {
setError("Failed to fetch AI summary. Please try again later.");
setLoading(false);
Expand Down
13 changes: 2 additions & 11 deletions frontend/src/components/github/GitHubComponents.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,7 @@ import {
RadarChart, Radar, PolarGrid, PolarAngleAxis, Cell,
PieChart, Pie, Legend,
} from "recharts";

export const COLORS = ["#000","#222","#444","#666","#888","#aaa","#ccc"];
export const fmt = (n) => n >= 1000 ? `${(n/1000).toFixed(1)}k` : String(n ?? 0);
export const timeAgo = (d) => {
const s = (Date.now() - new Date(d)) / 1000;
if (s < 60) return `${Math.floor(s)}s ago`;
if (s < 3600) return `${Math.floor(s/60)}m ago`;
if (s < 86400) return `${Math.floor(s/3600)}h ago`;
return `${Math.floor(s/86400)}d ago`;
};
import { COLORS, fmt, timeAgo } from "../../utils/githubHelpers";

const TT = ({ contentStyle = {}, ...props }) => (
<Tooltip
Expand Down Expand Up @@ -285,7 +276,7 @@ export function StarredInsights({ starredTopics, starredLangs, starred }) {
<div>
<p className="text-xs font-black uppercase tracking-widest text-gray-500 mb-3">Favorite Languages in Starred</p>
<div className="space-y-2">
{starredLangs?.slice(0, 6).map((l, i) => {
{starredLangs?.slice(0, 6).map((l) => {
const max = starredLangs[0]?.count || 1;
return (
<div key={l.name} className="flex items-center gap-3">
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/components/shared/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,10 @@ export default function Navbar() {

// ── Close mobile menu on route change ───────────────────────────────────
useEffect(() => {
setIsMenuOpen(false);
setMobileMegaOpen(false);
setTimeout(() => {
setIsMenuOpen(false);
setMobileMegaOpen(false);
}, 0);
}, [location.pathname]);

useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/shared/ProtectedRoute.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Navigate } from "react-router-dom";
import { useAuth } from "../../context/AuthContext";
import Loader from "./loaders/LoaderSwitcher";
import { GuardSkeleton } from "./skeletons/PageSkeletons";

const ProtectedRoute = ({ children }) => {
const { isAuthenticated, loading } = useAuth();

if (loading) return <Loader />;
if (loading) return <GuardSkeleton />;
if (!isAuthenticated) return <Navigate to="/login" replace />;

return children;
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/shared/PublicRoute.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Navigate } from "react-router-dom";
import { useAuth } from "../../context/AuthContext";
import Loader from "./loaders/LoaderSwitcher";
import { GuardSkeleton } from "./skeletons/PageSkeletons";

const PublicRoute = ({ children }) => {
const { isAuthenticated, loading } = useAuth();

if (loading) return <Loader />;
if (loading) return <GuardSkeleton />;
if (isAuthenticated) return <Navigate to="/dashboard" replace />;

return children;
Expand Down
Loading