"use client"; import { Button } from "@app/components/ui/button"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator } from "@app/components/ui/command"; import { Popover, PopoverContent, PopoverTrigger } from "@app/components/ui/popover"; import { useEnvContext } from "@app/hooks/useEnvContext"; import { cn } from "@app/lib/cn"; import { ListUserOrgsResponse } from "@server/routers/org"; import { Check, ChevronsUpDown, Plus } from "lucide-react"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { useUserContext } from "@app/hooks/useUserContext"; import { useTranslations } from "next-intl"; interface OrgSelectorProps { orgId?: string; orgs?: ListUserOrgsResponse["orgs"]; } export function OrgSelector({ orgId, orgs }: OrgSelectorProps) { const { user } = useUserContext(); const [open, setOpen] = useState(false); const router = useRouter(); const { env } = useEnvContext(); const t = useTranslations(); return ( {t('orgNotFound2')} {(!env.flags.disableUserCreateOrg || user.serverAdmin) && ( <> { router.push( "/setup" ); }} > {t('setupNewOrg')} )} {orgs?.map((org) => ( { router.push( `/${org.orgId}/settings` ); }} > {org.name} ))} ); }