Discord Permissions will be revoked, when under a penalty
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Penalty" ADD COLUMN "addPermissionApplied" BOOLEAN NOT NULL DEFAULT false,
|
||||
ADD COLUMN "removePermissionApplied" BOOLEAN NOT NULL DEFAULT false;
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- The primary key for the `FormerDiscordAccount` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
|
||||
*/
|
||||
-- DropIndex
|
||||
DROP INDEX "FormerDiscordAccount_discord_id_key";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "FormerDiscordAccount" DROP CONSTRAINT "FormerDiscordAccount_pkey",
|
||||
ADD COLUMN "id" SERIAL NOT NULL,
|
||||
ADD CONSTRAINT "FormerDiscordAccount_pkey" PRIMARY KEY ("id");
|
||||
@@ -10,6 +10,10 @@ model Penalty {
|
||||
|
||||
suspended Boolean @default(false)
|
||||
|
||||
// For Chronjob to know if permissions were already applied/removed
|
||||
removePermissionApplied Boolean @default(false)
|
||||
addPermissionApplied Boolean @default(false)
|
||||
|
||||
timestamp DateTime @default(now())
|
||||
|
||||
// relations:
|
||||
|
||||
@@ -94,14 +94,13 @@ model User {
|
||||
}
|
||||
|
||||
model FormerDiscordAccount {
|
||||
discordId String @unique @map(name: "discord_id")
|
||||
id Int @id @default(autoincrement())
|
||||
discordId String @map(name: "discord_id")
|
||||
userId String @map(name: "user_id")
|
||||
removedAt DateTime @default(now()) @map(name: "removed_at")
|
||||
|
||||
DiscordAccount DiscordAccount? @relation(fields: [discordId], references: [discordId], onDelete: SetNull)
|
||||
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@id([discordId, userId])
|
||||
}
|
||||
|
||||
model DiscordAccount {
|
||||
@@ -119,9 +118,9 @@ model DiscordAccount {
|
||||
updatedAt DateTime @default(now()) @map(name: "updated_at")
|
||||
|
||||
// Related User
|
||||
userId String? @unique
|
||||
User User? @relation(fields: [userId], references: [id], onDelete: SetNull)
|
||||
formerDiscordAccount FormerDiscordAccount?
|
||||
userId String? @unique
|
||||
User User? @relation(fields: [userId], references: [id], onDelete: SetNull)
|
||||
formerDiscordAccount FormerDiscordAccount[]
|
||||
|
||||
@@map(name: "discord_accounts")
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
import { ReactNode, useState } from "react";
|
||||
import { cn } from "../helper/cn";
|
||||
import { Button } from "./Button";
|
||||
|
||||
export const PenaltyDropdown = ({
|
||||
onClick,
|
||||
@@ -79,10 +80,10 @@ export const PenaltyDropdown = ({
|
||||
<option value="1y">1 Jahr</option>
|
||||
</select>
|
||||
)}
|
||||
<button
|
||||
<Button
|
||||
className={cn("btn btn-square btn-soft tooltip tooltip-bottom w-full", btnClassName)}
|
||||
data-tip={btnTip}
|
||||
onClick={() => {
|
||||
onClick={async () => {
|
||||
let untilDate: Date | null = null;
|
||||
if (until !== "default") {
|
||||
const now = new Date();
|
||||
@@ -124,11 +125,11 @@ export const PenaltyDropdown = ({
|
||||
untilDate = null;
|
||||
}
|
||||
}
|
||||
onClick({ reason, until: untilDate });
|
||||
await onClick({ reason, until: untilDate });
|
||||
}}
|
||||
>
|
||||
{Icon} {btnName}
|
||||
</button>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user