From 0a23633aa49ece18897a6ceaa56fdd3cd837b8e8 Mon Sep 17 00:00:00 2001 From: ilyayudovin Date: Tue, 15 Sep 2020 00:15:30 +0300 Subject: feat: add description to poll --- package-lock.json | 6 +++--- package.json | 2 +- src/components/PollCard/PollCard.tsx | 4 ++++ src/containers/Page/Page.tsx | 3 ++- src/containers/PollCreation/PollCreation.tsx | 13 ++++++++----- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index e25fb85..5a9140e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14429,9 +14429,9 @@ "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" }, "which-types": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/which-types/-/which-types-1.6.1.tgz", - "integrity": "sha512-uTCrp6+rbU48kyT9Z6upVo9CgGmiR50zFSwzDik8slE8oZ+0FC9SBEfJlfgADX/rFJVbIe8Vxsw4BsSxlL5Lsw==" + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/which-types/-/which-types-1.6.2.tgz", + "integrity": "sha512-+OAaJtZsqJab9YohByErzVqxWTsl/JvZ6AVpz7a0WrPEQHapv0aoA0RZIu1zrfSBFhAQLSJmw4fyvfqUvViO5g==" }, "word-wrap": { "version": "1.2.3", diff --git a/package.json b/package.json index 2bb2500..1d4abfe 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "react-virtualized": "^9.21.2", "swr": "^0.3.0", "typeface-roboto": "0.0.75", - "which-types": "^1.6.1", + "which-types": "^1.6.2", "yup": "^0.29.3" }, "scripts": { diff --git a/src/components/PollCard/PollCard.tsx b/src/components/PollCard/PollCard.tsx index 540679f..e2d06ee 100644 --- a/src/components/PollCard/PollCard.tsx +++ b/src/components/PollCard/PollCard.tsx @@ -42,6 +42,9 @@ const useStyles = makeStyles(theme => ({ height: theme.spacing(2), backgroundColor: theme.palette.primary.light, transitionDuration: '0.5s' + }, + description: { + padding: '0px 16px 10px' } })); @@ -93,6 +96,7 @@ const PollCard: React.FC = React.memo(({ poll, setPoll }) => { return ( +
{poll.description}
diff --git a/src/containers/Page/Page.tsx b/src/containers/Page/Page.tsx index e60f7da..9a904a4 100644 --- a/src/containers/Page/Page.tsx +++ b/src/containers/Page/Page.tsx @@ -17,7 +17,8 @@ const useStyles = makeStyles(theme => ({ }, [theme.breakpoints.up('md')]: { padding: theme.spacing(15, 5, 8, 5) - } + }, + backgroundColor: 'whitesmoke' } })); diff --git a/src/containers/PollCreation/PollCreation.tsx b/src/containers/PollCreation/PollCreation.tsx index 68f41d2..7f29119 100644 --- a/src/containers/PollCreation/PollCreation.tsx +++ b/src/containers/PollCreation/PollCreation.tsx @@ -1,7 +1,7 @@ -import React from 'react'; +import React, {useRef} from 'react'; import Bluebird from 'bluebird'; import { makeStyles } from '@material-ui/core/styles'; -import { Card, Container, LinearProgress } from '@material-ui/core'; +import { Card, Container, LinearProgress, Divider } from '@material-ui/core'; import SendIcon from '@material-ui/icons/Send'; import { useSnackbar } from 'notistack'; @@ -25,8 +25,9 @@ const useStyles = makeStyles(theme => ({ const PollCreation: React.FC = () => { const classes = useStyles(); - const { user } = useAuth(); + const ref = useRef(null); const { enqueueSnackbar } = useSnackbar(); + const { user } = useAuth(); const { mutate: updateFeed } = useFeed(); const { mutate: updateProfile } = useProfile(user?.username || ''); const { @@ -50,8 +51,8 @@ const PollCreation: React.FC = () => { left: { url: leftUrl }, right: { url: rightUrl } }; - - post('/polls/', { contents }).then(() => { + const description = ref?.current?.value; + post('/polls/', { contents, description }).then(() => { updateFeed(); updateProfile(); enqueueSnackbar('Your poll has been successfully created!', { variant: 'success' }); @@ -71,6 +72,8 @@ const PollCreation: React.FC = () => { {user && } + +