2026-10-09 08:18:00 +00:00
|
|
|
import { navigateTo, useBrowserLocation } from "@metis/core/client";
|
|
|
|
|
import type { SessionResponseDTO } from "@metis/identity/common";
|
|
|
|
|
import { useEffect } from "react";
|
|
|
|
|
|
|
|
|
|
import { appRedirect } from "./app-redirect";
|
|
|
|
|
|
|
|
|
|
export function useAppNavigation(session: SessionResponseDTO | undefined) {
|
|
|
|
|
const location = useBrowserLocation();
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-09 08:18:00 +00:00
|
|
|
useEffect(() => {
|
|
|
|
|
if (!session) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const destination = appRedirect(location, session);
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-09 08:18:00 +00:00
|
|
|
if (destination) {
|
|
|
|
|
navigateTo(destination, { replace: true });
|
|
|
|
|
}
|
|
|
|
|
}, [location, session]);
|
|
|
|
|
}
|