mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-08-28 14:18:04 -05:00
Enable subs tab toggle
This commit is contained in:
@@ -414,6 +414,8 @@ export interface TournamentSettings {
|
||||
thirdPlaceMatch?: boolean;
|
||||
isRanked?: boolean;
|
||||
enableNoScreenToggle?: boolean;
|
||||
/** Enable the subs tab, default true */
|
||||
enableSubs?: boolean;
|
||||
deadlines?: "STRICT" | "DEFAULT";
|
||||
requireInGameNames?: boolean;
|
||||
isInvitational?: boolean;
|
||||
|
||||
@@ -474,6 +474,7 @@ type CreateArgs = Pick<
|
||||
isInvitational?: boolean;
|
||||
deadlines: TournamentSettings["deadlines"];
|
||||
enableNoScreenToggle?: boolean;
|
||||
enableSubs?: boolean;
|
||||
autonomousSubs?: boolean;
|
||||
regClosesAt?: number;
|
||||
rules: string | null;
|
||||
@@ -506,6 +507,7 @@ export async function create(args: CreateArgs) {
|
||||
deadlines: args.deadlines,
|
||||
isInvitational: args.isInvitational,
|
||||
enableNoScreenToggle: args.enableNoScreenToggle,
|
||||
enableSubs: args.enableSubs,
|
||||
autonomousSubs: args.autonomousSubs,
|
||||
regClosesAt: args.regClosesAt,
|
||||
requireInGameNames: args.requireInGameNames,
|
||||
@@ -655,6 +657,7 @@ export async function update(args: UpdateArgs) {
|
||||
deadlines: args.deadlines,
|
||||
isInvitational: args.isInvitational,
|
||||
enableNoScreenToggle: args.enableNoScreenToggle,
|
||||
enableSubs: args.enableSubs,
|
||||
autonomousSubs: args.autonomousSubs,
|
||||
regClosesAt: args.regClosesAt,
|
||||
requireInGameNames: args.requireInGameNames,
|
||||
|
||||
@@ -98,6 +98,7 @@ export const action: ActionFunction = async ({ request }) => {
|
||||
isInvitational: data.isInvitational ?? false,
|
||||
deadlines: data.strictDeadline ? ("STRICT" as const) : ("DEFAULT" as const),
|
||||
enableNoScreenToggle: data.enableNoScreenToggle ?? undefined,
|
||||
enableSubs: data.enableSubs ?? undefined,
|
||||
requireInGameNames: data.requireInGameNames ?? undefined,
|
||||
autonomousSubs: data.autonomousSubs ?? undefined,
|
||||
swissGroupCount: data.swissGroupCount ?? undefined,
|
||||
@@ -274,6 +275,7 @@ export const newCalendarEventActionSchema = z
|
||||
checkboxValueToBoolean,
|
||||
z.boolean().nullish(),
|
||||
),
|
||||
enableSubs: z.preprocess(checkboxValueToBoolean, z.boolean().nullish()),
|
||||
autonomousSubs: z.preprocess(checkboxValueToBoolean, z.boolean().nullish()),
|
||||
strictDeadline: z.preprocess(checkboxValueToBoolean, z.boolean().nullish()),
|
||||
isInvitational: z.preprocess(checkboxValueToBoolean, z.boolean().nullish()),
|
||||
|
||||
@@ -239,6 +239,7 @@ function EventForm() {
|
||||
<RegClosesAtSelect />
|
||||
<RankedToggle />
|
||||
<EnableNoScreenToggle />
|
||||
<EnableSubsToggle />
|
||||
<AutonomousSubsToggle />
|
||||
<RequireIGNToggle />
|
||||
<InvitationalToggle
|
||||
@@ -844,6 +845,33 @@ function EnableNoScreenToggle() {
|
||||
);
|
||||
}
|
||||
|
||||
function EnableSubsToggle() {
|
||||
const baseEvent = useBaseEvent();
|
||||
const [enableSubs, setEnableSubs] = React.useState(
|
||||
baseEvent?.tournament?.ctx.settings.enableSubs ?? true,
|
||||
);
|
||||
const id = React.useId();
|
||||
|
||||
return (
|
||||
<div>
|
||||
<label htmlFor={id} className="w-max">
|
||||
Subs tab
|
||||
</label>
|
||||
<Toggle
|
||||
name="enableSubs"
|
||||
id={id}
|
||||
tiny
|
||||
checked={enableSubs}
|
||||
setChecked={setEnableSubs}
|
||||
/>
|
||||
<FormMessage type="info">
|
||||
Allow users to sign up as "subs" in addition to the normal event
|
||||
sign-up.
|
||||
</FormMessage>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function AutonomousSubsToggle() {
|
||||
const baseEvent = useBaseEvent();
|
||||
const [autonomousSubs, setAutonomousSubs] = React.useState(
|
||||
|
||||
@@ -782,7 +782,7 @@ export class Tournament {
|
||||
}
|
||||
|
||||
get subsFeatureEnabled() {
|
||||
return !this.isInvitational;
|
||||
return this.ctx.settings.enableSubs ?? true;
|
||||
}
|
||||
|
||||
get canAddNewSubPost() {
|
||||
|
||||
Reference in New Issue
Block a user