1- import { useState , useRef , useEffect , Fragment } from "react" ;
2- // import { useState, Fragment } from "react";
3- import accountLogo from "../../assets/account.svg" ;
1+ import { useState , useRef , useEffect } from "react" ;
42import { Link , useNavigate , useLocation } from "react-router-dom" ;
5- import LoginMenuDropDown from "./LoginMenuDropDown" ;
63import "../../components/Header/header.css" ;
74import Chat from "./Chat" ;
85import { FeatureMenuDropDown } from "./FeatureMenuDropDown" ;
96import MdNavBar from "./MdNavBar" ;
10- import { connect , useDispatch } from "react-redux" ;
7+ import { connect } from "react-redux" ;
118import { RootState } from "../../services/actions/types" ;
12- import { logout , AppDispatch } from "../../services/actions/auth" ;
13- import { HiChevronDown } from "react-icons/hi" ;
9+ import { FaChevronDown , FaSignOutAlt } from "react-icons/fa" ;
1410import { useGlobalContext } from "../../contexts/GlobalContext.tsx" ;
1511
1612interface LoginFormProps {
@@ -24,44 +20,16 @@ const Header: React.FC<LoginFormProps> = ({ isAuthenticated, isSuperuser }) => {
2420 const dropdownRef = useRef ( null ) ;
2521 let delayTimeout : number | null = null ;
2622 const [ showChat , setShowChat ] = useState ( false ) ;
27- const [ showLoginMenu , setShowLoginMenu ] = useState ( false ) ;
28- const [ redirect , setRedirect ] = useState ( false ) ;
2923 const { setShowSummary, setEnterNewPatient, triggerFormReset, setIsEditing } =
3024 useGlobalContext ( ) ;
3125
32- const dispatch = useDispatch < AppDispatch > ( ) ;
33-
34- const logout_user = ( ) => {
35- dispatch ( logout ( ) ) ;
36- setRedirect ( false ) ;
37- } ;
38-
39- const guestLinks = ( ) => (
40- < nav onClick = { handleLoginMenu } className = "flex cursor-pointer items-center" >
41- < img
42- src = { accountLogo }
43- alt = "logo"
44- className = "mr-5 h-5 object-contain lg:h-4 "
45- />
46- < span className = " text-black hover:border-b-2 hover:border-blue-600 hover:text-black hover:no-underline lg:text-sm xl:text-lg" >
47- Sign in
48- </ span >
49- </ nav >
50- ) ;
51-
5226 const authLinks = ( ) => (
53- < nav onClick = { logout_user } className = "flex cursor-pointer items-center" >
54- < img src = { accountLogo } alt = "logo" className = "mr-5 h-5 object-contain " />
55- < span className = " text-black hover:border-b-2 hover:border-blue-600 hover:text-black hover:no-underline lg:text-sm xl:text-lg" >
56- Sign out
57- </ span >
58- </ nav >
27+ < Link to = "/logout" className = "font-satoshi flex cursor-pointer items-center text-black hover:text-blue-600" >
28+ Sign Out
29+ < FaSignOutAlt className = "ml-2 inline-block" />
30+ </ Link >
5931 ) ;
6032
61- const handleLoginMenu = ( ) => {
62- setShowLoginMenu ( ! showLoginMenu ) ;
63- } ;
64-
6533 const handleMouseEnter = ( ) => {
6634 if ( delayTimeout !== null ) {
6735 clearTimeout ( delayTimeout ) ;
@@ -126,7 +94,7 @@ const Header: React.FC<LoginFormProps> = ({ isAuthenticated, isSuperuser }) => {
12694 Balancer
12795 </ span >
12896 </ Link >
129- < nav className = " flex space-x-2 font-satoshi lg:space-x-3 xl:gap-3 xl:font-bold " >
97+ < nav className = "flex space-x-2 font-satoshi lg:space-x-3 xl:gap-3 xl:font-bold " >
13098 < Link
13199 to = "/"
132100 onClick = { ( ) => handleForm ( ) }
@@ -186,7 +154,7 @@ const Header: React.FC<LoginFormProps> = ({ isAuthenticated, isSuperuser }) => {
186154 >
187155 Donate
188156 </ a >
189- { isSuperuser && (
157+ { ( isAuthenticated && isSuperuser ) && (
190158 < div
191159 onMouseEnter = { handleMouseEnter }
192160 onMouseLeave = { handleMouseLeave }
@@ -210,25 +178,20 @@ const Header: React.FC<LoginFormProps> = ({ isAuthenticated, isSuperuser }) => {
210178 : "absolute ml-1.5 "
211179 } `}
212180 >
213- < HiChevronDown className = "inline-block" />
181+ < FaChevronDown className = "inline-block" />
214182 </ span >
215183 </ span >
216184 { showFeaturesMenu && < FeatureMenuDropDown /> }
217185 </ div >
218186 ) }
219-
220- { redirect ? navigate ( "/" ) : < Fragment > </ Fragment > }
221187 </ >
222188 </ nav >
223- < LoginMenuDropDown
224- showLoginMenu = { showLoginMenu }
225- handleLoginMenu = { handleLoginMenu }
226- />
227189 { isAuthenticated && (
228- < Chat showChat = { showChat } setShowChat = { setShowChat } />
190+ < >
191+ < Chat showChat = { showChat } setShowChat = { setShowChat } />
192+ </ >
229193 ) }
230- { /* <Chat showChat={showChat} setShowChat={setShowChat} /> */ }
231- { isAuthenticated ? authLinks ( ) : guestLinks ( ) }
194+ { isAuthenticated && authLinks ( ) }
232195 </ div >
233196 < MdNavBar handleForm = { handleForm } isAuthenticated = { isAuthenticated } />
234197 </ header >
0 commit comments