From 1f646377c35b65b97d6eeebb1e88f6d8307e1ef0 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Mon, 29 Jun 2020 23:59:15 +0300
Subject: feat!: create useAuth hook

---
 src/pages/FeedPage/PollSubmission.tsx | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

(limited to 'src/pages/FeedPage/PollSubmission.tsx')

diff --git a/src/pages/FeedPage/PollSubmission.tsx b/src/pages/FeedPage/PollSubmission.tsx
index 16c8350..4e06254 100644
--- a/src/pages/FeedPage/PollSubmission.tsx
+++ b/src/pages/FeedPage/PollSubmission.tsx
@@ -12,9 +12,9 @@ import PollSubmissionImage from './PollSubmissionImage';
 import UserStrip from '../../components/UserStrip/UserStrip';
 import { post } from '../../requests';
 import { Contents } from './types';
+import { useAuth } from '../../hooks/useAuth';
 
 interface PropTypes{
-  user: User;
   addPoll: (poll: Poll) => void;
 }
 
@@ -30,10 +30,11 @@ const emptyContents: Contents = {
   right: { url: '' }
 };
 
-const PollSubmission: React.FC<PropTypes> = ({ user, addPoll }) => {
+const PollSubmission: React.FC<PropTypes> = ({ addPoll }) => {
   const classes = useStyles();
   const [expanded, setExpanded] = useState(false);
   const [contents, setContents] = useState<Contents>(emptyContents);
+  const { user } = useAuth();
 
   const readyToSubmit = contents.left.url && contents.right.url;
 
@@ -47,7 +48,7 @@ const PollSubmission: React.FC<PropTypes> = ({ user, addPoll }) => {
 
   const handleClick = () => {
     if (expanded && readyToSubmit) {
-      post('/polls/', { authorId: user._id, contents }).then(response => {
+      post('/polls/', { contents }).then(response => {
         addPoll(response.data);
       });
       setContents({ ...emptyContents });
@@ -59,7 +60,7 @@ const PollSubmission: React.FC<PropTypes> = ({ user, addPoll }) => {
     <ClickAwayListener onClickAway={handleClickAway}>
       <Card>
         <Collapse in={expanded} timeout="auto" unmountOnExit>
-          <UserStrip user={user} info="" navigate={() => {}} />
+          {user && <UserStrip user={user} info="" navigate={() => {}} />}
           <Divider />
           <div className={classes.root}>
             <PollSubmissionImage url={contents.left.url} setUrl={setUrl('left')} />
-- 
cgit v1.2.3


From 1499c0126d1a7a2377b0267b761479100c636ee9 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Tue, 30 Jun 2020 00:41:09 +0300
Subject: feat!: create useNavigate hook

---
 src/pages/FeedPage/PollSubmission.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/pages/FeedPage/PollSubmission.tsx')

diff --git a/src/pages/FeedPage/PollSubmission.tsx b/src/pages/FeedPage/PollSubmission.tsx
index 4e06254..42612f0 100644
--- a/src/pages/FeedPage/PollSubmission.tsx
+++ b/src/pages/FeedPage/PollSubmission.tsx
@@ -60,7 +60,7 @@ const PollSubmission: React.FC<PropTypes> = ({ addPoll }) => {
     <ClickAwayListener onClickAway={handleClickAway}>
       <Card>
         <Collapse in={expanded} timeout="auto" unmountOnExit>
-          {user && <UserStrip user={user} info="" navigate={() => {}} />}
+          {user && <UserStrip user={user} info="" />}
           <Divider />
           <div className={classes.root}>
             <PollSubmissionImage url={contents.left.url} setUrl={setUrl('left')} />
-- 
cgit v1.2.3


From 5ccb1ec0be71ed4efb22b4942d70d9132415f69e Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Tue, 30 Jun 2020 00:43:48 +0300
Subject: style: fix some eslint errors

---
 src/pages/FeedPage/PollSubmission.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/pages/FeedPage/PollSubmission.tsx')

diff --git a/src/pages/FeedPage/PollSubmission.tsx b/src/pages/FeedPage/PollSubmission.tsx
index 42612f0..18f029c 100644
--- a/src/pages/FeedPage/PollSubmission.tsx
+++ b/src/pages/FeedPage/PollSubmission.tsx
@@ -7,7 +7,7 @@ import {
   ClickAwayListener,
   Divider
 } from '@material-ui/core';
-import { User, Poll, Which } from 'which-types';
+import { Poll, Which } from 'which-types';
 import PollSubmissionImage from './PollSubmissionImage';
 import UserStrip from '../../components/UserStrip/UserStrip';
 import { post } from '../../requests';
-- 
cgit v1.2.3

