Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

dashboard: allow accepted users in

Carl-Gerhard Lindesvärd4786adb05242
diff --git a/apps/dashboard/src/app/(app)/[organizationId]/page.tsx b/apps/dashboard/src/app/(app)/[organizationId]/page.tsx
index 1b1b08ba6..ea705c603 100644
--- a/apps/dashboard/src/app/(app)/[organizationId]/page.tsx
+++ b/apps/dashboard/src/app/(app)/[organizationId]/page.tsx
@@ -1,10 +1,12 @@
import { LogoSquare } from '@/components/Logo';
import { ProjectCard } from '@/components/projects/project-card';
+import { notFound, redirect } from 'next/navigation';
+
import {
getOrganizationBySlug,
getProjectsByOrganizationSlug,
+ isWaitlistUserAccepted,
} from '@openpanel/db';
-import { notFound, redirect } from 'next/navigation';
import { CreateProject } from './create-project';
@@ -25,18 +27,21 @@ export default async function Page({ params: { organizationId } }: PageProps) {
}
if (process.env.BLOCK) {
- return (
- <div className="flex items-center justify-center h-screen">
- <div className="max-w-lg w-full">
- <LogoSquare className="w-20 md:w-28 mb-8" />
- <h1 className="font-medium text-3xl">Not quite there yet</h1>
- <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!
+ const isAccepted = await isWaitlistUserAccepted();
+ if (!isAccepted) {
+ return (
+ <div className="flex items-center justify-center h-screen">
+ <div className="max-w-lg w-full">
+ <LogoSquare className="w-20 md:w-28 mb-8" />
+ <h1 className="font-medium text-3xl">Not quite there yet</h1>
+ <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>
- );
+ );
+ }
}
if (projects.length === 0) {
diff --git a/apps/dashboard/src/app/(app)/page.tsx b/apps/dashboard/src/app/(app)/page.tsx
index 86a03e2b5..45907d65d 100644
--- a/apps/dashboard/src/app/(app)/page.tsx
+++ b/apps/dashboard/src/app/(app)/page.tsx
@@ -1,27 +1,30 @@
// import { CreateOrganization } from '@clerk/nextjs';
import { LogoSquare } from '@/components/Logo';
-import { getCurrentOrganizations } from '@openpanel/db';
import { redirect } from 'next/navigation';
+import { getCurrentOrganizations, isWaitlistUserAccepted } from '@openpanel/db';
+
import { CreateOrganization } from './create-organization';
export default async function Page() {
const organizations = await getCurrentOrganizations();
-
if (process.env.BLOCK) {
- return (
- <div className="flex items-center justify-center h-screen">
- <div className="max-w-lg w-full">
- <LogoSquare className="w-20 md:w-28 mb-8" />
- <h1 className="font-medium text-3xl">Not quite there yet</h1>
- <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!
+ const isAccepted = await isWaitlistUserAccepted();
+ if (!isAccepted) {
+ return (
+ <div className="flex items-center justify-center h-screen">
+ <div className="max-w-lg w-full">
+ <LogoSquare className="w-20 md:w-28 mb-8" />
+ <h1 className="font-medium text-3xl">Not quite there yet</h1>
+ <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>
- );
+ );
+ }
}
if (organizations.length > 0) {
diff --git a/packages/db/prisma/migrations/20240311201118_add_accepted_to_waitinglist/migration.sql b/packages/db/prisma/migrations/20240311201118_add_accepted_to_waitinglist/migration.sql
new file mode 100644
index 000000000..4d3ef3055
--- /dev/null
+++ b/packages/db/prisma/migrations/20240311201118_add_accepted_to_waitinglist/migration.sql
@@ -0,0 +1,2 @@
+-- AlterTable
+ALTER TABLE "waitlist" ADD COLUMN "accepted" BOOLEAN NOT NULL DEFAULT false;
diff --git a/packages/db/prisma/schema.prisma b/packages/db/prisma/schema.prisma
index 815e63c54..1800d5786 100644
--- a/packages/db/prisma/schema.prisma
+++ b/packages/db/prisma/schema.prisma
@@ -153,6 +153,7 @@ model Waitlist {
email String @unique
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
+ accepted Boolean @default(false)
@@map("waitlist")
}
diff --git a/packages/db/src/services/user.service.ts b/packages/db/src/services/user.service.ts
index a41815ce2..8921fe1cc 100644
--- a/packages/db/src/services/user.service.ts
+++ b/packages/db/src/services/user.service.ts
@@ -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;
+}