From 9b12f09b39013718c7e895d70af0bbaebbda6213 Mon Sep 17 00:00:00 2001 From: Werapat Date: Sat, 28 Oct 2023 21:35:34 +0700 Subject: [PATCH] fixed : stuck loading screen on guest user --- app/product/[id]/page.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/product/[id]/page.tsx b/app/product/[id]/page.tsx index b732238..615b9da 100644 --- a/app/product/[id]/page.tsx +++ b/app/product/[id]/page.tsx @@ -42,14 +42,15 @@ export default async function Page({ params }: { params: { id: string } }) { }, })); - if (!is_reviewable || !user) return
Loading ....
- const prev_review = await db.review.findFirst({ + if (is_reviewable === null) return
Loading ...
+ + const prev_review = (!user) ? null : ( await db.review.findFirst({ where : { productId : id, userId : user.id as string } - }) - + })) + console.log(prev_review) const is_reviewables : Cascade_review[] = is_reviewable.reviews const data = await db.product.findFirst({ where: { @@ -176,7 +177,7 @@ export default async function Page({ params }: { params: { id: string } }) {
Review section
- + {(isAuthenticated()) ? ( ): (<>)}