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
3 changes: 0 additions & 3 deletions backend/src/routes/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ router.get("/get", async (req: Request, res: Response) => {
res.json(drivers);
} catch (error) {
const errorMessage = (error as Error).message;
console.error("Error fetching drivers:", errorMessage); // Log the error for debugging
res.status(500).json({ title: "Unknown Error", message: errorMessage });
}
});
Expand Down Expand Up @@ -192,7 +191,6 @@ router.delete("/delete", async (req: Request, res: Response) => {
const { id } = req.body;

if (!id) {
console.error("No ID provided in the request body");
res.status(400).json({
title: "Validation Error",
message: "Driver ID is required to delete a record.",
Expand All @@ -210,7 +208,6 @@ router.delete("/delete", async (req: Request, res: Response) => {
);

if (resultDriver.rowCount === 0) {
console.error("Driver not found in the database");
res.status(404).json({
title: "Not Found",
message: "Driver with the specified ID does not exist.",
Expand Down
6 changes: 2 additions & 4 deletions backend/src/routes/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ router.post("/add", async (req: Req, res: Response) => {
title: "Notification Sent",
message: "Notification has been sent successfully.",
});
} catch (err) {
console.error("ERROR", err);
} catch {
res
.status(500)
.json({ error: "An error occurred while creating notification." });
Expand All @@ -94,8 +93,7 @@ router.delete("/delete", async (req: Req, res: Response) => {
message: "Notification successfully deleted.",
});
}
} catch (err) {
console.error(err);
} catch {
res
.status(500)
.json({ message: "An error occurred while deleting the notification." });
Expand Down
7 changes: 1 addition & 6 deletions backend/src/routes/registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ router.get("/get", async (_req: Request, res: Response) => {
res.json(registrations); // Send the registration list as a response
} catch (error) {
const errorMessage = (error as Error).message;
console.error("Error fetching registration list:", errorMessage);
res.status(500).json({ title: "Unknown Error", message: errorMessage });
}
});
Expand Down Expand Up @@ -86,10 +85,8 @@ router.post("/add", async (req: Request, res: Response) => {
});
} catch (error) {
if (error instanceof Error) {
console.error("Error occurred:", error.message);
res.status(500).json({ title: "Server Error", message: error.message });
} else {
console.error("Unexpected error occurred:", error);
res.status(500).json({
title: "Server Error",
message: "An unexpected error occurred.",
Expand All @@ -114,8 +111,7 @@ router.delete("/delete", async (req: Request, res: Response): Promise<void> => {
title: "Registration Deleted",
message: `Registration with license number ${license_number} has been successfully deleted.`,
});
} catch (error) {
console.error("Error occurred during deletion:", error);
} catch {
res.status(500).json({
success: false,
title: "Server Error",
Expand Down Expand Up @@ -208,7 +204,6 @@ router.post("/approve", async (req: Request, res: Response) => {
}
} catch (error) {
await client.query("ROLLBACK");
console.error("Error during approval process:", (error as Error).message);
res
.status(500)
.json({ title: "Server Error", message: (error as Error).message });
Expand Down
2 changes: 0 additions & 2 deletions backend/src/routes/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ router.get("/get", async (req: Request, res: Response) => {
isDriver: drivers[0] ? true : false,
}); // Send the user data as a response
} catch (error) {
console.error(error);
const errorMessage = (error as Error).message;
console.error("Error fetching the user:", errorMessage);
res.status(500).json({ title: "Unknown Error", message: errorMessage });
}
});
Expand Down
1 change: 0 additions & 1 deletion backend/src/routes/violation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ router.post("/add", async (req: Request, res: Response) => {
});
} catch (error) {
const errorMessage = (error as Error).message;
console.error("Error:", errorMessage);
res.status(500).json({ title: "Error", message: errorMessage });
}
});
Expand Down
1 change: 0 additions & 1 deletion frontend/src/hooks/car-hooks/useAddCar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const useAddCar = () => {

if (!response.ok) {
const errorData = await response.json();
console.error("Error response from server:", errorData); // Log server response
toast.error(errorData.message);
return;
}
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/hooks/car-hooks/useCheckLicenseNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ const useCheckLicenseNumber = () => {
const driver = await response.json();

return driver;
} catch (error) {
console.error("Error checking license number:", error);
} catch {
toast.error("Failed to verify license number.");
return;
} finally {
Expand Down
7 changes: 1 addition & 6 deletions frontend/src/hooks/car-hooks/useDeleteCar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ export const useDeleteCar = () => {

if (!response.ok) {
const errorData = await response.json();
console.error("Error response from server:", errorData); // Log server response

toast.error(errorData.message);

return;
}

Expand All @@ -34,10 +31,8 @@ export const useDeleteCar = () => {

return;
} catch (err: unknown) {
console.error("Network error:", err);

// Narrow down `err` to ensure it has a `message` property
const errorMessage =
const errorMessage =
err instanceof Error ? err.message : "Failed to connect to the server";

toast.error(errorMessage);
Expand Down
1 change: 0 additions & 1 deletion frontend/src/hooks/car-hooks/useEditCars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const useEditCar = () => {

if (!response.ok) {
const errorData = await response.json();
console.error("Error response from server:", errorData); // Log server response
toast.error(errorData.message);
return;
}
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/hooks/driver-hooks/useAddDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ export const useAddDriver = () => {
const error: BackendMessage = await response.json();
setError(error);
}
} catch (error) {
console.error("Unexpected error:", error);
} catch {
setError({ message: "An unexpected error occurred" } as BackendMessage);
} finally {
setTimeout(() => {
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 @@ -22,7 +22,6 @@ export const useDeleteDriver = () => {

if (!response.ok) {
const errorData = await response.json();
console.error("Error response from server:", errorData); // Log server response
toast.error(errorData.message);
return;
}
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/hooks/driver-hooks/useDrivers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@
const drivers: DriverWithVandC[] = await response.json();
setData(drivers);
}
} catch (err) {
console.error("Unexpected error:", err);
} catch {
setError({ message: "An unexpected error occurred" } as BackendMessage);
} finally {
setLoading(false);
}
}, [auth]);

Check warning on line 36 in frontend/src/hooks/driver-hooks/useDrivers.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

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

Check warning on line 36 in frontend/src/hooks/driver-hooks/useDrivers.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

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

Check warning on line 36 in frontend/src/hooks/driver-hooks/useDrivers.ts

View workflow job for this annotation

GitHub Actions / build (22.x)

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

useEffect(() => {
fetchDrivers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ export const useApproveRegistration = () => {

const data = await response.json();
toast.success(data.message || "Registration approved successfully!");
} catch (error) {
console.error("Error approving registration:", error);
} catch {
toast.error(
"Network error occurred. Could not connect to the server. Please try again.",
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ export const useDeleteRegistration = () => {
let responseBody;
try {
responseBody = await response.json();
} catch (error) {
console.error("Failed to parse JSON response:", error);
} catch {
throw new Error("Invalid JSON response from server.");
}

Expand All @@ -47,8 +46,7 @@ export const useDeleteRegistration = () => {
} else {
toast.error("Deletion failed on the server side.");
}
} catch (error) {
console.error("Error during deletion:", error);
} catch {
toast.error("Unexpected error occurred.");
} finally {
setAppLoading!(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@
const registration = await response.json();
setRegistration(registration);
} catch (err) {
console.error("Unexpected error:", err);
alert(err);
} finally {
setLoading(false);
}
};
fetchRegistration();
}, [auth]);

Check warning on line 41 in frontend/src/hooks/registration-hooks/useGetRegistration.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

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

Check warning on line 41 in frontend/src/hooks/registration-hooks/useGetRegistration.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 41 in frontend/src/hooks/registration-hooks/useGetRegistration.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 { registration, loading };
};
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/hooks/useAddRegistration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ export const useAddRegistration = () => {
const error: BackendMessage = await response.json();
setError(error);
}
} catch (error) {
console.error("Unexpected error:", error);
} catch {
setError({ message: "An unexpected error occurred" } as BackendMessage);
} finally {
setTimeout(() => {
Expand Down
1 change: 0 additions & 1 deletion frontend/src/hooks/useGetRegistration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@
const registration = await response.json();
setRegistration(registration);
} catch (err) {
console.error("Unexpected error:", err);
alert(err);
} finally {
setLoading(false);
}
};
fetchRegistration();
}, [auth]);

Check warning on line 41 in frontend/src/hooks/useGetRegistration.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

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

Check warning on line 41 in frontend/src/hooks/useGetRegistration.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 41 in frontend/src/hooks/useGetRegistration.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 { registration, loading };
};
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/hooks/useUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@
}
const user: UserType = await response.json();
setData(user);
} catch (err) {
console.error("Error fetching user:", err);
} catch {
setError({ message: "An unexpected error occurred" } as BackendMessage);
} finally {
setLoading(false);
}
};
fetchUser();
}, [auth]);

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

View workflow job for this annotation

GitHub Actions / build (18.x)

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

Check warning on line 38 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 38 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
1 change: 0 additions & 1 deletion frontend/src/hooks/violation-hooks/useAddViolation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const useAddViolation = () => {

if (!response.ok) {
const errorData = await response.json();
console.error("Error response from server:", errorData); // Log server response
toast.error(errorData.message);
return;
}
Expand Down
5 changes: 1 addition & 4 deletions frontend/src/hooks/violation-hooks/useDeleteViolation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ export const useDeleteViolation = () => {

if (!response.ok) {
const errorData = await response.json();
console.error("Error response from server:", errorData); // Log server response

toast.error(errorData.message);

return;
}

Expand All @@ -34,7 +31,7 @@ export const useDeleteViolation = () => {

return;
} catch (err: unknown) {
console.error("Network error:", err);
toast.error("Network error occurred.");

// Narrow down `err` to ensure it has a `message` property
const errorMessage =
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/hooks/violation-hooks/useEditViolation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ export const useEditViolation = () => {

if (!response.ok) {
const errorData = await response.json();
console.error("Error response from server:", errorData); // Log server response
toast.error(errorData.message);
return;
}

const notificationAPI = await response.json();

toast.success(notificationAPI.message);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/AddDriver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const AddDriver = () => {
}, 5000);
} catch (error) {
setLoading(false);
console.error("Error submitting driver:", error);
toast.error((error as Error).message);
}
};

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/RegisterDriver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const RegisterDriver = () => {
const isValid = validateForm(); // Validate the form
if (isValid) navigate("/homepage"); // Redirect to the homepage
} catch (error) {
console.error("Error submitting the form:", error);
toast.error((error as Error).message);
}
};
const handleChange = (
Expand Down
Loading