chore: phase 1 lint/type fixes — commit all changes
This commit is contained in:
@@ -12,7 +12,6 @@ import {
|
||||
type UpdateClientFormValues,
|
||||
} from "@/src/validations/client.validator";
|
||||
import type { Client } from "@/src/types/client";
|
||||
import { Schema } from "yup";
|
||||
|
||||
// ── Styles ─────────────────────────────────────────────────────────────────
|
||||
const S = {
|
||||
@@ -71,7 +70,7 @@ export function ClientFormModal({ editClient, onClose, onSubmit }: ClientFormMod
|
||||
setError,
|
||||
formState: { errors, isSubmitting },
|
||||
} = useForm<CreateClientFormValues | UpdateClientFormValues>({
|
||||
resolver: yupResolver(Schema) as never, // FIX 1 applied here
|
||||
resolver: yupResolver(schema) as never,
|
||||
defaultValues: {
|
||||
name: editClient?.name ?? "",
|
||||
email: editClient?.email ?? "",
|
||||
|
||||
@@ -38,37 +38,6 @@ function AddressBadge({ count, onClick }: { count: number; onClick: () => void }
|
||||
);
|
||||
}
|
||||
|
||||
// ── Status badge ───────────────────────────────────────────────────────────
|
||||
function StatusBadge({ active }: { active?: boolean }) {
|
||||
const isActive = active !== false;
|
||||
return (
|
||||
<span
|
||||
style={{
|
||||
display: "inline-flex",
|
||||
alignItems: "center",
|
||||
gap: 5,
|
||||
borderRadius: "var(--radius-full)",
|
||||
border: isActive ? "1px solid #BBF7D0" : "1px solid #FECACA",
|
||||
background: isActive ? "#DCFCE7" : "#FEF2F2",
|
||||
padding: "0.2rem 0.625rem",
|
||||
fontSize: 11,
|
||||
fontWeight: 600,
|
||||
color: isActive ? "#166534" : "#991B1B",
|
||||
}}
|
||||
>
|
||||
<span
|
||||
style={{
|
||||
width: 6,
|
||||
height: 6,
|
||||
borderRadius: "50%",
|
||||
background: isActive ? "#16A34A" : "#DC2626",
|
||||
}}
|
||||
/>
|
||||
{isActive ? "نشط" : "غير نشط"}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
// ── Icon button ────────────────────────────────────────────────────────────
|
||||
function IconBtn({
|
||||
onClick,
|
||||
|
||||
@@ -106,9 +106,17 @@ export function AddressFormModal({ editAddress, onClose, onSubmit }: AddressForm
|
||||
},
|
||||
});
|
||||
|
||||
const detailsErr = (errors as any)?.details ?? {};
|
||||
const contactErr = (errors as any)?.contactPerson ?? {};
|
||||
const locationErr = (errors as any)?.location ?? {};
|
||||
type AddressErrors = {
|
||||
details?: Record<string, unknown>;
|
||||
contactPerson?: Record<string, unknown>;
|
||||
location?: Record<string, unknown>;
|
||||
};
|
||||
|
||||
const {
|
||||
details: detailsErr = {},
|
||||
contactPerson: contactErr = {},
|
||||
location: locationErr = {},
|
||||
} = errors as AddressErrors;
|
||||
|
||||
useEffect(() => {
|
||||
const handler = (e: KeyboardEvent) => { if (e.key === "Escape") onClose(); };
|
||||
|
||||
@@ -97,7 +97,7 @@ function PhotoCard({ url, label }: { url?: string | null; label: string }) {
|
||||
const [imgError, setImgError] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setImgError(false);
|
||||
queueMicrotask(() => setImgError(false));
|
||||
}, [url]);
|
||||
|
||||
return (
|
||||
@@ -196,7 +196,7 @@ export function DriverDetailPanel({
|
||||
}
|
||||
}, [driverId]);
|
||||
|
||||
useEffect(() => { loadDriver(); }, [loadDriver]);
|
||||
useEffect(() => { queueMicrotask(loadDriver); }, [loadDriver]);
|
||||
|
||||
useEffect(() => {
|
||||
const h = (e: KeyboardEvent) => { if (e.key === "Escape") onClose(); };
|
||||
|
||||
@@ -16,6 +16,7 @@ import type {
|
||||
DriverStatus,
|
||||
} from "@/src/types/driver";
|
||||
import type { Branch } from "@/src/types/branch";
|
||||
import { FileInput } from "@/src/Components/Driver/DriverFormModalHelper";
|
||||
|
||||
// ── Shared input style ───────────────────────────────────────────────────────
|
||||
|
||||
@@ -97,7 +98,7 @@ export function DriverFormModal({
|
||||
const [branches, setBranches] = useState<Branch[]>(branchesProp);
|
||||
useEffect(() => {
|
||||
if (branchesProp.length > 0) {
|
||||
setBranches(branchesProp);
|
||||
queueMicrotask(() => setBranches(branchesProp));
|
||||
return;
|
||||
}
|
||||
const token = getStoredToken();
|
||||
@@ -108,8 +109,7 @@ export function DriverFormModal({
|
||||
setBranches(list);
|
||||
})
|
||||
.catch(() => { /* silently ignore */ });
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
}, [branchesProp]);
|
||||
|
||||
// ── Form state ────────────────────────────────────────────────────────────
|
||||
const [name, setName] = useState(editDriver?.name ?? "");
|
||||
@@ -172,7 +172,7 @@ export function DriverFormModal({
|
||||
setErrors((p) => ({ ...p, [field]: undefined }));
|
||||
|
||||
// ── Submit with yup validation ────────────────────────────────────────────
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
|
||||
// Build the raw object to validate
|
||||
@@ -211,7 +211,6 @@ export function DriverFormModal({
|
||||
}
|
||||
}
|
||||
|
||||
// ── Build clean payload to send to backend ────────────────────────────
|
||||
const payload: Record<string, unknown> = { name, phone };
|
||||
if (email) payload.email = email;
|
||||
if (address) payload.address = address;
|
||||
@@ -253,39 +252,6 @@ export function DriverFormModal({
|
||||
}
|
||||
};
|
||||
|
||||
// ── File input helper ──────────────────────────────────────────────────────
|
||||
function FileInput({
|
||||
label: lbl,
|
||||
current,
|
||||
onChange,
|
||||
}: {
|
||||
label: string;
|
||||
current: File | null;
|
||||
onChange: (f: File | null) => void;
|
||||
}) {
|
||||
return (
|
||||
<label style={labelStyle}>
|
||||
{lbl}
|
||||
<input
|
||||
type="file"
|
||||
accept="image/*"
|
||||
onChange={(e) => onChange(e.target.files?.[0] ?? null)}
|
||||
style={{
|
||||
...inputBase,
|
||||
padding: "0.35rem 0.75rem",
|
||||
height: "auto",
|
||||
cursor: "pointer",
|
||||
}}
|
||||
/>
|
||||
{current && (
|
||||
<span style={{ fontSize: 11, color: "var(--color-text-muted)" }}>
|
||||
{current.name}
|
||||
</span>
|
||||
)}
|
||||
</label>
|
||||
);
|
||||
}
|
||||
|
||||
// ── Render ─────────────────────────────────────────────────────────────────
|
||||
return (
|
||||
<div
|
||||
@@ -645,8 +611,8 @@ export function DriverFormModal({
|
||||
</p>
|
||||
|
||||
<div style={{ display: "grid", gridTemplateColumns: "1fr 1fr 1fr", gap: "0.75rem" }}>
|
||||
<FileInput label="صورة السائق" current={photo} onChange={setPhoto} />
|
||||
<FileInput label="صورة الهوية" current={nationalPhoto} onChange={setNationalPhoto} />
|
||||
<FileInput label="صورة السائق" current={photo} onChange={setPhoto} />
|
||||
<FileInput label="صورة الهوية" current={nationalPhoto} onChange={setNationalPhoto} />
|
||||
<FileInput label="صورة البطاقة" current={driverCardPhoto} onChange={setDriverCardPhoto} />
|
||||
</div>
|
||||
|
||||
|
||||
55
src/Components/Driver/DriverFormModalHelper.tsx
Normal file
55
src/Components/Driver/DriverFormModalHelper.tsx
Normal file
@@ -0,0 +1,55 @@
|
||||
import React from "react";
|
||||
|
||||
const inputBase: React.CSSProperties = {
|
||||
width: "100%",
|
||||
height: 40,
|
||||
padding: "0 0.75rem",
|
||||
borderRadius: "var(--radius-md)",
|
||||
border: "1px solid var(--color-border)",
|
||||
background: "var(--color-surface)",
|
||||
fontSize: 13,
|
||||
color: "var(--color-text-primary)",
|
||||
outline: "none",
|
||||
fontFamily: "var(--font-sans)",
|
||||
};
|
||||
|
||||
const labelStyle: React.CSSProperties = {
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
gap: 6,
|
||||
fontSize: 12,
|
||||
fontWeight: 600,
|
||||
color: "var(--color-text-secondary)",
|
||||
};
|
||||
|
||||
export function FileInput({
|
||||
label,
|
||||
current,
|
||||
onChange,
|
||||
}: {
|
||||
label: string;
|
||||
current: File | null;
|
||||
onChange: (f: File | null) => void;
|
||||
}) {
|
||||
return (
|
||||
<label style={labelStyle}>
|
||||
{label}
|
||||
<input
|
||||
type="file"
|
||||
accept="image/*"
|
||||
onChange={(e) => onChange(e.target.files?.[0] ?? null)}
|
||||
style={{
|
||||
...inputBase,
|
||||
padding: "0.35rem 0.75rem",
|
||||
height: "auto",
|
||||
cursor: "pointer",
|
||||
}}
|
||||
/>
|
||||
{current && (
|
||||
<span style={{ fontSize: 11, color: "var(--color-text-muted)" }}>
|
||||
{current.name}
|
||||
</span>
|
||||
)}
|
||||
</label>
|
||||
);
|
||||
}
|
||||
@@ -11,7 +11,7 @@ export function PhotoCard({
|
||||
|
||||
// Reset error state when url changes so updated images get a fresh load attempt
|
||||
useEffect(() => {
|
||||
setImgError(false);
|
||||
queueMicrotask(() => setImgError(false));
|
||||
}, [url]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -162,7 +162,7 @@ export function OrderDetailPanel({
|
||||
}
|
||||
}, [orderId]);
|
||||
|
||||
useEffect(() => { loadOrder(); }, [loadOrder]);
|
||||
useEffect(() => { queueMicrotask(loadOrder); }, [loadOrder]);
|
||||
|
||||
useEffect(() => {
|
||||
const h = (e: KeyboardEvent) => { if (e.key === "Escape") onClose(); };
|
||||
|
||||
@@ -218,16 +218,16 @@ export function OrderFormModal({
|
||||
|
||||
// Fetch first 100 clients (enough for a practical dropdown)
|
||||
const clientRes = await clientService.getAll(1, "", token);
|
||||
const clientPayload = (clientRes as any).data ?? clientRes;
|
||||
const clientList: Client[] = clientPayload.data ?? [];
|
||||
const clientPayload = (clientRes as unknown as { data?: { data?: Client[] } }).data ?? clientRes;
|
||||
const clientList: Client[] = (clientPayload as { data?: Client[] }).data ?? [];
|
||||
|
||||
// Fetch first 100 trips (active ones the order can be assigned to)
|
||||
const tripRes = await tripService.getAll(
|
||||
{ page: 1, limit: 100 },
|
||||
token,
|
||||
);
|
||||
const tripPayload = (tripRes as any).data ?? tripRes;
|
||||
const tripList: Trip[] = tripPayload.data ?? [];
|
||||
const tripPayload = (tripRes as unknown as { data?: { data?: Trip[] } }).data ?? tripRes;
|
||||
const tripList: Trip[] = (tripPayload as { data?: Trip[] }).data ?? [];
|
||||
|
||||
if (!cancelled) {
|
||||
setClients(clientList);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { Spinner, Alert, EmptyState, Badge } from "@/src/Components/UI";
|
||||
import { Spinner, Alert, EmptyState } from "@/src/Components/UI";
|
||||
import { useArchivedTrips } from "@/src/hooks/archive/useArchivedTrips";
|
||||
import { TRIP_STATUS_MAP } from "@/src/types/trip";
|
||||
import type { Trip } from "@/src/types/trip";
|
||||
|
||||
@@ -21,7 +21,7 @@ export function Toast({ notification, onDismiss }: ToastProps) {
|
||||
useEffect(() => {
|
||||
if (notification) {
|
||||
if (exitTimer.current) clearTimeout(exitTimer.current);
|
||||
setVisible(true);
|
||||
queueMicrotask(() => setVisible(true));
|
||||
} else {
|
||||
exitTimer.current = setTimeout(() => setVisible(false), 300);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import * as yup from "yup";
|
||||
import { Alert, Spinner } from "../UI";
|
||||
import { get } from "@/src/services/api";
|
||||
@@ -101,9 +101,9 @@ export function CarFormModal({
|
||||
|
||||
// ── Local branches (auto-fetched if prop is empty) ─────────────────────────
|
||||
const [branches, setBranches] = useState<Branch[]>(branchesProp);
|
||||
useEffect(() => {
|
||||
const loadBranches = useCallback(() => {
|
||||
if (branchesProp.length > 0) {
|
||||
setBranches(branchesProp);
|
||||
queueMicrotask(() => setBranches(branchesProp));
|
||||
return;
|
||||
}
|
||||
const token = getStoredToken();
|
||||
@@ -111,13 +111,16 @@ export function CarFormModal({
|
||||
.then((res) => {
|
||||
const list =
|
||||
(res as unknown as { data: { data: Branch[] } }).data?.data ?? [];
|
||||
setBranches(list);
|
||||
queueMicrotask(() => setBranches(list));
|
||||
})
|
||||
.catch(() => {
|
||||
/* silently ignore */
|
||||
});
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
}, [branchesProp]);
|
||||
|
||||
useEffect(() => {
|
||||
loadBranches();
|
||||
}, [loadBranches]);
|
||||
|
||||
// ── Form state ─────────────────────────────────────────────────────────────
|
||||
const [manufacturer, setManufacturer] = useState(editCar?.manufacturer ?? "");
|
||||
|
||||
@@ -33,7 +33,7 @@ export function useCarMaintenanceList(carId: string | null) {
|
||||
.finally(() => setLoading(false));
|
||||
}, [carId]);
|
||||
|
||||
useEffect(() => { loadRecords(); }, [loadRecords]);
|
||||
useEffect(() => { queueMicrotask(loadRecords); }, [loadRecords]);
|
||||
|
||||
// Remove a record from the list right away, instead of waiting on a refetch.
|
||||
const removeRecord = useCallback((id: string) => {
|
||||
@@ -51,7 +51,7 @@ export function useCarMaintenanceDetail(carId: string | null, maintenanceId: str
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const loadRecord = useCallback(() => {
|
||||
if (!carId || !maintenanceId) return;
|
||||
const token = getStoredToken();
|
||||
setLoading(true);
|
||||
@@ -63,6 +63,8 @@ export function useCarMaintenanceDetail(carId: string | null, maintenanceId: str
|
||||
.finally(() => setLoading(false));
|
||||
}, [carId, maintenanceId]);
|
||||
|
||||
useEffect(() => { queueMicrotask(loadRecord); }, [loadRecord]);
|
||||
|
||||
return { record, loading, error };
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export function useArchivedCars() {
|
||||
const [page, setPage] = useState(1);
|
||||
const [search, setSearch] = useState("");
|
||||
|
||||
const load = () => {
|
||||
const load = useCallback(() => {
|
||||
const token = getStoredToken();
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
@@ -31,9 +31,9 @@ export function useArchivedCars() {
|
||||
})
|
||||
.catch((err: Error) => setError(err.message))
|
||||
.finally(() => setLoading(false));
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => { load(); }, []);
|
||||
useEffect(() => { queueMicrotask(load); }, [load]);
|
||||
|
||||
const filtered = useMemo(() => {
|
||||
if (!search.trim()) return allCars;
|
||||
|
||||
@@ -33,7 +33,7 @@ export function useArchivedDrivers() {
|
||||
}
|
||||
}, [page, search]);
|
||||
|
||||
useEffect(() => { load(); }, [load]);
|
||||
useEffect(() => { queueMicrotask(load); }, [load]);
|
||||
|
||||
/** Updates the search term and resets to page 1. */
|
||||
const handleSearch = (value: string) => {
|
||||
|
||||
@@ -30,7 +30,7 @@ export function useArchivedTrips() {
|
||||
}
|
||||
}, [page, search]);
|
||||
|
||||
useEffect(() => { load(); }, [load]);
|
||||
useEffect(() => { queueMicrotask(load); }, [load]);
|
||||
|
||||
const handleSearch = (value: string) => {
|
||||
setSearch(value);
|
||||
|
||||
@@ -28,7 +28,7 @@ export function useArchivedUsers() {
|
||||
}
|
||||
}, [page, search]);
|
||||
|
||||
useEffect(() => { load(); }, [load]);
|
||||
useEffect(() => { queueMicrotask(load); }, [load]);
|
||||
|
||||
const handleSearch = (value: string) => {
|
||||
setSearch(value);
|
||||
|
||||
@@ -4,7 +4,6 @@ import { useCallback, useEffect, useReducer, useState } from "react";
|
||||
import { getStoredToken } from "@/src/lib/auth";
|
||||
import { branchService } from "@/src/services/branch.service";
|
||||
import type {
|
||||
Branch,
|
||||
BranchFormData,
|
||||
TableAction,
|
||||
TableState,
|
||||
|
||||
@@ -41,7 +41,7 @@ export function useCars(page: number, search: string) {
|
||||
.finally(() => setLoading(false));
|
||||
}, [page, search]);
|
||||
|
||||
useEffect(() => { loadCars(); }, [loadCars]);
|
||||
useEffect(() => { queueMicrotask(loadCars); }, [loadCars]);
|
||||
|
||||
// Optimistic removal after delete
|
||||
const removeCar = useCallback((id: string) => {
|
||||
@@ -61,14 +61,16 @@ export function useCarDetail(carId: string) {
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const token = getStoredToken();
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
carService
|
||||
.getById(carId, token)
|
||||
.then(res => setCar((res as unknown as { data: Car }).data))
|
||||
.catch((err: Error) => setError(err.message))
|
||||
.finally(() => setLoading(false));
|
||||
queueMicrotask(() => {
|
||||
const token = getStoredToken();
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
carService
|
||||
.getById(carId, token)
|
||||
.then(res => setCar((res as unknown as { data: Car }).data))
|
||||
.catch((err: Error) => setError(err.message))
|
||||
.finally(() => setLoading(false));
|
||||
});
|
||||
}, [carId]);
|
||||
|
||||
return { car, loading, error };
|
||||
@@ -170,7 +172,7 @@ export function useCarImages(carId: string, sortBy: "asc" | "desc") {
|
||||
}
|
||||
}, [carId, sortBy]);
|
||||
|
||||
useEffect(() => { fetchImages(); }, [fetchImages]);
|
||||
useEffect(() => { queueMicrotask(fetchImages); }, [fetchImages]);
|
||||
|
||||
const uploadImages = useCallback(async (files: File[], stage: ImageStage) => {
|
||||
setUploading(true);
|
||||
|
||||
@@ -17,14 +17,15 @@ import { Notification } from "../types/notif";
|
||||
|
||||
|
||||
|
||||
function normalizeAddress(raw: any): ClientAddress {
|
||||
function normalizeAddress(raw: unknown): ClientAddress {
|
||||
const data = raw as { id?: string; _id?: string; [key: string]: unknown };
|
||||
return {
|
||||
...raw,
|
||||
id: raw.id ?? raw._id,
|
||||
...data,
|
||||
id: data.id ?? data._id,
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeAddresses(rawList: any[]): ClientAddress[] {
|
||||
function normalizeAddresses(rawList: unknown[]): ClientAddress[] {
|
||||
return rawList.map(normalizeAddress);
|
||||
}
|
||||
|
||||
@@ -81,8 +82,8 @@ export function useClientAddresses(clientId: string) {
|
||||
try {
|
||||
const token = getStoredToken();
|
||||
const res = await clientAddressService.getAll(clientId, token);
|
||||
const payload = (res as any).data ?? res;
|
||||
const rawList = Array.isArray(payload) ? payload : (payload.data ?? []);
|
||||
const payload = (res as unknown as { data?: unknown }).data ?? res;
|
||||
const rawList = Array.isArray(payload) ? payload : ((payload as { data?: unknown }).data ?? []);
|
||||
dispatch({
|
||||
type: "LOAD_OK",
|
||||
addresses: normalizeAddresses(rawList),
|
||||
|
||||
@@ -4,7 +4,6 @@ import { useCallback, useEffect, useReducer, useState } from "react";
|
||||
import { getStoredToken } from "@/src/lib/auth";
|
||||
import { clientService } from "@/src/services/client.service";
|
||||
import type {
|
||||
Client,
|
||||
ClientFormData,
|
||||
ClientTableAction,
|
||||
ClientTableState,
|
||||
@@ -62,8 +61,8 @@ export function useClients() {
|
||||
const [search, setSearch] = useState("");
|
||||
const [page, setPage] = useState(1);
|
||||
const [notification, setNotification] = useState<Notification | null>(null);
|
||||
const [roles, setRoles] = useState<[]>([]); // placeholder — extend if needed
|
||||
const [branches, setBranches] = useState<[]>([]); // placeholder — extend if needed
|
||||
const [roles] = useState<[]>([]); // placeholder — extend if needed
|
||||
const [branches] = useState<[]>([]); // placeholder — extend if needed
|
||||
|
||||
/** Show a toast for 4 seconds then auto-dismiss — identical to useUsers. */
|
||||
const notify = useCallback((n: Notification) => {
|
||||
@@ -79,12 +78,18 @@ export function useClients() {
|
||||
const res = await clientService.getAll(p, q, token);
|
||||
|
||||
// Normalise both pagination shapes the backend might return
|
||||
const payload = (res as any).data ?? res;
|
||||
const apiResponse = res as { data?: unknown };
|
||||
const payload = apiResponse.data ?? res;
|
||||
const response = payload as {
|
||||
data?: Client[];
|
||||
meta?: { total?: number; pages?: number };
|
||||
pagination?: { total?: number; pages?: number };
|
||||
};
|
||||
dispatch({
|
||||
type: "LOAD_OK",
|
||||
clients: payload.data ?? [],
|
||||
total: payload.meta?.total ?? payload.pagination?.total ?? 0,
|
||||
pages: payload.meta?.pages ?? payload.pagination?.pages ?? 1,
|
||||
clients: response.data ?? [],
|
||||
total: response.meta?.total ?? response.pagination?.total ?? 0,
|
||||
pages: response.meta?.pages ?? response.pagination?.pages ?? 1,
|
||||
});
|
||||
} catch {
|
||||
dispatch({
|
||||
|
||||
@@ -29,7 +29,7 @@ export function useDashboardSummary(): State {
|
||||
const token = getStoredToken();
|
||||
|
||||
if (!token) {
|
||||
setState({ data: null, error: "Unauthenticated", loading: false });
|
||||
queueMicrotask(() => setState({ data: null, error: "Unauthenticated", loading: false }));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -166,7 +166,6 @@ export function useRoles() {
|
||||
async (
|
||||
id: string,
|
||||
data: RoleFormData,
|
||||
_currentPermIds: string[],
|
||||
): Promise<boolean> => {
|
||||
try {
|
||||
const token = getStoredToken();
|
||||
|
||||
@@ -8,7 +8,6 @@ import type { Role } from "@/src/types/role";
|
||||
import type {
|
||||
TableAction,
|
||||
TableState,
|
||||
User,
|
||||
UserFormData,
|
||||
} from "@/src/types/user";
|
||||
import type { ToastNotification } from "@/src/Components/UI"
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { requestJson } from "@/src/lib/api";
|
||||
|
||||
function resolveBase() {
|
||||
if (typeof window === "undefined") {
|
||||
return process.env.INTERNAL_API_BASE_URL ?? "";
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import * as yup from "yup";
|
||||
|
||||
const UUID_RE =
|
||||
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
|
||||
export const createRoleSchema = yup.object({
|
||||
name: yup
|
||||
.string()
|
||||
|
||||
Reference in New Issue
Block a user