From 3e3e63ad9d6898de4b9660552ec8527e7b9baffa Mon Sep 17 00:00:00 2001 From: andrechamoun555 Date: Wed, 17 Sep 2025 13:58:02 +0200 Subject: [PATCH] done --- src/sections/Advice/components/AdviceSlip.jsx | 12 ++++++ .../Advice/components/FavouriteSlipsList.jsx | 14 +++++++ src/sections/Advice/index.jsx | 41 +++++++++++++++++-- src/sections/Art/components/ArtList.jsx | 13 ++++++ src/sections/Art/components/ArtListItem.jsx | 19 +++++++++ .../Art/components/PublicationHistoryList.jsx | 13 ++++++ src/sections/Art/index.jsx | 34 +++++++++++++-- src/sections/Art/template.html | 2 +- src/sections/Users/components/UsersList.jsx | 13 ++++++ .../Users/components/UsersListItem.jsx | 13 ++++++ src/sections/Users/index.jsx | 24 +++++++++-- 11 files changed, 186 insertions(+), 12 deletions(-) diff --git a/src/sections/Advice/components/AdviceSlip.jsx b/src/sections/Advice/components/AdviceSlip.jsx index e69de29b..b15eb46c 100644 --- a/src/sections/Advice/components/AdviceSlip.jsx +++ b/src/sections/Advice/components/AdviceSlip.jsx @@ -0,0 +1,12 @@ +function AdviceSlip({ advice, onGetMore, onSave }) { + 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..7aba7626 100644 --- a/src/sections/Advice/components/FavouriteSlipsList.jsx +++ b/src/sections/Advice/components/FavouriteSlipsList.jsx @@ -0,0 +1,14 @@ +function FavouriteSlipsList({ items }) { + return ( +
+

Favourite Advice Slips

+ +
+ ); +} + +export default FavouriteSlipsList; diff --git a/src/sections/Advice/index.jsx b/src/sections/Advice/index.jsx index 0405f11f..43afb077 100644 --- a/src/sections/Advice/index.jsx +++ b/src/sections/Advice/index.jsx @@ -1,11 +1,44 @@ +import { useState, useEffect } from "react"; +import AdviceSlip from "./components/AdviceSlip.jsx"; +import FavouriteSlipsList from "./components/FavouriteSlipsList.jsx"; + +const ADVICE_API = "https://api.adviceslip.com"; + function AdviceSection() { + const [advice, setAdvice] = useState(""); + const [favouriteSlips, setFavouriteSlips] = useState([]); + + const fetchAdvice = () => { + fetch(`${ADVICE_API}/advice`) + .then((response) => response.json()) + .then((data) => setAdvice(data.slip.advice)); + }; + + useEffect(() => { + fetchAdvice(); + }, []); + + const handleSave = () => { + if (advice && !favouriteSlips.includes(advice)) { + setFavouriteSlips([...favouriteSlips, advice]); + } + }; + return (

Advice Section

-
-
+
+ +
+
+ +
- ) + ); } -export default AdviceSection +export default AdviceSection; \ No newline at end of file diff --git a/src/sections/Art/components/ArtList.jsx b/src/sections/Art/components/ArtList.jsx index e69de29b..6351042a 100644 --- a/src/sections/Art/components/ArtList.jsx +++ b/src/sections/Art/components/ArtList.jsx @@ -0,0 +1,13 @@ +import ArtListItem from "./ArtListItem.jsx"; + +function ArtList({ artworks }) { + return ( + + ); +} + +export default ArtList; diff --git a/src/sections/Art/components/ArtListItem.jsx b/src/sections/Art/components/ArtListItem.jsx index e69de29b..0e5d992c 100644 --- a/src/sections/Art/components/ArtListItem.jsx +++ b/src/sections/Art/components/ArtListItem.jsx @@ -0,0 +1,19 @@ +function ArtListItem({ artwork }) { + return ( +
  • +
    + {artwork.title} +
    +

    {artwork.title}

    +

    Artist: {artwork.artist}

    +

    Publication History:

    + +
  • + ); +} + +export default ArtListItem; diff --git a/src/sections/Art/components/PublicationHistoryList.jsx b/src/sections/Art/components/PublicationHistoryList.jsx index d3f5a12f..654f1f11 100644 --- a/src/sections/Art/components/PublicationHistoryList.jsx +++ b/src/sections/Art/components/PublicationHistoryList.jsx @@ -1 +1,14 @@ +function PublicationHistoryList({ entries = [] }) { + return ( + <> +

    Publication History:

    + + + ); +} +export default PublicationHistoryList; diff --git a/src/sections/Art/index.jsx b/src/sections/Art/index.jsx index 0c74ffc2..08f8ccab 100644 --- a/src/sections/Art/index.jsx +++ b/src/sections/Art/index.jsx @@ -1,10 +1,36 @@ +import { useEffect, useState } from "react"; +import ArtList from "./components/ArtList.jsx"; + +const BASE = "https://boolean-uk-api-server.fly.dev"; + function ArtsSection() { + const [artworks, setArtworks] = useState([]); + + useEffect(() => { + fetch(`${BASE}/art`) + .then((response) => response.json()) + .then((data) => { + const artworksWithData = data.map((art) => { + return { + id: art.id, + title: art.title, + artist: art.artist, + imageUrl: `${BASE}${art.imageURL}`, + publicationHistoryList: art.publicationHistory || [], + }; + }); + setArtworks(artworksWithData); + }); + }, []); + return (
    -

    Arts Section

    -
    +

    Art Section

    +
    + +
    - ) + ); } -export default ArtsSection +export default ArtsSection; diff --git a/src/sections/Art/template.html b/src/sections/Art/template.html index 1850dbc7..b0a88c9f 100644 --- a/src/sections/Art/template.html +++ b/src/sections/Art/template.html @@ -5,7 +5,7 @@

    Arts Section

  • Paris Street; Rainy Day

    diff --git a/src/sections/Users/components/UsersList.jsx b/src/sections/Users/components/UsersList.jsx index e69de29b..f889b049 100644 --- a/src/sections/Users/components/UsersList.jsx +++ b/src/sections/Users/components/UsersList.jsx @@ -0,0 +1,13 @@ +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..1bd19c14 100644 --- a/src/sections/Users/components/UsersListItem.jsx +++ b/src/sections/Users/components/UsersListItem.jsx @@ -0,0 +1,13 @@ +function UsersListItem({ user }) { + const fullName = `${user.firstName} ${user.lastName}`; + + return ( +
  • + {fullName} +

    {fullName}

    +

    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..1fb0d332 100644 --- a/src/sections/Users/index.jsx +++ b/src/sections/Users/index.jsx @@ -1,10 +1,28 @@ +import { useState, useEffect } from "react"; +import UsersList from "./components/UsersList"; + +const BASE_URL = "https://boolean-uk-api-server.fly.dev"; + function UsersSection() { + const [users, setUsers] = useState([]); + + // Replace with your GitHub username + const GITHUB_USERNAME = "andrechamoun555"; + + useEffect(() => { + fetch(`${BASE_URL}/${GITHUB_USERNAME}/contact`) + .then((response) => response.json()) + .then(setUsers); + }, []); + return (

    Users Section

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