From 96e8af57ecc75e2059ae633fe42d82dad407430d Mon Sep 17 00:00:00 2001 From: "Rayyan (Rayy)" Date: Tue, 28 Nov 2023 09:03:22 +0000 Subject: [PATCH] Fix issues with Submitting Reviews --- src/components/ReviewForm.js | 16 +++++++++------- src/pages/Detail.js | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/ReviewForm.js b/src/components/ReviewForm.js index 5b370e3..719cf7b 100644 --- a/src/components/ReviewForm.js +++ b/src/components/ReviewForm.js @@ -6,13 +6,7 @@ import { FSContext } from "../contexts/FSContext" import { useContext, useState, useEffect } from "react" import { collection, addDoc } from "firebase/firestore"; -const submitHandler = async (event) => { -event.preventDefault() -const userReview = {title: title, star: star, body: review } -const col = collection(db, `movies/${props.movieId}/reviews`) -const ref = await addDoc(col, userReview ) -console.log( ref ) -} + export function ReviewForm(props) { const auth = useContext(AuthContext) @@ -31,6 +25,14 @@ export function ReviewForm(props) { setValid( false ) } }, [star, title, review]) + + const submitHandler = async (event) => { + event.preventDefault() + const userReview = {title: title, star: star, body: review } + const col = collection(db, `movies/${props.movieId}/reviews`) + const ref = await addDoc(col, userReview ) + console.log( ref ) + } if (auth) { return ( diff --git a/src/pages/Detail.js b/src/pages/Detail.js index 6475fbd..de77680 100644 --- a/src/pages/Detail.js +++ b/src/pages/Detail.js @@ -50,7 +50,7 @@ export function Detail(props) { - +