import { httpGet } from '../../lib/http'; import { useEffect, useState } from 'react'; type GetFriendCountsResponse = { sentCount: number; acceptedCount: number; receivedCount: number; rejectedCount: number; gotRejectedCount: number; }; export function SidebarFriendsCounter() { const [friendCounts, setFriendCounts] = useState(); async function getFriendCounts() { const { response, error } = await httpGet( `${import.meta.env.PUBLIC_API_URL}/v1-get-friend-counts` ); if (error || !response) { return; } setFriendCounts(response); } useEffect(() => { getFriendCounts().finally(() => null); }, []); const pendingCount = friendCounts?.receivedCount || 0; if (!pendingCount) { return null; } return ( {pendingCount} ); }