Anmeldung und Kalendar

This commit is contained in:
Ismail Ali
2025-07-15 20:38:04 +02:00
parent 2a34091404
commit 1cc8951c12
51 changed files with 19961 additions and 177 deletions

View File

@@ -0,0 +1,66 @@
import React, { useState } from 'react';
import { View, TextInput, Button, Text, StyleSheet, Alert } from 'react-native';
import { authenticateUser } from '../services/auth';
import { storeUserSession } from '../utils/storage';
import { useNavigation } from '@react-navigation/native';
const LoginForm = () => {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const navigation = useNavigation();
const handleLogin = async () => {
if (!email || !password) {
Alert.alert('Error', 'Please fill in all fields');
return;
}
try {
const response = await authenticateUser(email, password);
if (response.success) {
await storeUserSession(response.data);
navigation.navigate('WelcomeScreen');
} else {
Alert.alert('Error', response.message);
}
} catch (error) {
Alert.alert('Error', 'An error occurred during login');
}
};
return (
<View style={styles.container}>
<TextInput
style={styles.input}
placeholder="Email"
value={email}
onChangeText={setEmail}
keyboardType="email-address"
autoCapitalize="none"
/>
<TextInput
style={styles.input}
placeholder="Password"
value={password}
onChangeText={setPassword}
secureTextEntry
/>
<Button title="Login" onPress={handleLogin} />
</View>
);
};
const styles = StyleSheet.create({
container: {
padding: 20,
},
input: {
height: 40,
borderColor: 'gray',
borderWidth: 1,
marginBottom: 10,
paddingHorizontal: 10,
},
});
export default LoginForm;

View File

@@ -0,0 +1,63 @@
import React, { useState } from 'react';
import { View, TextInput, Button, Text, StyleSheet } from 'react-native';
import { registerUser } from '../services/auth';
const RegisterForm = ({ navigation }) => {
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');
const [error, setError] = useState('');
const handleRegister = async () => {
setError('');
try {
await registerUser(username, password);
navigation.navigate('WelcomeScreen');
} catch (err) {
setError(err.message);
}
};
return (
<View style={styles.container}>
<Text style={styles.title}>Register</Text>
{error ? <Text style={styles.error}>{error}</Text> : null}
<TextInput
style={styles.input}
placeholder="Username"
value={username}
onChangeText={setUsername}
/>
<TextInput
style={styles.input}
placeholder="Password"
secureTextEntry
value={password}
onChangeText={setPassword}
/>
<Button title="Register" onPress={handleRegister} />
</View>
);
};
const styles = StyleSheet.create({
container: {
padding: 20,
},
title: {
fontSize: 24,
marginBottom: 20,
},
input: {
height: 40,
borderColor: 'gray',
borderWidth: 1,
marginBottom: 10,
paddingLeft: 8,
},
error: {
color: 'red',
marginBottom: 10,
},
});
export default RegisterForm;

View File

@@ -0,0 +1,31 @@
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
const WelcomeScreen = () => {
return (
<View style={styles.container}>
<Text style={styles.welcomeText}>Willkommen in der App!</Text>
<Text style={styles.instructionText}>Sie können sich jetzt anmelden oder registrieren.</Text>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f5f5f5',
},
welcomeText: {
fontSize: 24,
fontWeight: 'bold',
marginBottom: 10,
},
instructionText: {
fontSize: 16,
textAlign: 'center',
},
});
export default WelcomeScreen;