import { useLocation } from '@tanstack/react-router' import { cn } from 'ui' import { PageContainer } from 'ui-patterns/PageContainer' import { PageHeader, PageHeaderMeta, PageHeaderSummary, PageHeaderTitle, } from 'ui-patterns/PageHeader' import { PageSection } from 'ui-patterns/PageSection' import { Header, LoadingCardView, NoOrganizationsState, } from '@/components/interfaces/Home/ProjectList/EmptyStates' import { buildOrgUrl } from '@/components/interfaces/Organization/Organization.utils' import { OrganizationCard } from '@/components/interfaces/Organization/OrganizationCard' import { useOrganizationsQuery } from '@/data/organizations/organizations-query' import { useCustomContent } from '@/hooks/custom-content/useCustomContent' import { withAuth } from '@/hooks/misc/withAuth' import { buildStudioPageTitle } from '@/lib/page-title' function SelectOrganization() { const { pathname, searchStr, hash } = useLocation() // `/org/_/billing` → ['billing']; the splat route nests under the `/org/_` route, // which renders this page, so the trailing path is read from the location const trailingSegments = pathname .replace(/^\/org\/_\/?/, '') .split('/') .filter(Boolean) const routeSlug = trailingSegments.length > 0 ? trailingSegments : undefined const { appTitle } = useCustomContent(['app:title']) const queryString = searchStr.replace(/^\?/, '') const { data: organizations, isPending: isLoading } = useOrganizationsQuery() const pageTitle = buildStudioPageTitle({ section: 'Select an organization', surface: 'Organizations', brand: appTitle || 'Supabase', }) return ( <> {pageTitle}
Select an organization to continue
{isLoading ? ( ) : organizations?.length === 0 ? ( ) : (
    {organizations?.map((org) => ( ))}
)}
) } export const SelectOrganizationPage = withAuth(SelectOrganization)