Skip to content

Commit

Permalink
refactor(invitesRouter): type checks
Browse files Browse the repository at this point in the history
  • Loading branch information
SySagar committed Aug 30, 2024
1 parent 19c9769 commit a3b21ba
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions apps/platform/trpc/routers/orgRouter/users/invitesRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,22 @@ export const invitesRouter = router({
// Insert account profile - save ID
return db.transaction(async (db) => {
//check existing email invite
await db.query.orgInvitations
.findFirst({
where: eq(
orgInvitations.email,
notification?.notificationEmailAddress as string
),
columns: {
id: true
}
})
.then((res: any) => {
if (res) {
throw new TRPCError({
code: 'UNPROCESSABLE_CONTENT',
message: 'Email already invited'
});
}
const sentInviteEmails = await db.query.orgInvitations.findFirst({
where: eq(
orgInvitations.email,
notification!!.notificationEmailAddress

Check failure on line 77 in apps/platform/trpc/routers/orgRouter/users/invitesRouter.ts

View workflow job for this annotation

GitHub Actions / Check and Build

This assertion is unnecessary since it does not change the type of the expression

Check failure on line 77 in apps/platform/trpc/routers/orgRouter/users/invitesRouter.ts

View workflow job for this annotation

GitHub Actions / Check and Build

Forbidden extra non-null assertion
),
columns: {
id: true
}
});

if (sentInviteEmails) {
throw new TRPCError({
code: 'BAD_REQUEST',
message: 'Email already invited'
});
}

const orgMemberProfilePublicId = typeIdGenerator('orgMemberProfile');
const orgMemberProfileResponse = await db
Expand Down

0 comments on commit a3b21ba

Please sign in to comment.