Currently broken, Johannes to investigate
This commit is contained in:
parent
5ae1e96146
commit
0d7d7d575a
|
@ -125,6 +125,7 @@ const readData = async () => {
|
||||||
listdata.push( item )
|
listdata.push( item )
|
||||||
})
|
})
|
||||||
setData( listdata )
|
setData( listdata )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,44 +3,73 @@ import Col from 'react-bootstrap/Col';
|
||||||
import Container from "react-bootstrap/Container";
|
import Container from "react-bootstrap/Container";
|
||||||
import Card from "react-bootstrap/Card";
|
import Card from "react-bootstrap/Card";
|
||||||
|
|
||||||
import {ref, getDownloadURL} from "firebase/storage"
|
import { ref, getDownloadURL } from "firebase/storage"
|
||||||
import { useState, useEffect, useContext } from "react"
|
import { useState, useEffect, useContext } from "react"
|
||||||
import { StorageContext } from '../contexts/StorageContext';
|
import { StorageContext } from '../contexts/StorageContext';
|
||||||
|
|
||||||
export function Home ( props ) {
|
export function Home(props) {
|
||||||
const [ books, setBooks ] = useState([])
|
const [books, setBooks] = useState([props.items])
|
||||||
|
|
||||||
const Storage = useContext( StorageContext )
|
const Storage = useContext(StorageContext)
|
||||||
|
console.log(props.items)
|
||||||
|
|
||||||
useEffect( () => {
|
// useEffect( () => {
|
||||||
setBooks( props.items )
|
// if( books.length === 0 )
|
||||||
console.log( props.items )
|
// setBooks(props.items)
|
||||||
},[props.items])
|
// }
|
||||||
|
// , [props.items])
|
||||||
|
|
||||||
// collection
|
// card image component
|
||||||
const Items = books.map( (item, key) => {
|
const ItemImage = (props) => {
|
||||||
|
const [image, setImage] = useState()
|
||||||
|
useEffect(() => {
|
||||||
|
|
||||||
|
|
||||||
|
}, [props.name, image])
|
||||||
|
const imgRef = ref(Storage, `book_covers/${props.name}`)
|
||||||
|
if (image) {
|
||||||
|
return (
|
||||||
|
<Card.Img variant="top" src={image} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
return (
|
||||||
|
<p>Loading...</p>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!books) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// collection
|
||||||
|
const Items = books.map((item, key) => {
|
||||||
return (
|
return (
|
||||||
<Col key={key} md="4">
|
<Col key={key} md="4">
|
||||||
<Card>
|
<Card>
|
||||||
<Card.Body>
|
<Card.Body>
|
||||||
|
<ItemImage name={item.cover_image} />
|
||||||
<Card.Title>{item.book_title}</Card.Title>
|
<Card.Title>{item.book_title}</Card.Title>
|
||||||
<Card.Text>
|
<Card.Text>
|
||||||
By {item.author}
|
By {item.author}
|
||||||
</Card.Text>
|
</Card.Text>
|
||||||
|
<Card.Text>{item.cover_image}</Card.Text>
|
||||||
</Card.Body>
|
</Card.Body>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
</Col>
|
</Col>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
return (
|
||||||
|
<Container>
|
||||||
|
<Row>
|
||||||
|
{Items}
|
||||||
|
</Row>
|
||||||
|
</Container>
|
||||||
|
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
|
||||||
<Container>
|
|
||||||
<Row>
|
|
||||||
{Items}
|
|
||||||
</Row>
|
|
||||||
</Container>
|
|
||||||
|
|
||||||
)
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue