Skip to content

Commit

Permalink
Handle deleting org badges where no longer manager of
Browse files Browse the repository at this point in the history
  • Loading branch information
Sendouc committed Jan 20, 2025
1 parent 81b4ae5 commit 99fa990
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};
}

0 comments on commit 99fa990

Please sign in to comment.