Commit 216da516 by G

showing a basic error message when authentication is a failure

parent e9fa692c
...@@ -22,6 +22,7 @@ const UserLoginScreen: UnloggedUserStackScreenComponentProps<"userLoginScreen"> ...@@ -22,6 +22,7 @@ const UserLoginScreen: UnloggedUserStackScreenComponentProps<"userLoginScreen">
const [email, setEmail] = useState(""); const [email, setEmail] = useState("");
const [password, setPassword] = useState(""); const [password, setPassword] = useState("");
const [error, setError] = useState("");
const authenticationMutation = useMutation({ const authenticationMutation = useMutation({
mutationFn: authenticateUser, mutationFn: authenticateUser,
...@@ -30,7 +31,11 @@ const UserLoginScreen: UnloggedUserStackScreenComponentProps<"userLoginScreen"> ...@@ -30,7 +31,11 @@ const UserLoginScreen: UnloggedUserStackScreenComponentProps<"userLoginScreen">
navigation.navigate("bottomTabs"); navigation.navigate("bottomTabs");
}, },
onError: (error) => { onError: (error) => {
console.error("error :: ", error); console.error("error :: ", error.response.data);
if (error.response.status === 400) {
return setError("Bad request");
}
setError(error.response.data.detail);
}, },
}); });
...@@ -77,6 +82,7 @@ const UserLoginScreen: UnloggedUserStackScreenComponentProps<"userLoginScreen"> ...@@ -77,6 +82,7 @@ const UserLoginScreen: UnloggedUserStackScreenComponentProps<"userLoginScreen">
<Input <Input
label="Email" label="Email"
// value={email} // value={email}
autoCorrect={false}
textContentType="emailAddress" textContentType="emailAddress"
onChangeText={setEmail} onChangeText={setEmail}
/> />
...@@ -89,6 +95,11 @@ const UserLoginScreen: UnloggedUserStackScreenComponentProps<"userLoginScreen"> ...@@ -89,6 +95,11 @@ const UserLoginScreen: UnloggedUserStackScreenComponentProps<"userLoginScreen">
/> />
</Box> </Box>
</Box> </Box>
{error && (
<Text variant={"error"} textAlign={"center"}>
{error}
</Text>
)}
<Box p={"s"}> <Box p={"s"}>
<Button <Button
variant={"full"} variant={"full"}
......
...@@ -15,6 +15,8 @@ const palette = { ...@@ -15,6 +15,8 @@ const palette = {
lightGray: "#F4F5F7", lightGray: "#F4F5F7",
gray: "#747E98", gray: "#747E98",
yellow: "#F4C44A", yellow: "#F4C44A",
red: "#FF0000",
}; };
const theme = createTheme({ const theme = createTheme({
...@@ -27,6 +29,7 @@ const theme = createTheme({ ...@@ -27,6 +29,7 @@ const theme = createTheme({
lightGray: palette.lightGray, lightGray: palette.lightGray,
gray: palette.gray, gray: palette.gray,
yellow: palette.yellow, yellow: palette.yellow,
red: palette.red,
}, },
spacing: { spacing: {
s: 8, s: 8,
...@@ -82,6 +85,9 @@ const theme = createTheme({ ...@@ -82,6 +85,9 @@ const theme = createTheme({
lightGray: { lightGray: {
color: "lightGray", color: "lightGray",
}, },
error: {
color: "red",
},
}, },
cardVariants: { cardVariants: {
defaults: { defaults: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment