Skip to content

Commit

Permalink
[spaces] handle not found page
Browse files Browse the repository at this point in the history
  • Loading branch information
sabovyan committed Dec 3, 2023
1 parent 45b4033 commit a49383c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
22 changes: 22 additions & 0 deletions app/spaces/[id]/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Link from 'next/link';

export default function NotFound() {
return (
<div>
<h3 className="text-3xl">Oops Your Space was not found</h3>

<div className="flex flex-col gap-2 mt-4">
<p>
Go back to{' '}
<Link href="/spaces" className="underline">
Your Spaces
</Link>{' '}
or{' '}
<Link href="/" className="underline">
Home Page
</Link>
</p>
</div>
</div>
);
}
10 changes: 8 additions & 2 deletions app/spaces/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { notFound } from 'next/navigation';

import { prisma } from '@/lib/prisma';

export default async function SingleSpace({
Expand All @@ -7,9 +9,13 @@ export default async function SingleSpace({
}) {
const space = await prisma.space.findUnique({ where: { id: params.id } });

return space ? (
if (!space) {
notFound();
}

return (
<div>
<h1>{space.name}</h1>
</div>
) : null;
);
}

0 comments on commit a49383c

Please sign in to comment.