import { useState } from 'react'; import { ScrollView, TextInput } 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 { font, useColors } from '../src/theme'; /** Mon compte : changement du mot de passe (tous les rôles). */ export default function Account() { const c = useColors(); const { me } = useSession(); const [current, setCurrent] = useState(''); const [next, setNext] = useState(''); const [error, setError] = useState(null); const [done, setDone] = useState(false); const [busy, setBusy] = useState(false); async function save() { setBusy(true); setError(null); setDone(false); try { await api.post('/api/staff/password', { current, next }); setCurrent(''); setNext(''); setDone(true); } catch (e) { setError(describe(e).detail); } finally { setBusy(false); } } const input = { borderWidth: 1, borderColor: c.border, borderRadius: 14, padding: 14, backgroundColor: c.surface, color: c.text, fontFamily: font.regular, fontSize: 16 } as const; return ( {me?.displayName} · {me?.role === 'MANAGER' ? 'Dirigeant' : 'Employé'} {error && {error}} {done && Mot de passe modifié.} Mot de passe actuel Nouveau mot de passe 10 caractères minimum.