diff options
Diffstat (limited to 'src/pages/ProfilePage/ProfilePage.tsx')
-rw-r--r-- | src/pages/ProfilePage/ProfilePage.tsx | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/pages/ProfilePage/ProfilePage.tsx b/src/pages/ProfilePage/ProfilePage.tsx index b7a4a75..ba4db7d 100644 --- a/src/pages/ProfilePage/ProfilePage.tsx +++ b/src/pages/ProfilePage/ProfilePage.tsx @@ -15,9 +15,11 @@ const ProfilePage: React.FC = () => { const [totalVotes, setTotalVotes] = useState<number>(0); const { page, navigate } = useNavigate(); const { user } = useAuth(); + const [isLoading, setIsLoading] = useState(false); useEffect(() => { const id = page?.id || user?._id; + setIsLoading(true); if (id) { get(`/users/${id}`).then(response => { setUserInfo(response.data); @@ -31,6 +33,7 @@ const ProfilePage: React.FC = () => { return total + left.votes + right.votes; }, 0 )); + setIsLoading(false); }); } else navigate('auth'); }, [navigate, page, user]); @@ -42,6 +45,7 @@ const ProfilePage: React.FC = () => { setUserInfo={setUserInfo} savedPolls={polls.length} totalVotes={totalVotes} + loading={isLoading} /> <Feed polls={[...polls]} /> </Container> |