import { useState } from 'react' import { View, Text, ScrollView, TouchableOpacity, StyleSheet, ActivityIndicator, Alert, } from 'react-native' import { useRouter } from 'expo-router' import { useCollections } from '../../src/shared/hooks/useSupabaseData' import { adminService } from '../../src/admin/services/adminService' import type { Collection } from '../../src/shared/types' export default function AdminCollectionsScreen() { const router = useRouter() const { collections, loading, refetch } = useCollections() const [updatingId, setUpdatingId] = useState(null) const handleDelete = (collection: Collection) => { Alert.alert( 'Delete Collection', `Are you sure you want to delete "${collection.title}"?`, [ { text: 'Cancel', style: 'cancel' }, { text: 'Delete', style: 'destructive', onPress: async () => { Alert.alert('Info', 'Collection deletion not yet implemented') } }, ] ) } if (loading) { return ( ) } return ( router.back()} style={styles.backButton}> ← Back Collections + Add {collections.map((collection) => ( {collection.icon} {collection.title} {collection.description} {collection.workoutIds.length} workouts Edit handleDelete(collection)} disabled={updatingId === collection.id} > {updatingId === collection.id ? '...' : 'Delete'} ))} ) } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#000', }, centered: { justifyContent: 'center', alignItems: 'center', }, header: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', padding: 20, paddingTop: 60, borderBottomWidth: 1, borderBottomColor: '#1C1C1E', }, backButton: { padding: 8, }, backText: { color: '#FF6B35', fontSize: 16, }, title: { fontSize: 20, fontWeight: 'bold', color: '#fff', }, addButton: { backgroundColor: '#FF6B35', paddingHorizontal: 16, paddingVertical: 8, borderRadius: 8, }, addButtonText: { color: '#000', fontWeight: 'bold', }, content: { flex: 1, padding: 16, }, collectionCard: { backgroundColor: '#1C1C1E', borderRadius: 12, padding: 16, marginBottom: 12, flexDirection: 'row', alignItems: 'center', }, iconContainer: { width: 48, height: 48, borderRadius: 24, backgroundColor: '#2C2C2E', justifyContent: 'center', alignItems: 'center', marginRight: 12, }, icon: { fontSize: 24, }, collectionInfo: { flex: 1, }, collectionTitle: { fontSize: 16, fontWeight: 'bold', color: '#fff', marginBottom: 4, }, collectionDescription: { fontSize: 14, color: '#999', marginBottom: 4, }, collectionMeta: { fontSize: 12, color: '#666', }, actions: { flexDirection: 'row', gap: 8, }, editButton: { backgroundColor: '#2C2C2E', paddingHorizontal: 12, paddingVertical: 8, borderRadius: 6, }, editText: { color: '#5AC8FA', }, deleteButton: { backgroundColor: '#2C2C2E', paddingHorizontal: 12, paddingVertical: 8, borderRadius: 6, }, disabledButton: { opacity: 0.5, }, deleteText: { color: '#FF3B30', }, })