From f8565eb16b336567c34e9996129ad6f6cf0e58b1 Mon Sep 17 00:00:00 2001 From: Jakub Mroz Date: Mon, 1 Sep 2025 10:23:37 +0200 Subject: [PATCH 1/4] feat: core art --- src/sections/Art/components/ArtList.jsx | 14 +++++++ src/sections/Art/components/ArtListItem.jsx | 21 ++++++++++ .../Art/components/PublicationHistoryList.jsx | 13 +++++++ src/sections/Art/index.jsx | 38 ++++++++++++++++++- 4 files changed, 85 insertions(+), 1 deletion(-) diff --git a/src/sections/Art/components/ArtList.jsx b/src/sections/Art/components/ArtList.jsx index e69de29b..3f22ed0a 100644 --- a/src/sections/Art/components/ArtList.jsx +++ b/src/sections/Art/components/ArtList.jsx @@ -0,0 +1,14 @@ +import React from 'react' +import ArtListItem from './ArtListItem' + +function ArtList({data, url}) { + 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..556edcc0 100644 --- a/src/sections/Art/components/ArtListItem.jsx +++ b/src/sections/Art/components/ArtListItem.jsx @@ -0,0 +1,21 @@ +import React, { useEffect, useState } from 'react' +import PublicationHistoryList from './PublicationHistoryList' + +function ArtListItem({entity, url}) { + + return ( +
  • ArtListItem +
    + +
    +

    {entity.title}

    +

    Artist: {entity.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..5b552499 100644 --- a/src/sections/Art/components/PublicationHistoryList.jsx +++ b/src/sections/Art/components/PublicationHistoryList.jsx @@ -1 +1,14 @@ +import React from 'react' + +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..ffcd8020 100644 --- a/src/sections/Art/index.jsx +++ b/src/sections/Art/index.jsx @@ -1,8 +1,44 @@ +import { useState, useEffect } from 'react' +import ArtList from './components/ArtList'; + function ArtsSection() { + const apiUrl = "https://boolean-uk-api-server.fly.dev/art"; + const imgUrl = "https://boolean-uk-api-server.fly.dev"; + const [data, setData] = useState([]); + const [loading, setLoading] = useState(true); + + useEffect(() => { + fetch(apiUrl) + .then((res) => res.json()) + .then((result) => { + setData(result); + setLoading(false); + }) + .catch((error) => { + console.error("Fetch error:", error); + setLoading(false); + }); + }, []); + + useEffect(() => { + console.log(data); + }, [data]) + + if (loading){ + return
    +

    Arts Section

    +
    + +
    +
    + } + return (

    Arts Section

    -
    +
    + +
    ) } From f054e6503111ff651ab111c5d727f77dbfc0a76f Mon Sep 17 00:00:00 2001 From: Jakub Mroz Date: Mon, 1 Sep 2025 10:45:21 +0200 Subject: [PATCH 2/4] feat: users core --- src/sections/Art/components/ArtList.jsx | 2 +- src/sections/Art/index.jsx | 2 + src/sections/Users/components/UsersList.jsx | 16 ++++++++ .../Users/components/UsersListItem.jsx | 20 ++++++++++ src/sections/Users/index.jsx | 38 ++++++++++++++++++- 5 files changed, 76 insertions(+), 2 deletions(-) diff --git a/src/sections/Art/components/ArtList.jsx b/src/sections/Art/components/ArtList.jsx index 3f22ed0a..9144ada6 100644 --- a/src/sections/Art/components/ArtList.jsx +++ b/src/sections/Art/components/ArtList.jsx @@ -4,7 +4,7 @@ import ArtListItem from './ArtListItem' function ArtList({data, url}) { return ( diff --git a/src/sections/Art/index.jsx b/src/sections/Art/index.jsx index ffcd8020..f0420a70 100644 --- a/src/sections/Art/index.jsx +++ b/src/sections/Art/index.jsx @@ -20,9 +20,11 @@ function ArtsSection() { }); }, []); + /* useEffect(() => { console.log(data); }, [data]) + */ if (loading){ return
    diff --git a/src/sections/Users/components/UsersList.jsx b/src/sections/Users/components/UsersList.jsx index e69de29b..54e97020 100644 --- a/src/sections/Users/components/UsersList.jsx +++ b/src/sections/Users/components/UsersList.jsx @@ -0,0 +1,16 @@ +import React from 'react' +import UsersListItem from './UsersListItem' + +function UsersList({data}) { + return ( +
    +
      + {data.map((item, 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..ed1e5bff 100644 --- a/src/sections/Users/components/UsersListItem.jsx +++ b/src/sections/Users/components/UsersListItem.jsx @@ -0,0 +1,20 @@ +import React from 'react' + +function UsersListItem({entity}) { + const style = { + background: entity.favouriteColour + }; + + return ( +
  • + {entity.firstName +

    {entity.firstName} {entity.lastName}

    +

    Email: {entity.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..245dd035 100644 --- a/src/sections/Users/index.jsx +++ b/src/sections/Users/index.jsx @@ -1,8 +1,44 @@ +import { useState, useEffect } from 'react' +import UsersList from './components/UsersList'; + function UsersSection() { + const apiUrl = "https://boolean-uk-api-server.fly.dev/JakubMroz4/contact"; + const [data, setData] = useState([]); + const [loading, setLoading] = useState(true); + + useEffect(() => { + fetch(apiUrl) + .then((res) => res.json()) + .then((result) => { + setData(result); + setLoading(false); + }) + .catch((error) => { + console.error("Fetch error:", error); + setLoading(false); + }); + }, []); + + useEffect(() => { + console.log(data); + }, [data]) + + if (loading){ + return
    +

    Users Section

    +
    + +
    +
    + } + + return (

    Users Section

    -
    +
    + +
    ) } From 528931aef74f9fd6c422016e546799cd5c690c2f Mon Sep 17 00:00:00 2001 From: Jakub Mroz Date: Mon, 1 Sep 2025 11:43:34 +0200 Subject: [PATCH 3/4] feat: advice --- src/sections/Advice/components/AdviceSlip.jsx | 48 +++++++++++++++++++ .../Advice/components/FavouriteSlipItem.jsx | 37 ++++++++++++++ .../Advice/components/FavouriteSlipsList.jsx | 23 +++++++++ src/sections/Advice/index.jsx | 13 ++++- src/sections/Users/index.jsx | 2 + 5 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 src/sections/Advice/components/FavouriteSlipItem.jsx diff --git a/src/sections/Advice/components/AdviceSlip.jsx b/src/sections/Advice/components/AdviceSlip.jsx index e69de29b..4d88cc47 100644 --- a/src/sections/Advice/components/AdviceSlip.jsx +++ b/src/sections/Advice/components/AdviceSlip.jsx @@ -0,0 +1,48 @@ +import React from 'react' +import { useState, useEffect } from 'react' + +function AdviceSlip({url, setFavourite, favourites}) { + + const [data, setData] = useState([]); + const [loading, setLoading] = useState(true); + + useEffect(() => { + handleFetch() + }, []); + + const handleFetch = () => { + setLoading(true); + fetch(url) + .then((res) => res.json()) + .then((result) => { + setData(result); + setLoading(false); + }) + .catch((error) => { + console.error("Fetch error:", error); + setLoading(false); + });} + +const AddFavourite = (favId) => { + if (favourites.includes(favId)){ + return; + } + setFavourite((prevIds) => [...prevIds, favId]); +} + +if (loading){ + return
    +
    + } + + return ( +
    +

    Some Advice

    +

    {data.slip.advice}

    + + +
    + ) +} + +export default AdviceSlip \ No newline at end of file diff --git a/src/sections/Advice/components/FavouriteSlipItem.jsx b/src/sections/Advice/components/FavouriteSlipItem.jsx new file mode 100644 index 00000000..b3e5dcb4 --- /dev/null +++ b/src/sections/Advice/components/FavouriteSlipItem.jsx @@ -0,0 +1,37 @@ +import React from 'react' +import { useState, useEffect } from 'react' + +function FavouriteSlipItem({url, id}) { + const [data, setData] = useState([]); + const [loading, setLoading] = useState(true); + + useEffect(() => { + fetch(url + "/" + id) + .then((res) => res.json()) + .then((result) => { + setData(result); + setLoading(false); + }) + .catch((error) => { + console.error("Fetch error:", error); + setLoading(false); + }); + }, []); + + useEffect(() => { + console.log(data); + }, [data]) + +if (loading){ + return
    +
    +} + + return ( +
  • + {data.slip.advice} +
  • + ) +} + +export default FavouriteSlipItem \ No newline at end of file diff --git a/src/sections/Advice/components/FavouriteSlipsList.jsx b/src/sections/Advice/components/FavouriteSlipsList.jsx index e69de29b..8a7feee7 100644 --- a/src/sections/Advice/components/FavouriteSlipsList.jsx +++ b/src/sections/Advice/components/FavouriteSlipsList.jsx @@ -0,0 +1,23 @@ +import React from 'react' +import { useState, useEffect } from 'react' +import FavouriteSlipItem from './FavouriteSlipItem' + +function FavouriteSlipsList({url, favourites}) { + + useEffect(() => { + console.log(favourites) + }, [favourites]) + + return ( +
    +

    Favourite Advice Slips

    +
      + {favourites.map((item, index) => ( + + ))} +
    +
    + ) +} + +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..8b6dfe2e 100644 --- a/src/sections/Advice/index.jsx +++ b/src/sections/Advice/index.jsx @@ -1,9 +1,18 @@ +import { useState, useEffect } from 'react' +import AdviceSlip from './components/AdviceSlip'; +import FavouriteSlipsList from './components/FavouriteSlipsList'; + function AdviceSection() { + const apiUrl = "https://api.adviceslip.com/advice"; + + + const [favourites, setFavourites] = useState([]); + return (

    Advice Section

    -
    -
    + +
    ) } diff --git a/src/sections/Users/index.jsx b/src/sections/Users/index.jsx index 245dd035..825d64c9 100644 --- a/src/sections/Users/index.jsx +++ b/src/sections/Users/index.jsx @@ -19,9 +19,11 @@ function UsersSection() { }); }, []); + /* useEffect(() => { console.log(data); }, [data]) + */ if (loading){ return
    From 75d55f28e6cf45776635034e720afc01614b0c36 Mon Sep 17 00:00:00 2001 From: Jakub Mroz Date: Mon, 1 Sep 2025 11:49:26 +0200 Subject: [PATCH 4/4] chore: formatter --- src/sections/Advice/components/AdviceSlip.jsx | 81 ++++++++++--------- .../Advice/components/FavouriteSlipItem.jsx | 31 +++---- .../Advice/components/FavouriteSlipsList.jsx | 29 ++++--- src/sections/Advice/index.jsx | 19 +++-- src/sections/Art/components/ArtList.jsx | 16 ++-- src/sections/Art/components/ArtListItem.jsx | 29 +++---- .../Art/components/PublicationHistoryList.jsx | 19 +++-- src/sections/Art/index.jsx | 26 +++--- src/sections/Users/components/UsersList.jsx | 20 ++--- .../Users/components/UsersListItem.jsx | 26 +++--- src/sections/Users/index.jsx | 27 +++---- 11 files changed, 159 insertions(+), 164 deletions(-) diff --git a/src/sections/Advice/components/AdviceSlip.jsx b/src/sections/Advice/components/AdviceSlip.jsx index 4d88cc47..594e8503 100644 --- a/src/sections/Advice/components/AdviceSlip.jsx +++ b/src/sections/Advice/components/AdviceSlip.jsx @@ -1,48 +1,49 @@ -import React from 'react' -import { useState, useEffect } from 'react' - -function AdviceSlip({url, setFavourite, favourites}) { - - const [data, setData] = useState([]); - const [loading, setLoading] = useState(true); - - useEffect(() => { - handleFetch() - }, []); - - const handleFetch = () => { - setLoading(true); - fetch(url) - .then((res) => res.json()) - .then((result) => { - setData(result); - setLoading(false); - }) - .catch((error) => { - console.error("Fetch error:", error); - setLoading(false); - });} - -const AddFavourite = (favId) => { - if (favourites.includes(favId)){ - return; +import React from "react"; +import { useState, useEffect } from "react"; + +function AdviceSlip({ url, setFavourite, favourites }) { + const [data, setData] = useState([]); + const [loading, setLoading] = useState(true); + + useEffect(() => { + handleFetch(); + }, []); + + const handleFetch = () => { + setLoading(true); + fetch(url) + .then((res) => res.json()) + .then((result) => { + setData(result); + setLoading(false); + }) + .catch((error) => { + console.error("Fetch error:", error); + setLoading(false); + }); + }; + + const AddFavourite = (favId) => { + if (favourites.includes(favId)) { + return; } setFavourite((prevIds) => [...prevIds, favId]); -} + }; -if (loading){ - return
    -
    - } + if (loading) { + return
    ; + } return (
    -

    Some Advice

    -

    {data.slip.advice}

    - - -
    - ) +

    Some Advice

    +

    {data.slip.advice}

    + + +
    + ); } -export default AdviceSlip \ No newline at end of file +export default AdviceSlip; diff --git a/src/sections/Advice/components/FavouriteSlipItem.jsx b/src/sections/Advice/components/FavouriteSlipItem.jsx index b3e5dcb4..652069ff 100644 --- a/src/sections/Advice/components/FavouriteSlipItem.jsx +++ b/src/sections/Advice/components/FavouriteSlipItem.jsx @@ -1,11 +1,11 @@ -import React from 'react' -import { useState, useEffect } from 'react' +import React from "react"; +import { useState, useEffect } from "react"; -function FavouriteSlipItem({url, id}) { - const [data, setData] = useState([]); - const [loading, setLoading] = useState(true); - - useEffect(() => { +function FavouriteSlipItem({ url, id }) { + const [data, setData] = useState([]); + const [loading, setLoading] = useState(true); + + useEffect(() => { fetch(url + "/" + id) .then((res) => res.json()) .then((result) => { @@ -20,18 +20,13 @@ function FavouriteSlipItem({url, id}) { useEffect(() => { console.log(data); - }, [data]) + }, [data]); -if (loading){ - return
    -
    -} + if (loading) { + return
    ; + } - return ( -
  • - {data.slip.advice} -
  • - ) + return
  • {data.slip.advice}
  • ; } -export default FavouriteSlipItem \ No newline at end of file +export default FavouriteSlipItem; diff --git a/src/sections/Advice/components/FavouriteSlipsList.jsx b/src/sections/Advice/components/FavouriteSlipsList.jsx index 8a7feee7..10ef9e10 100644 --- a/src/sections/Advice/components/FavouriteSlipsList.jsx +++ b/src/sections/Advice/components/FavouriteSlipsList.jsx @@ -1,23 +1,22 @@ -import React from 'react' -import { useState, useEffect } from 'react' -import FavouriteSlipItem from './FavouriteSlipItem' +import React from "react"; +import { useEffect } from "react"; +import FavouriteSlipItem from "./FavouriteSlipItem"; -function FavouriteSlipsList({url, favourites}) { - - useEffect(() => { - console.log(favourites) - }, [favourites]) +function FavouriteSlipsList({ url, favourites }) { + useEffect(() => { + console.log(favourites); + }, [favourites]); return (
    -

    Favourite Advice Slips

    -
      +

      Favourite Advice Slips

      +
        {favourites.map((item, index) => ( - + ))} -
      -
    - ) + +
    + ); } -export default FavouriteSlipsList \ No newline at end of file +export default FavouriteSlipsList; diff --git a/src/sections/Advice/index.jsx b/src/sections/Advice/index.jsx index 8b6dfe2e..5ef6ad4a 100644 --- a/src/sections/Advice/index.jsx +++ b/src/sections/Advice/index.jsx @@ -1,20 +1,23 @@ -import { useState, useEffect } from 'react' -import AdviceSlip from './components/AdviceSlip'; -import FavouriteSlipsList from './components/FavouriteSlipsList'; +import { useState } from "react"; +import AdviceSlip from "./components/AdviceSlip"; +import FavouriteSlipsList from "./components/FavouriteSlipsList"; function AdviceSection() { const apiUrl = "https://api.adviceslip.com/advice"; - const [favourites, setFavourites] = useState([]); return (

    Advice Section

    - - + +
    - ) + ); } -export default AdviceSection +export default AdviceSection; diff --git a/src/sections/Art/components/ArtList.jsx b/src/sections/Art/components/ArtList.jsx index 9144ada6..9ffa291a 100644 --- a/src/sections/Art/components/ArtList.jsx +++ b/src/sections/Art/components/ArtList.jsx @@ -1,14 +1,14 @@ -import React from 'react' -import ArtListItem from './ArtListItem' +import React from "react"; +import ArtListItem from "./ArtListItem"; -function ArtList({data, url}) { +function ArtList({ data, url }) { return ( - ) + ); } -export default ArtList \ No newline at end of file +export default ArtList; diff --git a/src/sections/Art/components/ArtListItem.jsx b/src/sections/Art/components/ArtListItem.jsx index 556edcc0..96e43c26 100644 --- a/src/sections/Art/components/ArtListItem.jsx +++ b/src/sections/Art/components/ArtListItem.jsx @@ -1,21 +1,18 @@ -import React, { useEffect, useState } from 'react' -import PublicationHistoryList from './PublicationHistoryList' - -function ArtListItem({entity, url}) { +import PublicationHistoryList from "./PublicationHistoryList"; +function ArtListItem({ entity, url }) { return ( -
  • ArtListItem -
    - -
    -

    {entity.title}

    -

    Artist: {entity.artist}

    -

    Publication History:

    - +
  • + ArtListItem +
    + +
    +

    {entity.title}

    +

    Artist: {entity.artist}

    +

    Publication History:

    +
  • - ) + ); } -export default ArtListItem \ No newline at end of file +export default ArtListItem; diff --git a/src/sections/Art/components/PublicationHistoryList.jsx b/src/sections/Art/components/PublicationHistoryList.jsx index 5b552499..83eb45d3 100644 --- a/src/sections/Art/components/PublicationHistoryList.jsx +++ b/src/sections/Art/components/PublicationHistoryList.jsx @@ -1,14 +1,13 @@ +import React from "react"; -import React from 'react' - -function PublicationHistoryList({publications}) { +function PublicationHistoryList({ publications }) { return ( - - ) + + ); } -export default PublicationHistoryList \ No newline at end of file +export default PublicationHistoryList; diff --git a/src/sections/Art/index.jsx b/src/sections/Art/index.jsx index f0420a70..cbf56c18 100644 --- a/src/sections/Art/index.jsx +++ b/src/sections/Art/index.jsx @@ -1,5 +1,5 @@ -import { useState, useEffect } from 'react' -import ArtList from './components/ArtList'; +import { useState, useEffect } from "react"; +import ArtList from "./components/ArtList"; function ArtsSection() { const apiUrl = "https://boolean-uk-api-server.fly.dev/art"; @@ -26,23 +26,23 @@ function ArtsSection() { }, [data]) */ - if (loading){ - return
    -

    Arts Section

    -
    - -
    -
    - } + if (loading) { + return ( +
    +

    Arts Section

    +
    +
    + ); + } return (

    Arts Section

    - +
    - ) + ); } -export default ArtsSection +export default ArtsSection; diff --git a/src/sections/Users/components/UsersList.jsx b/src/sections/Users/components/UsersList.jsx index 54e97020..f90d2fed 100644 --- a/src/sections/Users/components/UsersList.jsx +++ b/src/sections/Users/components/UsersList.jsx @@ -1,16 +1,16 @@ -import React from 'react' -import UsersListItem from './UsersListItem' +import React from "react"; +import UsersListItem from "./UsersListItem"; -function UsersList({data}) { +function UsersList({ data }) { return (
    -
      - {data.map((item, index) => ( - - ))} -
    +
      + {data.map((item, index) => ( + + ))} +
    - ) + ); } -export default UsersList \ No newline at end of file +export default UsersList; diff --git a/src/sections/Users/components/UsersListItem.jsx b/src/sections/Users/components/UsersListItem.jsx index ed1e5bff..099f6a9b 100644 --- a/src/sections/Users/components/UsersListItem.jsx +++ b/src/sections/Users/components/UsersListItem.jsx @@ -1,20 +1,22 @@ -import React from 'react' +import React from "react"; -function UsersListItem({entity}) { - const style = { - background: entity.favouriteColour +function UsersListItem({ entity }) { + const style = { + background: entity.favouriteColour, }; return (
  • - {entity.firstName -

    {entity.firstName} {entity.lastName}

    -

    Email: {entity.email}

    + {entity.firstName +

    + {entity.firstName} {entity.lastName} +

    +

    Email: {entity.email}

  • - ) + ); } -export default UsersListItem \ No newline at end of file +export default UsersListItem; diff --git a/src/sections/Users/index.jsx b/src/sections/Users/index.jsx index 825d64c9..b310d1c7 100644 --- a/src/sections/Users/index.jsx +++ b/src/sections/Users/index.jsx @@ -1,5 +1,5 @@ -import { useState, useEffect } from 'react' -import UsersList from './components/UsersList'; +import { useState, useEffect } from "react"; +import UsersList from "./components/UsersList"; function UsersSection() { const apiUrl = "https://boolean-uk-api-server.fly.dev/JakubMroz4/contact"; @@ -25,24 +25,23 @@ function UsersSection() { }, [data]) */ - if (loading){ - return
    -

    Users Section

    -
    - -
    -
    - } - + if (loading) { + return ( +
    +

    Users Section

    +
    +
    + ); + } return (

    Users Section

    - +
    - ) + ); } -export default UsersSection +export default UsersSection;