import { View, Text, ScrollView, RefreshControl, ActivityIndicator } from 'react-native';
import { useQuery } from '@tanstack/react-query';
import { api } from '../../services/api';
import { useAuthStore } from '../../stores/authStore';
function KpiCard({ label, value, color }: { label: string; value: string | number; color: string }) {
return (
{label}
{value}
);
}
export default function DashboardScreen() {
const { user } = useAuthStore();
const { data, isLoading, refetch, isRefetching } = useQuery({
queryKey: ['dashboard'],
queryFn: () => api.get('/api/v1/dashboard/summary').then(r => r.data),
});
return (
}
>
Welcome back,
{user?.firstName ?? 'Field Staff'}
{isLoading ? (
) : (
Overview
Recent Tickets
{(data?.recentTickets ?? []).length === 0 ? (
No recent tickets
) : (
(data?.recentTickets ?? []).map((t: any) => (
{t.subject}
{t.clientName} · {t.status}
))
)}
)}
);
}