|
@@ -3,6 +3,7 @@ import {Footer, Links} from "./index"
|
|
|
import {BrowserRouter as Router, Route, Link, Switch, Redirect} from 'react-router-dom';
|
|
|
import createHistory from "history/createBrowserHistory";
|
|
|
import {Provider, connect} from 'react-redux';
|
|
|
+import {actionAuthLogout} from "../reducers"
|
|
|
import {createStore, combineReducers, applyMiddleware} from 'redux';
|
|
|
import thunk from 'redux-thunk';
|
|
|
|
|
@@ -49,9 +50,27 @@ const TabletMenu = ({}) => {
|
|
|
)
|
|
|
}
|
|
|
|
|
|
+const ToLoginPage = ({login, onLogout}) => {
|
|
|
+
|
|
|
+ return(
|
|
|
+ <>
|
|
|
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-person" viewBox="0 0 16 16">
|
|
|
+ <path d="M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm2-3a2 2 0 1 1-4 0 2 2 0 0 1 4 0zm4 8c0 1-1 1-1 1H3s-1 0-1-1 1-4 6-4 6 3 6 4zm-1-.004c-.001-.246-.154-.986-.832-1.664C11.516 10.68 10.289 10 8 10c-2.29 0-3.516.68-4.168 1.332-.678.678-.83 1.418-.832 1.664h10z"/>
|
|
|
+ </svg>
|
|
|
+ <Link to = {login ? "/yourPage": "/login"} >
|
|
|
+ <span className = "link">{login ? login : "Вхід"}</span>
|
|
|
+ {login && <button onClick = {onLogout}>Вихід</button>}
|
|
|
+ </Link>
|
|
|
+ </>
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+const CToLoginPage =connect(s => ({login: s.auth.payload && s.auth.payload.sub.login}), {onLogout: actionAuthLogout}) (ToLoginPage);
|
|
|
+
|
|
|
const Header = ({}) => {
|
|
|
const [basketCount, buyDelete] = useState(0);
|
|
|
const [wishes, wishesCount] = useState(0);
|
|
|
+ console.log(connect((s) => ({isLoggedIn: s.auth.payload})))
|
|
|
return(
|
|
|
<>
|
|
|
<div className = "header">
|
|
@@ -69,10 +88,13 @@ const Header = ({}) => {
|
|
|
<span>Хочу({wishes})</span>
|
|
|
</div>
|
|
|
<div>
|
|
|
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-person" viewBox="0 0 16 16">
|
|
|
+ <CToLoginPage/>
|
|
|
+ {/* <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-person" viewBox="0 0 16 16">
|
|
|
<path d="M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm2-3a2 2 0 1 1-4 0 2 2 0 0 1 4 0zm4 8c0 1-1 1-1 1H3s-1 0-1-1 1-4 6-4 6 3 6 4zm-1-.004c-.001-.246-.154-.986-.832-1.664C11.516 10.68 10.289 10 8 10c-2.29 0-3.516.68-4.168 1.332-.678.678-.83 1.418-.832 1.664h10z"/>
|
|
|
</svg>
|
|
|
- <span>Вхід</span>
|
|
|
+ <Link to = "/login" >
|
|
|
+ <span className = "link">Вхід</span>
|
|
|
+ </Link> */}
|
|
|
</div>
|
|
|
<div>
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bag" viewBox="0 0 16 16">
|