From c3029711eb6b31e497eb006259f059e181c76e6a Mon Sep 17 00:00:00 2001 From: talksik Date: Tue, 14 Apr 2026 15:11:43 -0700 Subject: [PATCH] tweak network settings better hierarchy --- js/src/features/network-settings.tsx | 168 +++++++++++++++++++-------- 1 file changed, 119 insertions(+), 49 deletions(-) diff --git a/js/src/features/network-settings.tsx b/js/src/features/network-settings.tsx index e98d30b..f44ddbf 100644 --- a/js/src/features/network-settings.tsx +++ b/js/src/features/network-settings.tsx @@ -1,6 +1,6 @@ -import { useCallback, useEffect, useRef, useState } from "react"; -import { useNavigate, useParams } from "react-router-dom"; -import { ArrowLeft, Mail, Shield, X } from "lucide-react"; +import { useEffect, useRef, useState } from "react"; +import { useNavigate, useParams, useSearchParams } from "react-router-dom"; +import { ArrowLeft, CreditCard, Mail, Shield, Users, X } from "lucide-react"; import { toast } from "sonner"; import { Avatar, AvatarFallback } from "@/components/ui/avatar"; import { Badge } from "@/components/ui/badge"; @@ -20,13 +20,7 @@ import { useAuthStore } from "@/stores/auth-store"; import { BillingSection } from "@/features/network-billing"; import type { Human } from "@/api/types"; -function MemberRow({ - human, - isAdmin, -}: { - human: Human; - isAdmin: boolean; -}) { +function MemberRow({ human, isAdmin }: { human: Human; isAdmin: boolean }) { const initials = human.email_prefix.slice(0, 2).toUpperCase(); return ( @@ -74,7 +68,7 @@ function InviteForm({ networkId }: { networkId: string }) {
setEmail(e.target.value)} className="flex-1" @@ -112,7 +106,7 @@ function PendingInvitationRow({ return (
- +
@@ -132,33 +126,63 @@ function PendingInvitationRow({ ); } -function SettingsGroup({ +function SectionHeader({ + icon, title, - children, + description, + trailing, }: { + icon: React.ReactNode; title: string; - children: React.ReactNode; + description?: string; + trailing?: React.ReactNode; }) { return ( -
-

- {title} -

-
{children}
+
+ + {icon} + +
+
+

{title}

+ {trailing} +
+ {description && {description}} +
); } +function Section({ children }: { children: React.ReactNode }) { + return ( +
+ {children} +
+ ); +} + export default function NetworkSettingsPage() { const navigate = useNavigate(); const { networkId } = useParams<{ networkId: string }>(); + const [searchParams] = useSearchParams(); const { data: networks } = useNetworks(); const network = networks?.find((n) => n.id === networkId); const { data: invitations } = useNetworkInvitations(networkId!); const currentUser = useAuthStore((s) => s.user); const isAdmin = currentUser?.id === network?.admin_human.id; + const billingRef = useRef(null); + + useEffect(() => { + if (searchParams.get("section") === "billing") { + billingRef.current?.scrollIntoView({ behavior: "smooth", block: "start" }); + } + }, [searchParams]); + const networkName = network?.name ?? "Network"; + const memberCount = network?.humans.length ?? 0; + const pendingCount = invitations?.length ?? 0; + const networkInitials = networkName.slice(0, 2).toUpperCase(); return (
@@ -172,18 +196,38 @@ export default function NetworkSettingsPage() { > - {networkName} + Settings
- - - +
+ + + {networkInitials} + + +
+

{networkName}

+ + {memberCount} {memberCount === 1 ? "member" : "members"} + {isAdmin ? " ยท You're an admin" : ""} + +
+
- - - +
+ } + title="Members" + description="People with access to this network." + trailing={ + + {memberCount} + + } + /> + {network?.humans.map((human, index) => (
))} - - - +
{isAdmin && network && ( - <> - - - - - - - - {invitations && invitations.length > 0 ? ( - invitations.map((inv, index) => ( +
+ } + title="Invitations" + description="Invite teammates by email. They'll get a link to join." + trailing={ + pendingCount > 0 ? ( + + {pendingCount} pending + + ) : undefined + } + /> + + + {pendingCount > 0 && ( + <> + +
+ + Pending + +
+ {invitations!.map((inv, index) => (
- {index < invitations.length - 1 && ( + {index < invitations!.length - 1 && ( )}
- )) - ) : ( -

- No pending invitations -

- )} - - + ))} + + )} +
)} + +
+
+ } + title="Billing" + description={ + isAdmin + ? "Manage your plan, seats, and payment." + : "Your network's current plan and usage." + } + /> + + +
+
+ +
);