From 70130f666e43a231bfb28957382bc230bd082fbf Mon Sep 17 00:00:00 2001 From: Vegard Stigen Date: Tue, 2 Sep 2025 09:31:27 +0200 Subject: [PATCH] core done, started extension --- src/sections/Advice/index.jsx | 40 +++++++++++++++++++++++++++-- src/sections/Art/index.jsx | 47 ++++++++++++++++++++++++++++++++++- src/sections/Users/index.jsx | 43 +++++++++++++++++++++++++++++++- 3 files changed, 126 insertions(+), 4 deletions(-) diff --git a/src/sections/Advice/index.jsx b/src/sections/Advice/index.jsx index 0405f11f..37308f0e 100644 --- a/src/sections/Advice/index.jsx +++ b/src/sections/Advice/index.jsx @@ -1,9 +1,45 @@ +/* eslint-disable no-unused-vars */ +import { useState, useEffect } from 'react' + + function AdviceSection() { + + const url = "https://api.adviceslip.com/advice"; + const [data, setData] = useState([]); + const [filteredData, setFilteredData] = useState([]); + const [searchTerm, setSearchTerm] = useState(''); + + const fetchData = async () => { + const response = await fetch(url); + const jsonData = await response.json(); + setData(jsonData); + setFilteredData(jsonData); + }; + useEffect(() => { + fetchData(); + }, []); + + return (

Advice Section

-
-
+
+

Advice Section

+
+

Some Advice

+

{data.slip ? (data.slip.advice) : ('no advice')}

+ + +
+
+

Favourite Advice Slips

+
    +
  • Measure twice, cut once.
  • +
  • {"Don't let the bastards grind you down."}
  • +
  • Always the burrito.
  • +
+
+
) } diff --git a/src/sections/Art/index.jsx b/src/sections/Art/index.jsx index 0c74ffc2..a3176da8 100644 --- a/src/sections/Art/index.jsx +++ b/src/sections/Art/index.jsx @@ -1,9 +1,54 @@ +/* eslint-disable no-unused-vars */ +import { useState, useEffect } from 'react' + function ArtsSection() { + + const url = "https://boolean-uk-api-server.fly.dev/art"; + const [data, setData] = useState([]); + const [filteredData, setFilteredData] = useState([]); + const [searchTerm, setSearchTerm] = useState(''); + + useEffect(() => { + const fetchData = async () => { + const response = await fetch(url); + const jsonData = await response.json(); + setData(jsonData); + setFilteredData(jsonData); + }; + fetchData(); + }, []); + + + return (

Arts Section

-
+ +
+
    + {data.map((art, index) => ( +
  • +
    + +
    +

    {art.title}

    +

    Artist: {art.artist}

    +

    Publication History:

    +
      + {art.publicationHistory.map((history, index) => ( +
    • {history}
    • + ))} +
    +
  • + + ))} +
+
+
+ ) } diff --git a/src/sections/Users/index.jsx b/src/sections/Users/index.jsx index 77332830..9b6cbfbb 100644 --- a/src/sections/Users/index.jsx +++ b/src/sections/Users/index.jsx @@ -1,8 +1,49 @@ +/* eslint-disable no-unused-vars */ +import { useState, useEffect } from 'react' + function UsersSection() { + + const url = "https://boolean-uk-api-server.fly.dev/Vegard-S/contact"; + const [data, setData] = useState([]); + const [filteredData, setFilteredData] = useState([]); + const [searchTerm, setSearchTerm] = useState(''); + + useEffect(() => { + const fetchData = async () => { + const response = await fetch(url); + const jsonData = await response.json(); + setData(jsonData); + setFilteredData(jsonData); + }; + fetchData(); + }, []); + + + + + return (

Users Section

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

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

    +

    {user.email}

    +
  • + ))} + + + +
+
+
) }