Continue Account log
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { PersonIcon } from "@radix-ui/react-icons";
|
||||
import { prisma } from "@repo/db";
|
||||
import { Log, prisma } from "@repo/db";
|
||||
import {
|
||||
AdminForm,
|
||||
ConnectionHistory,
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
} from "./_components/forms";
|
||||
import { Error } from "../../../../_components/Error";
|
||||
import { getUserPenaltys } from "@repo/shared-components";
|
||||
import { PaginatedTable } from "_components/PaginatedTable";
|
||||
import { ColumnDef } from "@tanstack/react-table";
|
||||
|
||||
export default async function Page({ params }: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await params;
|
||||
@@ -35,6 +37,26 @@ export default async function Page({ params }: { params: Promise<{ id: string }>
|
||||
});
|
||||
}
|
||||
|
||||
const userLog = await prisma.log.findMany({
|
||||
where: {
|
||||
userId: user?.id,
|
||||
},
|
||||
});
|
||||
|
||||
const sameIpLogs = await prisma.log.findMany({
|
||||
where: {
|
||||
ip: {
|
||||
in: userLog.map((log) => log.ip).filter((ip): ip is string => ip !== null),
|
||||
},
|
||||
userId: {
|
||||
not: user?.id,
|
||||
},
|
||||
},
|
||||
include: {
|
||||
User: true,
|
||||
},
|
||||
});
|
||||
|
||||
const formerDiscordAccounts = await prisma.formerDiscordAccount.findMany({
|
||||
where: {
|
||||
userId: user?.id,
|
||||
@@ -152,6 +174,41 @@ export default async function Page({ params }: { params: Promise<{ id: string }>
|
||||
openTimebans={openTimeban}
|
||||
/>
|
||||
</div>
|
||||
<div className="card bg-base-200 col-span-6 mb-4 shadow-xl xl:col-span-6">
|
||||
<PaginatedTable
|
||||
prismaModel={"log"}
|
||||
columns={
|
||||
[
|
||||
{
|
||||
header: "Zeitstempel",
|
||||
accessorKey: "timestamp",
|
||||
cell: (info) => new Date(info.getValue<string>()).toLocaleString("de-DE"),
|
||||
},
|
||||
{
|
||||
header: "Aktion",
|
||||
accessorKey: "action",
|
||||
cell: ({ row }) => {
|
||||
const action = row.original.type;
|
||||
|
||||
if (action !== "PROFILE_CHANGE") {
|
||||
return action;
|
||||
} else {
|
||||
return `${row.original.field} von "${row.original.oldValue}" zu "${row.original.newValue}"`;
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
header: "IP-Adresse",
|
||||
accessorKey: "ip",
|
||||
},
|
||||
{
|
||||
header: "Gerät",
|
||||
accessorKey: "browser",
|
||||
},
|
||||
] as ColumnDef<Log>[]
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<div className="card bg-base-200 col-span-6 mb-4 shadow-xl xl:col-span-6">
|
||||
<UserReports user={user} />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user