fix: resolve all remaining type safety errors

- Create types.ts with proper TypeScript interfaces for dashboard data
- Replace all 'any' types in dashboard/page.tsx with DashboardStats and RecentInvoice
- Fix type safety in invoice-form.tsx:
  - Replace 'any' in updateItem with proper union type
  - Add generic type parameter to updateField for type safety
  - Fix status type assertion (any -> proper union type)
  - Replace || with ?? for safer null handling
- All TypeScript compilation errors resolved
- Lint down to 1 warning (false positive for 'loading' variable)
This commit is contained in:
2025-12-11 20:15:29 -05:00
parent cf4ef928b8
commit 75c4362d97
3 changed files with 29 additions and 13 deletions
+4 -3
View File
@@ -24,12 +24,13 @@ import { RevenueChart } from "~/app/dashboard/_components/revenue-chart";
import { InvoiceStatusChart } from "~/app/dashboard/_components/invoice-status-chart";
import { MonthlyMetricsChart } from "~/app/dashboard/_components/monthly-metrics-chart";
import { AnimatedStatsCard } from "~/app/dashboard/_components/animated-stats-card";
import type { DashboardStats, RecentInvoice } from "./types";
// Hero section with clean mono design
// Enhanced stats cards with better visuals
function DashboardStats({ stats }: { stats: any }) { // TODO: Import RouterOutput type
function DashboardStats({ stats }: { stats: DashboardStats }) { // TODO: Import RouterOutput type
const formatTrend = (value: number, isCount = false) => {
if (isCount) {
return value > 0 ? `+${value}` : value.toString();
@@ -101,7 +102,7 @@ function DashboardStats({ stats }: { stats: any }) { // TODO: Import RouterOutpu
}
// Charts section
async function ChartsSection({ stats }: { stats: any }) {
async function ChartsSection({ stats }: { stats: DashboardStats }) {
// We still fetch all invoices for the status chart for now, or we could aggregate that too.
// For now, let's keep status chart as is (fetching all) but use aggregated for revenue.
// Actually, let's fetch invoices here for the status chart to keep it working.
@@ -309,7 +310,7 @@ async function CurrentWork() {
}
// Enhanced recent activity
async function RecentActivity({ recentInvoices }: { recentInvoices: any[] }) {
async function RecentActivity({ recentInvoices }: { recentInvoices: RecentInvoice[] }) {
// Use passed recentInvoices instead of fetching all
const getStatusStyle = (status: string) => {
+13
View File
@@ -0,0 +1,13 @@
import { type RouterOutputs } from "~/trpc/react";
// Dashboard stats type from the dashboard router
export type DashboardStats = RouterOutputs["dashboard"]["getStats"];
// Individual invoice type from the invoices router
export type Invoice = RouterOutputs["invoices"]["getAll"][number];
// Recent invoice type (includes client relation)
export type RecentInvoice = DashboardStats["recentInvoices"][number];
// Revenue chart data point
export type RevenueChartDataPoint = DashboardStats["revenueChartData"][number];