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')} + Get More Advice + Save to Favourties + + + 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.lastName} + {user.email} + + ))} + + + + + + ) }
{data.slip ? (data.slip.advice) : ('no advice')}
Artist: {art.artist}
{user.email}