mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-18 07:26:27 +00:00
25 lines
599 B
TypeScript
25 lines
599 B
TypeScript
"use client";
|
|
|
|
import { useEffect } from "react";
|
|
import { useRouter } from "next/navigation";
|
|
import { getInternalRedirectTarget } from "@app/lib/internalRedirect";
|
|
|
|
type RedirectToOrgProps = {
|
|
targetOrgId: string;
|
|
};
|
|
|
|
export default function RedirectToOrg({ targetOrgId }: RedirectToOrgProps) {
|
|
const router = useRouter();
|
|
|
|
useEffect(() => {
|
|
try {
|
|
const target = getInternalRedirectTarget(targetOrgId);
|
|
router.replace(target);
|
|
} catch {
|
|
router.replace(`/${targetOrgId}`);
|
|
}
|
|
}, [targetOrgId, router]);
|
|
|
|
return null;
|
|
}
|