Einstellungen sind eingeschränkt wenn Nutzer gebannt ist

This commit is contained in:
PxlLoewe
2025-06-25 18:07:05 -07:00
parent 577a18d595
commit b95319d61e
6 changed files with 191 additions and 68 deletions

View File

@@ -14,7 +14,13 @@ import {
} from "@repo/db";
import { useRef, useState } from "react";
import { useForm } from "react-hook-form";
import { deleteDispoHistory, deletePilotHistory, editUser, resetPassword } from "../../action";
import {
deleteDispoHistory,
deletePilotHistory,
deleteUser,
editUser,
resetPassword,
} from "../../action";
import { toast } from "react-hot-toast";
import {
PersonIcon,
@@ -41,6 +47,7 @@ import {
PlaneIcon,
RedoDot,
Timer,
Trash2,
X,
} from "lucide-react";
import Link from "next/link";
@@ -475,6 +482,7 @@ export const AdminForm = ({
discordAccount,
}: AdminFormProps) => {
const router = useRouter();
const { data: session } = useSession();
return (
<div className="card-body">
@@ -502,6 +510,22 @@ export const AdminForm = ({
>
<LockOpen1Icon /> Passwort zurücksetzen
</Button>
{session?.user.permissions.includes("ADMIN_USER_ADVANCED") && (
<div
className="tooltip flex-1 min-w-[250px] tooltip-warning"
data-tip="Dies löscht den Nutzer sofort, außerdem alle Reports, Verbindungs-Verlauf und Chat-Nachrichten"
>
<Button
className="btn-error btn-outline btn-sm w-full"
onClick={async () => {
await deleteUser(user.id);
router.push("/admin/user");
}}
>
<Trash2 size={15} /> Nutzer löschen
</Button>
</div>
)}
{user.isBanned && (
<Button
onClick={async () => {

View File

@@ -50,8 +50,15 @@ export const deletePilotHistory = async (id: number) => {
},
});
};
export const deleteUser = async (id: string) => {
return await prisma.user.delete({
where: {
id: id,
},
});
};
export const CheckEmailCode = async (code: string) => {
export const checkEmailCode = async (code: string) => {
const users = await prisma.user.findMany({
where: {
emailVerificationToken: code,