diff --git a/pro/app/account.tsx b/pro/app/account.tsx index 68d69c1..975635b 100644 --- a/pro/app/account.tsx +++ b/pro/app/account.tsx @@ -1,17 +1,18 @@ import { useState } from 'react'; -import { ScrollView, TextInput } from 'react-native'; +import { Alert, Pressable, ScrollView, TextInput, View } from 'react-native'; import { api } from '../src/api'; import { describe } from '../src/errors'; import { useSession } from '../src/session'; -import { Banner, Button, T } from '../src/ui'; +import { Banner, Button, Card, T } from '../src/ui'; import { font, useColors } from '../src/theme'; -/** Mon compte : changement du mot de passe (tous les rôles). */ +/** Mon compte : profil, changement du mot de passe, déconnexion (tous les rôles). */ export default function Account() { const c = useColors(); - const { me } = useSession(); + const { me, logout } = useSession(); const [current, setCurrent] = useState(''); const [next, setNext] = useState(''); + const [show, setShow] = useState(false); const [error, setError] = useState(null); const [done, setDone] = useState(false); const [busy, setBusy] = useState(false); @@ -32,20 +33,85 @@ export default function Account() { } } - const input = { borderWidth: 1, borderColor: c.border, borderRadius: 14, padding: 14, backgroundColor: c.surface, color: c.text, fontFamily: font.regular, fontSize: 16 } as const; + const manager = me?.role === 'MANAGER'; + // Indication simple : longueur, puis variété (chiffres, majuscules, symboles). + const variety = [/\d/, /[A-Z]/, /[^A-Za-z0-9]/].filter((r) => r.test(next)).length; + const strength = next.length < 10 ? 0 : variety >= 2 || next.length >= 14 ? 2 : 1; + const strengthLabel = ['Trop court (10 caractères minimum)', 'Correct', 'Solide'][strength]; + const strengthColor = [c.err, c.warn, c.ok][strength]; + const input = { borderWidth: 1, borderColor: c.border, borderRadius: 14, padding: 14, backgroundColor: c.bg, color: c.text, fontFamily: font.regular, fontSize: 16 } as const; + return ( - - - {me?.displayName} · {me?.role === 'MANAGER' ? 'Dirigeant' : 'Employé'} - + + {/* Profil */} + + + {me?.displayName.charAt(0).toUpperCase()} + + {me?.displayName} + + + {manager ? 'Dirigeant' : 'Employé'} + + {me?.store.name} + + + {error && {error}} {done && Mot de passe modifié.} - Mot de passe actuel - - Nouveau mot de passe - - 10 caractères minimum. -