Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function App() {
const [pets, setPets] = useState([]);
const [page, setPage] = useState(1);
const [totalPages, setTotalPages] = useState(1);
let content, pagination;

useEffect(() => {
async function fetchData() {
Expand All @@ -33,6 +34,14 @@ function App() {
setPage(data.activePage);
};

if(pets.length > 0) {
content = <Card.Group className="centered" stackable>{pets.map(pet => PetCard(pet))}</Card.Group>;
pagination = <Pagination activePage={page} onPageChange={onPageChange} totalPages={totalPages}></Pagination>;
} else {
content = <div><h1>Where are our pets ?</h1><p>It seems like these guys are playing hide and seek.<br /> They'll be back once we find them.</p></div>;
pagination = '';
}

return (
<div className="App">
<header className="App-header">
Expand All @@ -43,15 +52,11 @@ function App() {
</header>
<div className="App-content">
<Container>
<Card.Group className="centered" stackable>{pets.map(pet => PetCard(pet))}</Card.Group>
{content}
</Container>
</div>
<div className="App-pagination">
<Pagination
activePage={page}
onPageChange={onPageChange}
totalPages={totalPages}
></Pagination>
{pagination}
</div>
</div>
);
Expand Down