Skip to content

Commit 527057f

Browse files
authored
Get rid of the early access gating (#125)
1 parent a5fd611 commit 527057f

File tree

1 file changed

+34
-23
lines changed

1 file changed

+34
-23
lines changed

apps/web/src/app/(centered)/select-org/SelectOrg.tsx

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
'use client';
22

3-
import Link from 'next/link';
4-
import { OrganizationList, useOrganizationList } from '@clerk/nextjs';
3+
import { useEffect } from 'react';
4+
import { useRouter } from 'next/navigation';
5+
import { OrganizationList, useOrganizationList, useClerk } from '@clerk/nextjs';
56
import { LoaderCircle } from 'lucide-react';
67

78
import { useAuthState } from '@/hooks/useAuthState';
8-
import { Button } from '@/components/ui';
99

1010
export const SelectOrg = () => {
1111
const authState = useAuthState();
12+
const router = useRouter();
13+
const { setActive } = useClerk();
1214

1315
const { isLoaded, userMemberships, userSuggestions, userInvitations } =
1416
useOrganizationList({
@@ -27,30 +29,39 @@ export const SelectOrg = () => {
2729
userInvitations.isLoading ||
2830
userSuggestions.isLoading;
2931

32+
// Auto-redirect if user has no organizations or exactly one organization
33+
useEffect(() => {
34+
if (isLoaded) {
35+
const membershipCount = userMemberships.data?.length || 0;
36+
37+
if (membershipCount === 0) {
38+
// No organizations - redirect directly
39+
router.push(redirectUrl);
40+
} else if (membershipCount === 1) {
41+
// One organization - set it as active and redirect
42+
const singleOrg = userMemberships.data[0];
43+
if (singleOrg) {
44+
setActive({ organization: singleOrg.organization.id })
45+
.then(() => {
46+
router.push(redirectUrl);
47+
})
48+
.catch((error: unknown) => {
49+
console.error('Failed to set active organization:', error);
50+
// If setting active org fails, fall back to showing the org list
51+
});
52+
}
53+
}
54+
}
55+
}, [isLoaded, userMemberships.data, redirectUrl, router, setActive]);
56+
3057
if (isLoading) {
3158
return <LoaderCircle className="animate-spin" />;
3259
}
3360

34-
const isBlocked =
35-
userMemberships.count === 0 &&
36-
userInvitations.count === 0 &&
37-
userSuggestions.count === 0;
38-
39-
if (isBlocked) {
40-
return (
41-
<div className="flex flex-row items-center gap-2">
42-
<div className="flex flex-col gap-2 items-center">
43-
<div>Roo Code Cloud is in closed beta.</div>
44-
<div>
45-
<Button asChild>
46-
<Link href="https://roocode.com/enterprise#contact">
47-
Request Early Access
48-
</Link>
49-
</Button>
50-
</div>
51-
</div>
52-
</div>
53-
);
61+
// If user has 0 or 1 organizations, show loading while redirecting
62+
const membershipCount = userMemberships.data?.length || 0;
63+
if (membershipCount === 0 || membershipCount === 1) {
64+
return <LoaderCircle className="animate-spin" />;
5465
}
5566

5667
return (

0 commit comments

Comments
 (0)