Skip to content

Commit 912d2d5

Browse files
committed
Fix deleted website visibility bug
Closes #3865
1 parent 3072f02 commit 912d2d5

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

src/app/(main)/links/[linkId]/page.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import type { Metadata } from 'next';
2+
import { getLink } from '@/queries/prisma';
23
import { LinkPage } from './LinkPage';
34

45
export default async function ({ params }: { params: Promise<{ linkId: string }> }) {
56
const { linkId } = await params;
7+
const link = await getLink(linkId);
8+
9+
if (!link || link?.deletedAt) {
10+
return null;
11+
}
612

713
return <LinkPage linkId={linkId} />;
814
}

src/app/(main)/pixels/[pixelId]/page.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import type { Metadata } from 'next';
2+
import { getPixel } from '@/queries/prisma';
23
import { PixelPage } from './PixelPage';
34

45
export default async function ({ params }: { params: { pixelId: string } }) {
56
const { pixelId } = await params;
7+
const pixel = await getPixel(pixelId);
8+
9+
if (!pixel || pixel?.deletedAt) {
10+
return null;
11+
}
612

713
return <PixelPage pixelId={pixelId} />;
814
}

src/app/(main)/websites/[websiteId]/layout.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Metadata } from 'next';
22
import { WebsiteLayout } from '@/app/(main)/websites/[websiteId]/WebsiteLayout';
3+
import { getWebsite } from '@/queries/prisma';
34

45
export default async function ({
56
children,
@@ -9,6 +10,11 @@ export default async function ({
910
params: Promise<{ websiteId: string }>;
1011
}) {
1112
const { websiteId } = await params;
13+
const website = await getWebsite(websiteId);
14+
15+
if (!website || website?.deletedAt) {
16+
return null;
17+
}
1218

1319
return <WebsiteLayout websiteId={websiteId}>{children}</WebsiteLayout>;
1420
}

src/lib/request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export async function setWebsiteDate(websiteId: string, userId: string, data: Re
8585
const website = await fetchWebsite(websiteId);
8686
const cloudMode = !!process.env.CLOUD_MODE;
8787

88-
if (cloudMode && !website.teamId) {
88+
if (cloudMode && website && !website.teamId) {
8989
const account = await fetchAccount(userId);
9090

9191
if (!account?.hasSubscription) {

0 commit comments

Comments
 (0)