Skip to content

Commit 4e3ca52

Browse files
MatejMa2urclaude
andauthored
fix: scope table assignment to current hackathon (#70)
Pass hackathonId through TablesManager → TeamRow → AssignTableDialog → assignTeamToTable so the table lookup is scoped to the correct event, preventing cross-event assignments. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 15c6e42 commit 4e3ca52

1 file changed

Lines changed: 22 additions & 13 deletions

File tree

‎src/server/actions/dashboard/tables/assignTeamToTable.ts‎

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,29 @@ const assignTeamToTable = async ({
1515
}: AssignTeamToTableInput) => {
1616
await requireAdminSession();
1717

18+
const team = await prisma.team.findFirst({
19+
where: {
20+
id: teamId,
21+
},
22+
select: {
23+
members: {
24+
select: {
25+
hackathonId: true,
26+
},
27+
},
28+
},
29+
});
30+
31+
if (!team || team.members.length === 0) {
32+
throw new ExpectedServerActionError("Team not found");
33+
}
34+
35+
const hackathonId = team.members[0].hackathonId;
36+
1837
const table = await prisma.table.findFirst({
1938
where: {
2039
code: tableCode,
40+
hackathonId,
2141
},
2242
select: {
2343
id: true,
@@ -28,27 +48,16 @@ const assignTeamToTable = async ({
2848
throw new ExpectedServerActionError("Table not found");
2949
}
3050

31-
const { members } = await prisma.team.update({
51+
await prisma.team.update({
3252
where: {
3353
id: teamId,
3454
},
3555
data: {
3656
tableId: table.id,
3757
},
38-
select: {
39-
members: {
40-
select: {
41-
hackathonId: true,
42-
},
43-
},
44-
},
4558
});
4659

47-
if (members.length === 0) {
48-
throw new ExpectedServerActionError("Team not found");
49-
}
50-
51-
revalidatePath(`/dashboard/${members[0].hackathonId}/tables`);
60+
revalidatePath(`/dashboard/${hackathonId}/tables`);
5261
};
5362

5463
export default assignTeamToTable;

0 commit comments

Comments
 (0)