diff --git a/src/contributor/index.js b/src/contributor/index.js index 124b4b8..57e348a 100644 --- a/src/contributor/index.js +++ b/src/contributor/index.js @@ -10,6 +10,7 @@ import RandomAnswerImage from "./random-answer-image"; import RandomDogImage from './random-dog-image'; import RandomMemeImage from "./random-meme-image"; import RandomUserProfile from './random-user-profile'; +import RandomCompany from "./random-company"; export const data_contributor = [ RandomFoxImage, @@ -24,4 +25,5 @@ export const data_contributor = [ RandomAnswerImage, RandomDogImage, RandomMemeImage, + RandomCompany, ]; diff --git a/src/contributor/random-company.js b/src/contributor/random-company.js new file mode 100644 index 0000000..bd65d56 --- /dev/null +++ b/src/contributor/random-company.js @@ -0,0 +1,51 @@ +import { useEffect, useState } from "react"; +import axios from "axios"; +import { Card } from "../components"; + +const BASE_URL = 'https://random-data-api.com/api/' + +const RandomCompany = () => { + const [data, setData] = useState({ logo: '' }); + const [loading, setLoading] = useState(false); + + const get = async () => { + const { data } = await axios.get(`${BASE_URL}/company/random_company`); + + data ? setLoading(false) : setLoading(true); + setData(data); + } + + useEffect(() => { + get().finally(); + return () => { + setLoading(false); + } + }, []) + + return ( + + { + loading ? ( +

Loading...

+ ) : ( + company-logo + ) + } +
+ ) +} + + +export default RandomCompany;