mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-06-02 22:26:57 -05:00
Do not allow making tournament draft if already was not draft
This commit is contained in:
parent
e5c54bfd1e
commit
ce45bdb7f8
|
|
@ -138,6 +138,11 @@ export const action: ActionFunction = async ({ request }) => {
|
||||||
);
|
);
|
||||||
|
|
||||||
errorToastIfFalsy(tournament.isAdmin(user), "Not authorized");
|
errorToastIfFalsy(tournament.isAdmin(user), "Not authorized");
|
||||||
|
|
||||||
|
// once published, a tournament can't be flipped back to draft
|
||||||
|
if (!tournament.isDraft) {
|
||||||
|
commonArgs.isDraft = false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// editing regular calendar event
|
// editing regular calendar event
|
||||||
errorToastIfFalsy(
|
errorToastIfFalsy(
|
||||||
|
|
|
||||||
|
|
@ -977,12 +977,18 @@ function TestToggle() {
|
||||||
|
|
||||||
function DraftToggle() {
|
function DraftToggle() {
|
||||||
const { t } = useTranslation(["calendar"]);
|
const { t } = useTranslation(["calendar"]);
|
||||||
|
const { eventToEdit } = useLoaderData<typeof loader>();
|
||||||
const baseEvent = useBaseEvent();
|
const baseEvent = useBaseEvent();
|
||||||
const [isDraft, setIsDraft] = React.useState(
|
const [isDraft, setIsDraft] = React.useState(
|
||||||
baseEvent?.tournament?.ctx.settings.isDraft ?? false,
|
baseEvent?.tournament?.ctx.settings.isDraft ?? false,
|
||||||
);
|
);
|
||||||
const id = React.useId();
|
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 (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<label htmlFor={id}>{t("calendar:forms.draft")}</label>
|
<label htmlFor={id}>{t("calendar:forms.draft")}</label>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user