Skip to content

Commit

Permalink
fix: handle fetch github stars errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoapolo committed Jan 3, 2025
1 parent 197b8e3 commit f408886
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions frontend/web/components/GithubStar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,43 @@ const GithubStar: FC<GithubStarType> = ({}) => {
.then(function (res) {
setStars(res.stargazers_count)
})
.catch(() => {
setStars(undefined)
})
}
}, [planName])

if (planName === planNames.enterprise) {
return <></>
}

return (
<>
if (!stars) {
return (
<a
style={{ width: 90 }}
target='_blank'
href='https://github.com/flagsmith/flagsmith'
className='btn btn-sm btn-with-icon text-body'
rel='noreferrer'
>
<div className='d-flex flex-row justify-content-center align-items-center'>
<IonIcon style={{ fontSize: 16 }} icon={logoGithub} />
<div className='ms-1'>{stars}</div>
</div>
<IonIcon style={{ fontSize: 16 }} icon={logoGithub} />
</a>
</>
)
}

return (
<a
style={{ width: 90 }}
target='_blank'
href='https://github.com/flagsmith/flagsmith'
className='btn btn-sm btn-with-icon text-body'
rel='noreferrer'
>
<div className='d-flex flex-row justify-content-center align-items-center'>
<IonIcon style={{ fontSize: 16 }} icon={logoGithub} />
<div className='ms-1'>{stars}</div>
</div>
</a>
)
}

Expand Down

0 comments on commit f408886

Please sign in to comment.