mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-15 23:41:53 -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");
|
||||
|
||||
// once published, a tournament can't be flipped back to draft
|
||||
if (!tournament.isDraft) {
|
||||
commonArgs.isDraft = false;
|
||||
}
|
||||
} else {
|
||||
// editing regular calendar event
|
||||
errorToastIfFalsy(
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user