Skip to content

Commit 55380c1

Browse files
authored
Merge pull request #71 from React-ChatBotify/fix-navbar
navbar fix
2 parents 21d53cb + 1b85620 commit 55380c1

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/components/NavigationBar/NavigationBar.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ const NavigationBar = () => {
2828

2929
// handles page navigation
3030
const navigate = useNavigate()
31+
const handleLogout = () => {
32+
setIsLoggedIn(false)
33+
setUserData(null)
34+
navigate('/')
35+
}
3136

3237
// menu used for mobile view
3338
const [menuOpen, setMenuOpen] = useState(false)
@@ -233,19 +238,20 @@ const NavigationBar = () => {
233238
<button
234239
className="block px-4 py-2 hover:bg-gray-700"
235240
type="button"
241+
onClick={handleLogout}
236242
>
237243
Logout
238244
</button>
239245
</li>
240246
</>
241247
) : (
242248
<li className="my-1">
243-
<Link
244-
to="/login"
249+
<button
250+
onClick={() => handleLogin()}
245251
className="block px-4 py-2 hover:bg-gray-700"
246252
>
247253
Login
248-
</Link>
254+
</button>
249255
</li>
250256
)}
251257
</ul>
@@ -336,11 +342,7 @@ const NavigationBar = () => {
336342
<li>
337343
<button
338344
type="button"
339-
onClick={() => {
340-
setIsLoggedIn(false)
341-
setUserData(null)
342-
navigate('/')
343-
}}
345+
onClick={handleLogout}
344346
className="mr-8"
345347
>
346348
Logout

0 commit comments

Comments
 (0)