diff --git a/.gitignore b/.gitignore index e2e7e91e2..7350d5784 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ supabase.sh **/.vercel/ **/.DS_Store **/.env* +tests/ # **/.npmrc **/test.nnb diff --git a/frontend/src/views/onboarding/OnboardingView.tsx b/frontend/src/views/onboarding/OnboardingView.tsx index 7da28e268..6e43dd99d 100644 --- a/frontend/src/views/onboarding/OnboardingView.tsx +++ b/frontend/src/views/onboarding/OnboardingView.tsx @@ -6,11 +6,7 @@ import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; import { slugify } from "@/utils/formatUtils/formatTextUtils"; import { CustomToaster } from "@/components/general/CustomToaster"; -import { useAxiosInstance } from "@/services/useAxiosInstance"; -import { OrgService } from "@/services/OrgService"; import { toast } from "react-hot-toast"; -import { getBackendErr } from "@/utils/genUtils"; -import { AppEnv } from "@autumn/shared"; import { OrganizationList, OrganizationSwitcher, @@ -97,7 +93,12 @@ function OnboardingView({ sessionClaims }: { sessionClaims: any }) { ); - } else return ; + } else + return ( +
+ +
+ ); } export default OnboardingView; diff --git a/frontend/src/views/sidebar/SidebarTop.tsx b/frontend/src/views/sidebar/SidebarTop.tsx index 514d62553..783e0b20c 100644 --- a/frontend/src/views/sidebar/SidebarTop.tsx +++ b/frontend/src/views/sidebar/SidebarTop.tsx @@ -5,9 +5,26 @@ import { Avatar, cn } from "@nextui-org/react"; import { Button } from "@/components/ui/button"; import { ChevronLeft, ChevronRight } from "lucide-react"; import { AppEnv } from "@autumn/shared"; +import { OrganizationSwitcher, useOrganization } from "@clerk/nextjs"; +import React, { useEffect, useState } from "react"; +import { useRouter } from "next/navigation"; export function SidebarTop({ orgName, env }: { orgName: string; env: AppEnv }) { const { state, toggleSidebar } = useSidebar(); + const { organization, isLoaded } = useOrganization(); + const router = useRouter(); + const [curOrgId, setCurOrgId] = useState(null); + + useEffect(() => { + if (organization) { + setCurOrgId(organization.id); + } + + if (curOrgId !== null && organization?.id !== curOrgId) { + window.location.href = "/sandbox/customers"; + router.refresh(); + } + }, [organization]); return ( @@ -18,15 +35,36 @@ export function SidebarTop({ orgName, env }: { orgName: string; env: AppEnv }) { )} > {state == "expanded" && ( -
- -

{orgName}

-
+ + {isLoaded ? ( + { + // console.log(organization); + // router.refresh(); + // }} + /> + ) : ( +
+ +

{orgName}

+
+ )} +
)}