error notification

main
alex 2023-04-20 19:31:04 +02:00
parent 3580b7fac0
commit f58357c10e
1 changed files with 13 additions and 5 deletions

View File

@ -10,7 +10,19 @@ export default function Login({ setUserSession }) {
const [password, setPassword] = useState("");
const [api, contextHolder] = notification.useNotification();
const showErrorNotification = () => {
api["error"]({
message: "Login Failed!",
description: "Please check your username and password!",
});
};
const handleSubmit = () => {
if (username === "" || password === "") {
showErrorNotification();
return;
}
fetch(Constants.API_ADDRESS + "/user/auth/login", {
method: "POST",
headers: { "Content-Type": "application/json" },
@ -32,11 +44,7 @@ export default function Login({ setUserSession }) {
})
.catch((err) => {
console.error(err);
api["error"]({
message: "Login Failed!",
description: "Please check your username and password!",
});
showErrorNotification();
});
};