diff --git a/app/routes/play/match.$id.tsx b/app/routes/play/match.$id.tsx index 24503937a..0b5f2e628 100644 --- a/app/routes/play/match.$id.tsx +++ b/app/routes/play/match.$id.tsx @@ -108,9 +108,14 @@ export const action: ActionFunction = async ({ const match = await LFGMatch.findById(params.id); invariant(match, "Match is undefined"); - const ownGroup = match.groups.find((g) => + + let ownGroup = match.groups.find((g) => g.members.some((m) => m.memberId === user.id) ); + if (!ownGroup && isAdmin(user.id)) { + ownGroup = match.groups[0]; + } + validate(ownGroup, "Not own match"); validate(isGroupAdmin({ group: ownGroup, user }), "Not group admin"); @@ -457,20 +462,23 @@ export default function LFGMatchPage() { > {adminEditActive ? "Cancel" : "Edit"} - { - if (!confirm("Delete match?")) { - e.preventDefault(); - } - }} - loadingText="Deleting..." - > - Delete - + {!adminEditActive && ( + { + if (!confirm("Delete match?")) { + e.preventDefault(); + } + }} + loadingText="Deleting..." + > + Delete + + )} )} @@ -503,7 +511,7 @@ export default function LFGMatchPage() { invariant(winnerGroup, "Unexpected winnerGroup is undefined"); return winnerGroup.id; })} - canSubmitScore={data.isCaptain} + canSubmitScore={data.isCaptain || isAdmin(user?.id)} groupIds={{ our: data.groups[0].id, their: data.groups[1].id,