import React, { useEffect, useState } from 'react' import { Button } from 'ui' const GitHubButton = () => { const [stars, setStars] = useState('63') const kFormatter = (num: number) => { const kFormat = num / 1000 const decimals = kFormat.toFixed(2).split('.')[1] const firstDecimal = decimals.split('')[0] const showDecimals = firstDecimal !== '0' return kFormat.toFixed(showDecimals ? 1 : 0) } useEffect(() => { async function fetchOctoData() { const { Octokit } = await import('@octokit/core') const octokit = new Octokit() const res = await octokit.request('GET /repos/{org}/{repo}', { org: 'supabase', repo: 'supabase', type: 'public', }) setStars(kFormatter(res.data?.stargazers_count)) } fetchOctoData() }, []) return ( ) } export default GitHubButton