From 5d6e7692faec67d652ef141c92533c896c94cce6 Mon Sep 17 00:00:00 2001 From: Tony AVERTY Date: Wed, 7 Oct 2026 14:43:29 +0200 Subject: [PATCH] =?UTF-8?q?App=20:=20page=20d'accueil=20retravaill=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit En-tête avec logo du magasin, date et accès au compte ; salutation selon l'heure ; bouton de scan mis en valeur ; chiffres du jour à pictogrammes ; actions et réglages en lignes à pictogramme, regroupés par section ; écran « Dernière étape » avant la conception de la carte. Co-Authored-By: Claude Opus 5.5 --- pro/app/index.tsx | 199 +++++++++++++++++++++++++++------------------- 1 file changed, 118 insertions(+), 81 deletions(-) diff --git a/pro/app/index.tsx b/pro/app/index.tsx index 8abfa2e..6a8b1fc 100644 --- a/pro/app/index.tsx +++ b/pro/app/index.tsx @@ -1,16 +1,16 @@ import { useCallback, useState } from 'react'; -import { Alert, Linking, Pressable, ScrollView, View } from 'react-native'; +import { Image, Linking, Pressable, 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 { api, API_URL, Summary } from '../src/api'; import { useSession, useStore } from '../src/session'; -import { Banner, BrandSymbol, Button, Card, T, unit } from '../src/ui'; +import { BrandSymbol, Button, Card, T, unit } from '../src/ui'; import { font, useColors } from '../src/theme'; function ScanIcon({ color }: { color: string }) { return ( - + ); @@ -19,35 +19,91 @@ function ScanIcon({ color }: { color: string }) { /** Adresse de l'espace web du Dirigeant (conception de la carte). */ const ESPACE_URL = 'https://monespacepro.eu/espace'; +const greeting = () => (new Date().getHours() >= 18 ? 'Bonsoir' : 'Bonjour'); +const today = () => new Date().toLocaleDateString('fr-FR', { weekday: 'long', day: 'numeric', month: 'long' }); + export default function Home() { const { me } = useSession(); // Magasin inscrit en ligne : tant que la carte n'est pas conçue, pas de scan possible. return me?.store.cardDesign ? : ; } +/** En-tête commun : logo du magasin, date, accès au compte. */ +function Header() { + const c = useColors(); + const { me } = useSession(); + const logo = me?.store.cardDesign?.logoUrl; + const first = me?.displayName.split(' ')[0] ?? ''; + return ( + + + {logo ? : } + + + {me?.store.name} + {today()} + + router.push('/account')}> + {({ pressed }) => ( + + {first.charAt(0).toUpperCase()} + + )} + + + ); +} + +/** Ligne d'action ou de réglage : pictogramme, titre, sous-titre, chevron. */ +function Row({ icon, title, sub, onPress }: { icon: string; title: string; sub?: string; onPress: () => void }) { + const c = useColors(); + return ( + + {({ pressed }) => ( + + + {icon} + + + {title} + {!!sub && {sub}} + + › + + )} + + ); +} + +const sectionTitle = (c: ReturnType) => ({ color: c.text3, textTransform: 'uppercase' as const, fontSize: 13, letterSpacing: 0.5 }); + function NoCardYet() { const c = useColors(); - const { me, logout, reload } = useSession(); + const { me, reload } = useSession(); const isManager = me?.role === 'MANAGER'; return ( - - - - {me?.store.name} + +
+ + + 🎨 + + {isManager ? 'Dernière étape' : 'Presque prêt'} + + {isManager + ? 'Concevez votre carte de fidélité (logo, couleurs, récompenses) sur votre espace web. Le scan des cartes s’active ensuite.' + : 'La carte de fidélité du magasin n’est pas encore prête. Revenez un peu plus tard.'} + - - {isManager - ? 'Concevez votre carte de fidélité (logo, couleurs, récompenses) sur votre espace web : le scan des cartes s’active ensuite.' - : 'La carte de fidélité du magasin n’est pas encore prête. Revenez un peu plus tard.'} - - {isManager &&
); @@ -55,7 +111,7 @@ function NoCardYet() { function Counter() { const c = useColors(); - const { me, logout } = useSession(); + const { me } = useSession(); const store = useStore(); const [summary, setSummary] = useState(null); const [tab, setTab] = useState<'scan' | 'config'>('scan'); @@ -84,27 +140,7 @@ function Counter() { bounces={false} overScrollMode="never" > - - - - {store.name} - - Bonjour {me?.displayName.split(' ')[0]} · {isManager ? 'Dirigeant' : 'Employé'} - - - - Alert.alert('Se déconnecter ?', undefined, [ - { text: 'Annuler', style: 'cancel' }, - { text: 'Se déconnecter', style: 'destructive', onPress: logout }, - ]) - } - > - Déconnexion - - +
{isManager && ( @@ -131,46 +167,60 @@ function Counter() { ) : ( <> + + {greeting()} {me?.displayName.split(' ')[0]} 👋 + + + {/* Action principale */} router.push('/scan')} style={({ pressed }) => ({ backgroundColor: pressed ? c.primaryPressed : c.primary, - borderRadius: 24, - paddingVertical: 48, + borderRadius: 26, + paddingVertical: 40, + paddingHorizontal: 24, alignItems: 'center', gap: 14, + shadowColor: c.primary, + shadowOpacity: 0.35, + shadowRadius: 16, + shadowOffset: { width: 0, height: 8 }, + elevation: 6, })} > - + - Scanner une carte + Scanner une carte QR code du Wallet du client + {/* Chiffres du jour */} - {isManager ? "Aujourd'hui au magasin" : "Mes opérations aujourd'hui"} - + {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]) => ( - + ['🧾', summary?.operations ?? '—', 'opérations'], + ['➕', summary?.pointsGiven ?? '—', `${u} donnés`], + ['🎁', summary?.rewards ?? '—', 'récompenses'], + ].map(([icon, n, l]) => ( + + {icon} {n} - {l} - + {l} + ))} - - {isManager &&