sendou.ink/app/features/sendouq/core/groups.ts
Kalle fd48bced91
Migrate Prettier/Eslint/Stylelint setup to Biome (#1772)
* Initial

* CSS lint

* Test CI

* Add 1v1, 2v2, and 3v3 Tags (#1771)

* Initial

* CSS lint

* Test CI

* Rename step

---------

Co-authored-by: xi <104683822+ximk@users.noreply.github.com>
2024-06-24 13:07:17 +03:00

37 lines
846 B
TypeScript

import type { GroupMember } from "~/db/types";
import type { LookingGroup } from "../q-types";
// logic is that team who is bigger decides the settings
// but if groups are the same size then the one who liked
// is basically consenting that other team's setting are used
export function groupAfterMorph({
ourGroup,
theirGroup,
liker,
}: {
ourGroup: LookingGroup;
theirGroup: LookingGroup;
liker: "US" | "THEM";
}) {
const ourMembers = ourGroup.members ?? [];
const theirMembers = theirGroup.members ?? [];
if (ourMembers.length > theirMembers.length) {
return ourGroup;
}
if (theirMembers.length > ourMembers.length) {
return theirGroup;
}
if (liker === "US") {
return theirGroup;
}
return ourGroup;
}
export function hasGroupManagerPerms(role: GroupMember["role"]) {
return role === "OWNER" || role === "MANAGER";
}