chore: phase 1 lint/type fixes — commit all changes

This commit is contained in:
m7amedez5511
2026-07-02 20:07:38 +03:00
parent d225291b70
commit 25f3468d74
37 changed files with 162 additions and 176 deletions

View File

@@ -1,23 +1,6 @@
// app/dashboard/clients/[clientId]/addresses/page.tsx
//
// ── Refactor notes ──────────────────────────────────────────────────────────
// • Address cards are no longer clickable / navigable. Removed the `onView`
// prop, the card's onClick handler, and the pointer cursor + hover styles
// that implied the card itself was a link.
// • Each AddressCard now renders full address details inline (street, city,
// state, district, building/unit/additional no., zip code, country, and
// contact person), instead of a 3-line summary that deferred to the
// AddressDetail page.
// • Removed all routing to the address detail route.
// • Deleted as part of this refactor (no longer referenced anywhere):
// - app/dashboard/clients/[clientId]/addresses/[addressId]/page.tsx
// - app/dashboard/clients/[clientId]/addresses/[addressesId]/page.tsx
// - src/Components/Client_Adress/AddressDetails.tsx
// ─────────────────────────────────────────────────────────────────────────
"use client";
import { useEffect, useState } from "react";
import { useCallback, useEffect, useState } from "react";
import { useParams, useRouter } from "next/navigation";
import { Alert, Toast } from "@/src/Components/UI";
@@ -336,16 +319,22 @@ export default function ClientAddressesPage() {
const [client, setClient] = useState<Client | null>(null);
const [clientLoading, setClientLoading] = useState(true);
useEffect(() => {
const loadClient = useCallback(() => {
if (!clientId) return;
setClientLoading(true);
clientService
.getById(clientId, getStoredToken())
.then((res) => setClient(res.data))
.catch(() => router.replace("/dashboard/clients"))
.finally(() => setClientLoading(false));
queueMicrotask(() => {
setClientLoading(true);
clientService
.getById(clientId, getStoredToken())
.then((res) => setClient(res.data))
.catch(() => router.replace("/dashboard/clients"))
.finally(() => setClientLoading(false));
});
}, [clientId, router]);
useEffect(() => {
loadClient();
}, [loadClient]);
// ── Address hook ─────────────────────────────────────────────────────────
const {
addresses,
@@ -356,7 +345,6 @@ export default function ClientAddressesPage() {
createAddress,
updateAddress,
deleteAddress,
reload,
} = useClientAddresses(clientId ?? "");
// ── Modal state ──────────────────────────────────────────────────────────
@@ -386,7 +374,6 @@ export default function ClientAddressesPage() {
// ── Client edit handler ──────────────────────────────────────────────────
const handleClientEditSubmit = async (
data: ClientFormData,
_isNew: boolean
): Promise<boolean> => {
if (!client) return false;
try {

View File

@@ -6,11 +6,11 @@ import { Spinner } from "@/src/Components/UI";
import { DriverFormModal } from "@/src/Components/Driver/DriverFormModal";
import { DriverDeleteModal } from "@/src/Components/Driver/DriverDeleteModal";
import { DriverReportPanel } from "@/src/Components/Driver_Report/driverReport";
import { driverService } from "@/services";
import { getStoredToken } from "@/lib/auth";
import type { Driver, CreateDriverPayload, UpdateDriverPayload } from "@/src/types/driver";
import { DRIVER_STATUS_MAP, DRIVER_CARD_TYPE_MAP, NATIONAL_ID_TYPE_MAP } from "@/src/types/driver";
import { PhotoCard } from "@/src/Components/Driver/DriverPhotos";
import { driverService } from "@/src/services";
import { getStoredToken } from "@/src/lib/auth";
// ── Helpers ───────────────────────────────────────────────────────────────────
@@ -88,9 +88,7 @@ export default function DriverDetailPage() {
const [avatarError, setAvatarError] = useState(false);
// Reset avatar error when photo changes after an update
useEffect(() => {
console.log(driver?.photoUrl);
setAvatarError(false);
queueMicrotask(() => setAvatarError(false));
}, [driver?.photoUrl]);
// Toast shown after edit/delete actions on this page
const [toast, setToast] = useState<{ type: "success" | "error"; message: string } | null>(null);
@@ -120,11 +118,11 @@ export default function DriverDetailPage() {
}
}, [driverId]);
useEffect(() => { loadDriver(); }, [loadDriver]);
useEffect(() => { queueMicrotask(loadDriver); }, [loadDriver]);
// ── Edit submit ───────────────────────────────────────────────────────────
const handleEditSubmit = useCallback(
async (payload: CreateDriverPayload | UpdateDriverPayload, _isNew: boolean): Promise<boolean> => {
async (payload: CreateDriverPayload | UpdateDriverPayload): Promise<boolean> => {
if (!driver) return false;
try {
const token = getStoredToken();

View File

@@ -65,7 +65,7 @@ export default function DriversPage() {
drivers, loading, error, total, pages, page,
search, setPage, handleSearch, clearError,
createDriver, updateDriver, deleteDriver,
notification, reload,
notification,
} = useDrivers();
// ── Panel / modal state ───────────────────────────────────────────────────

View File

@@ -68,7 +68,7 @@ export default function OrderComponent() {
const {
orders, loading, error, total, pages, page,
search, statusFilter, setPage, handleSearch, handleStatusFilter, clearError,
createOrder, updateOrder, updateStatus, deleteOrder,
createOrder, updateOrder, deleteOrder,
notification, reload,
} = useOrders();

View File

@@ -221,14 +221,13 @@ export default function TripDetailPage() {
}, [tripId]);
useEffect(() => {
loadTrip();
queueMicrotask(loadTrip);
}, [loadTrip]);
// ── Edit submit ───────────────────────────────────────────────────────────
const handleEditSubmit = useCallback(
async (
payload: CreateTripPayload | UpdateTripPayload,
_isNew: boolean,
): Promise<boolean> => {
if (!trip) return false;
try {

View File

@@ -141,8 +141,7 @@ function ArchivedTripsModal({ onClose }: { onClose: () => void }) {
</div>
<div style={{ padding: "1.5rem" }}>
// Was pointing at the normal trip page — send it to the archived
route instead
{/* Was pointing at the normal trip page — send it to the archived route instead */}
<ArchivedTripList
onView={(trip) =>
router.push(`/dashboard/trips/archived/${trip.id}`)