2021-08-29 03:31:10 +00:00
|
|
|
import * as React from "react"
|
|
|
|
import {Anchor} from "@steffo/bluelib-react"
|
|
|
|
import Style from "./MoreProjects.module.css"
|
|
|
|
|
|
|
|
|
2021-10-25 11:27:29 +00:00
|
|
|
export function MoreProjects({user, minus}) {
|
2021-08-29 03:31:10 +00:00
|
|
|
const [data, setData] = React.useState(null)
|
|
|
|
const [error, setError] = React.useState(null)
|
|
|
|
|
|
|
|
const fetchData = React.useCallback(
|
|
|
|
() => {
|
|
|
|
fetch(`https://api.github.com/users/${user}`)
|
|
|
|
.then(r => r.json())
|
|
|
|
.then(d => setData(d))
|
|
|
|
.catch(e => setError(e))
|
|
|
|
},
|
|
|
|
[user, setData, setError]
|
|
|
|
)
|
|
|
|
|
|
|
|
React.useEffect(
|
|
|
|
() => {
|
|
|
|
fetchData()
|
|
|
|
},
|
|
|
|
[fetchData]
|
|
|
|
)
|
|
|
|
|
|
|
|
const contents = React.useMemo(
|
|
|
|
() => {
|
|
|
|
if(data === null) return "Loading..."
|
|
|
|
else if(error !== null) return "Error: {error}"
|
2021-10-25 11:27:29 +00:00
|
|
|
return `...and ${data["public_repos"] - minus} more!`
|
2021-08-29 03:31:10 +00:00
|
|
|
},
|
2021-10-25 11:39:41 +00:00
|
|
|
[data, error, minus]
|
2021-08-29 03:31:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={Style.More}>
|
|
|
|
<Anchor href={"https://github.com/Steffo99?tab=repositories"}>{contents}</Anchor>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|