1- 'use client' ;
21import { useContext , useEffect , useState } from 'react' ;
32import { useParams , Link } from 'react-router-dom' ;
43import { MdFavorite , MdFavoriteBorder , MdStar } from 'react-icons/md' ;
@@ -17,7 +16,7 @@ import { onAuthStateChanged, User } from 'firebase/auth';
1716import { AuthContext } from '@/lib/firebase' ;
1817import NotFound from './NotFound' ;
1918
20- const MoviePage = ( ) => {
19+ export default function MoviePage ( ) {
2120 const { id } = useParams ( ) as { id : string } ;
2221 const [ movie , setMovie ] = useState < GetMovieByIdResponse [ 'movie' ] | null > ( null ) ;
2322 const [ loading , setLoading ] = useState ( true ) ;
@@ -60,25 +59,25 @@ const MoviePage = () => {
6059 }
6160 } , [ id , authUser ] ) ;
6261
63- const fetchSimilarMovies = async ( description : string ) => {
62+ async function fetchSimilarMovies ( description : string ) {
6463 try {
6564 const response = await searchMovieDescriptionUsingL2similarity ( { query : description } ) ;
6665 setSimilarMovies ( response ?. data ?. movies_descriptionEmbedding_similarity ) ;
6766 } catch ( error ) {
6867 console . error ( 'Error fetching similar movies:' , error ) ;
6968 }
70- } ;
69+ }
7170
72- const checkIfFavorited = async ( ) => {
71+ async function checkIfFavorited ( ) {
7372 try {
7473 const response = await getIfFavoritedMovie ( { movieId : id } ) ;
7574 setIsFavorited ( ! ! response . data . favorite_movie ) ;
7675 } catch ( error ) {
7776 console . error ( 'Error checking if favorited:' , error ) ;
7877 }
79- } ;
78+ }
8079
81- const handleFavoriteToggle = async ( e : React . MouseEvent ) => {
80+ async function handleFavoriteToggle ( e : React . MouseEvent ) {
8281 e . stopPropagation ( ) ;
8382 e . preventDefault ( ) ;
8483 if ( ! authUser ) return ;
@@ -92,23 +91,23 @@ const MoviePage = () => {
9291 } catch ( error ) {
9392 console . error ( 'Error updating favorite status:' , error ) ;
9493 }
95- } ;
94+ }
9695
97- const handleReviewSubmit = async ( e : React . FormEvent ) => {
96+ async function handleReviewSubmit ( e : React . FormEvent ) {
9897 e . preventDefault ( ) ;
9998 if ( ! authUser ) return ;
10099 try {
101- await addReview ( { movieId : id , rating, reviewText } ) ;
100+ await addReview ( { movieId : id , rating, reviewText } ) ;
102101 setReviewText ( '' ) ;
103102 setRating ( 0 ) ;
104103 const updatedMovie = await getMovieById ( { id } ) ;
105104 setMovie ( updatedMovie . data . movie ) ;
106105 } catch ( error ) {
107106 console . error ( 'Error adding review:' , error ) ;
108107 }
109- } ;
108+ }
110109
111- const handleReviewDelete = async ( e : React . MouseEvent ) => {
110+ async function handleReviewDelete ( e : React . MouseEvent ) {
112111 e . stopPropagation ( ) ;
113112 e . preventDefault ( ) ;
114113 if ( ! authUser || ! userReview ) return ;
@@ -120,11 +119,13 @@ const MoviePage = () => {
120119 } catch ( error ) {
121120 console . error ( 'Error deleting review:' , error ) ;
122121 }
123- } ;
122+ }
123+
124124 if ( loading ) return < p > Loading...</ p > ;
125125 if ( ! movie ) return < NotFound /> ;
126+
126127 return (
127- < div className = "container mx-auto p-4 bg-gray-900 min-h-screen text-white" >
128+ < div className = "container mx-auto p-4 bg-gray-900 min-h-screen text-white" >
128129 < div className = "flex flex-col md:flex-row mb-8" >
129130 < img className = "w-full md:w-1/3 object-cover rounded-lg shadow-md" src = { movie . imageUrl } alt = { movie . title } />
130131 < div className = "md:ml-8 mt-4 md:mt-0 flex-1" >
@@ -272,7 +273,6 @@ const MoviePage = () => {
272273 ) ) }
273274 </ div >
274275 </ div >
275- </ div > ) ;
276- } ;
277-
278- export default MoviePage ;
276+ </ div >
277+ ) ;
278+ }
0 commit comments