diff --git a/src/Components/Sidebar/index.jsx b/src/Components/Sidebar/index.jsx index ee0071d4f..e1623e425 100644 --- a/src/Components/Sidebar/index.jsx +++ b/src/Components/Sidebar/index.jsx @@ -17,6 +17,7 @@ import { } from "@mui/material"; import ThemeSwitch from "../ThemeSwitch"; import Avatar from "../Avatar"; +import StarPrompt from "../StarPrompt"; import LockSvg from "../../assets/icons/lock.svg?react"; import UserSvg from "../../assets/icons/user.svg?react"; import TeamSvg from "../../assets/icons/user-two.svg?react"; @@ -590,6 +591,8 @@ function Sidebar() { + {!collapsed && } + { + const [isVisible, setIsVisible] = useState(false); + const [starCount, setStarCount] = useState('0'); + + useEffect(() => { + const fetchStarCount = async () => { + try { + const owner = 'bluewave-labs'; + const repo = 'checkmate'; + + const response = await fetch(`https://api.github.com/repos/${owner}/${repo}`); + const data = await response.json(); + + const count = data.stargazers_count; + const formattedCount = count >= 1000 + ? `${(count / 1000).toFixed(1)}k` + : count.toString(); + + setStarCount(formattedCount); + } catch (error) { + console.error('Error fetching star count:', error); + } + }; + + fetchStarCount(); + + const hasClosedPrompt = localStorage.getItem(storageKey); + if (!hasClosedPrompt) { + setIsVisible(true); + } + }, [storageKey]); + + const handleClose = () => { + localStorage.setItem(storageKey, 'true'); + setIsVisible(false); + }; + + const handleStarClick = () => { + window.open(repoUrl, '_blank'); + }; + + if (!isVisible) return null; + + return ( + + + + + {title} + + + + + + + + {description} + + + + + + Checkmate + + + {starCount} + + + + + ); +}; + +export default StarPrompt;