sendou.ink/app/features/tournament-admin/tournament-admin-utils.server.ts
Kalle 6e987d506f
Some checks are pending
E2E Tests / e2e (push) Waiting to run
Tests and checks on push / run-checks-and-tests (push) Waiting to run
Updates translation progress / update-translation-progress-issue (push) Waiting to run
Tournament layout refresh, improve admin experience (#3152)
2026-06-11 18:31:10 +03:00

20 lines
698 B
TypeScript

import type { AuthenticatedUser } from "~/features/auth/core/user.server";
import type { Tournament } from "~/features/tournament-bracket/core/Tournament";
import { errorToastIfFalsy } from "~/utils/remix.server";
/** Throws an error toast unless the user is an organizer of the tournament. */
export function requireTournamentOrganizer(
tournament: Tournament,
user: AuthenticatedUser,
) {
errorToastIfFalsy(tournament.isOrganizer(user), "Unauthorized");
}
/** Throws an error toast unless the user is an admin of the tournament. */
export function requireTournamentAdmin(
tournament: Tournament,
user: AuthenticatedUser,
) {
errorToastIfFalsy(tournament.isAdmin(user), "Unauthorized");
}