user changed notification
parent
2d53a734d4
commit
a134c36553
|
@ -22,6 +22,7 @@
|
|||
"Password": "Password",
|
||||
"Label": "Login",
|
||||
"ChangeUser": "Change user",
|
||||
"UserChanged": "User changed",
|
||||
"Logout": "Logout",
|
||||
"IncorrectCredentials": "Incorrect credentials.",
|
||||
"Hello": "Hi, {{username}}",
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
"Password": "Parolă",
|
||||
"Label": "Autentificare",
|
||||
"ChangeUser": "Schimbă utilizatorul",
|
||||
"UserChanged": "Utilizator schimbat",
|
||||
"Logout": "Deconectare",
|
||||
"IncorrectCredentials": "Credențiale incorecte.",
|
||||
"Hello": "Salut, {{username}}",
|
||||
|
|
|
@ -16,6 +16,7 @@ import {
|
|||
import { AccountBox, RotateLeft, ExitToApp } from "@material-ui/icons";
|
||||
import LoginComponent from "./LoginComponent";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useToast } from "../../../hooks";
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
card: {
|
||||
|
@ -42,6 +43,7 @@ const LoggedInComponent = ({
|
|||
const classes = useStyles();
|
||||
const { t } = useTranslation();
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
const { info } = useToast();
|
||||
|
||||
const handleExpandLogin = () => {
|
||||
setExpanded(!expanded);
|
||||
|
@ -58,6 +60,14 @@ const LoggedInComponent = ({
|
|||
return "N/A";
|
||||
}, [token, t]);
|
||||
|
||||
const handleLogin = async () => {
|
||||
const result = await onLogin();
|
||||
if (result) {
|
||||
setExpanded(false);
|
||||
info(t("Login.UserChanged"));
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Card className={classes.card}>
|
||||
<CardHeader
|
||||
|
@ -107,7 +117,7 @@ const LoggedInComponent = ({
|
|||
<LoginComponent
|
||||
credentials={credentials}
|
||||
onChange={onChange}
|
||||
onLogin={onLogin}
|
||||
onLogin={handleLogin}
|
||||
/>
|
||||
</CardContent>
|
||||
</Collapse>
|
||||
|
|
|
@ -27,6 +27,7 @@ const LoginContainer = () => {
|
|||
const response = await authenticate(userName, password);
|
||||
if (response.status === "SUCCESS") {
|
||||
dispatchActions.onAuthorizationTokenChange(response.token);
|
||||
return response.token;
|
||||
} else if (response.status === "BAD_CREDENTIALS") {
|
||||
error(t("Login.IncorrectCredentials"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue