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) { - +