diff --git a/client/components/ErrorBoundary.jsx b/client/components/ErrorBoundary.tsx similarity index 85% rename from client/components/ErrorBoundary.jsx rename to client/components/ErrorBoundary.tsx index 11fbbf4..f823a00 100644 --- a/client/components/ErrorBoundary.jsx +++ b/client/components/ErrorBoundary.tsx @@ -1,27 +1,36 @@ -import React from 'react'; +import React, { type ReactNode } from 'react'; import { AlertTriangle, RefreshCw } from 'lucide-react'; import { Button } from '@/components/ui/button'; -import { cn } from '@/lib/utils'; // ──────────────────────────────────────────────────────────────────────────── // ErrorBoundary Component // ──────────────────────────────────────────────────────────────────────────── -class ErrorBoundary extends React.Component { - constructor(props) { +interface ErrorBoundaryProps { + children?: ReactNode; +} + +interface ErrorBoundaryState { + hasError: boolean; + error: Error | null; + componentStack: string | null; +} + +class ErrorBoundary extends React.Component { + constructor(props: ErrorBoundaryProps) { super(props); this.state = { hasError: false, error: null, componentStack: null }; } - static getDerivedStateFromError(error) { + static getDerivedStateFromError(error: Error): Partial { return { hasError: true, error }; } - componentDidCatch(error, info) { + componentDidCatch(error: Error, info: React.ErrorInfo) { console.error('ErrorBoundary caught an error:', { error, componentStack: info?.componentStack, }); - this.setState({ error, componentStack: info?.componentStack }); + this.setState({ error, componentStack: info?.componentStack ?? null }); } handleReset = () => { @@ -45,15 +54,15 @@ class ErrorBoundary extends React.Component {
- +

Something went wrong

- +

An unexpected error occurred. You can try to recover by reloading the page or resetting this component.

- + {error && (

@@ -64,7 +73,7 @@ class ErrorBoundary extends React.Component {

)} - + {componentStack && (

@@ -75,7 +84,7 @@ class ErrorBoundary extends React.Component {

)} - +
); -} \ No newline at end of file +} diff --git a/client/components/PageTransition.jsx b/client/components/PageTransition.tsx similarity index 77% rename from client/components/PageTransition.jsx rename to client/components/PageTransition.tsx index 1b61ff4..d07ea0f 100644 --- a/client/components/PageTransition.jsx +++ b/client/components/PageTransition.tsx @@ -1,6 +1,7 @@ import { AnimatePresence, motion, useReducedMotion } from 'framer-motion'; +import type { ReactNode } from 'react'; -export default function PageTransition({ children, routeKey }) { +export default function PageTransition({ children, routeKey }: { children: ReactNode; routeKey?: string }) { const reduceMotion = useReducedMotion(); if (reduceMotion) return children; diff --git a/client/components/StatusBadge.jsx b/client/components/StatusBadge.tsx similarity index 92% rename from client/components/StatusBadge.jsx rename to client/components/StatusBadge.tsx index 6560c14..16db054 100644 --- a/client/components/StatusBadge.jsx +++ b/client/components/StatusBadge.tsx @@ -12,8 +12,8 @@ const STATUS_META = { skipped: { label: 'Skipped', cls: 'bg-muted text-muted-foreground border border-border' }, }; -export const StatusBadge = React.memo(function StatusBadge({ status }) { - const meta = useMemo(() => STATUS_META[status] || STATUS_META.upcoming, [status]); +export const StatusBadge = React.memo(function StatusBadge({ status }: { status: string }) { + const meta = useMemo(() => STATUS_META[status as keyof typeof STATUS_META] || STATUS_META.upcoming, [status]); const isUrgent = status === 'late' || status === 'missed'; return (