feat: Implement initial with admin and mobile clients, authentication, data models, and lead generation scripts.
This commit is contained in:
@@ -7,29 +7,40 @@ import { useRouter } from 'expo-router'
|
||||
import { SafeAreaView } from 'react-native-safe-area-context'
|
||||
import { Ionicons } from '@expo/vector-icons'
|
||||
import { authClient } from '@/lib/auth-client'
|
||||
import { useAuthStore } from '@/store/auth.store'
|
||||
|
||||
export default function LoginScreen() {
|
||||
const router = useRouter()
|
||||
const setSession = useAuthStore((s) => s.setSession)
|
||||
const [email, setEmail] = useState('')
|
||||
const [password, setPassword] = useState('')
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [error, setError] = useState('')
|
||||
|
||||
const canSubmit = email.trim().length > 0 && !loading
|
||||
const canSubmit = email.trim().length > 0 && password.length > 0 && !loading
|
||||
|
||||
async function handleSendLink() {
|
||||
if (!email.trim()) return
|
||||
async function handleLogin() {
|
||||
if (!canSubmit) return
|
||||
setLoading(true)
|
||||
setError('')
|
||||
const result = await authClient.signIn.magicLink({
|
||||
|
||||
const result = await authClient.signIn.email({
|
||||
email: email.trim().toLowerCase(),
|
||||
callbackURL: '/home',
|
||||
password,
|
||||
})
|
||||
setLoading(false)
|
||||
|
||||
if (result.error) {
|
||||
setError(result.error.message ?? 'Ein Fehler ist aufgetreten.')
|
||||
} else {
|
||||
router.push({ pathname: '/(auth)/check-email', params: { email } })
|
||||
setError(result.error.message ?? 'E-Mail oder Passwort falsch.')
|
||||
setLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
const token = (result.data as any)?.session?.token
|
||||
const user = (result.data as any)?.user
|
||||
await setSession(user ? { user } : null, token)
|
||||
|
||||
setLoading(false)
|
||||
router.replace('/(app)/home' as never)
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -60,7 +71,21 @@ export default function LoginScreen() {
|
||||
autoCorrect={false}
|
||||
value={email}
|
||||
onChangeText={setEmail}
|
||||
onSubmitEditing={handleSendLink}
|
||||
returnKeyType="next"
|
||||
/>
|
||||
</View>
|
||||
|
||||
<Text style={[styles.inputLabel, { marginTop: 4 }]}>Passwort</Text>
|
||||
<View style={styles.inputWrap}>
|
||||
<Ionicons name="lock-closed-outline" size={18} color="#94A3B8" />
|
||||
<TextInput
|
||||
style={styles.input}
|
||||
placeholder="••••••••"
|
||||
placeholderTextColor="#94A3B8"
|
||||
secureTextEntry
|
||||
value={password}
|
||||
onChangeText={setPassword}
|
||||
onSubmitEditing={handleLogin}
|
||||
returnKeyType="go"
|
||||
/>
|
||||
</View>
|
||||
@@ -72,7 +97,7 @@ export default function LoginScreen() {
|
||||
) : null}
|
||||
|
||||
<TouchableOpacity
|
||||
onPress={handleSendLink}
|
||||
onPress={handleLogin}
|
||||
disabled={!canSubmit}
|
||||
style={[styles.submitBtn, !canSubmit && styles.submitBtnDisabled]}
|
||||
activeOpacity={0.85}
|
||||
@@ -81,7 +106,7 @@ export default function LoginScreen() {
|
||||
<ActivityIndicator color="#FFFFFF" />
|
||||
) : (
|
||||
<View style={styles.submitContent}>
|
||||
<Text style={styles.submitLabel}>Login-Link senden</Text>
|
||||
<Text style={styles.submitLabel}>Anmelden</Text>
|
||||
<Ionicons name="arrow-forward" size={16} color="#FFFFFF" />
|
||||
</View>
|
||||
)}
|
||||
@@ -89,7 +114,7 @@ export default function LoginScreen() {
|
||||
</View>
|
||||
|
||||
<Text style={styles.hint}>
|
||||
Noch kein Zugang? Kontaktieren Sie Ihre Innungsgeschaeftsstelle.
|
||||
Noch kein Zugang? Kontaktieren Sie Ihre Innungsgeschäftsstelle.
|
||||
</Text>
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
@@ -98,109 +123,38 @@ export default function LoginScreen() {
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
safeArea: {
|
||||
flex: 1,
|
||||
backgroundColor: '#FFFFFF',
|
||||
},
|
||||
keyboardView: {
|
||||
flex: 1,
|
||||
},
|
||||
content: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
paddingHorizontal: 24,
|
||||
},
|
||||
logoSection: {
|
||||
alignItems: 'center',
|
||||
marginBottom: 40,
|
||||
},
|
||||
safeArea: { flex: 1, backgroundColor: '#FFFFFF' },
|
||||
keyboardView: { flex: 1 },
|
||||
content: { flex: 1, justifyContent: 'center', paddingHorizontal: 24 },
|
||||
logoSection: { alignItems: 'center', marginBottom: 40 },
|
||||
logoBox: {
|
||||
width: 64,
|
||||
height: 64,
|
||||
backgroundColor: '#003B7E',
|
||||
borderRadius: 18,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
marginBottom: 16,
|
||||
},
|
||||
logoLetter: {
|
||||
color: '#FFFFFF',
|
||||
fontSize: 30,
|
||||
fontWeight: '900',
|
||||
},
|
||||
appName: {
|
||||
fontSize: 30,
|
||||
fontWeight: '800',
|
||||
color: '#0F172A',
|
||||
letterSpacing: -0.6,
|
||||
marginBottom: 4,
|
||||
},
|
||||
tagline: {
|
||||
fontSize: 14,
|
||||
color: '#64748B',
|
||||
textAlign: 'center',
|
||||
},
|
||||
form: {
|
||||
gap: 12,
|
||||
},
|
||||
inputLabel: {
|
||||
fontSize: 14,
|
||||
fontWeight: '700',
|
||||
color: '#334155',
|
||||
width: 64, height: 64, backgroundColor: '#003B7E',
|
||||
borderRadius: 18, alignItems: 'center', justifyContent: 'center', marginBottom: 16,
|
||||
},
|
||||
logoLetter: { color: '#FFFFFF', fontSize: 30, fontWeight: '900' },
|
||||
appName: { fontSize: 30, fontWeight: '800', color: '#0F172A', letterSpacing: -0.6, marginBottom: 4 },
|
||||
tagline: { fontSize: 14, color: '#64748B', textAlign: 'center' },
|
||||
form: { gap: 8 },
|
||||
inputLabel: { fontSize: 14, fontWeight: '700', color: '#334155' },
|
||||
inputWrap: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F8FAFC',
|
||||
borderRadius: 14,
|
||||
borderWidth: 1,
|
||||
borderColor: '#E2E8F0',
|
||||
paddingHorizontal: 12,
|
||||
gap: 8,
|
||||
},
|
||||
input: {
|
||||
flex: 1,
|
||||
paddingVertical: 13,
|
||||
color: '#0F172A',
|
||||
fontSize: 15,
|
||||
flexDirection: 'row', alignItems: 'center',
|
||||
backgroundColor: '#F8FAFC', borderRadius: 14,
|
||||
borderWidth: 1, borderColor: '#E2E8F0',
|
||||
paddingHorizontal: 12, gap: 8,
|
||||
},
|
||||
input: { flex: 1, paddingVertical: 13, color: '#0F172A', fontSize: 15 },
|
||||
errorBox: {
|
||||
backgroundColor: '#FEF2F2',
|
||||
borderWidth: 1,
|
||||
borderColor: '#FECACA',
|
||||
borderRadius: 12,
|
||||
paddingHorizontal: 14,
|
||||
paddingVertical: 10,
|
||||
},
|
||||
errorText: {
|
||||
color: '#B91C1C',
|
||||
fontSize: 13,
|
||||
backgroundColor: '#FEF2F2', borderWidth: 1,
|
||||
borderColor: '#FECACA', borderRadius: 12,
|
||||
paddingHorizontal: 14, paddingVertical: 10,
|
||||
},
|
||||
errorText: { color: '#B91C1C', fontSize: 13 },
|
||||
submitBtn: {
|
||||
backgroundColor: '#003B7E',
|
||||
borderRadius: 14,
|
||||
paddingVertical: 14,
|
||||
alignItems: 'center',
|
||||
marginTop: 4,
|
||||
},
|
||||
submitBtnDisabled: {
|
||||
backgroundColor: '#CBD5E1',
|
||||
},
|
||||
submitContent: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
gap: 6,
|
||||
},
|
||||
submitLabel: {
|
||||
color: '#FFFFFF',
|
||||
fontWeight: '700',
|
||||
fontSize: 15,
|
||||
},
|
||||
hint: {
|
||||
marginTop: 24,
|
||||
textAlign: 'center',
|
||||
color: '#64748B',
|
||||
fontSize: 13,
|
||||
lineHeight: 18,
|
||||
backgroundColor: '#003B7E', borderRadius: 14,
|
||||
paddingVertical: 14, alignItems: 'center', marginTop: 8,
|
||||
},
|
||||
submitBtnDisabled: { backgroundColor: '#CBD5E1' },
|
||||
submitContent: { flexDirection: 'row', alignItems: 'center', gap: 6 },
|
||||
submitLabel: { color: '#FFFFFF', fontWeight: '700', fontSize: 15 },
|
||||
hint: { marginTop: 24, textAlign: 'center', color: '#64748B', fontSize: 13, lineHeight: 18 },
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user