-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathContributors.js
54 lines (53 loc) · 2.21 KB
/
Contributors.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { useEffect, useState } from "react"
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faHandsHelping } from '@fortawesome/free-solid-svg-icons'
import axios from 'axios'
export default function Contributers(props) {
const { setError } = props
const [contributors, setContributors] = useState([])
useEffect(() => {
axios.get('https://api.github.com/repos/skully-coder/competitiveprogramming/contributors')
.then(response => {
response.data.forEach(contributor => {
setContributors(contributors => contributors.concat({
login: contributor.login,
avatar: contributor.avatar_url,
url: contributor.html_url,
contributions: contributor.contributions,
}))
})
})
.catch(err => { setError(err.response) })
}, [setError])
return ( <
div className = "container-fluid" >
<
div className = "row" > {
contributors.map((contributor, index) => < div key = { index }
className = "col-12 col-md-3" >
<
div className = "card shadow-lg text-center" >
<
div className = "d-flex justify-content-between" >
<
h5 className = "font-weight-semi-bold" > { contributor.login } < /h5> <
h5 className = "rounded px-10 bg-success" > { contributor.contributions } < FontAwesomeIcon icon = { faHandsHelping }
/> <
/h5> <
/div> <
a href = { contributor.url }
target = "_blank"
rel = "noreferrer" >
<
img className = "rounded-circle"
src = { contributor.avatar }
width = "150"
alt = { contributor.login }
/> <
/a> <
/div> <
/div>)} <
/div> <
/div>
)
}