diff --git a/src/App.css b/src/App.css index 2e479417..27b2c14b 100644 --- a/src/App.css +++ b/src/App.css @@ -17,6 +17,7 @@ ul[class] { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); + gap: 2rem; } .scroll-container { diff --git a/src/sections/Advice/components/AdviceSlip.jsx b/src/sections/Advice/components/AdviceSlip.jsx index e69de29b..3f2a0758 100644 --- a/src/sections/Advice/components/AdviceSlip.jsx +++ b/src/sections/Advice/components/AdviceSlip.jsx @@ -0,0 +1,16 @@ +function AdviceSlip({ advice, onGetNewAdvice, onSaveToFavourites }) { + if (!advice) { + return

Loading advice...

+ } + + return ( +
+

Some Advice For You:

+

{advice.advice}

+ + +
+ ) +} + +export default AdviceSlip \ No newline at end of file diff --git a/src/sections/Advice/components/FavouriteSlipsList.jsx b/src/sections/Advice/components/FavouriteSlipsList.jsx index e69de29b..c640c930 100644 --- a/src/sections/Advice/components/FavouriteSlipsList.jsx +++ b/src/sections/Advice/components/FavouriteSlipsList.jsx @@ -0,0 +1,25 @@ +function FavouriteSlipsList({ favouriteSlips }) { + if (favouriteSlips.length === 0) { + return ( +
+

Your Favourite Advice Slips

+

No favourite slips yet. Save some advice!

+
+ ) + } + + return ( +
+

Your Favourite Advice Slips

+ +
+ ) +} + +export default FavouriteSlipsList \ No newline at end of file diff --git a/src/sections/Advice/index.jsx b/src/sections/Advice/index.jsx index 0405f11f..66dcfd62 100644 --- a/src/sections/Advice/index.jsx +++ b/src/sections/Advice/index.jsx @@ -1,9 +1,41 @@ +import { useState, useEffect } from 'react' +import AdviceSlip from './components/AdviceSlip' +import FavouriteSlipsList from './components/FavouriteSlipsList' + function AdviceSection() { + const [currentAdvice, setCurrentAdvice] = useState(null) + const [favouriteSlips, setFavouriteSlips] = useState([]) + + const fetchAdvice = () => { + fetch(`https://api.adviceslip.com/advice?timestamp=${Date.now()}`) + .then(response => response.json()) + .then(data => setCurrentAdvice(data.slip)) + .catch(error => console.error('Error fetching advice:', error)) + } + + const saveToFavourites = () => { + if (currentAdvice && !favouriteSlips.some(slip => slip.id === currentAdvice.id)) { + setFavouriteSlips([...favouriteSlips, currentAdvice]) + } + } + + useEffect(() => { + fetchAdvice() + }, []) + return (

Advice Section

-
-
+
+ +
+
+ +
) } diff --git a/src/sections/Art/components/ArtList.jsx b/src/sections/Art/components/ArtList.jsx index e69de29b..69c147f8 100644 --- a/src/sections/Art/components/ArtList.jsx +++ b/src/sections/Art/components/ArtList.jsx @@ -0,0 +1,13 @@ +import ArtListItem from './ArtListItem' + +function ArtList({ artworks }) { + return ( + + ) +} + +export default ArtList \ No newline at end of file diff --git a/src/sections/Art/components/ArtListItem.jsx b/src/sections/Art/components/ArtListItem.jsx index e69de29b..99276e60 100644 --- a/src/sections/Art/components/ArtListItem.jsx +++ b/src/sections/Art/components/ArtListItem.jsx @@ -0,0 +1,19 @@ +import PublicationHistoryList from './PublicationHistoryList' + +function ArtListItem({ artwork }) { + const imageUrl = `https://boolean-uk-api-server.fly.dev${artwork.imageURL}` + + return ( +
  • +
    + {artwork.title} +
    +

    {artwork.title}

    +

    Artist: {artwork.artist}

    +

    Publication History:

    + +
  • + ) +} + +export default ArtListItem \ No newline at end of file diff --git a/src/sections/Art/components/PublicationHistoryList.jsx b/src/sections/Art/components/PublicationHistoryList.jsx index d3f5a12f..c319d585 100644 --- a/src/sections/Art/components/PublicationHistoryList.jsx +++ b/src/sections/Art/components/PublicationHistoryList.jsx @@ -1 +1,11 @@ +function PublicationHistoryList({ publications }) { + return ( + + ) +} +export default PublicationHistoryList \ No newline at end of file diff --git a/src/sections/Art/index.jsx b/src/sections/Art/index.jsx index 0c74ffc2..6201ad51 100644 --- a/src/sections/Art/index.jsx +++ b/src/sections/Art/index.jsx @@ -1,8 +1,21 @@ +import { useState, useEffect } from 'react' +import ArtList from './components/ArtList' + function ArtsSection() { + const [artworks, setArtworks] = useState([]) + + useEffect(() => { + fetch('https://boolean-uk-api-server.fly.dev/art') + .then(response => response.json()) + .then(data => setArtworks(data)) + }, []) + return (

    Arts Section

    -
    +
    + +
    ) } diff --git a/src/sections/Users/components/UsersList.jsx b/src/sections/Users/components/UsersList.jsx index e69de29b..1dc574d0 100644 --- a/src/sections/Users/components/UsersList.jsx +++ b/src/sections/Users/components/UsersList.jsx @@ -0,0 +1,13 @@ +import UsersListItem from './UsersListItem' + +function UsersList({ users }) { + return ( + + ) +} + +export default UsersList \ No newline at end of file diff --git a/src/sections/Users/components/UsersListItem.jsx b/src/sections/Users/components/UsersListItem.jsx index e69de29b..76f97577 100644 --- a/src/sections/Users/components/UsersListItem.jsx +++ b/src/sections/Users/components/UsersListItem.jsx @@ -0,0 +1,14 @@ +function UsersListItem({ user }) { + const gravatarUrl = `https://www.gravatar.com/avatar/${user.email}?s=120&d=identicon` + const fullName = `${user.title} ${user.firstName} ${user.lastName}` + + return ( +
  • + {fullName} +

    {fullName}

    +

    Email: {user.email}

    +
  • + ) +} + +export default UsersListItem \ No newline at end of file diff --git a/src/sections/Users/index.jsx b/src/sections/Users/index.jsx index 77332830..cec31110 100644 --- a/src/sections/Users/index.jsx +++ b/src/sections/Users/index.jsx @@ -1,8 +1,22 @@ +import { useState, useEffect } from 'react' +import UsersList from './components/UsersList' + function UsersSection() { + const [users, setUsers] = useState([]) + + useEffect(() => { + fetch('https://boolean-uk-api-server.fly.dev/davidstern/contact') + .then(response => response.json()) + .then(data => setUsers(data)) + .catch(error => console.error('Error fetching users:', error)) + }, []) + return (

    Users Section

    -
    +
    + +
    ) }