Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 356x 42x 116x 116x 42x 42x 42x 7x 42x 35x 7x | import { ReactElement, useEffect } from "react";
import { Navigate } from "react-router";
import { submitLogout } from "client/views/logout/logoutActions";
import { useAppDispatch, useAppSelector } from "client/utils/hooks";
import { postKompassiLogoutRedirect } from "client/services/loginServices";
import { Loading } from "client/components/Loading";
import { UserGroup } from "shared/types/models/user";
import { AppRoute } from "client/app/AppRoutes";
export const LogoutView = (): ReactElement => {
const dispatch = useAppDispatch();
const userGroup = useAppSelector((state) => state.login.userGroup);
const kompassiId = useAppSelector((state) => state.login.kompassiId);
const isLocalLogin = !kompassiId;
useEffect(() => {
const doKompassiLogout = async (): Promise<void> => {
await postKompassiLogoutRedirect();
};
if (isLocalLogin || userGroup === UserGroup.ADMIN) {
dispatch(submitLogout());
} else {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
doKompassiLogout();
}
}, [dispatch, isLocalLogin, userGroup]);
return (
<>
{isLocalLogin && <Navigate to={AppRoute.PROGRAM} replace />}
{!isLocalLogin && <Loading />}
</>
);
};
|