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
145 changes: 110 additions & 35 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,88 +1,163 @@
import { createTheme, MantineProvider } from "@mantine/core";
import { MantineProvider, createTheme } from "@mantine/core";
import { Suspense, lazy } from "react";
import { useSelector } from "react-redux";
import "@mantine/core/styles.css";
import "@mantine/notifications/styles.css";
import { Route, Routes, Navigate, useLocation } from "react-router-dom";
import {
Route,
Routes,
Navigate,
useLocation,
useParams,
} from "react-router-dom";
import { Notifications } from "@mantine/notifications";
import { host } from "./routes/globalRoutes";
import { Layout } from "./components/layout";
import Dashboard from "./Modules/Dashboard/dashboardNotifications";
import Profile from "./Modules/Dashboard/StudentProfile/profilePage";
import LoginPage from "./pages/login";
import ForgotPassword from "./pages/forgotPassword";
import AcademicPage from "./Modules/Academic/index";
import ValidateAuth from "./helper/validateauth";
import FacultyProfessionalProfile from "./Modules/facultyProfessionalProfile/facultyProfessionalProfile";
import InactivityHandler from "./helper/inactivityhandler";
import Examination from "./Modules/Examination/examination";
import Database from "./Modules/Database/database";
import ProgrammeCurriculumRoutes from "./Modules/Program_curriculum/programmCurriculum";
import NotFoundPage from "./components/NotFoundPage";
import PatentRoutes from "./Modules/Patent/routes/PatentRoutes";

// Working module imports
const Dashboard = lazy(
() => import("./Modules/Dashboard/dashboardNotifications"),
);
const Profile = lazy(
() => import("./Modules/Dashboard/StudentProfile/profilePage"),
);
const LoginPage = lazy(() => import("./pages/login"));
const ForgotPassword = lazy(() => import("./pages/forgotPassword"));
const AcademicPage = lazy(() => import("./Modules/Academic/index"));
const ValidateAuth = lazy(() => import("./helper/validateauth"));
const MessPage = lazy(() => import("./Modules/Mess/messContent"));
const FacultyProfessionalProfile = lazy(
() =>
import("./Modules/facultyProfessionalProfile/facultyProfessionalProfile"),
);
const InactivityHandler = lazy(() => import("./helper/inactivityhandler.js"));
const Examination = lazy(() => import("./Modules/Examination/examination"));
const ProgrammeCurriculumRoutes = lazy(
() => import("./Modules/Program_curriculum/programmCurriculum"),
);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ValidateAuth and InactivityHandler are lazy-loaded but rendered without a <Suspense> boundary. They are imported with lazy() but used directly outside of <Routes> with no <Suspense fallback={...}> wrapper. If their chunks haven't loaded yet, React will throw an error at runtime. Wrap them:

<Suspense fallback={null}>
  {!isLoginPage && <ValidateAuth />}
  {!isLoginPage && <InactivityHandler />}
</Suspense>


const theme = createTheme({
breakpoints: {
xxs: "300px",
xs: "375px",
sm: "768px",
md: "992px",
lg: "1200px",
xl: "1408px",
},
breakpoints: { xs: "30em", sm: "48em", md: "64em", lg: "74em", xl: "90em" },
});

function ProfileRouteWithUsername() {
const { username } = useParams();
return <Profile connectionRoute={`${host}/dep/api/profile/${username}/`} />;
}

export default function App() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Custom breakpoints removed — may break existing components. The previous breakpoints (xxs: '300px', xs: '375px', etc. with px values) are replaced with Mantine's default em-based values. Any existing component that was responsive to the old custom breakpoints (especially xxs) will silently stop working at those widths. Verify this doesn't regress existing modules.

const location = useLocation();
const role = useSelector((state) => state.user.role);

return (
<MantineProvider theme={theme}>
<Notifications position="top-center" autoClose={2000} limit={1} />
{location.pathname !== "/accounts/login" && <ValidateAuth />}

{![
"/accounts/login",
"/reset-password",
].includes(location.pathname) && <ValidateAuth />}
{location.pathname !== "/accounts/login" && <InactivityHandler />}

<Routes>
<Route path="/" element={<Navigate to="/accounts/login" replace />} />

<Route
path="/dashboard"
element={
<Layout>
<Dashboard />
<Suspense fallback={<div>Loading .... </div>}>
<Dashboard />
</Suspense>
</Layout>
}
/>

<Route
path="/academics"
element={
<Layout>
<AcademicPage />
<Suspense fallback={<div>Loading .... </div>}>
<AcademicPage />
</Suspense>
</Layout>
}
/>

<Route
path="/programme_curriculum/*"
element={
<Layout>
<Suspense fallback={<div>Loading .... </div>}>
<ProgrammeCurriculumRoutes />
</Suspense>
</Layout>
}
/>

<Route
path="/examination/*"
element={
<Layout>
<Suspense fallback={<div>Loading .... </div>}>
<Examination />
</Suspense>
</Layout>
}
/>

<Route
path="/mess"
element={
<Layout>
<Suspense fallback={<div>Loading .... </div>}>
<MessPage />
</Suspense>
</Layout>
}
/>

<Route
path="/profile"
element={
<Layout>
<Profile />
<Suspense fallback={<div>Loading .... </div>}>
<Profile />
</Suspense>
</Layout>
}
/>

<Route
path="/facultyprofessionalprofile/*"
path="/profile/:username"
element={
<Layout>
<FacultyProfessionalProfile />
<Suspense fallback={<div>Loading .... </div>}>
<ProfileRouteWithUsername />
</Suspense>
</Layout>
}
/>

<Route
path="/programme_curriculum/*"
path="/facultyprofessionalprofile/*"
element={
<div>
<ProgrammeCurriculumRoutes />
</div>
<Layout>
<Suspense fallback={<div>Loading .... </div>}>
<FacultyProfessionalProfile />
</Suspense>
</Layout>
}
/>

<Route path="/patent/*" element={<PatentRoutes />} />

<Route path="/accounts/login" element={<LoginPage />} />
<Route path="/reset-password" element={<ForgotPassword />} />
<Route path="/examination/*" element={<Examination />} />
<Route path="/database/*" element={<Database />} />
<Route path="*" element={<NotFoundPage />} />

{/* Catch-all route for modules not yet implemented */}
<Route path="*" element={<Navigate to="/dashboard" replace />} />
</Routes>
</MantineProvider>
);
Expand Down
Loading