Do not allow making tournament draft if already was not draft

This commit is contained in:
Kalle 2026-05-11 17:12:36 +03:00
parent e5c54bfd1e
commit ce45bdb7f8
2 changed files with 11 additions and 0 deletions

View File

@ -138,6 +138,11 @@ export const action: ActionFunction = async ({ request }) => {
);
errorToastIfFalsy(tournament.isAdmin(user), "Not authorized");
// once published, a tournament can't be flipped back to draft
if (!tournament.isDraft) {
commonArgs.isDraft = false;
}
} else {
// editing regular calendar event
errorToastIfFalsy(

View File

@ -977,12 +977,18 @@ function TestToggle() {
function DraftToggle() {
const { t } = useTranslation(["calendar"]);
const { eventToEdit } = useLoaderData<typeof loader>();
const baseEvent = useBaseEvent();
const [isDraft, setIsDraft] = React.useState(
baseEvent?.tournament?.ctx.settings.isDraft ?? false,
);
const id = React.useId();
// once a tournament is published, it can't be flipped back to draft (users may have already saved it)
if (eventToEdit && !eventToEdit.tournament?.ctx.settings.isDraft) {
return null;
}
return (
<div>
<label htmlFor={id}>{t("calendar:forms.draft")}</label>