From 55d0ce4b69ec286acd787601efac639962afe7f4 Mon Sep 17 00:00:00 2001 From: thaisrocine_ Date: Fri, 14 Feb 2025 18:45:47 -0300 Subject: [PATCH] correcao no endpoint --- src/app/reviews/view/[bookId]/page.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/app/reviews/view/[bookId]/page.tsx b/src/app/reviews/view/[bookId]/page.tsx index 4f4fb88..7fea842 100644 --- a/src/app/reviews/view/[bookId]/page.tsx +++ b/src/app/reviews/view/[bookId]/page.tsx @@ -17,20 +17,22 @@ export default function Reviews() { const router = useRouter(); const handleCreateReview = (type: string) => { - if (book) { + if (!book?.id) { + console.error("ID do livro não encontrado!"); + return; + } + + if (type === "create") { localStorage.setItem("bookIdForReview", book.id); - if (type === "create") { - router.push("/reviews/create"); - } else { - console.log(book.id, "meu id book"); - router.push(`/reviews/all/${book.id}`); - } + router.push("/reviews/create"); + } else { + router.push(`/reviews/book/${book.id}`); } }; useEffect(() => { if (!bookId || Array.isArray(bookId)) { - setError("ID do livro inválido."); + setError("ID do livro inválido!"); setLoading(false); return; }