App : page de connexion retravaillée
Bandeau de marque, formulaire en carte, passage au champ suivant au clavier, affichage facultatif du mot de passe, lien vers les formules. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9c5695758d
commit
47a3030100
1 changed files with 78 additions and 46 deletions
|
|
@ -1,17 +1,20 @@
|
|||
import { useState } from 'react';
|
||||
import { KeyboardAvoidingView, Platform, TextInput, View } from 'react-native';
|
||||
import { useRef, useState } from 'react';
|
||||
import { KeyboardAvoidingView, Linking, Platform, Pressable, ScrollView, TextInput, View } from 'react-native';
|
||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||
import { useSession } from '../src/session';
|
||||
import { Banner, BrandSymbol, Button, T } from '../src/ui';
|
||||
import { Banner, BrandSymbol, Button, Card, T } from '../src/ui';
|
||||
import { font, useColors } from '../src/theme';
|
||||
|
||||
/** Connexion (Dirigeant et employés) : mêmes identifiants que l'espace web. */
|
||||
export default function Login() {
|
||||
const c = useColors();
|
||||
const { login } = useSession();
|
||||
const [email, setEmail] = useState('');
|
||||
const [password, setPassword] = useState('');
|
||||
const [show, setShow] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const pwdRef = useRef<TextInput>(null);
|
||||
|
||||
async function submit() {
|
||||
setBusy(true);
|
||||
|
|
@ -28,57 +31,86 @@ export default function Login() {
|
|||
const input = {
|
||||
height: 56,
|
||||
borderWidth: 1,
|
||||
borderColor: '#8A897F',
|
||||
borderRadius: 12,
|
||||
borderColor: c.border,
|
||||
borderRadius: 14,
|
||||
paddingHorizontal: 16,
|
||||
fontSize: 17,
|
||||
fontFamily: font.regular,
|
||||
color: c.text,
|
||||
backgroundColor: c.surface,
|
||||
backgroundColor: c.bg,
|
||||
};
|
||||
|
||||
return (
|
||||
<SafeAreaView style={{ flex: 1, backgroundColor: c.bg }}>
|
||||
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} style={{ flex: 1, padding: 24, justifyContent: 'center', gap: 28 }}>
|
||||
<View style={{ alignItems: 'center', gap: 12 }}>
|
||||
<BrandSymbol size={64} />
|
||||
<T v="h1" style={{ textAlign: 'center' }}>
|
||||
MonEspace<T v="h1" style={{ color: c.primary }}>Pro</T>
|
||||
<View style={{ flex: 1, backgroundColor: c.bg }}>
|
||||
{/* Bandeau de marque */}
|
||||
<View style={{ backgroundColor: c.primary, borderBottomLeftRadius: 32, borderBottomRightRadius: 32, paddingBottom: 72 }}>
|
||||
<SafeAreaView edges={['top']}>
|
||||
<View style={{ alignItems: 'center', gap: 10, paddingTop: 28 }}>
|
||||
<View style={{ width: 84, height: 84, borderRadius: 24, backgroundColor: c.surface, alignItems: 'center', justifyContent: 'center' }}>
|
||||
<BrandSymbol size={56} />
|
||||
</View>
|
||||
<T style={{ fontFamily: font.extrabold, fontSize: 30, color: c.onPrimary }}>MonEspacePro</T>
|
||||
<T style={{ color: c.onPrimary, opacity: 0.85, fontSize: 15 }}>La fidélité de vos clients, au comptoir</T>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
</View>
|
||||
|
||||
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} style={{ flex: 1 }}>
|
||||
<ScrollView contentContainerStyle={{ paddingHorizontal: 20, paddingBottom: 32, gap: 18 }} keyboardShouldPersistTaps="handled" bounces={false} overScrollMode="never" style={{ marginTop: -48 }}>
|
||||
<Card style={{ padding: 20, gap: 14 }}>
|
||||
<T v="h2">Connexion</T>
|
||||
{error && <Banner tone="error">{error}</Banner>}
|
||||
<View style={{ gap: 6 }}>
|
||||
<T v="label" nativeID="l-email">E-mail</T>
|
||||
<TextInput
|
||||
accessibilityLabelledBy="l-email"
|
||||
style={input}
|
||||
value={email}
|
||||
onChangeText={setEmail}
|
||||
placeholder="vous@exemple.fr"
|
||||
placeholderTextColor={c.text3}
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
autoComplete="email"
|
||||
keyboardType="email-address"
|
||||
textContentType="username"
|
||||
returnKeyType="next"
|
||||
onSubmitEditing={() => pwdRef.current?.focus()}
|
||||
/>
|
||||
</View>
|
||||
<View style={{ gap: 6 }}>
|
||||
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
||||
<T v="label" nativeID="l-pwd">Mot de passe</T>
|
||||
<Pressable accessibilityRole="button" hitSlop={10} onPress={() => setShow(!show)}>
|
||||
<T style={{ color: c.primary, fontFamily: font.semibold, fontSize: 14 }}>{show ? 'Masquer' : 'Afficher'}</T>
|
||||
</Pressable>
|
||||
</View>
|
||||
<TextInput
|
||||
ref={pwdRef}
|
||||
accessibilityLabelledBy="l-pwd"
|
||||
style={input}
|
||||
value={password}
|
||||
onChangeText={setPassword}
|
||||
secureTextEntry={!show}
|
||||
autoComplete="current-password"
|
||||
textContentType="password"
|
||||
returnKeyType="go"
|
||||
onSubmitEditing={submit}
|
||||
/>
|
||||
</View>
|
||||
<Button large label="Se connecter" onPress={submit} loading={busy} disabled={!email || !password} />
|
||||
</Card>
|
||||
|
||||
<T v="muted" style={{ textAlign: 'center', fontSize: 14 }}>
|
||||
Employé ? Vos identifiants vous sont fournis par votre dirigeant.
|
||||
</T>
|
||||
<T v="muted">Espace employés</T>
|
||||
</View>
|
||||
{error && <Banner tone="error">{error}</Banner>}
|
||||
<View style={{ gap: 6 }}>
|
||||
<T v="label" nativeID="l-email">E-mail</T>
|
||||
<TextInput
|
||||
accessibilityLabelledBy="l-email"
|
||||
style={input}
|
||||
value={email}
|
||||
onChangeText={setEmail}
|
||||
autoCapitalize="none"
|
||||
autoComplete="email"
|
||||
keyboardType="email-address"
|
||||
textContentType="username"
|
||||
returnKeyType="next"
|
||||
/>
|
||||
</View>
|
||||
<View style={{ gap: 6 }}>
|
||||
<T v="label" nativeID="l-pwd">Mot de passe</T>
|
||||
<TextInput
|
||||
accessibilityLabelledBy="l-pwd"
|
||||
style={input}
|
||||
value={password}
|
||||
onChangeText={setPassword}
|
||||
secureTextEntry
|
||||
autoComplete="current-password"
|
||||
textContentType="password"
|
||||
returnKeyType="go"
|
||||
onSubmitEditing={submit}
|
||||
/>
|
||||
</View>
|
||||
<Button label="Se connecter" onPress={submit} loading={busy} disabled={!email || password.length < 8} />
|
||||
<T v="muted" style={{ textAlign: 'center' }}>Identifiants fournis par votre dirigeant.</T>
|
||||
<Pressable accessibilityRole="link" onPress={() => Linking.openURL('https://monespacepro.eu/tarif/')}>
|
||||
<T style={{ textAlign: 'center', fontSize: 14, color: c.text3 }}>
|
||||
Pas encore client ? <T style={{ fontSize: 14, color: c.primary, fontFamily: font.semibold }}>Découvrir les formules</T>
|
||||
</T>
|
||||
</Pressable>
|
||||
</ScrollView>
|
||||
</KeyboardAvoidingView>
|
||||
</SafeAreaView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue