From 60b4d093d643fc7d7ddc66719afb139726341895 Mon Sep 17 00:00:00 2001 From: Trym Haugan Berger Date: Tue, 2 Sep 2025 09:48:12 +0200 Subject: [PATCH] completed --- src/sections/Advice/components/AdviceSlip.jsx | 16 ++++++++++++ .../Advice/components/FavouriteSlipsList.jsx | 15 +++++++++++ src/sections/Advice/index.jsx | 26 ++++++++++++++++--- src/sections/Art/components/ArtList.jsx | 14 ++++++++++ src/sections/Art/components/ArtListItem.jsx | 22 ++++++++++++++++ src/sections/Art/index.jsx | 20 ++++++++++---- src/sections/Users/components/UsersList.jsx | 14 ++++++++++ .../Users/components/UsersListItem.jsx | 15 +++++++++++ src/sections/Users/index.jsx | 15 +++++++++-- 9 files changed, 147 insertions(+), 10 deletions(-) diff --git a/src/sections/Advice/components/AdviceSlip.jsx b/src/sections/Advice/components/AdviceSlip.jsx index e69de29b..54627795 100644 --- a/src/sections/Advice/components/AdviceSlip.jsx +++ b/src/sections/Advice/components/AdviceSlip.jsx @@ -0,0 +1,16 @@ + +function AdviceSlip({newadvice, fetchNewAdvice, saveToFavourites}) { + return ( + <> +

Advice Section

+
+

Advice #{newadvice.slip.id}

+

{newadvice.slip.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..bef93dbf 100644 --- a/src/sections/Advice/components/FavouriteSlipsList.jsx +++ b/src/sections/Advice/components/FavouriteSlipsList.jsx @@ -0,0 +1,15 @@ + +function FavouriteSlipsList({favourites}) { + return ( +
+

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..6b7245a9 100644 --- a/src/sections/Advice/index.jsx +++ b/src/sections/Advice/index.jsx @@ -1,9 +1,29 @@ +import { useEffect, useState } from "react" +import AdviceSlip from "./components/AdviceSlip"; +import FavouriteSlipsList from "./components/FavouriteSlipsList"; + function AdviceSection() { + +const [favAdvices, setfavAdvices] = useState([]); +const [newadvice, setnewadvice] = useState({slip:{id: "0", advice: "Loading..."}}); +const [newfetch, setnewfetch] = useState(false) +const baseurl = 'https://api.adviceslip.com/advice' + +useEffect(() => {fetch(baseurl).then(res => res.json()).then(setnewadvice)}, [newfetch]) +console.log(newadvice) + +const fetchNewAdvice = () => { + setnewfetch(!newfetch) +}; + +const saveToFavourites = () => { + setfavAdvices(prev => [...prev, newadvice]) +} + return (
-

Advice Section

-
-
+ +
) } diff --git a/src/sections/Art/components/ArtList.jsx b/src/sections/Art/components/ArtList.jsx index e69de29b..5405a72b 100644 --- a/src/sections/Art/components/ArtList.jsx +++ b/src/sections/Art/components/ArtList.jsx @@ -0,0 +1,14 @@ +import ArtListItem from "./ArtListItem" + + +function ArtList({arts, baseurl}) { + 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..b18bd77f 100644 --- a/src/sections/Art/components/ArtListItem.jsx +++ b/src/sections/Art/components/ArtListItem.jsx @@ -0,0 +1,22 @@ + +function ArtListItem({baseurl, art}) { + return ( +
  • +
    + +
    +

    {art.title}

    +

    Artist: {art.artist}

    +

    Publication History:

    + +
  • + ) +} + +export default ArtListItem \ No newline at end of file diff --git a/src/sections/Art/index.jsx b/src/sections/Art/index.jsx index 0c74ffc2..0e1db9b2 100644 --- a/src/sections/Art/index.jsx +++ b/src/sections/Art/index.jsx @@ -1,10 +1,20 @@ +import { useEffect, useState } from "react" +import ArtList from "./components/ArtList"; + function ArtsSection() { + + const [arts, setArts] = useState([]); + const baseurl = 'https://boolean-uk-api-server.fly.dev' + + useEffect(() => {fetch('https://boolean-uk-api-server.fly.dev/art').then(res => res.json()).then(setArts)}, []) + return ( -
    -

    Arts Section

    -
    -
    +
    +

    Arts Section

    +
    + +
    +
    ) } - export default ArtsSection diff --git a/src/sections/Users/components/UsersList.jsx b/src/sections/Users/components/UsersList.jsx index e69de29b..c7c85a7a 100644 --- a/src/sections/Users/components/UsersList.jsx +++ b/src/sections/Users/components/UsersList.jsx @@ -0,0 +1,14 @@ +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..b7f37427 100644 --- a/src/sections/Users/components/UsersListItem.jsx +++ b/src/sections/Users/components/UsersListItem.jsx @@ -0,0 +1,15 @@ + +function UsersListItem({user}) { + return ( +
  • + {user.firstName.concat(" +

    {user.firstName.concat(" ").concat(user.lastName)}

    +

    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..d0e2c4b9 100644 --- a/src/sections/Users/index.jsx +++ b/src/sections/Users/index.jsx @@ -1,8 +1,19 @@ +import { useEffect, useState } from "react" +import UsersList from "./components/UsersList"; + function UsersSection() { + +const [users, setUsers] = useState([]); +const baseurl = 'https://boolean-uk-api-server.fly.dev/598115/contact' + +useEffect(() => {fetch(baseurl).then(res => res.json()).then(setUsers)}, []) + return (
    -

    Users Section

    -
    +

    Users Section

    +
    + +
    ) }