Skip to content

Commit dff44b0

Browse files
committed
link members sidebar to members page
1 parent 08055ca commit dff44b0

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

src/app/organizations/[id]/members/layout.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import "@/styles/globals.css";
33
import { siteConfig } from "@/site.config.ts";
44

55
import { SiteHeader } from "@/components/ui/site-header";
6+
import { AppSidebar } from "@/components/ui/app-sidebar";
7+
import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";
68
export const metadata: Metadata = {
79
title: siteConfig.name,
810
description: "Manage coaching members",
@@ -14,11 +16,14 @@ export default function MembersLayout({
1416
children: React.ReactNode;
1517
}>) {
1618
return (
17-
// Ensure that SiteHeader has enough vertical space to stay sticky at the top
18-
// of the page by using "min-h-screen" in the parent div
19-
<div className="min-h-screen">
20-
<SiteHeader />
21-
<main>{children}</main>
22-
</div>
19+
<SidebarProvider>
20+
<div className="flex min-h-screen min-w-full">
21+
<AppSidebar />
22+
<SidebarInset>
23+
<SiteHeader />
24+
<main className="flex-1 p-6">{children}</main>
25+
</SidebarInset>
26+
</div>
27+
</SidebarProvider>
2328
);
2429
}

src/components/ui/app-sidebar.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
SidebarRail,
2121
SidebarSeparator,
2222
} from "@/components/ui/sidebar";
23+
import { useOrganizationStateStore } from "@/lib/providers/organization-state-store-provider";
2324

2425
// Custom styles for menu buttons to ensure consistent centering
2526
const menuButtonStyles = {
@@ -30,6 +31,8 @@ const menuButtonStyles = {
3031
};
3132

3233
export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
34+
const { currentOrganizationId } = useOrganizationStateStore((state) => state);
35+
3336
return (
3437
<Sidebar collapsible="icon" {...props}>
3538
<SidebarHeader className="h-16 flex flex-col justify-between pb-0">
@@ -101,7 +104,7 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
101104
menuButtonStyles.buttonCollapsed
102105
)}
103106
>
104-
<a href="/members">
107+
<a href={`/organizations/${currentOrganizationId}/members`}>
105108
<span className={menuButtonStyles.iconWrapper}>
106109
<Users className="h-4 w-4" />
107110
</span>

src/components/ui/organization-selector.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,17 @@ function OrganizationsList({ userId }: { userId: Id }) {
3030

3131
// Be sure to cache the list of current organizations in the OrganizationStateStore
3232
useEffect(() => {
33-
if (!organizations.length) return;
33+
if (!organizations?.length) return;
3434
console.debug(
3535
`organizations (useEffect): ${JSON.stringify(organizations)}`
3636
);
3737
setCurrentOrganizations(organizations);
38-
}, [organizations]);
38+
}, [organizations, setCurrentOrganizations]);
3939

4040
if (isLoading) return <div>Loading...</div>;
4141
if (isError) return <div>Error loading organizations</div>;
4242
if (!organizations?.length) return <div>No organizations found</div>;
4343

44-
console.debug(`organizations: ${JSON.stringify(organizations)}`);
45-
4644
return (
4745
<>
4846
{organizations.map((org) => (
@@ -61,7 +59,7 @@ export default function OrganizationSelector({
6159
}: OrganizationSelectorProps) {
6260
const {
6361
currentOrganizationId,
64-
setCurrentOrganizationId,
62+
setCurrentOrganization,
6563
getCurrentOrganization,
6664
} = useOrganizationStateStore((state) => state);
6765
const { resetCoachingSessionState } = useCoachingSessionStateStore(
@@ -72,7 +70,8 @@ export default function OrganizationSelector({
7270
);
7371

7472
const handleSetOrganization = (organizationId: Id) => {
75-
setCurrentOrganizationId(organizationId);
73+
const organization = getCurrentOrganization(organizationId);
74+
setCurrentOrganization(organization);
7675
console.info("Resetting Coaching Session State");
7776
resetCoachingRelationshipState();
7877
resetCoachingSessionState();

0 commit comments

Comments
 (0)