aboutsummaryrefslogtreecommitdiff
path: root/src/pages/FeedPage
diff options
context:
space:
mode:
authorilyayudovin <ilyayudovin123@gmail.com>2020-06-28 19:32:48 +0300
committerilyayudovin <ilyayudovin123@gmail.com>2020-06-28 19:32:48 +0300
commit28c80d1c2e33706a3a754b3e5e26dc2685cf8592 (patch)
tree3fada7e63634d1f2e1c07a0794c725d33b2b2b4f /src/pages/FeedPage
parent7ad127942bb12ee9de691e10dc9386849459ea46 (diff)
downloadwhich-ui-28c80d1c2e33706a3a754b3e5e26dc2685cf8592.tar.gz
fix: able to add 2 different images to poll submission
Diffstat (limited to 'src/pages/FeedPage')
-rw-r--r--src/pages/FeedPage/PollSubmission.tsx4
-rw-r--r--src/pages/FeedPage/PollSubmissionImage.tsx15
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});
};