-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
145 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,135 +1,14 @@ | ||
"use client"; | ||
import AdminDashboard from "@good-dog/components/admin/AdminDashboard"; | ||
import { HydrateClient, trpc } from "@good-dog/trpc/server"; | ||
|
||
import { useState } from "react"; | ||
export const dynamic = "force-dynamic"; | ||
|
||
import type { GetProcedureOutput } from "@good-dog/trpc/utils"; | ||
import { DataTable } from "@good-dog/components/admin/DataTable"; | ||
import Loading from "@good-dog/components/loading/Loading"; | ||
import { trpc } from "@good-dog/trpc/client"; | ||
import { | ||
Card, | ||
CardContent, | ||
CardDescription, | ||
CardHeader, | ||
CardTitle, | ||
} from "@good-dog/ui/card"; | ||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@good-dog/ui/tabs"; | ||
|
||
import NotFound from "~/not-found"; | ||
|
||
type AdminDataTypes = GetProcedureOutput<"adminData">; | ||
interface DataColumn<T extends keyof AdminDataTypes> { | ||
accessorKey: keyof AdminDataTypes[T][number]; | ||
header: string; | ||
cell?: (value: AdminDataTypes[T][keyof AdminDataTypes[T]]) => JSX.Element; | ||
} | ||
|
||
const columns = { | ||
users: [ | ||
{ accessorKey: "firstName", header: "First Name" }, | ||
{ accessorKey: "lastName", header: "Last Name" }, | ||
{ accessorKey: "email", header: "Email" }, | ||
{ accessorKey: "role", header: "Role" }, | ||
{ accessorKey: "stageName", header: "Stage Name" }, | ||
{ accessorKey: "isSongWriter", header: "Songwriter?" }, | ||
{ accessorKey: "isAscapAffiliated", header: "ASCAP Affiliated?" }, | ||
{ accessorKey: "isBmiAffiliated", header: "BMI Affiliated?" }, | ||
{ accessorKey: "createdAt", header: "Date of Creation" }, | ||
{ accessorKey: "updatedAt", header: "Date Last Updated" }, | ||
], | ||
groups: [ | ||
{ accessorKey: "name", header: "Name" }, | ||
{ accessorKey: "createdAt", header: "Date of Creation" }, | ||
{ accessorKey: "updatedAt", header: "Date Last Updated" }, | ||
], | ||
groupInvites: [ | ||
{ accessorKey: "email", header: "Email" }, | ||
{ accessorKey: "firstName", header: "First Name" }, | ||
{ accessorKey: "lastName", header: "Last Name" }, | ||
{ accessorKey: "stageName", header: "Stage Name" }, | ||
{ accessorKey: "role", header: "Role" }, | ||
{ accessorKey: "isSongWriter", header: "Songwriter?" }, | ||
{ accessorKey: "isAscapAffiliated", header: "ASCAP Affiliated?" }, | ||
{ accessorKey: "isBmiAffiliated", header: "BMI Affiliated?" }, | ||
{ accessorKey: "createdAt", header: "Date of Creation" }, | ||
], | ||
} as const satisfies { [T in keyof AdminDataTypes]: DataColumn<T>[] }; | ||
|
||
export default function AdminDashboard() { | ||
const [activeTab, setActiveTab] = useState("users"); | ||
const { data, isPending, isError } = trpc.adminData.useQuery(); | ||
if (isPending) { | ||
return <Loading />; | ||
} | ||
if (isError) { | ||
return NotFound; | ||
} | ||
const userData = data.users; | ||
const groupData = data.groups; | ||
const groupInvitesData = data.groupInvites; | ||
export default async function AdminPage() { | ||
void trpc.adminData.prefetch(); | ||
|
||
return ( | ||
<div className="bg-good-dog-violet pb-10"> | ||
<div className="mx-10"> | ||
<h1 className="mb-6 text-7xl font-bold text-white">Admin Dashboard</h1> | ||
<Tabs value={activeTab} onValueChange={setActiveTab} className="w-full"> | ||
<TabsList> | ||
<TabsTrigger className="text-xl" value="users"> | ||
Users | ||
</TabsTrigger> | ||
<TabsTrigger className="text-xl" value="groups"> | ||
Groups | ||
</TabsTrigger> | ||
<TabsTrigger className="text-xl" value="invites"> | ||
Invites | ||
</TabsTrigger> | ||
</TabsList> | ||
<div className="pt-2"> | ||
<TabsContent className="text-3xl" value="users"> | ||
<Card> | ||
<CardHeader> | ||
<CardTitle>Users</CardTitle> | ||
<CardDescription className="text-xl"> | ||
Manage user accounts in the system. | ||
</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
<DataTable columns={columns.users} data={userData} /> | ||
</CardContent> | ||
</Card> | ||
</TabsContent> | ||
<TabsContent className="text-3xl" value="groups"> | ||
<Card> | ||
<CardHeader> | ||
<CardTitle>Groups</CardTitle> | ||
<CardDescription className="text-xl"> | ||
Manage user groups and permissions. | ||
</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
<DataTable columns={columns.groups} data={groupData} /> | ||
</CardContent> | ||
</Card> | ||
</TabsContent> | ||
<TabsContent className="text-3xl" value="invites"> | ||
<Card> | ||
<CardHeader> | ||
<CardTitle>Invites</CardTitle> | ||
<CardDescription className="text-xl"> | ||
Manage pending invitations. | ||
</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
<DataTable | ||
columns={columns.groupInvites} | ||
data={groupInvitesData} | ||
/> | ||
</CardContent> | ||
</Card> | ||
</TabsContent> | ||
</div> | ||
</Tabs> | ||
</div> | ||
</div> | ||
<HydrateClient> | ||
<AdminDashboard /> | ||
</HydrateClient> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
"use client"; | ||
|
||
import { useState } from "react"; | ||
|
||
import { trpc } from "@good-dog/trpc/client"; | ||
import { | ||
Card, | ||
CardContent, | ||
CardDescription, | ||
CardHeader, | ||
CardTitle, | ||
} from "@good-dog/ui/card"; | ||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@good-dog/ui/tabs"; | ||
|
||
import { DataTable } from "./DataTable"; | ||
|
||
export default function AdminDashboard() { | ||
const [activeTab, setActiveTab] = useState("users"); | ||
const [data] = trpc.adminData.useSuspenseQuery(); | ||
|
||
const userData = data.users; | ||
const groupData = data.groups; | ||
const groupInvitesData = data.groupInvites; | ||
|
||
return ( | ||
<div className="bg-good-dog-violet pb-10"> | ||
<div className="mx-10"> | ||
<h1 className="mb-6 text-7xl font-bold text-white">Admin Dashboard</h1> | ||
<Tabs value={activeTab} onValueChange={setActiveTab} className="w-full"> | ||
<TabsList> | ||
<TabsTrigger className="text-xl" value="users"> | ||
Users | ||
</TabsTrigger> | ||
<TabsTrigger className="text-xl" value="groups"> | ||
Groups | ||
</TabsTrigger> | ||
<TabsTrigger className="text-xl" value="invites"> | ||
Invites | ||
</TabsTrigger> | ||
</TabsList> | ||
<div className="pt-2"> | ||
<TabsContent className="text-3xl" value="users"> | ||
<Card> | ||
<CardHeader> | ||
<CardTitle>Users</CardTitle> | ||
<CardDescription className="text-xl"> | ||
Manage user accounts in the system. | ||
</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
<DataTable table="users" data={userData} /> | ||
</CardContent> | ||
</Card> | ||
</TabsContent> | ||
<TabsContent className="text-3xl" value="groups"> | ||
<Card> | ||
<CardHeader> | ||
<CardTitle>Groups</CardTitle> | ||
<CardDescription className="text-xl"> | ||
Manage user groups and permissions. | ||
</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
<DataTable table="groups" data={groupData} /> | ||
</CardContent> | ||
</Card> | ||
</TabsContent> | ||
<TabsContent className="text-3xl" value="invites"> | ||
<Card> | ||
<CardHeader> | ||
<CardTitle>Invites</CardTitle> | ||
<CardDescription className="text-xl"> | ||
Manage pending invitations. | ||
</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
<DataTable table="groupInvites" data={groupInvitesData} /> | ||
</CardContent> | ||
</Card> | ||
</TabsContent> | ||
</div> | ||
</Tabs> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters