-
Notifications
You must be signed in to change notification settings - Fork 696
Expand file tree
/
Copy pathMobileNavigation.jsx
More file actions
89 lines (82 loc) · 2.51 KB
/
MobileNavigation.jsx
File metadata and controls
89 lines (82 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { BasketToggle } from 'components/basket';
import { HOME, SIGNIN } from 'constants/routes';
import PropType from 'prop-types';
import React from 'react';
import { Link, useLocation } from 'react-router-dom';
import UserNav from 'views/account/components/UserAvatar';
import Badge from './Badge';
import FiltersToggle from './FiltersToggle';
import SearchBar from './SearchBar';
const Navigation = (props) => {
const {
isAuthenticating, basketLength, disabledPaths, user
} = props;
const { pathname } = useLocation();
const onClickLink = (e) => {
if (isAuthenticating) e.preventDefault();
};
return (
<nav className="mobile-navigation">
<div className="mobile-navigation-main">
<div className="mobile-navigation-logo">
<Link onClick={onClickLink} to={HOME}>
<h2>LUNETAS-CAM</h2>
</Link>
</div>
<BasketToggle>
{({ onClickToggle }) => (
<button
className="button-link navigation-menu-link basket-toggle"
onClick={onClickToggle}
disabled={disabledPaths.includes(pathname)}
type="button"
>
<Badge count={basketLength}>
<i className="fa fa-shopping-bag" style={{ fontSize: '2rem' }} />
</Badge>
</button>
)}
</BasketToggle>
<ul className="mobile-navigation-menu">
{user ? (
<li className="mobile-navigation-item">
<UserNav />
</li>
) : (
<>
{pathname !== SIGNIN && (
<li className="mobile-navigation-item">
<Link
className="navigation-menu-link"
onClick={onClickLink}
to={SIGNIN}
>
Sign In
</Link>
</li>
)}
</>
)}
</ul>
</div>
<div className="mobile-navigation-sec">
<SearchBar />
<FiltersToggle>
<button className="button-link button-small" type="button">
<i className="fa fa-filter" />
</button>
</FiltersToggle>
</div>
</nav>
);
};
Navigation.propTypes = {
isAuthenticating: PropType.bool.isRequired,
basketLength: PropType.number.isRequired,
disabledPaths: PropType.arrayOf(PropType.string).isRequired,
user: PropType.oneOfType([
PropType.bool,
PropType.object
]).isRequired
};
export default Navigation;