Skip to content

Commit

Permalink
reruns formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
xwilson03 committed Sep 8, 2024
1 parent a422b9b commit a8488a6
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 33 deletions.
12 changes: 6 additions & 6 deletions apps/web/src/app/api/team/invite/accept/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ export async function POST(
where: eq(userCommonData.clerkID, userId),
with: {
hackerData: {
with: {
invites: {
where: eq(invites.teamID, body.data.teamInviteID),
},
}
},
with: {
invites: {
where: eq(invites.teamID, body.data.teamInviteID),
},
},
},
},
});
if (!user) return NextResponse.json("Unauthorized", { status: 401 });
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/app/api/team/invite/create/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ export async function POST(
hackerData: {
with: {
team: true,
invites: {
where: eq(invites.teamID, user.hackerData.teamID),
},
invites: {
where: eq(invites.teamID, user.hackerData.teamID),
},
},
},
},
Expand Down
18 changes: 9 additions & 9 deletions apps/web/src/app/api/team/invite/decline/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ export async function POST(req: Request) {
});
}

// TODO(xander): adjust logic here. null check shouldnt require a join, and invite can be queried directly
// TODO(xander): adjust logic here. null check shouldnt require a join, and invite can be queried directly
const user = await db.query.userCommonData.findFirst({
where: eq(userCommonData.clerkID, userId),
with: {
hackerData: {
with: {
invites: {
where: eq(invites.teamID, body.data.teamInviteID),
},
}
}
hackerData: {
with: {
invites: {
where: eq(invites.teamID, body.data.teamInviteID),
},
},
},
},
});

if (!user) return NextResponse.json("Unauthorized", { status: 401 });

// TODO(xander): get invite using body data here to avoid joins above
// TODO(xander): get invite using body data here to avoid joins above
await db
.update(invites)
.set({
Expand Down
10 changes: 5 additions & 5 deletions apps/web/src/app/dash/team/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ export default async function Page() {
},
},
},
invites: {
with: {
team: true,
},
},
invites: {
with: {
team: true,
},
},
},
},
},
Expand Down
23 changes: 13 additions & 10 deletions packages/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,20 @@ export const userHackerData = pgTable("user_hacker_data", {
isEmailable: boolean("is_emailable").notNull(),
});

export const userHackerRelations = relations(userHackerData, ({ one, many }) => ({
commonData: one(userCommonData, {
fields: [userHackerData.clerkID],
references: [userCommonData.clerkID],
}),
team: one(teams, {
fields: [userHackerData.teamID],
references: [teams.id],
export const userHackerRelations = relations(
userHackerData,
({ one, many }) => ({
commonData: one(userCommonData, {
fields: [userHackerData.clerkID],
references: [userCommonData.clerkID],
}),
team: one(teams, {
fields: [userHackerData.teamID],
references: [teams.id],
}),
invites: many(invites),
}),
invites: many(invites),
}));
);

export const events = pgTable("events", {
id: bigserial("id", { mode: "number" }).notNull().primaryKey().unique(),
Expand Down

0 comments on commit a8488a6

Please sign in to comment.