aboutsummaryrefslogtreecommitdiff
path: root/src/pages/ProfilePage/ProfilePage.tsx
diff options
context:
space:
mode:
authorEugene Sokolov <eug-vs@keemail.me>2020-07-05 14:28:41 +0300
committerGitHub <noreply@github.com>2020-07-05 14:28:41 +0300
commit5474ff317a603d15de62f42f71e579f49adf5ff9 (patch)
treefdf7e9b933fc52f030d148e3a4d3c35202209d69 /src/pages/ProfilePage/ProfilePage.tsx
parent35a932bea0edc897e6e50ce6f727a8d5d3d0d492 (diff)
parentc02ba097faa134266dc226be9bccc2070855e2b7 (diff)
downloadwhich-ui-5474ff317a603d15de62f42f71e579f49adf5ff9.tar.gz
Merge pull request #64 from which-ecosystem/loader
add loader
Diffstat (limited to 'src/pages/ProfilePage/ProfilePage.tsx')
-rw-r--r--src/pages/ProfilePage/ProfilePage.tsx5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/pages/ProfilePage/ProfilePage.tsx b/src/pages/ProfilePage/ProfilePage.tsx
index 3beeb00..34c9efa 100644
--- a/src/pages/ProfilePage/ProfilePage.tsx
+++ b/src/pages/ProfilePage/ProfilePage.tsx
@@ -16,16 +16,19 @@ const ProfilePage: React.FC = () => {
const { page, navigate } = useNavigate();
const { user } = useAuth();
const [isInfoLoading, setIsInfoLoading] = useState(false);
+ const [isPollsLoading, setIsPollsLoading] = useState(false);
useEffect(() => {
const id = page?.id || user?._id;
setIsInfoLoading(true);
+ setIsPollsLoading(true);
if (id) {
get(`/users/${id}`).then(response => {
setUserInfo(response.data);
setIsInfoLoading(false);
});
get(`/profiles/${id}`).then(response => {
+ setIsPollsLoading(false);
setPolls([]);
setPolls(response.data);
setTotalVotes(response.data.reduce(
@@ -47,7 +50,7 @@ const ProfilePage: React.FC = () => {
totalVotes={totalVotes}
isLoading={isInfoLoading}
/>
- <Feed polls={[...polls]} />
+ {isPollsLoading ? <Feed polls={[]} /> : (polls.length > 0 && <Feed polls={polls} />)}
</Container>
);
};