Add Book Review Form to Book Detail Page
This commit is contained in:
parent
258483b023
commit
6761b6358d
|
@ -1,33 +1,35 @@
|
||||||
import Row from 'react-bootstrap/Row';
|
import Row from 'react-bootstrap/Row';
|
||||||
import Col from 'react-bootstrap/Col';
|
import Col from 'react-bootstrap/Col';
|
||||||
|
import Form from 'react-bootstrap/Form';
|
||||||
import Container from "react-bootstrap/Container";
|
import Container from "react-bootstrap/Container";
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { ItemImage } from '../components/ItemImage';
|
import { ItemImage } from '../components/ItemImage';
|
||||||
|
import Button from 'react-bootstrap/Button';
|
||||||
|
|
||||||
export function Detail(props) {
|
export function Detail(props) {
|
||||||
const [bookData, setBookData] = useState()
|
const [bookData, setBookData] = useState()
|
||||||
|
|
||||||
let { id } = useParams();
|
let { id } = useParams();
|
||||||
|
|
||||||
useEffect( () => {
|
useEffect(() => {
|
||||||
if( !bookData ) {
|
if (!bookData) {
|
||||||
props.handler(id).then( (book) => setBookData(book) )
|
props.handler(id).then((book) => setBookData(book))
|
||||||
}
|
}
|
||||||
}, [id])
|
}, [id])
|
||||||
|
|
||||||
|
|
||||||
if( bookData ) {
|
if (bookData) {
|
||||||
return(
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
<Row>
|
<Row>
|
||||||
<Col>
|
<Col>
|
||||||
<h1>{bookData.book_title}</h1>
|
<h1>{bookData.book_title}</h1>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<Row>
|
<Row>
|
||||||
<Col md={6}>
|
<Col md={6}>
|
||||||
<ItemImage source={bookData.cover_image} />
|
<ItemImage source={bookData.cover_image} />
|
||||||
</Col>
|
</Col>
|
||||||
<Col md={6}>
|
<Col md={6}>
|
||||||
<h2>More information</h2>
|
<h2>More information</h2>
|
||||||
|
@ -36,14 +38,40 @@ export function Detail(props) {
|
||||||
<h3>Author</h3>
|
<h3>Author</h3>
|
||||||
<p>{bookData.author}</p>
|
<p>{bookData.author}</p>
|
||||||
<h3>ISBN</h3>
|
<h3>ISBN</h3>
|
||||||
<p>ISBN10 {bookData.isbn10}</p>
|
<p>ISBN10: {bookData.isbn10}</p>
|
||||||
<p>ISBN13 {bookData.isbn13}</p>
|
<p>ISBN13: {bookData.isbn13}</p>
|
||||||
|
<Form>
|
||||||
|
<h3>Review this book</h3>
|
||||||
|
<Form.Group>
|
||||||
|
<Form.Label>Star</Form.Label>
|
||||||
|
<Form.Select>
|
||||||
|
<option value="1">1</option>
|
||||||
|
<option value="2">2</option>
|
||||||
|
<option value="3">3</option>
|
||||||
|
<option value="4">4</option>
|
||||||
|
<option value="5">5</option>
|
||||||
|
</Form.Select>
|
||||||
|
</Form.Group>
|
||||||
|
<Form.Group>
|
||||||
|
<Form.Label>Title</Form.Label>
|
||||||
|
<Form.Control type="text" placeholder="I love this book" />
|
||||||
|
</Form.Group>
|
||||||
|
<Form.Group>
|
||||||
|
<Form.Label>Review</Form.Label>
|
||||||
|
<Form.Control as="textarea" rows={3} cols={30} placeholder="I could not put this down!" />
|
||||||
|
</Form.Group>
|
||||||
|
<Button type="submit" variant="primary">Submit</Button>
|
||||||
|
</Form>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
<Row>
|
||||||
|
<Col></Col>
|
||||||
|
</Row>
|
||||||
</Container>
|
</Container>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue