Fix issues with Submitting Reviews

This commit is contained in:
Ray 2023-11-28 09:03:22 +00:00 committed by GitHub
parent c67f881305
commit 96e8af57ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -6,13 +6,7 @@ import { FSContext } from "../contexts/FSContext"
import { useContext, useState, useEffect } from "react" import { useContext, useState, useEffect } from "react"
import { collection, addDoc } from "firebase/firestore"; 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) { export function ReviewForm(props) {
const auth = useContext(AuthContext) const auth = useContext(AuthContext)
@ -32,6 +26,14 @@ export function ReviewForm(props) {
} }
}, [star, title, review]) }, [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) { if (auth) {
return ( return (
<Form onSubmit={submitHandler} className="my-4"> <Form onSubmit={submitHandler} className="my-4">

View File

@ -50,7 +50,7 @@ export function Detail(props) {
</Row> </Row>
<Row> <Row>
<Col> <Col>
<ReviewForm movietitle={movieData.movie_title} movieId={movieData.movieId} /> <ReviewForm movietitle={movieData.movie_title} movieId={movieData.id} />
</Col> </Col>
</Row> </Row>
</Container> </Container>