diff options
author | eug-vs <eug-vs@keemail.me> | 2020-06-30 00:41:09 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-06-30 00:41:09 +0300 |
commit | 1499c0126d1a7a2377b0267b761479100c636ee9 (patch) | |
tree | 5d48eea7b8dffcac324034703ebc4e30448d75c6 /src/pages/ProfilePage/ProfilePage.tsx | |
parent | aa63dea15c71ab014b4b57010574c7abf1f9628b (diff) | |
download | which-ui-1499c0126d1a7a2377b0267b761479100c636ee9.tar.gz |
feat!: create useNavigate hook
Diffstat (limited to 'src/pages/ProfilePage/ProfilePage.tsx')
-rw-r--r-- | src/pages/ProfilePage/ProfilePage.tsx | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/pages/ProfilePage/ProfilePage.tsx b/src/pages/ProfilePage/ProfilePage.tsx index ad2da46..808d43a 100644 --- a/src/pages/ProfilePage/ProfilePage.tsx +++ b/src/pages/ProfilePage/ProfilePage.tsx @@ -4,16 +4,18 @@ import { User, Poll } from 'which-types'; import ProfileInfo from './ProfileInfo'; import Feed from '../../components/Feed/Feed'; import { get } from '../../requests'; +import { useAuth } from '../../hooks/useAuth'; +import { useNavigate } from '../../hooks/useNavigate'; -interface PropTypes { - navigate: (prefix: string, id: string) => void; - id: string; -} -const ProfilePage: React.FC<PropTypes> = ({ id, navigate }) => { +const ProfilePage: React.FC = () => { const [userInfo, setUserInfo] = useState<User>(); const [polls, setPolls] = useState<Poll[]>([]); const [totalVotes, setTotalVotes] = useState<number>(0); + const { page } = useNavigate(); + const { user } = useAuth(); + + const id = page?.id || user?._id; useEffect(() => { get(`/users/${id}`).then(response => { @@ -41,7 +43,7 @@ const ProfilePage: React.FC<PropTypes> = ({ id, navigate }) => { savedPolls={polls.length} totalVotes={totalVotes} /> - <Feed polls={[...polls]} navigate={navigate} /> + <Feed polls={[...polls]} /> </> ); }; |