Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions src/components/Navbar/Navbar.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import React, { useState } from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faSignOutAlt } from '@fortawesome/free-solid-svg-icons';
import { Link } from 'react-router-dom';
import { Link, useLocation } from 'react-router-dom';
import useAuth from "../../hooks/useAuth";

const Navbar = () => {
const location = useLocation();
const isLoginPage = location.pathname === '/login';
const { setAuth } = useAuth();

const handleLogout = () => {

window.location= "/login";
setAuth({ roles: null, token: null });
window.location = "/login";
};

const [open, setOpen] = useState(true);
Expand Down Expand Up @@ -58,11 +63,13 @@ const Navbar = () => {
>
Contact
</Link>
<div className="relative" onClick={() => setOpen(false)}>
<button className="flex flex-row text-gray-900 bg-gray-200 items-center w-full px-4 py-2 mt-2 text-sm font-semibold text-left bg-transparent rounded-lg dark-mode:bg-transparent dark-mode:focus:text-white dark-mode:hover:text-white dark-mode:focus:bg-gray-600 dark-mode:hover:bg-gray-600 md:w-auto md:inline md:mt-0 md:ml-4 hover:text-gray-900 focus:text-gray-900 hover:bg-gray-200 focus:bg-gray-200 focus:outline-none focus:shadow-outline" onClick={handleLogout}>
logout <FontAwesomeIcon icon={faSignOutAlt} />
</button>
</div>
{!isLoginPage && (
<div className="relative" onClick={() => setOpen(false)}>
<button className="flex flex-row text-gray-900 bg-gray-200 items-center w-full px-4 py-2 mt-2 text-sm font-semibold text-left bg-transparent rounded-lg dark-mode:bg-transparent dark-mode:focus:text-white dark-mode:hover:text-white dark-mode:focus:bg-gray-600 dark-mode:hover:bg-gray-600 md:w-auto md:inline md:mt-0 md:ml-4 hover:text-gray-900 focus:text-gray-900 hover:bg-gray-200 focus:bg-gray-200 focus:outline-none focus:shadow-outline" onClick={handleLogout}>
logout <FontAwesomeIcon icon={faSignOutAlt} />
</button>
</div>
)}
</nav>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/PostCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ export function PostCard({ post }) {
<div>
{" "}
<button
className="bg-sky-400 text-sm px-2 py-1 rounded-sm"
className="bg-gray-400 hover:bg-sky-400 text-sm px-2 py-1 rounded-sm"
onClick={() => navigate(`/posts/${post._id}`)}
>
Edit
</button>{" "}
<button
className="bg-red-600 text-sm px-2 py-1 rounded-sm "
className="bg-gray-400 hover:bg-red-600 text-sm px-2 py-1 rounded-sm "
onClick={() => handleDelete(post._id)}
>
Delete
Expand Down