diff --git a/src/sections/Advice/components/AdviceSlip.jsx b/src/sections/Advice/components/AdviceSlip.jsx index e69de29b..c1d450da 100644 --- a/src/sections/Advice/components/AdviceSlip.jsx +++ b/src/sections/Advice/components/AdviceSlip.jsx @@ -0,0 +1,29 @@ +import {useState, useEffect} from 'react'; + +function Advice({handleCreateFavorite}) { + + const [advice, setAdvice] = useState(); + + + const getNewAdvice = () => { + fetch(`https://api.adviceslip.com/advice`) + .then(res => res.json()) + .then(data => setAdvice(data.slip))} + + + useEffect(() => { + fetch(`https://api.adviceslip.com/advice`) + .then(res => res.json()) + .then(data =>setAdvice(data.slip)) + }, []) + + return( + <> +

{advice?.advice}

+ + + + ) + +} +export default Advice; \ No newline at end of file diff --git a/src/sections/Advice/components/FavouriteSlipsList.jsx b/src/sections/Advice/components/FavouriteSlipsList.jsx index e69de29b..d2d9747a 100644 --- a/src/sections/Advice/components/FavouriteSlipsList.jsx +++ b/src/sections/Advice/components/FavouriteSlipsList.jsx @@ -0,0 +1,17 @@ + +function FavouriteSlipsList({favorites}) { + +return( + <> + + +) + +} +export default FavouriteSlipsList; + + diff --git a/src/sections/Advice/index.jsx b/src/sections/Advice/index.jsx index 0405f11f..951f7deb 100644 --- a/src/sections/Advice/index.jsx +++ b/src/sections/Advice/index.jsx @@ -1,9 +1,30 @@ +import { useState } from 'react' +import AdviceSlip from './components/AdviceSlip.jsx' +import FavouriteSlipsList from './components/FavouriteSlipsList.jsx' + + function AdviceSection() { + +const [favorites, setFavorites] = useState([]) + + const handleCreateFavorite = (advice) => { + setFavorites(oldFavorites => [...oldFavorites, advice]) + + } return (

Advice Section

-
-
+
+

Some Advice

+ + +
+
+

Favourite Advice Slips

+ +
) } diff --git a/src/sections/Advice/template.html b/src/sections/Advice/template.html index 3949b691..bf677b94 100644 --- a/src/sections/Advice/template.html +++ b/src/sections/Advice/template.html @@ -1,12 +1,12 @@

Advice Section

-
+

Some Advice

Always the burrito.

-
+

Favourite Advice Slips

  • Measure twice, cut once.
  • diff --git a/src/sections/Art/components/ArtList.jsx b/src/sections/Art/components/ArtList.jsx index e69de29b..aec2dc36 100644 --- a/src/sections/Art/components/ArtList.jsx +++ b/src/sections/Art/components/ArtList.jsx @@ -0,0 +1,33 @@ +import ArtListItem from "./ArtListItem"; +import {useEffect, useState} from 'react'; + + + +function ArtList () { + const [artList, setArtList] = useState([]) + + useEffect(() => { + fetch("https://boolean-uk-api-server.fly.dev/art") + .then(res => res.json()) + .then(setArtList) + }, []) + + return ( + <> +
    +
      + {artList.map(item => ( + ))} +
    +
    + + ) + +} +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..0c2d76ef 100644 --- a/src/sections/Art/components/ArtListItem.jsx +++ b/src/sections/Art/components/ArtListItem.jsx @@ -0,0 +1,25 @@ + +import PublicationHistoryList from './PublicationHistoryList' + + +function ArtListItem({imageURL, title, artist, publicationHistory}) { + return( + <> +
  • +
    + +
    +

    {title}

    +

    Artist: {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..07878351 100644 --- a/src/sections/Art/components/PublicationHistoryList.jsx +++ b/src/sections/Art/components/PublicationHistoryList.jsx @@ -1 +1,11 @@ - +function PublicationHistoryList({publications}) { + return ( + <> + {publications.map((publication, index) => ( +
  • + {publication}
  • + ))} + + ) +} +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..dad9ae97 100644 --- a/src/sections/Art/index.jsx +++ b/src/sections/Art/index.jsx @@ -1,8 +1,10 @@ +import ArtList from './components/ArtList'; + function ArtsSection() { return (

    Arts Section

    -
    +
    ) } diff --git a/src/sections/Users/components/UsersList.jsx b/src/sections/Users/components/UsersList.jsx index e69de29b..21ebbc4c 100644 --- a/src/sections/Users/components/UsersList.jsx +++ b/src/sections/Users/components/UsersList.jsx @@ -0,0 +1,29 @@ +import {useEffect, useState} from 'react'; +import UsersListItem from './UsersListItem'; +function UsersList() { + + const [users, setUsers] = useState([]) + + useEffect(() => { + fetch(`https://boolean-uk-api-server.fly.dev/hannaklh/contact`) + .then(res => res.json()) + .then(setUsers) + }, []) + return( + <> +
    +
      + {users.map(user => ( + + ))} +
    +
    + + ) +} +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..992bd978 100644 --- a/src/sections/Users/components/UsersListItem.jsx +++ b/src/sections/Users/components/UsersListItem.jsx @@ -0,0 +1,15 @@ +function UsersListItem({imageURL, userName, favoriteColor, email}) { + return( + <> +
  • + {userName} +

    Mr {userName}

    +

    Email: {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..d23be72d 100644 --- a/src/sections/Users/index.jsx +++ b/src/sections/Users/index.jsx @@ -1,8 +1,11 @@ +import UsersList from './components/UsersList' + function UsersSection() { + return (

    Users Section

    -
    +
    ) }