Skip to content
Closed
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
9 changes: 1 addition & 8 deletions backend/src/routes/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
);

const user = (await users[0]) as User;
// console.log(user);

if (!user) {
res.status(401).json({
Expand All @@ -79,8 +78,7 @@
});
return;
}
// console.log(user.password);
// console.log(hashedPassword);


const refreshToken = generateRefreshToken(user.id!);
const accessToken = generateAccessToken(user.id!);
Expand All @@ -92,7 +90,6 @@
httpOnly: true,
maxAge: 24 * 60 * 60 * 1000,
});
// console.log(req.cookies.jwt);
res.status(200).json({ accessToken, isAdmin: user.is_admin, id: user.id });
} catch (error) {
const errorMessage = (error as Error).message;
Expand All @@ -112,15 +109,13 @@
}

const refreshToken = cookies.jwt;
// console.log(refreshToken);

const foundUser = (
await pool.query("SELECT * FROM users WHERE refresh_token = $1", [
refreshToken,
])
).rows[0];

// console.log(foundUser);

if (!foundUser) {
res.status(403).json({
Expand All @@ -137,13 +132,11 @@
process.env.REFRESH_TOKEN_SECRET!
) as JwtPayload;

console.log(payload.userId);
const accessToken = generateAccessToken(payload.userId);
res
.status(200)
.json({ accessToken, isAdmin: foundUser.is_admin, id: foundUser.id });
} catch (error) {

Check failure on line 139 in backend/src/routes/auth.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'error' is defined but never used

Check failure on line 139 in backend/src/routes/auth.ts

View workflow job for this annotation

GitHub Actions / build (22.x)

'error' is defined but never used
console.log(error);
res.status(403).json({
title: "No Access Rights",
message: "You do not have access to these features.",
Expand Down
14 changes: 0 additions & 14 deletions backend/src/routes/cars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
);

const driverFound = drivers[0];
console.log(drivers);

if (!driverFound) {
res.status(401).json({
Expand Down Expand Up @@ -42,14 +41,6 @@
license_number,
}: Cars = req.body;

console.log(
car_model,
license_plate,
license_number,
color,
driver_id,
brand
);

const { rows: drivers } = await pool.query(
`SELECT id
Expand All @@ -67,7 +58,7 @@
return;
}

const car = await pool.query(

Check failure on line 61 in backend/src/routes/cars.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'car' is assigned a value but never used

Check failure on line 61 in backend/src/routes/cars.ts

View workflow job for this annotation

GitHub Actions / build (22.x)

'car' is assigned a value but never used
`INSERT INTO cars (
driver_id,
car_model,
Expand All @@ -79,7 +70,6 @@

[driver_id, car_model, license_plate, brand, color, license_number]
);
console.log(car.rows);
res.status(200).json({
title: "Car Added!",
message: `Car ${brand} ${car_model} ${color} with a license plate of ${license_plate} has been added!`,
Expand All @@ -94,7 +84,6 @@
try {
const { driverId } = req.query;

console.log("Received driverId:", driverId);

if (!driverId) {
res.status(400).json({
Expand Down Expand Up @@ -162,7 +151,6 @@
}

const updateCar = result.rows[0];
console.log("Car updated successfully:", updateCar);

res.status(200).json({
title: "Car Updated!",
Expand All @@ -177,9 +165,8 @@

router.delete("/delete", async (req: Request, res: Response) => {
try {
console.log("Fetching. . .");

const car = await pool.query(

Check failure on line 169 in backend/src/routes/cars.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'car' is assigned a value but never used

Check failure on line 169 in backend/src/routes/cars.ts

View workflow job for this annotation

GitHub Actions / build (22.x)

'car' is assigned a value but never used
`DELETE FROM
cars
WHERE
Expand All @@ -189,7 +176,6 @@
);

res.status(200).json({ message: "Car Added Successfully" });
console.log("Driver deleted successfully:", car);
} catch (error) {
const errorMessage = (error as Error).message;
res.status(500).json({ title: "Unknown Error", message: errorMessage });
Expand Down
6 changes: 0 additions & 6 deletions backend/src/routes/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
license_expiration_date,
} = req.body as Driver;

const driver = await pool.query(

Check failure on line 21 in backend/src/routes/driver.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'driver' is assigned a value but never used

Check failure on line 21 in backend/src/routes/driver.ts

View workflow job for this annotation

GitHub Actions / build (22.x)

'driver' is assigned a value but never used
`INSERT INTO drivers (
email,
first_name,
Expand All @@ -44,7 +44,6 @@
]
);

console.log(driver.rows);
res.status(200).json({
title: "Driver Added!",
message: `Driver ${last_name}, ${first_name} ${middle_name} has been added`,
Expand All @@ -59,13 +58,11 @@

router.get("/get", async (req: Request, res: Response) => {
try {
console.log("Fetching drivers from the database...");

const { rows: drivers } = await pool.query(
`SELECT *
FROM drivers`
);
console.log("Drivers fetched successfully:", drivers);

// Send the drivers list as a response
res.json(drivers);
Expand Down Expand Up @@ -101,7 +98,6 @@
);

const foundDriver = await drivers[0];
console.log(foundDriver);

if (!foundDriver) {
res.status(404).json({ message: "Driver not found" });
Expand Down Expand Up @@ -193,7 +189,6 @@
});

router.delete("/delete", async (req: Request, res: Response) => {
console.log("Request body:", req.body); // Log the incoming request body
try {
const { id } = req.body;

Expand Down Expand Up @@ -225,7 +220,6 @@
}

const deletedDriver = resultDriver.rows[0];
console.log("Driver deleted successfully:", deletedDriver);

res.status(200).json({
title: "Driver Deleted",
Expand Down
1 change: 0 additions & 1 deletion backend/src/routes/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
} else {
res.json(notifications);
}
} catch (err) {

Check failure on line 28 in backend/src/routes/notification.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'err' is defined but never used

Check failure on line 28 in backend/src/routes/notification.ts

View workflow job for this annotation

GitHub Actions / build (22.x)

'err' is defined but never used
console.log(err);
res.status(500).json({
title: "Server Error",
message: "An unexpected error occurred while retrieving notifications",
Expand Down
1 change: 0 additions & 1 deletion backend/src/routes/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
);

res.status(200).json({ ...foundDriver, violations, cars });
} catch (error) {

Check failure on line 33 in backend/src/routes/profile.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'error' is defined but never used

Check failure on line 33 in backend/src/routes/profile.ts

View workflow job for this annotation

GitHub Actions / build (22.x)

'error' is defined but never used
console.log(error);
res.sendStatus(500);
}
});
Expand Down
8 changes: 0 additions & 8 deletions backend/src/routes/registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ const fetchRegistrationByLicense = async (license_number: string) => {
// GET route to fetch all registrations
router.get("/get", async (_req: Request, res: Response) => {
try {
console.log("Fetching registration from the database...");
const { rows: registrations } = await pool.query(
"SELECT user_id, license_number, school_email, first_name, last_name, middle_name, date_of_birth, driver_type, sex FROM registrations"
);
console.log("Registrations fetched successfully:", registrations);

res.json(registrations); // Send the registration list as a response
} catch (error) {
Expand All @@ -46,7 +44,6 @@ router.post("/add", async (req: Request, res: Response) => {
driver_type,
} = req.body as Registration;

console.log(req.body);
if (
![
license_number,
Expand Down Expand Up @@ -105,11 +102,6 @@ router.delete("/delete", async (req: Request, res: Response): Promise<void> => {
try {
const { license_number } = req.body as Registration; // Extract license_number from request body

console.log(
"Attempting to delete registration with license number:",
license_number
);

// Attempt to delete the registration
await pool.query(
`DELETE FROM registrations WHERE license_number = $1 RETURNING *`,
Expand Down
4 changes: 0 additions & 4 deletions backend/src/routes/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@
try {
const userId = req.user;

console.log(req.user);
console.log("Fetching user from the database...");
const { rows: users } = await pool.query(
"SELECT id, first_name, last_name FROM users WHERE id = $1",
[userId]
);
console.log("User fetched successfully:", users);

const { rows: registrations } = await pool.query(
"SELECT * FROM registrations WHERE user_id = $1",
Expand Down Expand Up @@ -102,9 +99,8 @@
title: "Password Changed",
message: "Password has been successfully changed.",
});
} catch (error) {

Check failure on line 102 in backend/src/routes/user.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'error' is defined but never used

Check failure on line 102 in backend/src/routes/user.ts

View workflow job for this annotation

GitHub Actions / build (22.x)

'error' is defined but never used
res.status(500).json({ message: "An Unknown Error Occured" });
console.log(error);
}
});

Expand Down
6 changes: 0 additions & 6 deletions backend/src/routes/violation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@
return;
}

console.log("THIS IS THE DRIVER FROM VIOLATION");
console.log(driverFound);

const violations = await pool.query(

Check failure on line 33 in backend/src/routes/violation.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'violations' is assigned a value but never used

Check failure on line 33 in backend/src/routes/violation.ts

View workflow job for this annotation

GitHub Actions / build (22.x)

'violations' is assigned a value but never used
`INSERT INTO violations (
driver_id,
violation_type,
Expand All @@ -43,7 +41,6 @@
[driver_id, violation_type, violation_date, description]
);

console.log(violations.rows[0]);

res.status(200).json({
title: "Violation Added!",
Expand Down Expand Up @@ -88,8 +85,7 @@
return;
}

const updateViolation = result.rows[0];

Check failure on line 88 in backend/src/routes/violation.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'updateViolation' is assigned a value but never used

Check failure on line 88 in backend/src/routes/violation.ts

View workflow job for this annotation

GitHub Actions / build (22.x)

'updateViolation' is assigned a value but never used
console.log("Violations updated successfully:", updateViolation);

res.status(200).json({
title: "Violation Updated!",
Expand All @@ -99,7 +95,6 @@

router.delete("/delete", async (req: Request, res: Response) => {
try {
console.log("Fetching. . .");

const { violationId } = req.body;

Expand All @@ -123,8 +118,7 @@
title: "Violation Deleted",
message: "Violation Deleted Successfully.",
});
} catch (error) {

Check failure on line 121 in backend/src/routes/violation.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'error' is defined but never used

Check failure on line 121 in backend/src/routes/violation.ts

View workflow job for this annotation

GitHub Actions / build (22.x)

'error' is defined but never used
console.log(error);
}
});

Expand Down
1 change: 0 additions & 1 deletion backend/src/routes/violators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ router.get("/get", async (_req: Request, res: Response) => {

res.status(200).json(violators);
} catch (error) {
console.log(error);
res.sendStatus(500);
}
});
Expand Down
1 change: 0 additions & 1 deletion frontend/src/hooks/car-hooks/useCheckLicenseNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const useCheckLicenseNumber = () => {

try {
// Make sure license_number is URL-safe
console.log(license_number);
const response = await fetchWithAuth(
navigate,
refresh,
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/hooks/car-hooks/useDeleteCar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const useDeleteCar = () => {
const deleteCar = async (carId: string) => {
setAppLoading!(true)
try {
console.log("Sending delete request for car ID:", carId); // Log driverId

const response = await fetchWithAuth(
navigate,
Expand All @@ -34,7 +33,6 @@ export const useDeleteCar = () => {
const notificationAPI = await response.json()
toast.success(notificationAPI.message)

console.log("Car deleted successfully");
return ;
} catch (err: unknown) {
console.error("Network error:", err);
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/hooks/driver-hooks/useAddDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const useAddDriver = () => {
setLoading(true);

try {
console.log(`FORM DATA: ${JSON.stringify(formData)}`);
const response = await fetchWithAuth(
navigate,
refresh,
Expand All @@ -27,7 +26,6 @@ export const useAddDriver = () => {
if (!response.ok) {
const error: BackendMessage = await response.json();
setError(error);
console.log("What are you doing?!");
}
} catch (error) {
console.error("Unexpected error:", error);
Expand Down
1 change: 0 additions & 1 deletion frontend/src/hooks/driver-hooks/useDeleteDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const useDeleteDriver = () => {
const deleteDriver = async (driverId: string) => {
setAppLoading!(true)
try {
console.log("Sending delete request for driver ID:", driverId); // Log driverId

const response = await fetchWithAuth(
navigate,
Expand Down
1 change: 0 additions & 1 deletion frontend/src/hooks/driver-hooks/useGetDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@
const fetchedDriver = await response.json();
setDriver(fetchedDriver);
} catch (error) {
console.log(error);
return {};
} finally {
setLoading(false);
}
};
fetchDriver(id);
}, [auth]);

Check warning on line 47 in frontend/src/hooks/driver-hooks/useGetDriver.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

React Hook useEffect has missing dependencies: 'id', 'navigate', and 'refresh'. Either include them or remove the dependency array

Check warning on line 47 in frontend/src/hooks/driver-hooks/useGetDriver.ts

View workflow job for this annotation

GitHub Actions / build (22.x)

React Hook useEffect has missing dependencies: 'id', 'navigate', and 'refresh'. Either include them or remove the dependency array

return { driver, loading };
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ export const useDeleteRegistration = () => {
setdeleteLoading(true);

try {
console.log(`Sending DELETE request to: /registration/delete`);
console.log("License Number to Delete:", licenseNumber);

// Send license_number in the request body as JSON
const response = await fetchWithAuth(
Expand All @@ -28,12 +26,10 @@ export const useDeleteRegistration = () => {
);

// Log the response status
console.log("Response Status:", response.status);

let responseBody;
try {
responseBody = await response.json();
console.log("Response Body:", responseBody);
} catch (error) {
console.error("Failed to parse JSON response:", error);
throw new Error("Invalid JSON response from server.");
Expand Down
1 change: 0 additions & 1 deletion frontend/src/hooks/useSignUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const useSignUp = () => {

if (!response.ok) {
const backendError: BackendMessage = await response.json();
console.log(backendError);
toast.error(`${backendError.message}`);
return false;
}
Expand Down
1 change: 0 additions & 1 deletion frontend/src/hooks/useUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
return;
}
const user: UserType = await response.json();
console.log(user);
setData(user);
} catch (err) {
console.error("Error fetching user:", err);
Expand All @@ -37,7 +36,7 @@
}
};
fetchUser();
}, [auth]);

Check warning on line 39 in frontend/src/hooks/useUser.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

React Hook useEffect has missing dependencies: 'navigate' and 'refresh'. Either include them or remove the dependency array

Check warning on line 39 in frontend/src/hooks/useUser.ts

View workflow job for this annotation

GitHub Actions / build (22.x)

React Hook useEffect has missing dependencies: 'navigate' and 'refresh'. Either include them or remove the dependency array

return { data, error, loading };
};
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/hooks/violation-hooks/useDeleteViolation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const useDeleteViolation = () => {
const deleteViolation = async (violationId: string) => {
setAppLoading!(true);
try {
console.log("Sending delete request for violation ID:", violationId); // Log driverId

const response = await fetchWithAuth(
navigate,
Expand All @@ -34,7 +33,6 @@ export const useDeleteViolation = () => {
const notificationAPI = await response.json();
toast.success(notificationAPI.message);

console.log("Violation deleted successfully");
return;
} catch (err: unknown) {
console.error("Network error:", err);
Expand Down
Loading
Loading