import React, { useState } from 'react'; import { View, StyleSheet, KeyboardAvoidingView, Platform, ScrollView } from 'react-native'; import { TextInput, Button, Text, Headline, HelperText } from 'react-native-paper'; import { useMutation } from '@apollo/client'; import { LOGIN } from '../graphql/mutations'; import { useAuth } from '../contexts/AuthContext'; export const LoginScreen = ({ navigation }: any) => { const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [showPassword, setShowPassword] = useState(false); const { login } = useAuth(); const [loginMutation, { loading, error }] = useMutation(LOGIN, { onCompleted: async (data) => { await login(data.login.access_token, data.login.user); }, onError: (error) => { console.error('Login error:', error); }, }); const handleLogin = () => { if (!username || !password) return; loginMutation({ variables: { username, password } }); }; return ( Вход в Prism setShowPassword(!showPassword)} /> } /> {error && ( {error.message} )} ); }; const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#f5f5f5', }, scrollContent: { flexGrow: 1, justifyContent: 'center', }, content: { padding: 20, maxWidth: 400, width: '100%', alignSelf: 'center', }, title: { textAlign: 'center', marginBottom: 30, }, input: { marginBottom: 15, }, button: { marginTop: 10, marginBottom: 10, }, linkButton: { marginTop: 10, }, });