dashboard: allow accepted users in

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-03-11 21:17:11 +01:00
parent 52a8195ad1
commit 4786adb052
5 changed files with 51 additions and 23 deletions

View File

@@ -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;
}