Skip to content
Merged
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
104 changes: 21 additions & 83 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import RegisterDriver from "./pages/RegisterDriver.tsx";
import SendNotif from "./pages/SendNotif.tsx";

import ViewProfile from "./pages/ViewProfile.tsx";
import Protocols from "./components/Policies/protocols.tsx";
import Rules from "./components/Policies/rules.tsx";
import Protocols from "./pages/Policies/Protocols.tsx";
import Rules from "./pages/Policies/Rules.tsx";
import ChangePassword from "./pages/ChangePassword.tsx";

import RequireAuth from "./components/RequireAuth.tsx";
Expand All @@ -42,99 +42,37 @@ const Main = () => {
<BrowserRouter>
<Routes>
{/* PUBLIC ROUTES */}
<Route
path="/"
element={
<Navigate
to="/login"
replace
/>
}
/>
<Route
path="/login"
element={<LoginPage />}
/>
<Route path="/" element={<Navigate to="/login" replace />} />
<Route path="/login" element={<LoginPage />} />

<Route
path="/signup"
element={<SignUpPage />}
/>
<Route path="/signup" element={<SignUpPage />} />

<Route
path="/unauthorized"
element={<UnauthorizedPage />}
/>
<Route path="/unauthorized" element={<UnauthorizedPage />} />

<Route element={<PersistLogin />}>
{/* FOR ALL LOGGED IN */}
<Route
path="/view-profile/:driverId"
element={<ViewProfile />}
/>
<Route
path="/changepassword"
element={<ChangePassword />}
/>
<Route path="/view-profile/:driverId" element={<ViewProfile />} />
<Route path="/changepassword" element={<ChangePassword />} />

{/* USER ROUTES */}
<Route element={<RequireAuth forAdmin={false} />}>
<Route
path="/homepage"
element={<HomePage />}
/>
<Route
path="/about"
element={<AboutPage />}
/>
<Route
path="/register-driver"
element={<RegisterDriver />}
/>
<Route
path="/protocols"
element={<Protocols />}
/>
<Route
path="/rules"
element={<Rules />}
/>
<Route path="/homepage" element={<HomePage />} />
<Route path="/about" element={<AboutPage />} />
<Route path="/register-driver" element={<RegisterDriver />} />
<Route path="/protocols" element={<Protocols />} />
<Route path="/rules" element={<Rules />} />
</Route>

{/* ADMIN ROUTES */}
<Route element={<RequireAuth forAdmin={true} />}>
<Route
path="/admin"
element={<AdminLandingPage />}
/>
<Route
path="/driverslist"
element={<DriversList />}
/>
<Route
path="/encode"
element={<EncodePage />}
/>
<Route
path="/add-driver"
element={<AddDriver />}
/>
<Route
path="/add-violation"
element={<AddViolationPage />}
/>
<Route
path="/violatorslist"
element={<ViolatorList />}
/>
<Route
path="/registration-list"
element={<RegistrationList />}
/>
<Route
path="/send-notif/:id"
element={<SendNotif />}
/>
<Route path="/admin" element={<AdminLandingPage />} />
<Route path="/driverslist" element={<DriversList />} />
<Route path="/encode" element={<EncodePage />} />
<Route path="/add-driver" element={<AddDriver />} />
<Route path="/add-violation" element={<AddViolationPage />} />
<Route path="/violatorslist" element={<ViolatorList />} />
<Route path="/registration-list" element={<RegistrationList />} />
<Route path="/send-notif/:id" element={<SendNotif />} />
</Route>
</Route>
</Routes>
Expand Down
78 changes: 0 additions & 78 deletions frontend/src/components/Policies/rules.tsx

This file was deleted.

7 changes: 6 additions & 1 deletion frontend/src/components/ViolationCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { useState, useRef, useEffect } from "react";
import { Violation } from "../types/datatypes";
import { useEditViolation } from "../hooks/violation-hooks/useEditViolation";
import useUpdateStatus from "../hooks/useUpdateStatus";
import useAuth from "../hooks/context-hooks/useAuth";
import { AuthContextType } from "../types/user.types";

const ViolationCard = ({ violation }: { violation: Violation }) => {
const [isMenuOpen, setIsMenuOpen] = useState(false);
Expand All @@ -11,6 +13,7 @@ const ViolationCard = ({ violation }: { violation: Violation }) => {
const { deleteViolation } = useDeleteViolation();
const { updateViolation } = useEditViolation();
const { handleUpdateStatus } = useUpdateStatus();
const { auth }: AuthContextType = useAuth();
const dropdownRef = useRef<HTMLDivElement>(null);
const date = new Date(violation.violation_date!);
const year = date.getFullYear();
Expand All @@ -36,7 +39,9 @@ const ViolationCard = ({ violation }: { violation: Violation }) => {
};

const handleStatusClick = async () => {
await handleUpdateStatus(violation.id!);
if (auth?.isAdmin) {
await handleUpdateStatus(violation.id!);
}
};

const handleEditViolation = () => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/AboutPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const AboutPage = () => {
<div className="w-full">
<Header />
</div>
<div className="w-7/8 h-auto max-h-[70vh] bg-gray-400 overflow-y-auto rounded-md mt-6 p-4 scrollbar bg-clip-padding backdrop-filter backdrop-blur-sm bg-opacity-10">
<div className="w-5/6 h-auto max-h-[70vh] bg-gray-400 overflow-y-auto rounded-md mt-6 p-4 scrollbar bg-clip-padding backdrop-filter backdrop-blur-sm bg-opacity-10">
<div className="text-left py-2 px-6 rounded-xl bg-clip-padding ">
<h1 className="text-textgreen font-syke-medium text-xl sm:text-2xl mt-4">About Us</h1>

Expand Down
3 changes: 1 addition & 2 deletions frontend/src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ const HomePage = () => {

<p className="text-sm sm:text-base leading-relaxed">
Please allow <b className="text-buttongreen">3-5</b> working days
for the validation process to complete. Once verified, you will
receive a notification.
for the validation process to complete.
</p>

<div className="mt-4">
Expand Down
Loading
Loading