Skip to content

Commit

Permalink
slight changes to frontend + add route
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjana-singhania committed Nov 21, 2024
1 parent 12c29a7 commit b7acf30
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 32 deletions.
24 changes: 12 additions & 12 deletions apps/web/app/(pages)/admin/page.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
//dont use use client

// import { HydrateClient, trpc } from "@good-dog/trpc/server";

// export default function AdminPage() {
// void trpc.user.prefetch();
// <HydrateClient>{/* your component here */}</HydrateClient>;
// }
"use client";

import { useState } from "react";

import { DataTable } from "@good-dog/components/admin/DataTable";
import { trpc } from "@good-dog/trpc/client";
import { Badge } from "@good-dog/ui/badge";
import {
Card,
Expand Down Expand Up @@ -80,16 +73,23 @@ const columns = {

export default function AdminDashboard() {
const [activeTab, setActiveTab] = useState("users");
const adminData = trpc.adminData;

return (
<div className="bg-good-dog-violet py-10">
<div className="mx-10">
<h1 className="mb-6 text-4xl font-bold text-white">Admin Dashboard</h1>
<h1 className="mb-6 text-7xl font-bold text-white">Admin Dashboard</h1>
<Tabs value={activeTab} onValueChange={setActiveTab} className="w-full">
<TabsList>
<TabsTrigger value="users">Users</TabsTrigger>
<TabsTrigger value="groups">Groups</TabsTrigger>
<TabsTrigger value="invites">Invites</TabsTrigger>
<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>
<TabsContent value="users">
<Card>
Expand Down
2 changes: 2 additions & 0 deletions packages/trpc/src/internal/router.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getAdminViewProcedure } from "../procedures/admin-view";
import {
deleteAccountProcedure,
signInProcedure,
Expand Down Expand Up @@ -25,6 +26,7 @@ export const appRouter = createTRPCRouter({
deleteAccount: deleteAccountProcedure,
authenticatedUser: getAuthenticatedUserProcedure,
user: getUserProcedure,
adminData: getAdminViewProcedure,
});

export type AppRouter = typeof appRouter;
27 changes: 7 additions & 20 deletions packages/trpc/src/procedures/admin-view.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
import { adminAuthenticatedProcedureBuilder } from "../internal/init";

export const userView = adminAuthenticatedProcedureBuilder.query(
export const getAdminViewProcedure = adminAuthenticatedProcedureBuilder.query(
async ({ ctx }) => {
const users = ctx.prisma.user.findMany();

return users;
},
);

export const groupView = adminAuthenticatedProcedureBuilder.query(
async ({ ctx }) => {
const groups = ctx.prisma.group.findMany();

return groups;
},
);

export const groupInvitesView = adminAuthenticatedProcedureBuilder.query(
async ({ ctx }) => {
const groupInvites = ctx.prisma.groupInvite.findMany();

return groupInvites;
const [users, groups, groupInvites] = await Promise.all([
ctx.prisma.user.findMany(),
ctx.prisma.group.findMany(),
ctx.prisma.groupInvite.findMany(),
]);
return { users, groups, groupInvites };
},
);

0 comments on commit b7acf30

Please sign in to comment.