-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from neynarxyz/kevin/neyn-1941-explorer-overal…
…l-metrics-on-homepage-v2 add total messages
- Loading branch information
Showing
4 changed files
with
119 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use client'; | ||
import { useState, useEffect } from 'react'; | ||
import { capitalizeNickname } from '@/lib/helpers'; | ||
import { getHubsInfo } from '@/lib/utils'; | ||
|
||
const HubsDataComponent = () => { | ||
const [hubsData, setHubsData] = useState<any>([]); | ||
|
||
useEffect(() => { | ||
async function fetchData() { | ||
try { | ||
const data = await getHubsInfo(); | ||
setHubsData(data as any); | ||
} catch (error) { | ||
console.error('Error fetching data:', error); | ||
} | ||
} | ||
fetchData(); | ||
}, []); | ||
|
||
return ( | ||
<div className="flex flex-row md:w-1/2"> | ||
<div className="flex md:flex-row flex-col md:items-start items-center justify-around w-full md:space-x-16"> | ||
{hubsData.map((hub: any, index: number) => ( | ||
<div className="space-y-2" key={index}> | ||
<p className="text-center"> | ||
Number of Messages on {capitalizeNickname(hub?.nickname)} | ||
</p> | ||
<div> | ||
{hub.dbStats.numMessages !== null ? ( | ||
<p className="text-center font-bold"> | ||
{hub?.dbStats?.numMessages} | ||
</p> | ||
) : ( | ||
<p className="text-center">Loading...</p> | ||
)} | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default HubsDataComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export function capitalizeNickname(nickname: string) { | ||
if (!nickname) return ''; | ||
return nickname.charAt(0).toUpperCase() + nickname.slice(1); | ||
} |
Oops, something went wrong.