display error on login when API is unreachable

This commit is contained in:
leander committed 2024-07-25 22:08:18 +02:00
1 parent 29b7dd10d9
commit fd9be09582
2 files changed
+4 -4

No files matched your search

+2 -2
View File
@@ -10,12 +10,11 @@ import theme from 'src/theme';
import useLogin from './useLogin';
const Login = () => {
const { isLoggingIn, errors, control, setFocus, onSubmit } = useLogin();
const { isLoggingIn, isSubmitted, errors, loginError, control, setFocus, onSubmit } = useLogin();
return (
<ScrollView>
<View style={styles.card}>
<FormErrors errors={errors} />
<FormInput
name="email"
label="E-post / Brukernavn"
@@ -51,6 +50,7 @@ const Login = () => {
>
<Text>Glemt passord?</Text>
</Button>
{loginError && isSubmitted && <FormErrors errors={loginError} />}
{isLoggingIn && <ActivityIndicator color={theme.colors.neufOrange} />}
</View>
</ScrollView>
+2 -2
View File
@@ -22,7 +22,7 @@ const useLogin = () => {
const {
control,
handleSubmit,
formState: { errors },
formState: { errors, isSubmitted },
setFocus,
} = useForm<LoginFormValues>();
@@ -37,7 +37,7 @@ const useLogin = () => {
}
}, [isAuthenticated, navigation]);
return { onSubmit, isLoggingIn, setFocus, control, errors: { ...errors, ...loginError } };
return { onSubmit, isLoggingIn, isSubmitted, setFocus, control, errors: { ...errors }, loginError };
};
export default useLogin;