Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Refactor organization-related components and enhance performance page title

Bill Yang334382c59586
diff --git a/client/src/api/admin/organizations.ts b/client/src/api/admin/organizations.ts
index 581c373c7..691d9c3ac 100644
--- a/client/src/api/admin/organizations.ts
+++ b/client/src/api/admin/organizations.ts
@@ -13,7 +13,7 @@ export type UserOrganization = {
role: string;
};
-export function getUserOrganizations(): Promise<UserOrganization[]> {
+function getUserOrganizations(): Promise<UserOrganization[]> {
return authedFetchWithError(`${BACKEND_URL}/user/organizations`);
}
diff --git a/client/src/app/[site]/performance/page.tsx b/client/src/app/[site]/performance/page.tsx
index db3ba443d..eed5f5d6a 100644
--- a/client/src/app/[site]/performance/page.tsx
+++ b/client/src/app/[site]/performance/page.tsx
@@ -5,8 +5,10 @@ import { PerformanceChart } from "./components/PerformanceChart";
import { PerformanceOverview } from "./components/PerformanceOverview";
import { PerformanceByDimensions } from "./components/PerformanceByDimensions";
import { DisabledOverlay } from "../../../components/DisabledOverlay";
+import { useSetPageTitle } from "../../../hooks/useSetPageTitle";
export default function PerformancePage() {
+ useSetPageTitle("Rybbit · Performance");
return (
<DisabledOverlay message="Performance">
<div className="p-2 md:p-4 max-w-[1100px] mx-auto space-y-3 ">
diff --git a/client/src/components/OrganizationInitializer.tsx b/client/src/components/OrganizationInitializer.tsx
index e37c20efd..a05345700 100644
--- a/client/src/components/OrganizationInitializer.tsx
+++ b/client/src/components/OrganizationInitializer.tsx
@@ -4,7 +4,7 @@ import { useEffect } from "react";
import { authClient } from "../lib/auth";
import { useUserOrganizations } from "../api/admin/organizations";
-export function OrganizationInitializer() {
+function OrganizationInitializerInner() {
const { data: organizations } = useUserOrganizations();
const { data: activeOrganization, isPending: isPendingActiveOrganization } =
authClient.useActiveOrganization();
@@ -23,3 +23,11 @@ export function OrganizationInitializer() {
return null; // This component doesn't render anything
}
+
+export function OrganizationInitializer() {
+ const session = authClient.useSession();
+ if (session.data?.user) {
+ return <OrganizationInitializerInner />;
+ }
+ return null;
+}
diff --git a/client/src/components/OrganizationSelector.tsx b/client/src/components/OrganizationSelector.tsx
index 0d18b1485..f0b9b534b 100644
--- a/client/src/components/OrganizationSelector.tsx
+++ b/client/src/components/OrganizationSelector.tsx
@@ -11,7 +11,8 @@ import {
import { useUserOrganizations } from "../api/admin/organizations";
export function OrganizationSelector() {
- const { data: organizations } = useUserOrganizations();
+ const { data: organizations, isLoading: isLoadingOrganizations } =
+ useUserOrganizations();
const { data: activeOrganization, isPending } =
authClient.useActiveOrganization();
@@ -34,6 +35,16 @@ export function OrganizationSelector() {
});
};
+ if (!isLoadingOrganizations && organizations?.length === 0) {
+ return (
+ <Select disabled>
+ <SelectTrigger className="w-full">
+ <SelectValue placeholder={"No organizations"} />
+ </SelectTrigger>
+ </Select>
+ );
+ }
+
// Show placeholder when loading or no active organization
if (isPending || !activeOrganization) {
return (