- Inscription depuis la page Tarif : paiement Stripe puis création automatique du magasin, de l'abonnement et du compte Dirigeant (webhook), e-mail de bienvenue - Plus d'essai gratuit (site, Stripe, e-mails) - Création d'un magasin dans l'admin : formule obligatoire, compte Dirigeant et lien de paiement permanent envoyés automatiquement - Ouverture automatique du magasin dès l'abonnement payé et la carte conçue - API du Dirigeant : carte, employés, fiche magasin ; changement de mot de passe - Anniversaire et parrainage : cadeau en nature remis en caisse - Campagnes : titre de notification choisi à chaque envoi - « Gérant » devient « Dirigeant » Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
84 lines
2.8 KiB
TypeScript
84 lines
2.8 KiB
TypeScript
import { useState } from 'react';
|
|
import { KeyboardAvoidingView, Platform, 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 { font, useColors } from '../src/theme';
|
|
|
|
export default function Login() {
|
|
const c = useColors();
|
|
const { login } = useSession();
|
|
const [email, setEmail] = useState('');
|
|
const [password, setPassword] = useState('');
|
|
const [error, setError] = useState<string | null>(null);
|
|
const [busy, setBusy] = useState(false);
|
|
|
|
async function submit() {
|
|
setBusy(true);
|
|
setError(null);
|
|
try {
|
|
await login(email.trim(), password);
|
|
} catch (e) {
|
|
setError((e as Error).message);
|
|
} finally {
|
|
setBusy(false);
|
|
}
|
|
}
|
|
|
|
const input = {
|
|
height: 56,
|
|
borderWidth: 1,
|
|
borderColor: '#8A897F',
|
|
borderRadius: 12,
|
|
paddingHorizontal: 16,
|
|
fontSize: 17,
|
|
fontFamily: font.regular,
|
|
color: c.text,
|
|
backgroundColor: c.surface,
|
|
};
|
|
|
|
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>
|
|
</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>
|
|
</KeyboardAvoidingView>
|
|
</SafeAreaView>
|
|
);
|
|
}
|