| 1 | import { BookLock, BookMarked, UsersRound } from "lucide-react"; |
| 2 | import Link from "next/link |
| 3 | import { notFound } |
| 4 | |
| 5 | import { AppHeader } |
| 6 | import { TeamMembers } |
| 7 | import { Badge } |
| 8 | import { Card } |
| 9 | import { |
| 10 | createServerClient, |
| 11 | getAdminOrganizations, |
| 12 | getServerSession, |
| 13 | } from "@/lib/api/server"; |
| 14 | import { roleLabels } |
| 15 | |
| 16 | /** A team's page: who is on it and which repositories it reaches. Teams are for the organization's members, and the API answers anyone else with a 404. */ |
| 17 | export default async function |
| 18 | params, |
| 19 | }: PageProps< |
| 20 | const { username: |
| 21 | const [session, |
| 22 | getServerSession(), |
| 23 | createServerClient(), |
| 24 | ]); |
| 25 | const viewer = |
| 26 | if (!viewer) |
| 27 | |
| 28 | const [{ data |
| 29 | client.GET("/api/organizations/{slug}/teams/{team} |
| 30 | params: { path: { |
| 31 | }), |
| 32 | getAdminOrganizations(), |
| 33 | ]); |
| 34 | if (!data) |
| 35 | |
| 36 | return ( |
| 37 | <div className="flex min-h-full flex-col |
| 38 | <AppHeader username={ |
| 39 | <main className="mx-auto flex w-full max-w-4xl flex-1 flex-col gap-8 px-4 py-8 md:px-6 |
| 40 | <div className="flex items-center gap-3 |
| 41 | <span className="flex size-10 items-center justify-center rounded-lg border bg-muted text-muted-foreground |
| 42 | <UsersRound className=" |
| 43 | </span> |
| 44 | <div className="flex flex-col |
| 45 | <h1 className="text-xl font-semibold |
| 46 | <p className="text-sm text-muted-foreground |
| 47 | <Link href={ |
| 48 | {organization} |
| 49 | </Link>{" " |
| 50 | · mention as @{organization}/{data |
| 51 | </p> |
| 52 | </div> |
| 53 | </div> |
| 54 | |
| 55 | <section> |
| 56 | <h2 className="mb-3 text-sm font-semibold |
| 57 | Members |
| 58 | <span className="ml-2 font-normal text-muted-foreground tabular-nums |
| 59 | {data.members.length |
| 60 | </span> |
| 61 | </h2> |
| 62 | <Card className=" |
| 63 | <TeamMembers |
| 64 | organization={organization} |
| 65 | team={team} |
| 66 | isAdmin={administered.includes |
| 67 | /> |
| 68 | </Card> |
| 69 | </section> |
| 70 | |
| 71 | <section> |
| 72 | <h2 className="mb-3 text-sm font-semibold |
| 73 | Repositories |
| 74 | <span className="ml-2 font-normal text-muted-foreground tabular-nums |
| 75 | {data.repositories.length |
| 76 | </span> |
| 77 | </h2> |
| 78 | {data.repositories.length |
| 79 | <p className="rounded-lg border border-dashed p-4 text-sm text-muted-foreground |
| 80 | This team has no repositories yet. Admins grant access from a |
| 81 | repository's Access settings. |
| 82 | </p> |
| 83 | ) : ( |
| 84 | <ul className="divide-y rounded-lg border |
| 85 | {data.repositories.map |
| 86 | const Icon = |
| 87 | repository.visibility === |
| 88 | return ( |
| 89 | <li |
| 90 | key={repository.slug |
| 91 | className="flex items-center gap-3 px-4 py-3 text-sm" |
| 92 | > |
| 93 | <Icon className=" |
| 94 | <Link |
| 95 | href={`/${organization |
| 96 | className="flex-1 font-medium hover:underline" |
| 97 | > |
| 98 | {repository.name} |
| 99 | </Link> |
| 100 | <Badge variant=" |
| 101 | {roleLabels[repository.role |
| 102 | </Badge> |
| 103 | </li> |
| 104 | ); |
| 105 | })} |
| 106 | </ul> |
| 107 | )} |
| 108 | </section> |
| 109 | </main> |
| 110 | </div> |
| 111 | ); |
| 112 | } |