- {error && (
-
-
{error}
-
-
- )}
-
- {loading ? (
-
-
-
- Loading contacts...
-
-
- ) : (
- <>
- {/* Controls */}
-
-
-
- {/* Search Input */}
-
setSearchTerm(e.target.value)}
- style={{
- flex: 1,
- minWidth: '200px',
- maxWidth: '300px',
- padding: '8px 12px',
- border: '1px solid #e5e7eb',
- borderRadius: '6px',
- fontSize: '14px',
- }}
- />
-
-
- Updated: {formatLastUpdated()}
-
-
-
-
- {/* Contacts List */}
- {filteredContacts.length === 0 ? (
-
-
- 📭
-
-
- {searchTerm
- ? 'No matching contacts found'
- : 'No contacts available'}
-
-
- {searchTerm
- ? 'Try a different search term'
- : 'Add your first contact to get started'}
-
- {searchTerm && (
-
- )}
-
- ) : (
- <>
-
-
- {filteredContacts.map((contact, index) => (
-
-
-
-
- {index + 1}
-
-
-
- {contact.first_name || contact.last_name
- ? `${contact.first_name || ''} ${contact.last_name || ''}`.trim()
- : 'Unnamed Contact'}
-
-
- 📱 {formatPhoneNumber(contact.phone_number)}
-
-
-
-
- ID: {contact.id}
-
-
-
- {/* Additional info */}
-
- {contact.created_at && (
-
- Created:{' '}
- {new Date(
- contact.created_at
- ).toLocaleDateString()}
-
- )}
-
-
- ))}
-
-
-
- {/* Summary */}
-
-
- {filteredContacts.length} contact
- {filteredContacts.length !== 1 ? 's' : ''}
- {searchTerm && ` (filtered from ${contacts.length})`}
-
-
- {searchTerm
- ? 'Showing search results'
- : 'All contacts loaded'}
-
-
- >
- )}
- >
- )}
-
-
-
-
-
-