import { useState } from 'react';
import { View, Text, ScrollView, TouchableOpacity, ActivityIndicator, Linking } from 'react-native';
import { useLocalSearchParams, router } from 'expo-router';
import { useQuery } from '@tanstack/react-query';
import { api } from '../../../services/api';
const TABS = ['Profile', 'Subscription', 'Invoices', 'Payments'];
export default function ClientDetailScreen() {
const { id } = useLocalSearchParams<{ id: string }>();
const [tab, setTab] = useState('Profile');
const { data: client, isLoading } = useQuery({
queryKey: ['client', id],
queryFn: () => api.get(`/api/v1/clients/${id}`).then(r => r.data),
});
if (isLoading) return ;
return (
router.back()} className="mr-3">
←
{client?.firstName} {client?.lastName}
{client?.accountNumber}
{TABS.map(t => (
setTab(t)} className={`flex-1 py-3 items-center border-b-2 ${tab === t ? 'border-primary' : 'border-transparent'}`}>
{t}
))}
{tab === 'Profile' && (
{[
{ label: 'Account #', value: client?.accountNumber },
{ label: 'Status', value: client?.status },
{ label: 'Email', value: client?.email },
{ label: 'Phone', value: client?.phone, onPress: () => client?.phone && Linking.openURL(`tel:${client.phone}`) },
{ label: 'Address', value: client?.address },
{ label: 'Area', value: client?.area?.name },
].map((item, i) => (
0 ? 'border-t border-gray-100' : ''}`}
>
{item.label}
{item.value ?? '—'}
))}
)}
{tab === 'Subscription' && Subscription details coming soon}
{tab === 'Invoices' && Invoices coming soon}
{tab === 'Payments' && Payments coming soon}
);
}