diff --git a/components/Quotes/Quotes.js b/components/Quotes/Quotes.js new file mode 100644 index 00000000..ab151035 --- /dev/null +++ b/components/Quotes/Quotes.js @@ -0,0 +1,52 @@ +import React, { useState, useEffect } from 'react'; +import axios from 'axios'; +import { Swiper, SwiperSlide } from 'swiper/react'; +import 'swiper/swiper-bundle.css'; +import styles from 'styles/Home.module.css'; // Import your styles + + +const Quotes = () => { + const [quotes, setQuotes] = useState([]); + + useEffect(() => { + const fetchQuotes = async () => { + try { + const response = await axios.get('https://api.quotable.io/quotes?limit=10'); + setQuotes(response.data.results); + } catch (error) { + console.log(error); + } + }; + fetchQuotes(); + }, []); + + if (quotes.length === 0) { + return

Loading quotes...

; + } + + return ( +
+

Quotes

+
+ + {quotes.map((quote, index) => ( + +
+

"{quote.content}"

+

- {quote.author}

+
+
+ ))} +
+
+
+ ); +}; + +export default Quotes; diff --git a/pages/index.js b/pages/index.js index 69f27daf..d3ef0a10 100644 --- a/pages/index.js +++ b/pages/index.js @@ -17,6 +17,9 @@ import 'aos/dist/aos.css'; import TestimonialCard from 'components/Testimonial/Testimonial'; import GoToTop from 'components/GoToTop'; +import Quotes from 'components/Quotes/Quotes'; + + export default function Home() { const { dispatch } = useContext(Store); @@ -295,6 +298,7 @@ export default function Home() { +