Added Account Dublicate fucntion, improved default sorts

This commit is contained in:
PxlLoewe
2025-12-26 01:23:32 +01:00
parent 51ef9cd90c
commit 17208eded9
18 changed files with 486 additions and 139 deletions

View File

@@ -3,7 +3,7 @@ import { User2 } from "lucide-react";
import { PaginatedTable } from "../../../_components/PaginatedTable";
import Link from "next/link";
import { ColumnDef } from "@tanstack/react-table";
import { User } from "@repo/db";
import { DiscordAccount, User } from "@repo/db";
import { useSession } from "next-auth/react";
const AdminUserPage = () => {
@@ -13,7 +13,10 @@ const AdminUserPage = () => {
<PaginatedTable
stickyHeaders
prismaModel="user"
searchFields={["publicId", "firstname", "lastname", "email"]}
searchFields={["publicId", "firstname", "lastname", "email", "discordAccounts.username"]}
include={{
discordAccounts: true,
}}
initialOrderBy={[
{
id: "publicId",
@@ -51,6 +54,16 @@ const AdminUserPage = () => {
);
},
},
{
header: "Discord",
cell(props) {
const discord = props.row.original.discordAccounts;
if (discord.length === 0) {
return <span className="text-gray-700">Nicht verbunden</span>;
}
return <span>{discord.map((d) => d.username).join(", ")}</span>;
},
},
...(session?.user.permissions.includes("ADMIN_USER_ADVANCED")
? [
{
@@ -69,7 +82,7 @@ const AdminUserPage = () => {
</div>
),
},
] as ColumnDef<User>[]
] as ColumnDef<User & { discordAccounts: DiscordAccount[] }>[]
} // Define the columns for the user table
leftOfSearch={
<p className="flex items-center gap-2 text-left text-2xl font-semibold">