diff options
Diffstat (limited to 'src/containers/FeedPage/FeedPage.tsx')
-rw-r--r-- | src/containers/FeedPage/FeedPage.tsx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/containers/FeedPage/FeedPage.tsx b/src/containers/FeedPage/FeedPage.tsx new file mode 100644 index 0000000..da0fb2a --- /dev/null +++ b/src/containers/FeedPage/FeedPage.tsx @@ -0,0 +1,27 @@ +import React from 'react'; +import { Poll } from 'which-types'; +import { Container } from '@material-ui/core/'; + +import Feed from '../../components/Feed/Feed'; +import PollSubmission from './PollSubmission'; +import { useAuth } from '../../hooks/useAuth'; +import { useFeed } from '../../hooks/APIClient'; + +const FeedPage: React.FC = () => { + const { data, mutate } = useFeed(); + const { isAuthenticated } = useAuth(); + + const addPoll = (poll: Poll): void => { + mutate([poll, ...data], true); + }; + + return ( + <Container maxWidth="sm" disableGutters> + {isAuthenticated && <PollSubmission addPoll={addPoll} />} + <Feed polls={data} /> + </Container> + ); +}; + +export default FeedPage; + |