error notification
parent
3580b7fac0
commit
f58357c10e
|
@ -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();
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue