diff options
Diffstat (limited to 'src/pages')
-rw-r--r-- | src/pages/FeedPage/PollSubmission.tsx | 4 | ||||
-rw-r--r-- | src/pages/FeedPage/PollSubmissionImage.tsx | 15 |
2 files changed, 6 insertions, 13 deletions
diff --git a/src/pages/FeedPage/PollSubmission.tsx b/src/pages/FeedPage/PollSubmission.tsx index c76e9fb..40ca3d7 100644 --- a/src/pages/FeedPage/PollSubmission.tsx +++ b/src/pages/FeedPage/PollSubmission.tsx @@ -68,8 +68,8 @@ const PollSubmission: React.FC<PropTypes> = ({ user }) => { <UserStrip user={user} info="" navigate={() => {}} /> <Divider /> <CardMedia className={classes.card}> - <PollSubmissionImage which="left" setContents={setContents} /> - <PollSubmissionImage which="right" setContents={setContents} /> + <PollSubmissionImage which="left" setContents={setContents} contents={contents}/> + <PollSubmissionImage which="right" setContents={setContents} contents={contents}/> </CardMedia> </Collapse> <Button onClick={handleClick} color="primary" variant="outlined" className={classes.button}> diff --git a/src/pages/FeedPage/PollSubmissionImage.tsx b/src/pages/FeedPage/PollSubmissionImage.tsx index c7e638c..bf268a3 100644 --- a/src/pages/FeedPage/PollSubmissionImage.tsx +++ b/src/pages/FeedPage/PollSubmissionImage.tsx @@ -6,6 +6,7 @@ import UploadImage from '../../components/UploadImage/UploadImage'; import { Contents } from './types'; interface PropTypes { + contents: Contents; setContents: (a: Contents) => void; which: 'left' | 'right'; } @@ -21,7 +22,7 @@ const useStyles = makeStyles(theme => ({ } })); -const PollSubmissionImage: React.FC<PropTypes> = ({ setContents, which }) => { +const PollSubmissionImage: React.FC<PropTypes> = ({ setContents, which, contents }) => { const classes = useStyles(); const [display, setDisplay] = useState(false); const [image, setImage] = useState(''); @@ -32,16 +33,8 @@ const PollSubmissionImage: React.FC<PropTypes> = ({ setContents, which }) => { const patchUrl = (url: string) => { setImage(url); - let nextImage; - which === 'left' ? nextImage = 'right' : nextImage = 'left'; - setContents({ - [which]: { - url - }, - [nextImage]: { - url - } - }); + contents[which] = {url}; + setContents({...contents}); }; |