|
|
@ -16,7 +16,7 @@ import authStorage from "../auth/storage"; |
|
|
|
import assets from "../config/assets"; |
|
|
|
import Button from "../components/Button"; |
|
|
|
import { TouchableNativeFeedback } from "react-native-gesture-handler"; |
|
|
|
import {login, userPersonalData} from "../api/auth"; |
|
|
|
import { login, userPersonalData } from "../api/auth"; |
|
|
|
|
|
|
|
const phoneRegex = RegExp( |
|
|
|
/^\(?[\(]?([0-9]{2})?\)?[)\b]?([0-9]{4,5})[-. ]?([0-9]{4})$/ |
|
|
@ -76,7 +76,7 @@ export default function LoginScreen(props) { |
|
|
|
const authContext = useContext(AuthContext); |
|
|
|
|
|
|
|
const handleSubmit = async (name, password, setLoginFailed) => { |
|
|
|
const result = await login(name, password); |
|
|
|
const result = await login(name, password); |
|
|
|
|
|
|
|
if (!result.ok) return setLoginFailed(true); |
|
|
|
await authStorage.setToken(result.data); |
|
|
@ -85,7 +85,6 @@ export default function LoginScreen(props) { |
|
|
|
setLoginFailed(false); |
|
|
|
const user = await userPersonalData(); |
|
|
|
user.ok && authContext.setUser(user.data); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
const [loginFailed, setLoginFailed] = useState(false); |
|
|
@ -102,14 +101,20 @@ export default function LoginScreen(props) { |
|
|
|
} |
|
|
|
> |
|
|
|
<View paddingHorizontal={14}> |
|
|
|
<Text style={styles.txtHeader}>Dados à Prova d'água</Text> |
|
|
|
<assets.AppLogoTitle |
|
|
|
preserveAspectRatio="xMidYMid meet" |
|
|
|
width={263} |
|
|
|
height={200} |
|
|
|
alignSelf="center" |
|
|
|
marginBottom={dimensions.spacing.big_padding} |
|
|
|
/> |
|
|
|
|
|
|
|
<ErrorMessage |
|
|
|
error="Email ou senha inválidos" |
|
|
|
visible={loginFailed} |
|
|
|
/> |
|
|
|
|
|
|
|
<View style={{ paddingVertical: 24 }}> |
|
|
|
<View style={{ paddingBottom: 24 }}> |
|
|
|
<FormField |
|
|
|
maxLength={12} |
|
|
|
name="name" |
|
|
@ -131,7 +136,7 @@ export default function LoginScreen(props) { |
|
|
|
|
|
|
|
<SubmitButton title="entrar" backgroundColor={colors.primary} /> |
|
|
|
|
|
|
|
{/* FIXME: update this in future versions */} |
|
|
|
{/* FIXME: update this in future versions */} |
|
|
|
{/* <TouchableNativeFeedback */} |
|
|
|
{/* onPress={() => { */} |
|
|
|
{/* props.navigation.navigate("ForgotPassword"); */} |
|
|
|