From 0d98511de64fb144224d70219ac47c453cef197a Mon Sep 17 00:00:00 2001 From: Linda Do Date: Mon, 1 Sep 2025 13:32:07 +0200 Subject: [PATCH 1/5] core --- src/sections/Art/index.jsx | 39 +++++++++++++++++++++++++++++++++++- src/sections/Users/index.jsx | 27 ++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/src/sections/Art/index.jsx b/src/sections/Art/index.jsx index 0c74ffc2..c0e8aaef 100644 --- a/src/sections/Art/index.jsx +++ b/src/sections/Art/index.jsx @@ -1,8 +1,45 @@ +import{ useEffect, useState } from 'react' + function ArtsSection() { + const baseUrl = "https://boolean-uk-api-server.fly.dev" + const url = "https://boolean-uk-api-server.fly.dev/art" + const [filteredData, setFilteredData] = useState([]) + + useEffect(() => { + const fetchData = async () => { + const response = await fetch(url) + const jsonData = await response.json() + setFilteredData(jsonData) + } + fetchData() + }, []) + + + return (

Arts Section

-
+
+
    +
  • + {filteredData.map((art, index) => ( +
    + {art.name} + {console.log(baseUrl + art.image)} +

    {art.title}

    +

    {"Artist: " + art.artist}

    +

    Publication History:

    +
      +
    • {art.publicationHistory[0]}
    • +
    • {art.publicationHistory[1]}
    • +
    • {art.publicationHistory[2]}
    • +
    +
    + ))} + +
  • +
+
) } diff --git a/src/sections/Users/index.jsx b/src/sections/Users/index.jsx index 77332830..4a351fcc 100644 --- a/src/sections/Users/index.jsx +++ b/src/sections/Users/index.jsx @@ -1,8 +1,33 @@ +import{ useEffect, useState } from 'react' + function UsersSection() { + const url = "https://boolean-uk-api-server.fly.dev/lindadqd/contact" + + const [filteredData, setFilteredData] = useState([]) + + useEffect(() => { + const fetchData = async () => { + const response = await fetch(url) + const jsonData = await response.json() + setFilteredData(jsonData) + } + fetchData() + }, []) + return (

Users Section

-
+
+
    + {filteredData.map((user, index) => ( +
  • + +

    {user.firstName +" "+ user.lastName}

    +

    Email: {user.email}

    +
  • + ))} +
+
) } From cb46b5497e1df1d15604a0cddb176a14602183df Mon Sep 17 00:00:00 2001 From: Linda Do Date: Mon, 1 Sep 2025 14:03:08 +0200 Subject: [PATCH 2/5] extension --- src/sections/Advice/index.jsx | 45 +++++++++++++++++++++++++++++++++-- src/sections/Art/index.jsx | 1 + 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/sections/Advice/index.jsx b/src/sections/Advice/index.jsx index 0405f11f..4fb9c024 100644 --- a/src/sections/Advice/index.jsx +++ b/src/sections/Advice/index.jsx @@ -1,11 +1,52 @@ +import{ useEffect, useState } from 'react' + function AdviceSection() { + const url = "https://api.adviceslip.com/advice" + const [random, setRandom] = useState(null) + const [favourites, setFavourites] = useState([]) + + const fetchData = async () => { + const response = await fetch(url) + const jsonData = await response.json() + setRandom(jsonData) + } + + useEffect(() => { + fetchData() + }, []) + + const handleAddFavourite = () => { + if (random && random.slip) { + // Avoid duplicates + if (!favourites.some(fav => fav.id === random.slip.id)) { + setFavourites([...favourites, random.slip]) + } + } + } + return (

Advice Section

-
-
+
+

Some Advice

+

{random && random.slip ? random.slip.advice : "Loading..."}

+ + +
+
+

Favourite Advice Slips

+
    + {favourites.map(slip => ( +
  • {slip.advice}
  • + ))} +
+
) } export default AdviceSection + + diff --git a/src/sections/Art/index.jsx b/src/sections/Art/index.jsx index c0e8aaef..84085312 100644 --- a/src/sections/Art/index.jsx +++ b/src/sections/Art/index.jsx @@ -33,6 +33,7 @@ function ArtsSection() {
  • {art.publicationHistory[0]}
  • {art.publicationHistory[1]}
  • {art.publicationHistory[2]}
  • + ))} From f74b5b6354d68d3c6191c6984cfd89398d75f7da Mon Sep 17 00:00:00 2001 From: Linda Do Date: Mon, 1 Sep 2025 14:31:54 +0200 Subject: [PATCH 3/5] art components --- src/sections/Art/components/ArtList.jsx | 17 ++++++++++++++++ src/sections/Art/components/ArtListItem.jsx | 15 ++++++++++++++ .../Art/components/PublicationHistoryList.jsx | 11 ++++++++++ src/sections/Art/index.jsx | 20 ++----------------- 4 files changed, 45 insertions(+), 18 deletions(-) diff --git a/src/sections/Art/components/ArtList.jsx b/src/sections/Art/components/ArtList.jsx index e69de29b..8906107d 100644 --- a/src/sections/Art/components/ArtList.jsx +++ b/src/sections/Art/components/ArtList.jsx @@ -0,0 +1,17 @@ +import ArtListItem from "./ArtListItem" + +function ArtList(props) { + const { artList } = props + const baseUrl = props + + console.log(baseUrl) + return ( +
  • + {artList.map((art, index) => ( + + ))} +
  • + ) +} + +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..dbfd7c17 100644 --- a/src/sections/Art/components/ArtListItem.jsx +++ b/src/sections/Art/components/ArtListItem.jsx @@ -0,0 +1,15 @@ +import PublicationHistoryList from "./PublicationHistoryList" + +function ArtListItem({art, index, baseUrl}){ + return ( +
    + {art.name} +

    {art.title}

    +

    {"Artist: " + art.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..a9780458 100644 --- a/src/sections/Art/components/PublicationHistoryList.jsx +++ b/src/sections/Art/components/PublicationHistoryList.jsx @@ -1 +1,12 @@ +function PublicationHistoryList({art}){ + return( +
      +
    • {art.publicationHistory[0]}
    • +
    • {art.publicationHistory[1]}
    • +
    • {art.publicationHistory[2]}
    • +
    + ) +} + +export default PublicationHistoryList \ No newline at end of file diff --git a/src/sections/Art/index.jsx b/src/sections/Art/index.jsx index 84085312..11d74808 100644 --- a/src/sections/Art/index.jsx +++ b/src/sections/Art/index.jsx @@ -1,4 +1,5 @@ import{ useEffect, useState } from 'react' +import ArtList from './components/ArtList' function ArtsSection() { const baseUrl = "https://boolean-uk-api-server.fly.dev" @@ -21,24 +22,7 @@ function ArtsSection() {

    Arts Section

      -
    • - {filteredData.map((art, index) => ( -
      - {art.name} - {console.log(baseUrl + art.image)} -

      {art.title}

      -

      {"Artist: " + art.artist}

      -

      Publication History:

      -
        -
      • {art.publicationHistory[0]}
      • -
      • {art.publicationHistory[1]}
      • -
      • {art.publicationHistory[2]}
      • - -
      -
      - ))} - -
    • +
    From 6f6e1bc1482e15df4b687badf58d9a5830549456 Mon Sep 17 00:00:00 2001 From: Linda Do Date: Mon, 1 Sep 2025 14:38:13 +0200 Subject: [PATCH 4/5] Users components --- src/sections/Users/components/UsersList.jsx | 15 +++++++++++++++ src/sections/Users/components/UsersListItem.jsx | 12 ++++++++++++ src/sections/Users/index.jsx | 11 ++--------- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/sections/Users/components/UsersList.jsx b/src/sections/Users/components/UsersList.jsx index e69de29b..87a50b8e 100644 --- a/src/sections/Users/components/UsersList.jsx +++ b/src/sections/Users/components/UsersList.jsx @@ -0,0 +1,15 @@ +import UsersListItem from "./UsersListItem" + +function UsersList(props) { + const { users } = props + + return ( +
      + {users.map((user, index) => ( + + ))} +
    + ) +} + +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..895dd13c 100644 --- a/src/sections/Users/components/UsersListItem.jsx +++ b/src/sections/Users/components/UsersListItem.jsx @@ -0,0 +1,12 @@ +function UsersListItem({user, index}) { + return ( +
  • + +

    {user.firstName +" "+ 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 4a351fcc..4f0f8da7 100644 --- a/src/sections/Users/index.jsx +++ b/src/sections/Users/index.jsx @@ -1,4 +1,5 @@ import{ useEffect, useState } from 'react' +import UsersList from './components/UsersList' function UsersSection() { const url = "https://boolean-uk-api-server.fly.dev/lindadqd/contact" @@ -18,15 +19,7 @@ function UsersSection() {

    Users Section

    -
      - {filteredData.map((user, index) => ( -
    • - -

      {user.firstName +" "+ user.lastName}

      -

      Email: {user.email}

      -
    • - ))} -
    +
    ) From 6d02b3d7c8fa9896067097ef0dae2d9a3173d31e Mon Sep 17 00:00:00 2001 From: Linda Do Date: Mon, 1 Sep 2025 15:11:54 +0200 Subject: [PATCH 5/5] completed --- src/sections/Advice/components/AdviceSlip.jsx | 16 ++++++++++++++ .../Advice/components/FavouriteSlipsList.jsx | 15 +++++++++++++ src/sections/Advice/index.jsx | 21 ++++--------------- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/sections/Advice/components/AdviceSlip.jsx b/src/sections/Advice/components/AdviceSlip.jsx index e69de29b..c89cf29d 100644 --- a/src/sections/Advice/components/AdviceSlip.jsx +++ b/src/sections/Advice/components/AdviceSlip.jsx @@ -0,0 +1,16 @@ +function AdviceSlip(props){ + const {random, handleAddFavourite, fetchData} = props + + return( +
    +

    Some Advice

    +

    {random && random.slip ? random.slip.advice : "Loading..."}

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

    Favourite Advice Slips

    +
      + {favourites.map(slip => ( +
    • {slip.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 4fb9c024..3eec577b 100644 --- a/src/sections/Advice/index.jsx +++ b/src/sections/Advice/index.jsx @@ -1,4 +1,6 @@ import{ useEffect, useState } from 'react' +import AdviceSlip from './components/AdviceSlip' +import FavouriteSlipsList from './components/FavouriteSlipsList' function AdviceSection() { const url = "https://api.adviceslip.com/advice" @@ -17,7 +19,6 @@ function AdviceSection() { const handleAddFavourite = () => { if (random && random.slip) { - // Avoid duplicates if (!favourites.some(fav => fav.id === random.slip.id)) { setFavourites([...favourites, random.slip]) } @@ -27,22 +28,8 @@ function AdviceSection() { return (

    Advice Section

    -
    -

    Some Advice

    -

    {random && random.slip ? random.slip.advice : "Loading..."}

    - - -
    -
    -

    Favourite Advice Slips

    -
      - {favourites.map(slip => ( -
    • {slip.advice}
    • - ))} -
    -
    + +
    ) }