Create Detailed Book Page + fixes

This commit is contained in:
Ray 2023-11-14 08:14:38 +00:00 committed by GitHub
parent c6a20f8f89
commit f3e076e450
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 3 deletions

View File

@ -22,7 +22,7 @@ import { Contact } from "./pages/Contact"
import { Signup } from "./pages/Signup" import { Signup } from "./pages/Signup"
import { Signout } from "./pages/Signout" import { Signout } from "./pages/Signout"
import { Signin } from "./pages/Signin" import { Signin } from "./pages/Signin"
import { Detail } from "./pages/Detail";
// contexts // contexts
import { AuthContext } from "./contexts/AuthContext" import { AuthContext } from "./contexts/AuthContext"
import { StorageContext } from "./contexts/StorageContext"; import { StorageContext } from "./contexts/StorageContext";
@ -141,6 +141,7 @@ const readData = async () => {
<Route path="/signup" element={ <Signup handler={signUp}/> } /> <Route path="/signup" element={ <Signup handler={signUp}/> } />
<Route path="/signout" element={ <Signout handler={logOut}/> } /> <Route path="/signout" element={ <Signout handler={logOut}/> } />
<Route path="/signin" element={ <Signin handler={signIn} authstate={auth}/> } /> <Route path="/signin" element={ <Signin handler={signIn} authstate={auth}/> } />
<Route path="/detail/:id" element={<Detail/>} />
</Routes> </Routes>
</StorageContext.Provider> </StorageContext.Provider>
</AuthContext.Provider> </AuthContext.Provider>

22
src/pages/Detail.js Normal file
View File

@ -0,0 +1,22 @@
import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';
import Container from "react-bootstrap/Container";
import { useParams } from 'react-router-dom';
export function Detail(props) {
let { id } = useParams();
return(
<Container>
<Row>
<Col md={6}>
<h1>Image</h1>
</Col>
<Col md={6}>
<h2>Details</h2>
<p>{id}</p>
</Col>
</Row>
</Container>
)
}

View File

@ -16,9 +16,12 @@ export function Home(props) {
const ItemCards = books.map( ( book, itemkey ) => { const ItemCards = books.map( ( book, itemkey ) => {
const itemLink = `/detail/${book.id}`
return( return(
<Col md={4}> <Col md={4} className="mb-4">
<Card key={itemkey}> <Card key={itemkey} className="position-relative">
<a href={itemLink} className="position-absolute" style={{top:0, left:0, right:0, bottom:0}}>
</a>
<ItemImage source={ book.cover_image} /> <ItemImage source={ book.cover_image} />
<Card.Body> <Card.Body>
<Card.Title>{ book.book_title }</Card.Title> <Card.Title>{ book.book_title }</Card.Title>