diff --git a/src/sections/Advice/components/AdviceSlip.jsx b/src/sections/Advice/components/AdviceSlip.jsx index e69de29b..06f37ea0 100644 --- a/src/sections/Advice/components/AdviceSlip.jsx +++ b/src/sections/Advice/components/AdviceSlip.jsx @@ -0,0 +1,11 @@ +const AdviceSlip = ({advice, fetchAdvice, saveToFavourites}) => { + return ( +
+

Some 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..a7c283ed 100644 --- a/src/sections/Advice/components/FavouriteSlipsList.jsx +++ b/src/sections/Advice/components/FavouriteSlipsList.jsx @@ -0,0 +1,13 @@ +const FavouriteSlipsList = ({favourites}) => { + return ( +
+

Favourite Advice Slips

+ {favourites.map((advice, index) => ( +
  • +

    {advice}

    +
  • + ))} +
    + ) +} +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..9d39e46a 100644 --- a/src/sections/Advice/index.jsx +++ b/src/sections/Advice/index.jsx @@ -1,9 +1,40 @@ +import { useEffect, useState } from "react" +import AdviceSlip from "./components/AdviceSlip"; +import FavouriteSlipsList from "./components/FavouriteSlipsList"; + function AdviceSection() { + const url = "https://api.adviceslip.com/advice"; + const [advice, setAdvice] = useState(""); + const [favourites, setFavourites] = useState([]); + + const fetchAdvice = async () => { + console.log("Fetching advice"); + const response = await fetch(url); + const jsonData = await response.json(); + setAdvice(jsonData.slip.advice); + } + + const saveToFavourites = () => { + if (favourites.includes(advice)) { + return; + } + setFavourites((prevFavourites) => [...prevFavourites, advice]); + console.log("Added advice"); + } + + useEffect( () => { + fetchAdvice(); + } , []); + return (

    Advice Section

    -
    -
    + +
    ) } diff --git a/src/sections/Art/components/ArtList.jsx b/src/sections/Art/components/ArtList.jsx index e69de29b..c0b93ecf 100644 --- a/src/sections/Art/components/ArtList.jsx +++ b/src/sections/Art/components/ArtList.jsx @@ -0,0 +1,25 @@ +import ArtListItem from "./ArtListItem"; + +const ArtList = ({data, baseImgUrl}) => { + + 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..ed4a09a8 100644 --- a/src/sections/Art/components/ArtListItem.jsx +++ b/src/sections/Art/components/ArtListItem.jsx @@ -0,0 +1,18 @@ +import PublicationHistoryList from "./PublicationHistoryList"; + +const ArtListItem = ({imageURL, title, artist, pubHistory}) => { + + 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..da3cdb41 100644 --- a/src/sections/Art/components/PublicationHistoryList.jsx +++ b/src/sections/Art/components/PublicationHistoryList.jsx @@ -1 +1,11 @@ +const PublicationHistoryList = ({ data }) => { + 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..67352274 100644 --- a/src/sections/Art/index.jsx +++ b/src/sections/Art/index.jsx @@ -1,8 +1,25 @@ +import { useEffect, useState } from "react" +import ArtList from "./components/ArtList"; + function ArtsSection() { + + const url = "https://boolean-uk-api-server.fly.dev/art"; + const baseImgUrl = "https://boolean-uk-api-server.fly.dev"; + const [data, setData] = useState([]); + + useEffect( () => { + const fetchData = async () => { + const response = await fetch(url); + const jsonData = await response.json(); + setData(jsonData) + } + fetchData(); + } , []); + return (

    Arts Section

    -
    +
    ) } diff --git a/src/sections/Users/components/UsersList.jsx b/src/sections/Users/components/UsersList.jsx index e69de29b..0f72cc81 100644 --- a/src/sections/Users/components/UsersList.jsx +++ b/src/sections/Users/components/UsersList.jsx @@ -0,0 +1,20 @@ +import UserListItem from "./UsersListItem"; + +const UserList = ( {data} ) => { + return ( + + ) +} + +export default UserList; \ No newline at end of file diff --git a/src/sections/Users/components/UsersListItem.jsx b/src/sections/Users/components/UsersListItem.jsx index e69de29b..8c12fdb8 100644 --- a/src/sections/Users/components/UsersListItem.jsx +++ b/src/sections/Users/components/UsersListItem.jsx @@ -0,0 +1,11 @@ +const UserListItem = ({image, firstName, lastName, email, favColor}) => { + return ( +
  • + {`${firstName} +

    {`${firstName} ${lastName}`}

    +

    Email: {email}

    +
  • + ) +} + +export default UserListItem; \ No newline at end of file diff --git a/src/sections/Users/index.jsx b/src/sections/Users/index.jsx index 77332830..936a2c62 100644 --- a/src/sections/Users/index.jsx +++ b/src/sections/Users/index.jsx @@ -1,8 +1,26 @@ +import {useState, useEffect} from "react"; +import UserList from "./components/UsersList"; + function UsersSection() { + + const url = "https://boolean-uk-api-server.fly.dev/hansjhaland/contact"; + const [data, setData] = useState([]); + + useEffect( () => { + const fetchData = async () => { + const response = await fetch(url); + const jsonData = await response.json(); + setData(jsonData) + } + fetchData(); + } , []); + return (

    Users Section

    -
    +
    + +
    ) }