| 1 | import Link from "next/link"; |
| 2 | import { notFound, redirect |
| 3 | |
| 4 | import { AppHeader } |
| 5 | import { SettingsNav } |
| 6 | import { Avatar, AvatarFallback |
| 7 | import { |
| 8 | createServerClient, |
| 9 | getAdminOrganizations, |
| 10 | getServerSession, |
| 11 | } from "@/lib/api/server"; |
| 12 | |
| 13 | /** An organization's settings, for its admins; everyone else has its profile at `/<slug>`. A user's settings live at `/settings`, so a username here goes there. */ |
| 14 | export default async function |
| 15 | params, |
| 16 | children, |
| 17 | }: LayoutProps< |
| 18 | const { username: |
| 19 | const [session, |
| 20 | getServerSession(), |
| 21 | createServerClient(), |
| 22 | ]); |
| 23 | const viewer = |
| 24 | if (!viewer) |
| 25 | redirect( |
| 26 | `/auth/sign-in?redirectTo=${encodeURIComponent(`/ |
| 27 | ); |
| 28 | } |
| 29 | |
| 30 | const [profile, |
| 31 | client.GET("/api/organizations/{slug} |
| 32 | getAdminOrganizations(), |
| 33 | ]); |
| 34 | if (!profile.data |
| 35 | if (slug === |
| 36 | notFound(); |
| 37 | } |
| 38 | if (!administered.includes |
| 39 | |
| 40 | const base = |
| 41 | return ( |
| 42 | <div className="flex min-h-full flex-col |
| 43 | <AppHeader username={ |
| 44 | <main className="mx-auto flex w-full max-w-6xl flex-1 flex-col gap-8 px-4 py-8 md:px-6 |
| 45 | <div className="flex items-center gap-3 |
| 46 | <Avatar className=" |
| 47 | <AvatarImage src={ |
| 48 | <AvatarFallback>{slug. |
| 49 | </Avatar> |
| 50 | <div className="flex flex-col |
| 51 | <h1 className="text-xl font-semibold |
| 52 | <Link |
| 53 | href={`/${slug |
| 54 | className="text-sm text-muted-foreground hover:underline" |
| 55 | > |
| 56 | View profile |
| 57 | </Link> |
| 58 | </div> |
| 59 | </div> |
| 60 | |
| 61 | <div className="grid gap-6 md:grid-cols-[200px_minmax(0,1fr)] md:gap-10 |
| 62 | <SettingsNav |
| 63 | label="Organization settings" |
| 64 | links={[ |
| 65 | { href: base, |
| 66 | { href: `${base |
| 67 | { href: `${base |
| 68 | { |
| 69 | href: `${base} |
| 70 | label: "Outside collaborators", |
| 71 | icon: "outside", |
| 72 | }, |
| 73 | { href: `${base |
| 74 | ]} |
| 75 | /> |
| 76 | <div className="min-w-0 max-w-3xl |
| 77 | </div> |
| 78 | </main> |
| 79 | </div> |
| 80 | ); |
| 81 | } |