Skip to content

Commit

Permalink
fix: Fix return types
Browse files Browse the repository at this point in the history
  • Loading branch information
David Code Howard committed Oct 5, 2023
1 parent 6a0e25b commit b91a342
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/account/accountService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ export const signOut = async () => {
}
};

export type UserInProjectError = "NoUser" | "InProject";

export const checkUserInProject = async (
projectId: string,
userEmail: string,
Expand Down Expand Up @@ -189,11 +191,11 @@ export const checkUserInProject = async (
}),
]);
if (userExists.users === undefined || userExists.users?.edges.length === 0) {
return { type: 'NoUser' };
return { type: 'NoUser' as UserInProjectError};
}
if (inProject.users?.totalCount !== 0) {
return { type: 'InProject' };
return { type: 'InProject' as UserInProjectError};
}

return userExists.users.edges[0];
return userExists.users.edges[0].node;
};

0 comments on commit b91a342

Please sign in to comment.