Fix sidebar display on no org zone
Signed-off-by: Émile Ré <nemile.re@gmail.com>
This commit is contained in:
@@ -27,7 +27,6 @@ import {
|
|||||||
ToyBrick,
|
ToyBrick,
|
||||||
Users,
|
Users,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { NavMainSkeleton } from "./NavMainSkeleton";
|
|
||||||
|
|
||||||
interface NavItem {
|
interface NavItem {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -47,7 +46,7 @@ export function NavMain() {
|
|||||||
const items: NavItem[] = getNavItems(organizationId);
|
const items: NavItem[] = getNavItems(organizationId);
|
||||||
|
|
||||||
if (!organizationId) {
|
if (!organizationId) {
|
||||||
return <NavMainSkeleton />;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isItemActive = (item: { url?: string; items?: { url: string }[] }) => {
|
const isItemActive = (item: { url?: string; items?: { url: string }[] }) => {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
import { ChevronsUpDown, LogOut } from "lucide-react";
|
import { ChevronsUpDown, LogOut } from "lucide-react";
|
||||||
import { graphql, useFragment } from "react-relay";
|
import { graphql, useFragment } from "react-relay";
|
||||||
import { useParams } from "react-router";
|
|
||||||
|
|
||||||
import { Avatar, AvatarFallback } from "@/components/ui/avatar";
|
import { Avatar, AvatarFallback } from "@/components/ui/avatar";
|
||||||
import {
|
import {
|
||||||
@@ -20,7 +19,6 @@ import {
|
|||||||
useSidebar,
|
useSidebar,
|
||||||
} from "@/components/ui/sidebar";
|
} from "@/components/ui/sidebar";
|
||||||
import { NavUser_viewer$key } from "./__generated__/NavUser_viewer.graphql";
|
import { NavUser_viewer$key } from "./__generated__/NavUser_viewer.graphql";
|
||||||
import { NavUserSkeleton } from "./NavUserSkeleton";
|
|
||||||
import { buildEndpoint } from "@/utils";
|
import { buildEndpoint } from "@/utils";
|
||||||
|
|
||||||
export const navUserFragment = graphql`
|
export const navUserFragment = graphql`
|
||||||
@@ -34,7 +32,6 @@ export const navUserFragment = graphql`
|
|||||||
export function NavUser({ viewer }: { viewer: NavUser_viewer$key }) {
|
export function NavUser({ viewer }: { viewer: NavUser_viewer$key }) {
|
||||||
const { isMobile } = useSidebar();
|
const { isMobile } = useSidebar();
|
||||||
const currentUser = useFragment(navUserFragment, viewer);
|
const currentUser = useFragment(navUserFragment, viewer);
|
||||||
const { organizationId } = useParams();
|
|
||||||
|
|
||||||
const handleLogout = async () => {
|
const handleLogout = async () => {
|
||||||
fetch(buildEndpoint("/api/console/v1/auth/logout"), {
|
fetch(buildEndpoint("/api/console/v1/auth/logout"), {
|
||||||
@@ -45,10 +42,6 @@ export function NavUser({ viewer }: { viewer: NavUser_viewer$key }) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!organizationId) {
|
|
||||||
return <NavUserSkeleton />;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SidebarMenu>
|
<SidebarMenu>
|
||||||
<SidebarMenuItem>
|
<SidebarMenuItem>
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import {
|
|||||||
OrganizationSwitcher_organizations$data,
|
OrganizationSwitcher_organizations$data,
|
||||||
} from "./__generated__/OrganizationSwitcher_organizations.graphql";
|
} from "./__generated__/OrganizationSwitcher_organizations.graphql";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { OrganizationSwitcherSkeleton } from "./OrganizationSwitcherSkeleton";
|
|
||||||
|
|
||||||
export const organizationSwitcherFragment = graphql`
|
export const organizationSwitcherFragment = graphql`
|
||||||
fragment OrganizationSwitcher_organizations on User {
|
fragment OrganizationSwitcher_organizations on User {
|
||||||
@@ -95,10 +94,6 @@ export function OrganizationSwitcher({
|
|||||||
navigate(`/organizations/${org.id}`);
|
navigate(`/organizations/${org.id}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!hasOrganizations) {
|
|
||||||
return <OrganizationSwitcherSkeleton />;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SidebarMenu>
|
<SidebarMenu>
|
||||||
<SidebarMenuItem>
|
<SidebarMenuItem>
|
||||||
|
|||||||
Reference in New Issue
Block a user