import { getRepos, getReposStats } from "@/actions"; import { SourcebotLogo } from "@/app/components/sourcebotLogo"; import { auth } from "@/auth"; import { Button } from "@/components/ui/button"; import { NavigationMenu as NavigationMenuBase } from "@/components/ui/navigation-menu"; import { Separator } from "@/components/ui/separator"; import { getSubscriptionInfo } from "@/ee/features/billing/actions"; import { IS_BILLING_ENABLED } from "@/ee/features/billing/stripe"; import { env } from "@/env.mjs"; import { ServiceErrorException } from "@/lib/serviceError"; import { isServiceError } from "@/lib/utils"; import { DiscordLogoIcon, GitHubLogoIcon } from "@radix-ui/react-icons"; import { RepoIndexingJobStatus, RepoIndexingJobType } from "@sourcebot/db"; import Link from "next/link"; import { redirect } from "next/navigation"; import { OrgSelector } from "../orgSelector"; import { SettingsDropdown } from "../settingsDropdown"; import WhatsNewIndicator from "../whatsNewIndicator"; import { NavigationItems } from "./navigationItems"; import { ProgressIndicator } from "./progressIndicator"; import { TrialIndicator } from "./trialIndicator"; const SOURCEBOT_DISCORD_URL = "https://discord.gg/6Fhp27x7Pb"; const SOURCEBOT_GITHUB_URL = "https://github.com/sourcebot-dev/sourcebot"; interface NavigationMenuProps { domain: string; } export const NavigationMenu = async ({ domain, }: NavigationMenuProps) => { const subscription = IS_BILLING_ENABLED ? await getSubscriptionInfo(domain) : null; const session = await auth(); const isAuthenticated = session?.user !== undefined; const repoStats = await getReposStats(); if (isServiceError(repoStats)) { throw new ServiceErrorException(repoStats); } const sampleRepos = await getRepos({ where: { jobs: { some: { type: RepoIndexingJobType.INDEX, status: { in: [ RepoIndexingJobStatus.PENDING, RepoIndexingJobStatus.IN_PROGRESS, ] } }, }, indexedAt: null, }, take: 5, }); if (isServiceError(sampleRepos)) { throw new ServiceErrorException(sampleRepos); } const { numberOfRepos, numberOfReposWithFirstTimeIndexingJobsInProgress, } = repoStats; return (