import { useCallback, useState } from 'react'; import { Alert, Pressable, RefreshControl, ScrollView, View } from 'react-native'; import { router, useFocusEffect } from 'expo-router'; import { SafeAreaView } from 'react-native-safe-area-context'; import Svg, { Path } from 'react-native-svg'; import { api, Summary } from '../src/api'; import { useSession, useStore } from '../src/session'; import { BrandSymbol, Button, Card, T, unit } from '../src/ui'; import { font, useColors } from '../src/theme'; function ScanIcon({ color }: { color: string }) { return ( ); } export default function Home() { const c = useColors(); const { me, logout } = useSession(); const store = useStore(); const [summary, setSummary] = useState(null); const [refreshing, setRefreshing] = useState(false); const load = useCallback(async () => { try { setSummary(await api.get('/api/staff/summary')); } catch { /* résumé indicatif : on garde l'ancien */ } }, []); useFocusEffect( useCallback(() => { load(); }, [load]), ); const isManager = me?.role === 'MANAGER'; const u = unit(store.design.pointsMode); return ( { setRefreshing(true); await load(); setRefreshing(false); }} /> } > {store.name} {me?.displayName} · {isManager ? 'Gérant' : 'Employé'} Alert.alert('Se déconnecter ?', undefined, [ { text: 'Annuler', style: 'cancel' }, { text: 'Se déconnecter', style: 'destructive', onPress: logout }, ]) } > Déconnexion router.push('/scan')} style={({ pressed }) => ({ backgroundColor: pressed ? c.primaryPressed : c.primary, borderRadius: 24, paddingVertical: 48, alignItems: 'center', gap: 14, })} > Scanner une carte QR code du Wallet du client {isManager ? "Aujourd'hui au magasin" : "Mes opérations aujourd'hui"} {[ [summary?.operations ?? '—', 'opérations'], [summary?.pointsGiven ?? '—', `${u} donnés`], [summary?.rewards ?? '—', 'récompenses'], ].map(([n, l]) => ( {n} {l} ))}