This commit is contained in:
Milana Ievlewa 2023-12-25 17:09:40 +03:00
parent 1b5a9cb0f8
commit 77f993bfac
8 changed files with 20 additions and 19 deletions

View File

@ -5,6 +5,7 @@
<meta charset="UTF-8" />
<link href="https://fonts.cdnfonts.com/css/correction-tape" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="\public\logo.ico" type="image/x-icon">
<title>TicketsBook</title>
</head>

BIN
public/logo.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

View File

@ -1,5 +1,5 @@
import { Card, Button, ButtonGroup } from 'react-bootstrap';
import { Link } from 'react-router-dom';
import { Link, useNavigate } from 'react-router-dom';
import { DashLg, PlusLg, XLg } from 'react-bootstrap-icons';
import { useEffect, useState } from 'react';
import { Form, } from 'react-bootstrap';
@ -8,6 +8,8 @@ import useCart from './CartHook';
const Cart = () => {
const navigate = useNavigate();
const [validated, setValidated] = useState(false);
const [name, setName] = useState('');
const [surname, setSurname] = useState('');
@ -54,7 +56,7 @@ const Cart = () => {
const handleLogout = () => {
localStorage.removeItem('user');
history.push('/');
navigate('/index.jsx');
};
const {

View File

@ -37,7 +37,7 @@ body{
border: 4px solid #1b1818;
border-radius: 5px;
max-width: 100%;
height: 35vh;
height: 30%;
margin-bottom: 2%;
}

View File

@ -3,14 +3,10 @@ import { Container, Nav, Navbar } from 'react-bootstrap';
import { Link, useLocation } from 'react-router-dom';
import './Navigation.css';
import Menu from '../menuWrapper/menuWrapper';
import useUser from '../users/userHook';
const Navigation = ({ routes }) => {
const storedUserData = localStorage.getItem('user');
const storedUser = storedUserData ? JSON.parse(storedUserData) : {};
const userName = storedUser && storedUser.handle ? storedUser.handle : '';
const isAdmin = userName.toLowerCase() === 'admin';
console.log(localStorage);
const {isAdmin, userName} = useUser();
const location = useLocation();
const pages = routes.filter((route) => Object.prototype.hasOwnProperty.call(route, 'title'));

View File

@ -11,9 +11,13 @@ export const UserProvider = ({ children }) => {
saveUser(user || null);
}, [user]);
return <UserContext.Provider value = {{ user, dispatch }}>
{children}
</UserContext.Provider>;
const userContextValue = { user, dispatch };
return (
<UserContext.Provider value = {userContextValue}>
{children}
</UserContext.Provider>
);
};
UserProvider.propTypes = {

View File

@ -3,17 +3,14 @@ import { userLogin, userLogout } from './userReducer.js';
import UserContext from './UserContext.jsx';
const useUser = () => {
const context = useContext(UserContext);
if (!context) {
throw new Error('useUser должен использоваться внутри UserProvider');
}
const { dispatch } = useContext(UserContext);
const {user, dispatch} = useContext(UserContext);
return {
isAdmin : user?.handle || null === 'admin',
userName : user?.handle || null,
userLogout: () => dispatch(userLogout()),
userLogin: (user) => dispatch(userLogin(user)),
};
};

View File

@ -35,6 +35,7 @@ const PersonalAccountLogin = () => {
} else if (result === 3) {
userLogin(formData);
navigate('/myTickets');
}
}
};