diff options
author | ilyayudovin <ilyayudovin123@gmail.com> | 2020-07-01 14:38:39 +0300 |
---|---|---|
committer | ilyayudovin <ilyayudovin123@gmail.com> | 2020-07-01 14:38:39 +0300 |
commit | 75c1dac4bceddab1d94b9e43c2fb2035297eb6bd (patch) | |
tree | d2b930d8c4464c64eb5c99077f2d5bbb4f1caf1a /src | |
parent | 75eb28d8338c1e0601c94640303f91ef09bd583a (diff) | |
download | which-ui-75c1dac4bceddab1d94b9e43c2fb2035297eb6bd.tar.gz |
fix eslint errors
Diffstat (limited to 'src')
-rw-r--r-- | src/components/PollCard/PollCard.tsx | 20 | ||||
-rw-r--r-- | src/index.tsx | 6 | ||||
-rw-r--r-- | src/pages/FeedPage/PollSubmission.tsx | 17 |
3 files changed, 21 insertions, 22 deletions
diff --git a/src/components/PollCard/PollCard.tsx b/src/components/PollCard/PollCard.tsx index aab0261..ef7391e 100644 --- a/src/components/PollCard/PollCard.tsx +++ b/src/components/PollCard/PollCard.tsx @@ -6,10 +6,10 @@ import { CardMedia } from '@material-ui/core/'; import { Which, Poll } from 'which-types'; +import { useSnackbar } from 'notistack'; import PercentageBar from './PercentageBar'; import UserStrip from '../UserStrip/UserStrip'; import { post } from '../../requests'; -import {useSnackbar} from "notistack"; interface PropTypes { initialPoll: Poll; @@ -57,28 +57,28 @@ const PollCard: React.FC<PropTypes> = ({ initialPoll }) => { const [poll, setPoll] = useState<Poll>(initialPoll); const classes = useStyles(); const { author, contents: { left, right }, vote } = poll; - const { enqueueSnackbar, closeSnackbar } = useSnackbar(); + const { enqueueSnackbar } = useSnackbar(); const date: string = new Date(poll.createdAt).toLocaleString('default', DATE_FORMAT); + + const showSnackBar = (message: string) => { + enqueueSnackbar(message, { + variant: 'error' + }); + }; + const handleVote = (which: Which) => { if (vote) { - showSnackBar('You have voted already'); + showSnackBar('You have already voted'); return; } post('votes/', { which, pollId: poll._id }).then(response => { - console.log(response.data); poll.contents[which].votes += 1; poll.vote = response.data; setPoll({ ...poll }); }); }; - const showSnackBar = (message: string) => { - enqueueSnackbar(message, { - variant: 'warning', - }); - }; - const handleLeft = () => handleVote('left'); const handleRight = () => handleVote('right'); diff --git a/src/index.tsx b/src/index.tsx index c304043..0ab06f5 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -5,14 +5,12 @@ import { CssBaseline } from '@material-ui/core'; import teal from '@material-ui/core/colors/teal'; import 'typeface-roboto'; +import { SnackbarProvider } from 'notistack'; import Header from './components/Header/Header'; import ScrollTopArrow from './components/ScrollTopArrow/ScrollTopArrow'; import Page from './pages/Page'; import { AuthProvider } from './hooks/useAuth'; import { NavigationProvider } from './hooks/useNavigate'; -import { SnackbarProvider } from 'notistack'; - - const theme = createMuiTheme({ palette: { @@ -30,7 +28,7 @@ const App: React.FC = () => { maxSnack={3} anchorOrigin={{ vertical: 'bottom', - horizontal: 'right', + horizontal: 'right' }} > <NavigationProvider> diff --git a/src/pages/FeedPage/PollSubmission.tsx b/src/pages/FeedPage/PollSubmission.tsx index f8ba26b..3088279 100644 --- a/src/pages/FeedPage/PollSubmission.tsx +++ b/src/pages/FeedPage/PollSubmission.tsx @@ -8,12 +8,12 @@ import { Divider } from '@material-ui/core'; import { Poll, Which } from 'which-types'; +import { useSnackbar } from 'notistack'; import PollSubmissionImage from './PollSubmissionImage'; import UserStrip from '../../components/UserStrip/UserStrip'; import { post } from '../../requests'; import { Contents } from './types'; import { useAuth } from '../../hooks/useAuth'; -import {useSnackbar} from "notistack"; interface PropTypes{ addPoll: (poll: Poll) => void; @@ -35,7 +35,7 @@ const PollSubmission: React.FC<PropTypes> = ({ addPoll }) => { const classes = useStyles(); const [expanded, setExpanded] = useState(false); const [contents, setContents] = useState<Contents>(emptyContents); - const { enqueueSnackbar, closeSnackbar } = useSnackbar(); + const { enqueueSnackbar } = useSnackbar(); const { user } = useAuth(); const readyToSubmit = contents.left.url && contents.right.url; @@ -48,6 +48,13 @@ const PollSubmission: React.FC<PropTypes> = ({ addPoll }) => { setExpanded(false); }; + const showSnackBar = (message: string) => { + enqueueSnackbar(message, { + variant: 'success' + }); + }; + + const handleClick = () => { if (expanded && readyToSubmit) { post('/polls/', { contents }).then(response => { @@ -59,12 +66,6 @@ const PollSubmission: React.FC<PropTypes> = ({ addPoll }) => { setExpanded(!expanded); }; - const showSnackBar = (message: string) => { - enqueueSnackbar(message, { - variant: 'success', - }); - }; - return ( <ClickAwayListener onClickAway={handleClickAway}> <Card> |