From 82402a3698d7b921c544f641501e12c42f4e73b9 Mon Sep 17 00:00:00 2001 From: eshanized Date: Thu, 2 Jan 2025 07:20:55 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20ui=20broken?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- src/components/home/StatsSection.tsx | 71 +++++++++++++++------------- 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/index.html b/index.html index 128d0c14..ebe25444 100644 --- a/index.html +++ b/index.html @@ -63,7 +63,7 @@ Snigdha OS - Advanced Penetration Testing Distribution - + diff --git a/src/components/home/StatsSection.tsx b/src/components/home/StatsSection.tsx index c05af281..8217f360 100644 --- a/src/components/home/StatsSection.tsx +++ b/src/components/home/StatsSection.tsx @@ -15,6 +15,8 @@ export function StatsSection() { { label: "GitHub Stars", value: "Loading...", icon: Star }, ]); + const [error, setError] = useState(false); + const fetchGitHubStats = async (username: string) => { try { const response = await fetch(`https://api.github.com/users/${username}`); @@ -32,12 +34,7 @@ export function StatsSection() { ]); } catch (error) { console.error("Error fetching GitHub data:", error); - setStats((prevStats) => - prevStats.map((stat) => ({ - ...stat, - value: "N/A", - })) - ); + setError(true); } }; @@ -47,7 +44,7 @@ export function StatsSection() { }, []); return ( -
+

Our Impact

@@ -55,36 +52,42 @@ export function StatsSection() { A snapshot of our growing community and contributions.

-
- {stats.map((stat, index) => ( - + {error ? ( +
+ Unable to fetch data. Please try again later. +
+ ) : ( +
+ {stats.map((stat, index) => ( - - - - {stat.value} - -

{stat.label}

- - ))} -
+ + + + + {stat.value} + +

{stat.label}

+
+ ))} +
+ )}
);