Handle deleting org badges where no longer manager of
Some checks failed
Tests and checks on push / run-checks-and-tests (push) Has been cancelled
Updates translation progress / update-translation-progress-issue (push) Has been cancelled

This commit is contained in:
Kalle 2025-01-20 19:54:45 +02:00
parent 81b4ae5680
commit 99fa990491

View File

@ -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(),
};
}