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 { useRef, useState } from 'react';
|
||||||
import { KeyboardAvoidingView, Platform, TextInput, View } from 'react-native';
|
import { KeyboardAvoidingView, Linking, Platform, Pressable, ScrollView, TextInput, View } from 'react-native';
|
||||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||||
import { useSession } from '../src/session';
|
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';
|
import { font, useColors } from '../src/theme';
|
||||||
|
|
||||||
|
/** Connexion (Dirigeant et employés) : mêmes identifiants que l'espace web. */
|
||||||
export default function Login() {
|
export default function Login() {
|
||||||
const c = useColors();
|
const c = useColors();
|
||||||
const { login } = useSession();
|
const { login } = useSession();
|
||||||
const [email, setEmail] = useState('');
|
const [email, setEmail] = useState('');
|
||||||
const [password, setPassword] = useState('');
|
const [password, setPassword] = useState('');
|
||||||
|
const [show, setShow] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
const [busy, setBusy] = useState(false);
|
const [busy, setBusy] = useState(false);
|
||||||
|
const pwdRef = useRef<TextInput>(null);
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
|
|
@ -28,25 +31,34 @@ export default function Login() {
|
||||||
const input = {
|
const input = {
|
||||||
height: 56,
|
height: 56,
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderColor: '#8A897F',
|
borderColor: c.border,
|
||||||
borderRadius: 12,
|
borderRadius: 14,
|
||||||
paddingHorizontal: 16,
|
paddingHorizontal: 16,
|
||||||
fontSize: 17,
|
fontSize: 17,
|
||||||
fontFamily: font.regular,
|
fontFamily: font.regular,
|
||||||
color: c.text,
|
color: c.text,
|
||||||
backgroundColor: c.surface,
|
backgroundColor: c.bg,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SafeAreaView style={{ flex: 1, backgroundColor: c.bg }}>
|
<View style={{ flex: 1, backgroundColor: c.bg }}>
|
||||||
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} style={{ flex: 1, padding: 24, justifyContent: 'center', gap: 28 }}>
|
{/* Bandeau de marque */}
|
||||||
<View style={{ alignItems: 'center', gap: 12 }}>
|
<View style={{ backgroundColor: c.primary, borderBottomLeftRadius: 32, borderBottomRightRadius: 32, paddingBottom: 72 }}>
|
||||||
<BrandSymbol size={64} />
|
<SafeAreaView edges={['top']}>
|
||||||
<T v="h1" style={{ textAlign: 'center' }}>
|
<View style={{ alignItems: 'center', gap: 10, paddingTop: 28 }}>
|
||||||
MonEspace<T v="h1" style={{ color: c.primary }}>Pro</T>
|
<View style={{ width: 84, height: 84, borderRadius: 24, backgroundColor: c.surface, alignItems: 'center', justifyContent: 'center' }}>
|
||||||
</T>
|
<BrandSymbol size={56} />
|
||||||
<T v="muted">Espace employés</T>
|
|
||||||
</View>
|
</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>}
|
{error && <Banner tone="error">{error}</Banner>}
|
||||||
<View style={{ gap: 6 }}>
|
<View style={{ gap: 6 }}>
|
||||||
<T v="label" nativeID="l-email">E-mail</T>
|
<T v="label" nativeID="l-email">E-mail</T>
|
||||||
|
|
@ -55,30 +67,50 @@ export default function Login() {
|
||||||
style={input}
|
style={input}
|
||||||
value={email}
|
value={email}
|
||||||
onChangeText={setEmail}
|
onChangeText={setEmail}
|
||||||
|
placeholder="vous@exemple.fr"
|
||||||
|
placeholderTextColor={c.text3}
|
||||||
autoCapitalize="none"
|
autoCapitalize="none"
|
||||||
|
autoCorrect={false}
|
||||||
autoComplete="email"
|
autoComplete="email"
|
||||||
keyboardType="email-address"
|
keyboardType="email-address"
|
||||||
textContentType="username"
|
textContentType="username"
|
||||||
returnKeyType="next"
|
returnKeyType="next"
|
||||||
|
onSubmitEditing={() => pwdRef.current?.focus()}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ gap: 6 }}>
|
<View style={{ gap: 6 }}>
|
||||||
|
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
||||||
<T v="label" nativeID="l-pwd">Mot de passe</T>
|
<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
|
<TextInput
|
||||||
|
ref={pwdRef}
|
||||||
accessibilityLabelledBy="l-pwd"
|
accessibilityLabelledBy="l-pwd"
|
||||||
style={input}
|
style={input}
|
||||||
value={password}
|
value={password}
|
||||||
onChangeText={setPassword}
|
onChangeText={setPassword}
|
||||||
secureTextEntry
|
secureTextEntry={!show}
|
||||||
autoComplete="current-password"
|
autoComplete="current-password"
|
||||||
textContentType="password"
|
textContentType="password"
|
||||||
returnKeyType="go"
|
returnKeyType="go"
|
||||||
onSubmitEditing={submit}
|
onSubmitEditing={submit}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<Button label="Se connecter" onPress={submit} loading={busy} disabled={!email || password.length < 8} />
|
<Button large label="Se connecter" onPress={submit} loading={busy} disabled={!email || !password} />
|
||||||
<T v="muted" style={{ textAlign: 'center' }}>Identifiants fournis par votre dirigeant.</T>
|
</Card>
|
||||||
|
|
||||||
|
<T v="muted" style={{ textAlign: 'center', fontSize: 14 }}>
|
||||||
|
Employé ? Vos identifiants vous sont 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>
|
</KeyboardAvoidingView>
|
||||||
</SafeAreaView>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue