Account logout method and the latest changes published by Tuitio were implemented
parent
d07e0742f7
commit
7cd40357ab
File diff suppressed because it is too large
Load Diff
|
@ -14,7 +14,7 @@
|
|||
"private": true,
|
||||
"dependencies": {
|
||||
"@flare/js-utils": "^1.0.3",
|
||||
"@flare/tuitio-client-react": "^1.0.1",
|
||||
"@flare/tuitio-client-react": "^1.1.1",
|
||||
"@material-ui/core": "^4.11.2",
|
||||
"@material-ui/icons": "^4.11.2",
|
||||
"axios": "^1.3.4",
|
||||
|
|
|
@ -3,10 +3,16 @@ import { IconButton, Menu, MenuItem } from "@material-ui/core";
|
|||
import AccountCircle from "@material-ui/icons/AccountCircle";
|
||||
import { useHistory } from "react-router-dom";
|
||||
import { useTuitioClient } from "@flare/tuitio-client-react";
|
||||
import { useToast } from "../../hooks";
|
||||
|
||||
const ProfileButton = () => {
|
||||
const history = useHistory();
|
||||
const { logout } = useTuitioClient();
|
||||
const { error } = useToast();
|
||||
|
||||
const { logout } = useTuitioClient({
|
||||
onLogoutFailed: errorMessage => error(errorMessage),
|
||||
onLogoutError: err => error(err.message)
|
||||
});
|
||||
|
||||
const [anchorEl, setAnchorEl] = useState(null);
|
||||
const openUserMenu = Boolean(anchorEl);
|
||||
|
@ -53,7 +59,7 @@ const ProfileButton = () => {
|
|||
>
|
||||
Profile
|
||||
</MenuItem>
|
||||
<MenuItem onClick={() => logout()}>Logout</MenuItem>
|
||||
<MenuItem onClick={logout}>Logout</MenuItem>
|
||||
</Menu>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -27,20 +27,16 @@ const LoggedInComponent = ({ credentials, onChange, onLogin, onLogout }) => {
|
|||
const { t } = useTranslation();
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
const { info } = useToast();
|
||||
const { lastLoginDate, userName } = useTuitioUser();
|
||||
const { userName } = useTuitioUser();
|
||||
|
||||
const handleExpandLogin = () => {
|
||||
setExpanded(!expanded);
|
||||
};
|
||||
|
||||
const loginDate = useMemo(() => {
|
||||
if (lastLoginDate) {
|
||||
const valueForDisplay = t("LONG_DATE", { date: lastLoginDate });
|
||||
return valueForDisplay;
|
||||
}
|
||||
|
||||
return "N/A";
|
||||
}, [lastLoginDate, t]);
|
||||
const valueForDisplay = t("LONG_DATE", { date: new Date() });
|
||||
return valueForDisplay;
|
||||
}, [t]);
|
||||
|
||||
const handleLogin = async () => {
|
||||
const result = await onLogin();
|
||||
|
|
|
@ -8,7 +8,7 @@ function getHeaders() {
|
|||
|
||||
return {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Basic ${token.raw}`,
|
||||
Authorization: `Tuitio ${token}`,
|
||||
"Accept-Language": `${language}`
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue