redirect to settings if org admin

This commit is contained in:
miloschwartz
2026-07-01 14:06:33 -04:00
parent 5a7ca5b542
commit 5a1d5cb66e
2 changed files with 22 additions and 5 deletions

View File

@@ -107,7 +107,15 @@ export default async function Page(props: {
}
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 (

View File

@@ -6,20 +6,29 @@ import { getInternalRedirectTarget } from "@app/lib/internalRedirect";
type RedirectToOrgProps = {
targetOrgId: string;
isAdminOrOwner?: boolean;
};
export default function RedirectToOrg({ targetOrgId }: RedirectToOrgProps) {
export default function RedirectToOrg({
targetOrgId,
isAdminOrOwner = false
}: RedirectToOrgProps) {
const router = useRouter();
useEffect(() => {
try {
const target =
getInternalRedirectTarget(targetOrgId) ?? `/${targetOrgId}`;
getInternalRedirectTarget(targetOrgId) ??
(isAdminOrOwner
? `/${targetOrgId}/settings`
: `/${targetOrgId}`);
router.replace(target);
} catch {
router.replace(`/${targetOrgId}`);
router.replace(
isAdminOrOwner ? `/${targetOrgId}/settings` : `/${targetOrgId}`
);
}
}, [targetOrgId, router]);
}, [targetOrgId, isAdminOrOwner, router]);
return null;
}