dashboard: allow accepted users in
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
import { LogoSquare } from '@/components/Logo';
|
import { LogoSquare } from '@/components/Logo';
|
||||||
import { ProjectCard } from '@/components/projects/project-card';
|
import { ProjectCard } from '@/components/projects/project-card';
|
||||||
|
import { notFound, redirect } from 'next/navigation';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getOrganizationBySlug,
|
getOrganizationBySlug,
|
||||||
getProjectsByOrganizationSlug,
|
getProjectsByOrganizationSlug,
|
||||||
|
isWaitlistUserAccepted,
|
||||||
} from '@openpanel/db';
|
} from '@openpanel/db';
|
||||||
import { notFound, redirect } from 'next/navigation';
|
|
||||||
|
|
||||||
import { CreateProject } from './create-project';
|
import { CreateProject } from './create-project';
|
||||||
|
|
||||||
@@ -25,18 +27,21 @@ export default async function Page({ params: { organizationId } }: PageProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.BLOCK) {
|
if (process.env.BLOCK) {
|
||||||
return (
|
const isAccepted = await isWaitlistUserAccepted();
|
||||||
<div className="flex items-center justify-center h-screen">
|
if (!isAccepted) {
|
||||||
<div className="max-w-lg w-full">
|
return (
|
||||||
<LogoSquare className="w-20 md:w-28 mb-8" />
|
<div className="flex items-center justify-center h-screen">
|
||||||
<h1 className="font-medium text-3xl">Not quite there yet</h1>
|
<div className="max-w-lg w-full">
|
||||||
<div className="text-lg">
|
<LogoSquare className="w-20 md:w-28 mb-8" />
|
||||||
We're still working on Openpanel, but we're not quite there yet.
|
<h1 className="font-medium text-3xl">Not quite there yet</h1>
|
||||||
We'll let you know when we're ready to go!
|
<div className="text-lg">
|
||||||
|
We're still working on Openpanel, but we're not quite there yet.
|
||||||
|
We'll let you know when we're ready to go!
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (projects.length === 0) {
|
if (projects.length === 0) {
|
||||||
|
|||||||
@@ -1,27 +1,30 @@
|
|||||||
// import { CreateOrganization } from '@clerk/nextjs';
|
// import { CreateOrganization } from '@clerk/nextjs';
|
||||||
|
|
||||||
import { LogoSquare } from '@/components/Logo';
|
import { LogoSquare } from '@/components/Logo';
|
||||||
import { getCurrentOrganizations } from '@openpanel/db';
|
|
||||||
import { redirect } from 'next/navigation';
|
import { redirect } from 'next/navigation';
|
||||||
|
|
||||||
|
import { getCurrentOrganizations, isWaitlistUserAccepted } from '@openpanel/db';
|
||||||
|
|
||||||
import { CreateOrganization } from './create-organization';
|
import { CreateOrganization } from './create-organization';
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const organizations = await getCurrentOrganizations();
|
const organizations = await getCurrentOrganizations();
|
||||||
|
|
||||||
if (process.env.BLOCK) {
|
if (process.env.BLOCK) {
|
||||||
return (
|
const isAccepted = await isWaitlistUserAccepted();
|
||||||
<div className="flex items-center justify-center h-screen">
|
if (!isAccepted) {
|
||||||
<div className="max-w-lg w-full">
|
return (
|
||||||
<LogoSquare className="w-20 md:w-28 mb-8" />
|
<div className="flex items-center justify-center h-screen">
|
||||||
<h1 className="font-medium text-3xl">Not quite there yet</h1>
|
<div className="max-w-lg w-full">
|
||||||
<div className="text-lg">
|
<LogoSquare className="w-20 md:w-28 mb-8" />
|
||||||
We're still working on Openpanel, but we're not quite there yet.
|
<h1 className="font-medium text-3xl">Not quite there yet</h1>
|
||||||
We'll let you know when we're ready to go!
|
<div className="text-lg">
|
||||||
|
We're still working on Openpanel, but we're not quite there yet.
|
||||||
|
We'll let you know when we're ready to go!
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (organizations.length > 0) {
|
if (organizations.length > 0) {
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "waitlist" ADD COLUMN "accepted" BOOLEAN NOT NULL DEFAULT false;
|
||||||
@@ -153,6 +153,7 @@ model Waitlist {
|
|||||||
email String @unique
|
email String @unique
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @default(now()) @updatedAt
|
updatedAt DateTime @default(now()) @updatedAt
|
||||||
|
accepted Boolean @default(false)
|
||||||
|
|
||||||
@@map("waitlist")
|
@@map("waitlist")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { auth, clerkClient } from '@clerk/nextjs';
|
import { auth, clerkClient } from '@clerk/nextjs';
|
||||||
import type { User } from '@clerk/nextjs/dist/types/server';
|
import type { User } from '@clerk/nextjs/dist/types/server';
|
||||||
|
|
||||||
|
import { db } from '../prisma-client';
|
||||||
|
|
||||||
export function transformUser(user: User) {
|
export function transformUser(user: User) {
|
||||||
return {
|
return {
|
||||||
name: `${user.firstName} ${user.lastName}`,
|
name: `${user.firstName} ${user.lastName}`,
|
||||||
@@ -22,3 +24,18 @@ export async function getCurrentUser() {
|
|||||||
export async function getUserById(id: string) {
|
export async function getUserById(id: string) {
|
||||||
return clerkClient.users.getUser(id).then(transformUser);
|
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