Fix issues with Submitting Reviews
This commit is contained in:
parent
c67f881305
commit
96e8af57ec
|
@ -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">
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in New Issue