aboutsummaryrefslogtreecommitdiff
path: root/src/containers/Feed/Feed.tsx
blob: 337f4c16276b6fc6c6594dba4f1df128001de316 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import React from 'react';
import { Container } from '@material-ui/core/';

import PollsList from '../../components/PollsList/PollsList';
import Fab from '../../components/Fab/Fab';
import Loading from '../../components/Loading/Loading';
import EmptyState from '../../components/EmptyState/EmptyState';
import { useAuth } from '../../hooks/useAuth';
import { useFeed } from '../../hooks/APIClient';


const Feed: React.FC = () => {
  const { data: polls, isValidating, mutate } = useFeed();
  const { isAuthenticated } = useAuth();

  return (
    <Container maxWidth="sm" disableGutters>
      {isAuthenticated && <Fab hideOnScroll />}
      {
        polls
          ? polls.length
            ? <PollsList polls={polls} mutate={mutate} />
            : <EmptyState />
          : isValidating && <Loading />
      }
    </Container>
  );
};

export default Feed;