Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ import { Outlet, useLocation, useNavigate } from 'react-router-dom';

import { AxiosError } from 'axios';

import { useFeatureAvailability } from '@ovh-ux/manager-react-components';

import { SkeletonLoading } from '@/components/Loading/SkeletonLoading';
import { PageLayout } from '@/components/PageLayout/PageLayout.component';
import { SessionModals } from '@/context/User/modals/SessionModals';
import { useProcedures } from '@/data/hooks/useProcedures';
import { createRoutePath, errorRoutePath, seeRoutePath } from '@/routes/mfa.constants';
import {
BETA_MANAGER_MFA_DISABLE,
createRoutePath,
errorRoutePath,
seeRoutePath,
} from '@/routes/mfa.constants';
import { accountDisable2faRoute } from '@/routes/routes';
import { Status2fa } from '@/types/status.type';

Expand All @@ -26,6 +33,19 @@ export default function DisableMFA() {
const navigate = useNavigate();
const location = useLocation();

const { data: availability, isLoading: isFeatureLoading } = useFeatureAvailability([
BETA_MANAGER_MFA_DISABLE,
]);
const isBetaManagerMfaDisableAvailable =
availability?.[BETA_MANAGER_MFA_DISABLE] ?? false;

useEffect(() => {
if (isBetaManagerMfaDisableAvailable) {
const betaUrl = `/beta/#/procedures${location.pathname}${location.search}`;
window.location.assign(betaUrl);
}
}, [isBetaManagerMfaDisableAvailable, location.pathname, location.search]);

const navigateTo = (url: string): void => {
if (location.pathname !== url) {
// To avoid redirecting user to the login page after navigating to another view,
Expand All @@ -51,6 +71,14 @@ export default function DisableMFA() {
}
}, [isFetched]);

if (isFeatureLoading || isBetaManagerMfaDisableAvailable) {
return (
<PageLayout>
<SkeletonLoading />
</PageLayout>
);
}

return (
<>
<PageLayout>{isLoading ? <SkeletonLoading /> : <Outlet />}</PageLayout>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const createRoutePath = 'create';
export const seeRoutePath = 'see';
export const errorRoutePath = 'error';
export const BETA_MANAGER_MFA_DISABLE = 'procedures:beta-mfa-disable';
Loading