dashboard: allow accepted users in
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { auth, clerkClient } from '@clerk/nextjs';
|
||||
import type { User } from '@clerk/nextjs/dist/types/server';
|
||||
|
||||
import { db } from '../prisma-client';
|
||||
|
||||
export function transformUser(user: User) {
|
||||
return {
|
||||
name: `${user.firstName} ${user.lastName}`,
|
||||
@@ -22,3 +24,18 @@ export async function getCurrentUser() {
|
||||
export async function getUserById(id: string) {
|
||||
return clerkClient.users.getUser(id).then(transformUser);
|
||||
}
|
||||
|
||||
export async function isWaitlistUserAccepted() {
|
||||
const user = await getCurrentUser();
|
||||
const waitlist = await db.waitlist.findFirst({
|
||||
where: {
|
||||
email: user?.email,
|
||||
},
|
||||
});
|
||||
|
||||
if (!waitlist) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return waitlist.accepted;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user