From 38a5d39f806e8b94508b236f6caaa614f769d76d Mon Sep 17 00:00:00 2001 From: "Rayyan (Rayy)" Date: Tue, 14 Nov 2023 14:40:00 +0000 Subject: [PATCH] Modiy lesson work from book context to movie context --- src/pages/Detail.js | 84 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 69 insertions(+), 15 deletions(-) diff --git a/src/pages/Detail.js b/src/pages/Detail.js index b19d52c..51106fb 100644 --- a/src/pages/Detail.js +++ b/src/pages/Detail.js @@ -1,22 +1,76 @@ import Row from 'react-bootstrap/Row'; import Col from 'react-bootstrap/Col'; +import Form from 'react-bootstrap/Form'; import Container from "react-bootstrap/Container"; - +import { useState, useEffect } from 'react'; import { useParams } from 'react-router-dom'; +import { ItemImage } from '../components/ItemImage'; +import Button from 'react-bootstrap/Button'; export function Detail(props) { + const [movieData, setBookData] = useState() + let { id } = useParams(); - return( - - - -

Image

- - -

Details

-

{id}

- -
-
- ) -} \ No newline at end of file + + useEffect(() => { + if (!movieData) { + props.handler(id).then((movie) => setMovieData(movie)) + } + }, [id]); + + if (movieData) { + return ( + + + +

{movieData.movie_title}

+ +
+ + + + + +

More information

+

Summary

+

{movieData.summary}

+

Author

+

{movieData.author}

+

ISBN

+

ISBN10: {movieData.isbn10}

+

ISBN13: {movieData.isbn13}

+
+

Review this movie

+ + Star + + + + + + + + + + Title + + + + Review + + + +
+ +
+ + + +
+ ) + } + else { + return null + } + +}