import { View, Text, StyleSheet, TouchableOpacity, ScrollView } from 'react-native'; import { useRouter } from 'expo-router'; import { Ionicons } from '@expo/vector-icons'; import { useAuthStore } from '@/lib/auth-store'; import { useRapport } from '@/hooks/useRapport'; import { useSaisies } from '@/hooks/useTracker'; import { Colors } from '@/lib/colors'; export default function DashboardScreen() { const router = useRouter(); const { user } = useAuthStore(); const { data: rapport } = useRapport('month'); const { data: saisies } = useSaisies(); const recentSaisies = (saisies || []).slice(0, 3); return ( Bonjour, {user?.prenom} 👋 Comment allez-vous aujourd'hui ? {/* Actions rapides */} router.push('/(tabs)/journal/new')}> Nouvelle saisie router.push('/(tabs)/journal/reports')}> Mes rapports {/* Stats du mois */} {rapport && ( Ce mois-ci {rapport.stats.total_saisies} Saisies {rapport.stats.intensite_moyenne?.toFixed(1) || '—'} Intensite moy. {rapport.stats.emotion_dominante?.icone || '—'} {rapport.stats.emotion_dominante?.nom || 'Aucune'} )} {/* Dernieres saisies */} {recentSaisies.length > 0 && ( Dernieres emotions router.push('/(tabs)/journal')}> Tout voir {recentSaisies.map((saisie) => ( {saisie.emotion?.icone || '🔵'} {saisie.emotion?.nom} {new Date(saisie.date_saisie).toLocaleDateString('fr-FR')} — Intensite: {saisie.intensite}/10 ))} )} ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: Colors.white }, content: { padding: 20 }, greeting: { fontSize: 28, fontWeight: '800', color: Colors.black, marginTop: 8 }, subtitle: { fontSize: 16, color: Colors.gray[500], marginTop: 4, marginBottom: 24 }, actionsRow: { flexDirection: 'row', gap: 12, marginBottom: 24 }, actionCard: { flex: 1, backgroundColor: Colors.gray[50], borderRadius: 16, padding: 20, alignItems: 'center', gap: 12, borderWidth: 1, borderColor: Colors.gray[100], }, actionIcon: { width: 56, height: 56, borderRadius: 16, justifyContent: 'center', alignItems: 'center' }, actionText: { fontSize: 14, fontWeight: '600', color: Colors.gray[700] }, statsContainer: { marginBottom: 24 }, sectionTitle: { fontSize: 18, fontWeight: '700', color: Colors.black, marginBottom: 12 }, statsRow: { flexDirection: 'row', gap: 12 }, statCard: { flex: 1, backgroundColor: Colors.gray[50], borderRadius: 16, padding: 16, alignItems: 'center', borderWidth: 1, borderColor: Colors.gray[100], }, statValue: { fontSize: 24, fontWeight: '800', color: Colors.black }, statLabel: { fontSize: 12, color: Colors.gray[500], marginTop: 4 }, recentContainer: { marginBottom: 24 }, sectionHeader: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginBottom: 12 }, seeAll: { fontSize: 14, fontWeight: '600', color: Colors.secondary }, saisieItem: { flexDirection: 'row', alignItems: 'center', gap: 12, padding: 14, backgroundColor: Colors.gray[50], borderRadius: 14, marginBottom: 8, borderWidth: 1, borderColor: Colors.gray[100], }, emotionIcon: { width: 44, height: 44, borderRadius: 12, justifyContent: 'center', alignItems: 'center' }, emotionEmoji: { fontSize: 22 }, saisieContent: { flex: 1 }, saisieEmotion: { fontSize: 15, fontWeight: '600', color: Colors.black }, saisieDate: { fontSize: 13, color: Colors.gray[500], marginTop: 2 }, });