aboutsummaryrefslogtreecommitdiff
path: root/src/pages/FeedPage/PollSubmissionImage.tsx
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-06-29 21:34:27 +0300
committereug-vs <eug-vs@keemail.me>2020-06-29 21:34:27 +0300
commitc68b0e0c3ad72a48ba421dbbc9b70d177f8ecbfc (patch)
tree7ed8560b2fba1d179e0678f9ab87242e9f9c44b9 /src/pages/FeedPage/PollSubmissionImage.tsx
parent8d0e34c5a94ec351ae22429fcc962112a85d7c19 (diff)
downloadwhich-ui-c68b0e0c3ad72a48ba421dbbc9b70d177f8ecbfc.tar.gz
style: fix eslint errors
Diffstat (limited to 'src/pages/FeedPage/PollSubmissionImage.tsx')
-rw-r--r--src/pages/FeedPage/PollSubmissionImage.tsx25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/pages/FeedPage/PollSubmissionImage.tsx b/src/pages/FeedPage/PollSubmissionImage.tsx
index 757083b..3c2eb8e 100644
--- a/src/pages/FeedPage/PollSubmissionImage.tsx
+++ b/src/pages/FeedPage/PollSubmissionImage.tsx
@@ -2,9 +2,11 @@ import React, { useState } from 'react';
import { makeStyles } from '@material-ui/core/styles';
import CloudUploadIcon from '@material-ui/icons/CloudUpload';
import { CardActionArea, CardMedia, Typography } from '@material-ui/core';
+import CancelOutlinedIcon from '@material-ui/icons/CancelOutlined';
+import _ from 'lodash';
+
import UploadImage from '../../components/UploadImage/UploadImage';
import { Contents } from './types';
-import CancelOutlinedIcon from '@material-ui/icons/CancelOutlined';
interface PropTypes {
contents: Contents;
@@ -12,7 +14,7 @@ interface PropTypes {
which: 'left' | 'right';
}
-const useStyles = makeStyles(theme => ({
+const useStyles = makeStyles({
root: {
display: 'flex',
justifyContent: 'center',
@@ -30,7 +32,7 @@ const useStyles = makeStyles(theme => ({
justifyContent: 'center',
alignItems: 'center'
}
-}));
+});
const PollSubmissionImage: React.FC<PropTypes> = ({ setContents, which, contents }) => {
@@ -39,21 +41,22 @@ const PollSubmissionImage: React.FC<PropTypes> = ({ setContents, which, contents
const [image, setImage] = useState('');
const [clearIconDisplay, setClearIconDisplay] = useState(false);
- const patchUrl = (url: string) => {
+ const patchUrl = (url: string): void => {
setImage(url);
- contents[which] = { url } ;
- setContents({ ...contents });
+ const newContents = _.set(contents, which, { url });
+ setContents({ ...newContents });
};
- const handleClick = () => {
- image ? patchUrl('') : setIsModalOpen(!isModalOpen);
+ const handleClick = (): void => {
+ if (image) patchUrl('');
+ else setIsModalOpen(!isModalOpen);
};
- const handleMouseEnter = () => {
+ const handleMouseEnter = (): void => {
setClearIconDisplay(true);
};
- const handleMouseLeave = () => {
+ const handleMouseLeave = (): void => {
setClearIconDisplay(false);
};
@@ -75,7 +78,7 @@ const PollSubmissionImage: React.FC<PropTypes> = ({ setContents, which, contents
>
{clearIconDisplay && <CancelOutlinedIcon className={classes.clearIcon} />}
</CardMedia>
- )
+ );
return (
<CardActionArea onClick={handleClick} className={classes.root}>