import { useState, useCallback } from 'react' import { View, Text, ScrollView, TouchableOpacity, StyleSheet, RefreshControl, } from 'react-native' import { useRouter } from 'expo-router' import { useAdminAuth } from '../../src/admin/components/AdminAuthProvider' import { useWorkouts, useTrainers, useCollections } from '../../src/shared/hooks/useSupabaseData' export default function AdminDashboardScreen() { const router = useRouter() const { signOut } = useAdminAuth() const [refreshing, setRefreshing] = useState(false) const { workouts, loading: workoutsLoading, refetch: refetchWorkouts } = useWorkouts() const { trainers, loading: trainersLoading, refetch: refetchTrainers } = useTrainers() const { collections, loading: collectionsLoading, refetch: refetchCollections } = useCollections() const onRefresh = useCallback(async () => { setRefreshing(true) await Promise.all([ refetchWorkouts(), refetchTrainers(), refetchCollections(), ]) setRefreshing(false) }, [refetchWorkouts, refetchTrainers, refetchCollections]) const handleLogout = async () => { await signOut() router.replace('/admin/login') } const isLoading = workoutsLoading || trainersLoading || collectionsLoading return ( Admin Dashboard Logout } > {workouts.length} Workouts {trainers.length} Trainers {collections.length} Collections Quick Actions router.push('/admin/workouts')} > 💪 Manage Workouts Add, edit, or delete workouts router.push('/admin/trainers')} > 👥 Manage Trainers Update trainer profiles router.push('/admin/collections')} > 📁 Manage Collections Organize workout collections router.push('/admin/media')} > 🎬 Media Library Upload videos and images ) } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#000', }, header: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', padding: 20, paddingTop: 60, borderBottomWidth: 1, borderBottomColor: '#1C1C1E', }, title: { fontSize: 28, fontWeight: 'bold', color: '#fff', }, logoutButton: { padding: 8, }, logoutText: { color: '#FF6B35', fontSize: 16, }, content: { flex: 1, padding: 20, }, statsGrid: { flexDirection: 'row', gap: 12, marginBottom: 32, }, statCard: { flex: 1, backgroundColor: '#1C1C1E', borderRadius: 12, padding: 16, alignItems: 'center', }, statNumber: { fontSize: 32, fontWeight: 'bold', color: '#FF6B35', }, statLabel: { fontSize: 14, color: '#999', marginTop: 4, }, sectionTitle: { fontSize: 20, fontWeight: 'bold', color: '#fff', marginBottom: 16, }, actionsGrid: { flexDirection: 'row', flexWrap: 'wrap', gap: 12, }, actionCard: { width: '47%', backgroundColor: '#1C1C1E', borderRadius: 12, padding: 20, marginBottom: 12, }, actionIcon: { fontSize: 32, marginBottom: 12, }, actionTitle: { fontSize: 16, fontWeight: 'bold', color: '#fff', marginBottom: 4, }, actionDescription: { fontSize: 14, color: '#999', }, })