Skip to content

Commit

Permalink
slightly simplifies leaveTeam action
Browse files Browse the repository at this point in the history
  • Loading branch information
xwilson03 committed Aug 14, 2024
1 parent 5c146bd commit 73a92be
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions apps/web/src/actions/teams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ export const leaveTeam = authenticatedAction(
throw new Error("User not found");
}

if (
user.hackerData.teamID === null ||
user.hackerData.teamID === undefined
) {
if (!user.hackerData.teamID) {
revalidatePath("/dash/team");
return {
success: false,
Expand All @@ -38,7 +35,7 @@ export const leaveTeam = authenticatedAction(
.set({ teamID: null })
.where(eq(userHackerData.clerkID, user.clerkID));
const team = await tx.query.teams.findFirst({
where: eq(teams.id, user.hackerData.teamID as string), // Added null check for user.hackerData.teamID. Converted to string since TS does not realise for some reason that we checked above.
where: eq(teams.id, user.hackerData.teamID as string), // Converted to string since TS does not realise for some reason that we checked above.
with: {
members: {
with: {
Expand Down

0 comments on commit 73a92be

Please sign in to comment.