mirror of
https://github.com/fosrl/pangolin.git
synced 2026-07-06 20:29:50 +00:00
redirect to settings if org admin
This commit is contained in:
@@ -107,7 +107,15 @@ export default async function Page(props: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (targetOrgId) {
|
if (targetOrgId) {
|
||||||
return <RedirectToOrg targetOrgId={targetOrgId} />;
|
const targetOrg = orgs.find((org) => org.orgId === targetOrgId);
|
||||||
|
return (
|
||||||
|
<RedirectToOrg
|
||||||
|
targetOrgId={targetOrgId}
|
||||||
|
isAdminOrOwner={Boolean(
|
||||||
|
targetOrg?.isAdmin || targetOrg?.isOwner
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -6,20 +6,29 @@ import { getInternalRedirectTarget } from "@app/lib/internalRedirect";
|
|||||||
|
|
||||||
type RedirectToOrgProps = {
|
type RedirectToOrgProps = {
|
||||||
targetOrgId: string;
|
targetOrgId: string;
|
||||||
|
isAdminOrOwner?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function RedirectToOrg({ targetOrgId }: RedirectToOrgProps) {
|
export default function RedirectToOrg({
|
||||||
|
targetOrgId,
|
||||||
|
isAdminOrOwner = false
|
||||||
|
}: RedirectToOrgProps) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
try {
|
try {
|
||||||
const target =
|
const target =
|
||||||
getInternalRedirectTarget(targetOrgId) ?? `/${targetOrgId}`;
|
getInternalRedirectTarget(targetOrgId) ??
|
||||||
|
(isAdminOrOwner
|
||||||
|
? `/${targetOrgId}/settings`
|
||||||
|
: `/${targetOrgId}`);
|
||||||
router.replace(target);
|
router.replace(target);
|
||||||
} catch {
|
} catch {
|
||||||
router.replace(`/${targetOrgId}`);
|
router.replace(
|
||||||
|
isAdminOrOwner ? `/${targetOrgId}/settings` : `/${targetOrgId}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}, [targetOrgId, router]);
|
}, [targetOrgId, isAdminOrOwner, router]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user