mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-28 06:10:01 -05:00
Add TO permissions via UI
This commit is contained in:
@@ -76,6 +76,14 @@ export function makeVideoAdderByUserId(userId: number) {
|
||||
.execute();
|
||||
}
|
||||
|
||||
export function makeTournamentOrganizerByUserId(userId: number) {
|
||||
return db
|
||||
.updateTable("User")
|
||||
.set({ isTournamentOrganizer: 1 })
|
||||
.where("User.id", "=", userId)
|
||||
.execute();
|
||||
}
|
||||
|
||||
export async function linkUserAndPlayer({
|
||||
userId,
|
||||
playerId,
|
||||
|
||||
@@ -68,6 +68,12 @@ export const action = async ({ request }: ActionFunctionArgs) => {
|
||||
await AdminRepository.makeVideoAdderByUserId(data.user);
|
||||
break;
|
||||
}
|
||||
case "TOURNAMENT_ORGANIZER": {
|
||||
validate(isMod(user), "Mod needed", 401);
|
||||
|
||||
await AdminRepository.makeTournamentOrganizerByUserId(data.user);
|
||||
break;
|
||||
}
|
||||
case "LINK_PLAYER": {
|
||||
validate(isMod(user), "Mod needed", 401);
|
||||
|
||||
@@ -155,6 +161,10 @@ export const adminActionSchema = z.union([
|
||||
_action: _action("VIDEO_ADDER"),
|
||||
user: z.preprocess(actualNumber, z.number().positive()),
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("TOURNAMENT_ORGANIZER"),
|
||||
user: z.preprocess(actualNumber, z.number().positive()),
|
||||
}),
|
||||
z.object({
|
||||
_action: _action("ARTIST"),
|
||||
user: z.preprocess(actualNumber, z.number().positive()),
|
||||
|
||||
@@ -41,6 +41,7 @@ export default function AdminPage() {
|
||||
{isMod(user) ? <LinkPlayer /> : null}
|
||||
{isMod(user) ? <GiveArtist /> : null}
|
||||
{isMod(user) ? <GiveVideoAdder /> : null}
|
||||
{isMod(user) ? <GiveTournamentOrganizer /> : null}
|
||||
{isMod(user) ? <UpdateFriendCode /> : null}
|
||||
|
||||
{process.env.NODE_ENV !== "production" || isAdmin(user) ? (
|
||||
@@ -202,6 +203,31 @@ function GiveVideoAdder() {
|
||||
);
|
||||
}
|
||||
|
||||
function GiveTournamentOrganizer() {
|
||||
const fetcher = useFetcher();
|
||||
|
||||
return (
|
||||
<fetcher.Form className="stack md" method="post">
|
||||
<h2>Give tournament organizer</h2>
|
||||
<div className="stack horizontal md">
|
||||
<div>
|
||||
<label>User</label>
|
||||
<UserSearch inputName="user" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="stack horizontal md">
|
||||
<SubmitButton
|
||||
type="submit"
|
||||
_action="TOURNAMENT_ORGANIZER"
|
||||
state={fetcher.state}
|
||||
>
|
||||
Add as tournament organizer
|
||||
</SubmitButton>
|
||||
</div>
|
||||
</fetcher.Form>
|
||||
);
|
||||
}
|
||||
|
||||
function UpdateFriendCode() {
|
||||
const fetcher = useFetcher();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user