import type { Metadata } from "next"; import Link from "next/link"; import { Label as MuLabel } from "@unlocalhosted/metalui"; import { leaveOrgAction } from "@/app/actions/orgs"; import { ActionButton } from "@/components/action-button"; import { GearIcon, OrganizationIcon, PlusIcon } from "@/components/icons"; import { SettingsSection } from "@/components/metal"; import { OrgInvitations } from "@/components/org-invitations"; import { ListRow } from "@/components/settings-plate"; import { Avatar, avatarUrl, Blankslate, ButtonLink, Label, PageTitle } from "@/components/ui"; import { requireViewer } from "@/lib/auth"; import { timeAgo } from "@/lib/format"; import { listInvitationsFor, listOrgsOf, ROLE_INFO } from "@/lib/orgs"; export const metadata: Metadata = { title: "Organizations" }; export default async function OrganizationsSettingsPage() { const viewer = await requireViewer("/settings/organizations"); const [memberships, invitations] = await Promise.all([listOrgsOf(viewer.id), listInvitationsFor(viewer.id)]); return (
}> New Organization } />
{invitations.length > 0 && (

Invitations · {invitations.length}

)} {memberships.map(({ org, role, joinedAt }) => ( } title={ <> {org.username} } meta={ {org.name && ( <> {org.name} ·{" "} )} Joined {timeAgo(joinedAt)} } > {role === "owner" && ( }> Settings )} Leave ))} {memberships.length === 0 && } title="You’re not a member of any organization" />}
); }