Skip to content

Commit

Permalink
feat: [P4PU-435] Call service logout (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
vito80ba authored Sep 13, 2024
2 parents 98b07d0 + 89e0c2b commit fe4860e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ export const Header = (props: HeaderProps) => {
const { onAssistanceClick = () => null } = props;
const navigate = useNavigate();

const logout = () => sessionClear(() => navigate(ArcRoutes.LOGIN));
async function logoutUser() {
try {
await utils.apiClient.logout.getLogoutEndpoint();
} catch (e) {
console.warn(e);
} finally {
sessionClear(() => navigate(ArcRoutes.LOGIN));
}
}

const { userInfo } = useUserInfo();

Expand All @@ -50,7 +58,7 @@ export const Header = (props: HeaderProps) => {
{
id: 'logout',
label: 'Esci',
onClick: logout,
onClick: logoutUser,
icon: <LogoutRoundedIcon fontSize="small" color="inherit" />
}
];
Expand Down

0 comments on commit fe4860e

Please sign in to comment.