From 533ca9982df9329a8889ad58004bccf8ce5c8433 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Fri, 25 Sep 2020 05:24:11 -0700 Subject: [PATCH] Fix New button --- src/components/Header/Header.tsx | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index 9081c364..65f18a9d 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -1,13 +1,19 @@ import React from 'react' +import { RouteComponentProps, useLocation, withRouter } from 'react-router-dom' import { useCookies } from 'react-cookie' +import history from '~utils/history' import Button from '~components/Button/Button' import UnauthMenu from '~components/UnauthMenu/UnauthMenu' import './Header.css' -const Header = () => { +interface Props {} +interface HeaderProps extends RouteComponentProps {} + +const Header: React.FC = (props: HeaderProps) => { const [cookies, setCookie] = useCookies(['user']) + let location = useLocation() function copyToClipboard() { const el = document.createElement('input') @@ -20,6 +26,15 @@ const Header = () => { el.remove() } + function newParty() { + if (props.history.location.pathname === '/') { + window.history.replaceState(null, `Grid Tool`, `/`) + props.history.go(0) + } else { + props.history.push('/') + } + } + if (cookies.user != null) { console.log(`Logged in as user "${cookies.user.username}"`) } @@ -34,10 +49,10 @@ const Header = () => {
- - - - + { (location.pathname !== '/') ? + : '' + } +
)