Skip to content

Commit

Permalink
Merge pull request #229 from fac28/handle-error-redirect
Browse files Browse the repository at this point in the history
Handle error redirect
  • Loading branch information
yuqingwwang authored Dec 6, 2023
2 parents 80848fb + a8544a2 commit 384fae2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
7 changes: 6 additions & 1 deletion app/item/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ export default async function listing({
.select(itemQuery)
.eq('item_id', params.id)
if (error || !data || data.length === 0) {
throw new Error('Error fetching data')
// throw new Error('Error fetching data')
return (
<PageContainer>
<h1>Oops, item not found</h1>
</PageContainer>
)
}

const {
Expand Down
12 changes: 12 additions & 0 deletions app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Link from 'next/link'
import PageContainer from '@/components/global-layout/PageContainer'

export default function NotFound() {
return (
<PageContainer>
<h2>Not Found</h2>
<p>Could not find requested resource</p>
<Link href="/">Return Home</Link>
</PageContainer>
)
}
3 changes: 1 addition & 2 deletions app/products/[category]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ export default async function Page({
}: {
params: { category: string }
}) {
// capitalize first letter of category

const categoryName =
decodeURIComponent(params.category)[0].toUpperCase() +
decodeURIComponent(params.category).slice(1)

const items = await fetchItemsByCategory(categoryName)
const { user, supabase } = await getUser()

Expand Down
4 changes: 1 addition & 3 deletions app/review/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ export default async function Review({ params }: { params: { id: string } }) {
</PageContainer>
) : (
<PageContainer>
<div>
<h1>Log in to leave a review</h1>
</div>
<h1>Log in to leave a review</h1>
</PageContainer>
)
}
6 changes: 5 additions & 1 deletion app/seller/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ export default async function listing({
.eq('id', sellerID)

if (error || !data || data.length === 0) {
throw new Error('Error fetching data')
return (
<PageContainer>
<h1>Oops, seller not found</h1>
</PageContainer>
)
}

const reviewData: Review[] = await fetchReviewBySeller(supabase, sellerID)
Expand Down

0 comments on commit 384fae2

Please sign in to comment.