Skip to content

Commit

Permalink
Dashboard: Add list to all projects for admins
Browse files Browse the repository at this point in the history
  • Loading branch information
tordans committed Oct 21, 2024
1 parent 666a57e commit 45f9cd2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"use client"
import { SuperAdminBox } from "@/src/core/components/AdminBox"
import { Link } from "@/src/core/components/links/Link"
import { shortTitle } from "@/src/core/components/text"
import { isAdmin } from "@/src/pagesComponents/users/utils/isAdmin"
import getProjects from "@/src/server/projects/queries/getProjects"
import { useCurrentUser } from "@/src/server/users/hooks/useCurrentUser"
import { useQuery } from "@blitzjs/rpc"

export const AdminProjectsList = () => {
const user = useCurrentUser()
const [projects] = useQuery(getProjects, {}, { enabled: isAdmin(user) })

return (
<SuperAdminBox className="prose">
<h2 className="mt-0">Alle Projekte</h2>
<ul>
{projects?.projects.map((project) => {
return (
<li key={project.id}>
<Link href={`/${project.slug}`}>{shortTitle(project.slug)}</Link>
</li>
)
})}
</ul>
</SuperAdminBox>
)
}
2 changes: 2 additions & 0 deletions src/app/(loggedInGeneral)/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { PageHeader } from "@/src/core/components/pages/PageHeader"
import getProjectsWithGeometryWithMembershipRole from "@/src/server/projects/queries/getProjectsWithGeometryWithMembershipRole"
import { Metadata } from "next"
import "server-only"
import { AdminProjectsList } from "./_components/AdminProjectsList"
import { NoProjectMembershipsYet } from "./_components/NoProjectMembershipsYet"
import { ProjectsMap } from "./_components/ProjectsMap"
import { ProjectsTable } from "./_components/ProjectsTable"
Expand All @@ -29,6 +30,7 @@ export default async function DashboardPage() {
/>
<ProjectsMap projects={projects} />
<ProjectsTable projects={projects} />
<AdminProjectsList />
<SuperAdminLogData data={projects} />
</>
)
Expand Down

0 comments on commit 45f9cd2

Please sign in to comment.