mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-07-15 16:01:34 -05:00
Handle deleting org badges where no longer manager of
This commit is contained in:
parent
81b4ae5680
commit
99fa990491
|
|
@ -11,10 +11,24 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
|
|||
|
||||
unauthorizedIfFalsy(canEditTournamentOrganization({ organization, user }));
|
||||
|
||||
const badgeOptions = async () => {
|
||||
const result = await BadgeRepository.findByManagersList(
|
||||
organization.members.map((member) => member.id),
|
||||
);
|
||||
|
||||
// handles edge case where the badge is not managed by the org anymore for whatever reason
|
||||
// -> let's still keep it still deletable
|
||||
for (const badge of organization.badges) {
|
||||
if (!result.find((b) => b.id === badge.id)) {
|
||||
result.push(badge);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
return {
|
||||
organization,
|
||||
badgeOptions: await BadgeRepository.findByManagersList(
|
||||
organization.members.map((member) => member.id),
|
||||
),
|
||||
badgeOptions: await badgeOptions(),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user