diff --git a/src/components/FullscreenWrapper.module.scss b/src/components/FullscreenWrapper.module.scss index 066957a..0ffffdf 100644 --- a/src/components/FullscreenWrapper.module.scss +++ b/src/components/FullscreenWrapper.module.scss @@ -1,6 +1,6 @@ .wrapper { width: 100%; - height: 100vh; + height: 100%; padding: 70px 30px 0; color: var(--color-black); diff --git a/src/components/Select.jsx b/src/components/Select.jsx new file mode 100644 index 0000000..5c25d62 --- /dev/null +++ b/src/components/Select.jsx @@ -0,0 +1,37 @@ +import PropTypes from "prop-types"; +import classnames from "classnames"; + +function Select({ name, disabled, className, options, value }) { + return ( + + ); + } + +Select.propTypes = { + name: PropTypes.string.isRequired, + disabled: PropTypes.bool, + className: PropTypes.string, + options: PropTypes.array, +}; + +Select.defaultProps = { + name: "Select", + disabled: false, + className: null, + options: [], + }; + +export default Select; \ No newline at end of file diff --git a/src/components/index.js b/src/components/index.js index f82e569..99c94ac 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -3,3 +3,4 @@ export { default as CustomLink } from "components/CustomLink"; export { default as FullscreenWrapper } from "components/FullscreenWrapper"; export { default as Input } from "components/Input"; export { default as Loader } from "components/Loader"; +export { default as Select } from "components/Select"; diff --git a/src/constants/ActionTypes.js b/src/constants/ActionTypes.js index 0eefe60..b7ace14 100644 --- a/src/constants/ActionTypes.js +++ b/src/constants/ActionTypes.js @@ -7,3 +7,9 @@ export const auth = keyMirror({ LOGOUT: null, }); + +export const dog = keyMirror({ + FETCH_DOG_PENDING: null, + FETCH_DOG_COMPLETED: null, + FETCH_DOG_FAILED: null, +}); \ No newline at end of file diff --git a/src/global.css b/src/global.css index efecfff..581506d 100644 --- a/src/global.css +++ b/src/global.css @@ -1,3 +1,23 @@ +.thumb { + width: 250px; + height: 250px; +} + +.small { + width: 500px; + height: 500px; +} + +.med { + width: 750px; + height: 750px; +} + +.full { + width: 1000px; + height: 1000px; +} + .m-all-1 { margin: var(--space-1); } diff --git a/src/pages/Home.jsx b/src/pages/Home.jsx index 30f8287..5f9c312 100644 --- a/src/pages/Home.jsx +++ b/src/pages/Home.jsx @@ -1,17 +1,138 @@ -import { FullscreenWrapper, CustomLink } from "components"; +import { useState, useEffect } from "react"; +import { useSelector, useDispatch } from "react-redux"; + +import { FullscreenWrapper, CustomLink, Loader, Button, Input, Select } from "components"; +import { logout } from "redux/actions/authActions"; + +import { fetchDogs } from "redux/actions/dogActions"; +import { waitForDomChange } from "@testing-library/react"; function Home() { - const userName = null; + const username = useSelector(s => s.auth.username); + const fetchingDogs = useSelector(s => s.dog.fetchingDogs); + const dogsList = useSelector(s => s.dog.dogsList); + + const dispatch = useDispatch(); + + const [currentPage, setCurrentPage] = useState(0); + const [photoLimit, setPhotoLimit] = useState(10); + const [ascending, setAscending] = useState(true); + const [selection, setSelection] = useState("thumb"); + + useEffect(function onMount(){ + if (username){ + dispatch(fetchDogs( + { + page: currentPage, + limit: photoLimit, + order: ascending ? "ASC" : "DESC" + } + )); + } + }, [currentPage, ascending, selection]); + + function handleValueChange(e, valueCb) { + const newValue = e.target.value; + valueCb(newValue); + } + + function handleCurrentPageDecrement() { + if (currentPage === 0) { + return; + } + + setCurrentPage(currentPage -1); + } + + function handleCurrentPageIncrement() { + setCurrentPage(currentPage +1); + } + + function handleOrderChange() { + setAscending(!ascending); + } + + function handleLogout() { + dispatch(logout()); + } + + function handleSelectChange(e, valueCb) { + console.log("selection changed") + const newValue = e.target.value; + valueCb(newValue); + } return (

Doggo List

- {userName - ? `Welcome, ${userName}!` + {username + ? `Welcome, ${username}!` : "To see a list of doggos, please log in first."}

- + {username ? ( +
+
+