-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.jsx
More file actions
51 lines (49 loc) · 1.47 KB
/
header.jsx
File metadata and controls
51 lines (49 loc) · 1.47 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
import React from 'react'
import {LogoutBtn , Logo } from '../index'
import Container from '../Component/Container'
import { Link } from 'react-router-dom'
import { useNavigate } from 'react-router-dom'
import { useSelector } from 'react-redux'
const Header = () => {
const authStatus = useSelector((state) => state.auth.status);
const navigate = useNavigate();
const NavContent = [
{ name: 'Home', path: '/', status: true },
{ name: 'Login', path: '/login', status: !authStatus },
{ name: 'AllPosts', path: '/all-posts', status: authStatus },
{ name: 'Add Post', path: '/add-post', status: authStatus }
]
return (
<header className="p-3">
<Container>
<nav className='flex'>
<div className='mr-2'>
<Link to='/'>
<Logo />
</Link>
</div>
<ul className='flex ml-auto'>
{
NavContent.map((item) => item.status ? (
<li key={item.name}>
<button
onClick={() => navigate(item.path)}
className='inline-bock px-6 py-2 duration-200 hover:bg-blue-100 rounded-full'
>
{item.name}
</button>
</li>
) : null)
}
{authStatus && (
<li>
<LogoutBtn />
</li>
)}
</ul>
</nav>
</Container>
</header>
)
}
export default Header