mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-24 06:58:10 -05:00
Prevent creating a scrim/scrim request with team that has less than 4 members
This commit is contained in:
parent
3f0e5fcd16
commit
2843fc63b5
|
|
@ -8,6 +8,7 @@ import { dateToDatabaseTimestamp } from "~/utils/dates";
|
|||
import invariant from "~/utils/invariant";
|
||||
import {
|
||||
actionError,
|
||||
errorToast,
|
||||
errorToastIfFalsy,
|
||||
parseRequestPayload,
|
||||
} from "~/utils/remix.server";
|
||||
|
|
@ -15,6 +16,7 @@ import { scrimsPage } from "~/utils/urls";
|
|||
import * as QRepository from "../../sendouq/QRepository.server";
|
||||
import * as TeamRepository from "../../team/TeamRepository.server";
|
||||
import * as ScrimPostRepository from "../ScrimPostRepository.server";
|
||||
import { SCRIM } from "../scrims-constants";
|
||||
import {
|
||||
type fromSchema,
|
||||
type newRequestSchema,
|
||||
|
|
@ -106,9 +108,15 @@ export const usersListForPost = async ({
|
|||
|
||||
// handle case when all users are from excluded roles
|
||||
const result = (
|
||||
filteredMembers.length > 0 ? filteredMembers : team.members
|
||||
filteredMembers.length >= SCRIM.MIN_MEMBERS_PER_TEAM
|
||||
? filteredMembers
|
||||
: team.members
|
||||
).map((member) => member.id);
|
||||
|
||||
if (result.length < SCRIM.MIN_MEMBERS_PER_TEAM) {
|
||||
errorToast("Your team does not have enough members (4) to scrim");
|
||||
}
|
||||
|
||||
// ensure author is included in the list even if they match the ignore condition
|
||||
return result.includes(authorId) ? result : [authorId, ...result];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ export const LUTI_DIVS = [
|
|||
|
||||
export const SCRIM = {
|
||||
MAX_PICKUP_SIZE_EXCLUDING_OWNER: 5,
|
||||
MIN_MEMBERS_PER_TEAM: 4,
|
||||
};
|
||||
|
||||
export const FF_SCRIMS_ENABLED = true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user