import { View, Text, FlatList, ActivityIndicator, TouchableOpacity, RefreshControl } from 'react-native'; import { useQuery } from '@tanstack/react-query'; import { useRouter } from 'expo-router'; import { api } from '../../../services/api'; const STATUS_COLOR: Record = { open: 'bg-yellow-100 text-yellow-700', in_progress: 'bg-blue-100 text-blue-700', resolved: 'bg-green-100 text-green-700', closed: 'bg-gray-100 text-gray-500', }; export default function TicketsScreen() { const router = useRouter(); const { data, isLoading, refetch, isRefetching } = useQuery({ queryKey: ['tickets'], queryFn: () => api.get('/api/v1/tickets').then(r => r.data?.data ?? r.data?.results ?? r.data), }); const tickets = Array.isArray(data) ? data : []; return ( Tickets {isLoading ? : ( item.id} refreshControl={} contentContainerStyle={{ paddingHorizontal: 16, paddingBottom: 24 }} renderItem={({ item }) => ( router.push(`/(app)/tickets/${item.id}`)} > {item.subject} {item.status} {item.clientName} ยท {item.priority} )} ListEmptyComponent={No tickets} /> )} ); }