fix: remove as-any casts, type Dashboard data properly
- Route handlers: add exhaustive return after error checks so TypeScript narrows the union and result properties are accessible without casts - attendance.service: use Prisma.attendanceGetPayload for included relations - projects.service: remove unnecessary cast on orders relation - Dashboard.tsx: replace Record<string,any> with proper DashData interface Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -15,8 +15,55 @@ import DashSessions from "../components/dashboard/DashSessions";
|
||||
|
||||
const API_BASE = "/api/admin";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
type DashData = Record<string, any>;
|
||||
interface DashData {
|
||||
my_shift?: { has_ongoing: boolean };
|
||||
attendance?: {
|
||||
present_today: number;
|
||||
total_active: number;
|
||||
on_leave: number;
|
||||
users: Array<{
|
||||
user_id: number | string;
|
||||
name: string;
|
||||
initials?: string;
|
||||
status: string;
|
||||
leave_type?: string;
|
||||
arrived_at?: string;
|
||||
}>;
|
||||
};
|
||||
offers?: {
|
||||
open_count: number;
|
||||
converted_count: number;
|
||||
expired_count: number;
|
||||
created_this_month: number;
|
||||
};
|
||||
projects?: {
|
||||
active_projects: Array<{
|
||||
id: number;
|
||||
name: string;
|
||||
customer_name: string | null;
|
||||
}>;
|
||||
};
|
||||
invoices?: {
|
||||
revenue_this_month: Array<{ amount: number; currency: string }>;
|
||||
unpaid_count: number;
|
||||
revenue_czk: number | null;
|
||||
};
|
||||
leave_pending?: { count: number };
|
||||
recent_activity?: Array<{
|
||||
id: number | string;
|
||||
action: string;
|
||||
entity_type: string;
|
||||
description: string;
|
||||
username?: string;
|
||||
created_at: string;
|
||||
}>;
|
||||
users_count?: number;
|
||||
active_projects?: number;
|
||||
pending_orders?: number;
|
||||
unpaid_invoices?: number;
|
||||
pending_leave_requests?: number;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export default function Dashboard() {
|
||||
const { user, updateUser, hasPermission } = useAuth();
|
||||
@@ -373,11 +420,11 @@ export default function Dashboard() {
|
||||
transition={{ duration: 0.25, delay: 0.12 }}
|
||||
>
|
||||
{hasPermission("settings.audit") && (
|
||||
<DashActivityFeed activities={dashData?.recent_activity} />
|
||||
<DashActivityFeed activities={dashData?.recent_activity ?? null} />
|
||||
)}
|
||||
|
||||
{hasPermission("attendance.admin") && (
|
||||
<DashAttendanceToday attendance={dashData?.attendance} />
|
||||
<DashAttendanceToday attendance={dashData?.attendance ?? null} />
|
||||
)}
|
||||
|
||||
{/* Pravy sloupec: projekty + nabidky */}
|
||||
|
||||
Reference in New Issue
Block a user