From ab3858cd8cacaa3772726940775bfd8f36e6d653 Mon Sep 17 00:00:00 2001
From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com>
Date: Sat, 16 Sep 2023 12:49:29 -0500
Subject: [PATCH] feat: add catch all 404 component
---
src/app/error.tsx | 3 +++
src/app/global-error.tsx | 2 ++
src/app/not-found.tsx | 24 ++++++++++++++++++++++++
src/app/profile/[id]/page.tsx | 4 ++--
src/components/DisplayPost.tsx | 6 +++---
src/components/EditPostForm.tsx | 4 ++--
6 files changed, 36 insertions(+), 7 deletions(-)
create mode 100644 src/app/not-found.tsx
diff --git a/src/app/error.tsx b/src/app/error.tsx
index 518afa1..9e2d2c1 100644
--- a/src/app/error.tsx
+++ b/src/app/error.tsx
@@ -7,6 +7,8 @@ export default function Error({
error: Error;
reset: () => void;
}) {
+ console.log(error);
+
return (
@@ -14,6 +16,7 @@ export default function Error({
Oops it looks like we've run into an issue.
+ );
+}
diff --git a/src/app/profile/[id]/page.tsx b/src/app/profile/[id]/page.tsx
index 8636556..70c5f8d 100644
--- a/src/app/profile/[id]/page.tsx
+++ b/src/app/profile/[id]/page.tsx
@@ -1,3 +1,4 @@
+import NotFound from '@/app/not-found';
import UserPosts from '@/components/UserPosts';
import UserProfile from '@/components/UserProfile';
import { getConvexClient } from '@/lib/convex';
@@ -19,8 +20,7 @@ export default async function UserProfilePage({
});
if (user === 'USER_NOT_FOUND') {
- // TODO: Show real not found component
- return
Not Found
;
+ return
;
}
return (
diff --git a/src/components/DisplayPost.tsx b/src/components/DisplayPost.tsx
index d638976..77f5ab2 100644
--- a/src/components/DisplayPost.tsx
+++ b/src/components/DisplayPost.tsx
@@ -1,9 +1,10 @@
'use client';
+import NotFound from '@/app/not-found';
+import { useRouter } from '@/hooks';
import { useUser } from '@clerk/nextjs';
import { useMutation, useQuery } from 'convex/react';
import Image from 'next/image';
-import { useRouter } from '@/hooks';
import { useEffect, useRef } from 'react';
import { api } from '../../convex/_generated/api';
import { Id } from '../../convex/_generated/dataModel';
@@ -62,8 +63,7 @@ export default function DisplayPost({
}
if (post === 'POST_NOT_FOUND' || post === 'USER_FOR_POST_NOT_FOUND') {
- // TODO: Return actual not found component
- return
Not Found
;
+ return
;
}
if (post !== undefined && user.isLoaded) {
diff --git a/src/components/EditPostForm.tsx b/src/components/EditPostForm.tsx
index 8929c48..e77ad94 100644
--- a/src/components/EditPostForm.tsx
+++ b/src/components/EditPostForm.tsx
@@ -1,5 +1,6 @@
'use client';
+import NotFound from '@/app/not-found';
import { useRouter } from '@/hooks';
import { useUser } from '@clerk/nextjs';
import { useMutation, useQuery } from 'convex/react';
@@ -22,8 +23,7 @@ export default function EditPostForm({ postId }: { postId: string }) {
}
if (post === 'POST_NOT_FOUND' || post === 'USER_FOR_POST_NOT_FOUND') {
- // TODO: Return actual not found component
- return
Not Found
;
+ return
;
}
async function submitAction({