diff options
author | eug-vs <eug-vs@keemail.me> | 2020-06-14 19:52:35 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-06-14 19:52:35 +0300 |
commit | c7f2999ee797ea5e3bfb29517a4f13206162cc6f (patch) | |
tree | f1aa1f0183720e509894e641cd2f5d1b2f9cd163 /src/components/Feed/Feed.tsx | |
parent | fabc53130685f70078343a6fd96d9a597b22008f (diff) | |
download | which-ui-c7f2999ee797ea5e3bfb29517a4f13206162cc6f.tar.gz |
refactor: use lowercase in folder names
Diffstat (limited to 'src/components/Feed/Feed.tsx')
-rw-r--r-- | src/components/Feed/Feed.tsx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/components/Feed/Feed.tsx b/src/components/Feed/Feed.tsx new file mode 100644 index 0000000..604c167 --- /dev/null +++ b/src/components/Feed/Feed.tsx @@ -0,0 +1,41 @@ +import React, { useState, useEffect } from 'react'; +import { makeStyles } from '@material-ui/core/styles'; +import { Poll } from '../../types'; +import PollCard from '../PollCard/PollCard'; +import { get } from '../../requests'; + +interface PropTypes { + page: string; +} + +const useStyles = makeStyles(theme => ({ + root: { + position: 'relative', + maxWidth: theme.spacing(75), + margin: '0 auto' + } +})); + +const Feed: React.FC<PropTypes> = ({ page }) => { + const [polls, setPolls] = useState<Poll[]>([]); + const classes = useStyles(); + + let endpoint = '/polls'; + // TODO: Make this work + if (page === 'feed') endpoint = '/polls'; + + useEffect(() => { + get(endpoint).then(response => { + setPolls(response.data); + }); + }, [endpoint]); + + return ( + <div className={classes.root}> + {polls.map(poll => <PollCard poll={poll} key={poll._id} />)} + </div> + ); +}; + +export default Feed; + |