Skip to content

Commit 24ad3f4

Browse files
Feature/waitlist (#281)
* feat: waitlist * fix rendering
1 parent c224dfd commit 24ad3f4

11 files changed

Lines changed: 84 additions & 7 deletions

File tree

apps/console/src/app.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { Suspense } from "react";
3838
import { FullScreenLoader } from "./components/common/FullScreenLoader";
3939
import { OrgPage } from "./pages/projects/OrgPage";
4040
import { useCurrentOrganization } from "./lib/hooks/useCurrentOrganization";
41+
import { WaitlistWrapper } from "~/pages/WaitlistWrapper";
4142

4243
initSuperTokens();
4344

@@ -101,7 +102,9 @@ export function App() {
101102
path="/onboarding"
102103
element={
103104
<LayoutWrapper withSideNav={false}>
104-
<OnboardingPage />
105+
<WaitlistWrapper>
106+
<OnboardingPage />
107+
</WaitlistWrapper>
105108
</LayoutWrapper>
106109
}
107110
/>
@@ -112,7 +115,9 @@ export function App() {
112115
element={
113116
<LayoutWrapper withSideNav={false} withOrgSubHeader={true}>
114117
<Suspense fallback={<FullScreenLoader />}>
115-
<Outlet />
118+
<WaitlistWrapper>
119+
<Outlet />
120+
</WaitlistWrapper>
116121
</Suspense>
117122
</LayoutWrapper>
118123
}
@@ -131,7 +136,9 @@ export function App() {
131136
<CurrentPromptProvider>
132137
<RequiredProviderApiKeyModalProvider>
133138
<LayoutWrapper withSideNav={true}>
134-
<Outlet />
139+
<WaitlistWrapper>
140+
<Outlet />
141+
</WaitlistWrapper>
135142
</LayoutWrapper>
136143
</RequiredProviderApiKeyModalProvider>
137144
</CurrentPromptProvider>

apps/console/src/components/layout/OrgSubHeader.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ const isActive = (href: string) => {
88

99
export const OrgSubHeader = () => {
1010
const navigate = useNavigate();
11-
const { organization } = useCurrentOrganization();
11+
const { organization, waitlisted } = useCurrentOrganization();
1212

13-
if (!organization) {
13+
if (!organization || waitlisted) {
1414
return;
1515
}
1616

apps/console/src/graphql/definitions/queries/organizations.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const GET_ORGANIZATION = graphql(/* GraphQL */ `
1818
organization(data: $data) {
1919
id
2020
name
21+
waitlisted
2122
members @include(if: $includeMembers) {
2223
id
2324
role

apps/console/src/lib/hooks/useCurrentOrganization.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,6 @@ export const useCurrentOrganization = ({
5959
error,
6060
currentOrgId,
6161
selectOrg,
62+
waitlisted: data?.organization?.waitlisted,
6263
};
6364
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { useMemo } from "react";
2+
import { useCurrentOrganization } from "./useCurrentOrganization";
3+
4+
export const useWaitlist = () => {
5+
const { isSuccess, currentOrgId, waitlisted } = useCurrentOrganization();
6+
7+
const shouldRenderWaitlistNotice = useMemo(() => {
8+
return isSuccess && currentOrgId && waitlisted;
9+
}, [isSuccess, currentOrgId, waitlisted]);
10+
11+
return {
12+
shouldRenderWaitlistNotice,
13+
};
14+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { useGetCurrentUser } from "~/graphql/hooks/queries";
2+
import { useWaitlist } from "~/lib/hooks/useWaitlist";
3+
4+
export const WaitlistWrapper = ({ children }) => {
5+
const { shouldRenderWaitlistNotice } = useWaitlist();
6+
const { data: currentUserData } = useGetCurrentUser();
7+
8+
if (shouldRenderWaitlistNotice) {
9+
return (
10+
<div className="container mx-auto p-8 text-center">
11+
<h1 className="mb-4 font-heading font-medium">
12+
You're on the waitlist!
13+
</h1>
14+
<div className="space-y-4 text-neutral-400">
15+
<p>Thank you for signing up for Pezzo Cloud.</p>
16+
<p>
17+
You will receive an invitation at{" "}
18+
<span className="font-semibold">{currentUserData.me.email}</span>{" "}
19+
soon.
20+
</p>
21+
<p>
22+
Need access sooner? Email us at{" "}
23+
<a
24+
className="font-semibold text-primary underline"
25+
href="mailto:[email protected]"
26+
>
27+
28+
</a>
29+
</p>
30+
</div>
31+
</div>
32+
);
33+
} else {
34+
return children;
35+
}
36+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- AlterTable
2+
ALTER TABLE "Organization" ADD COLUMN "waitlisted" BOOLEAN NOT NULL DEFAULT false;

apps/server/prisma/schema.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ model Organization {
8383
apiKeys ApiKey[]
8484
providerApiKeys ProviderApiKey[]
8585
invitations Invitation[]
86+
waitlisted Boolean @default(false)
8687
}
8788

8889
model OrganizationMember {

apps/server/src/app/config/common-config-schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const commonConfigSchema = {
2222
KMS_KEY_ARN: Joi.string().default(
2323
"arn:aws:kms:us-east-1:111122223333:key/demo-master-key"
2424
),
25+
WAITLIST_ENABLED: Joi.boolean().default(false),
2526
};
2627

2728
const cloudConfigSchema = {

apps/server/src/app/identity/organizations.service.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { Injectable } from "@nestjs/common";
22
import { PrismaService } from "../prisma.service";
33
import { OrgRole } from "@prisma/client";
4+
import { ConfigService } from "@nestjs/config";
45

56
@Injectable()
67
export class OrganizationsService {
7-
constructor(private readonly prisma: PrismaService) {}
8+
constructor(
9+
private readonly prisma: PrismaService,
10+
private config: ConfigService
11+
) {}
812

913
async getById(id: string) {
1014
return await this.prisma.organization.findUnique({ where: { id } });
@@ -108,9 +112,12 @@ export class OrganizationsService {
108112
}
109113

110114
async createOrg(name: string, creatorUserId: string) {
115+
const waitlisted = this.config.get("WAITLIST_ENABLED");
116+
111117
return await this.prisma.organization.create({
112118
data: {
113119
name,
120+
waitlisted,
114121
members: {
115122
create: {
116123
userId: creatorUserId,

0 commit comments

Comments
 (0)