-
-
Notifications
You must be signed in to change notification settings - Fork 430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/815 #927
base: master
Are you sure you want to change the base?
Fix/815 #927
Changes from 6 commits
b4564e1
c083cfe
3cbc1b7
ed5fa5b
d4e77cd
edf66eb
18abca0
0344e5d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import React from 'react'; | ||
import React, { useEffect } from 'react'; | ||
import { useRouter } from 'next/router'; | ||
import classNames from 'classnames'; | ||
import styled from 'styled-components/macro'; | ||
|
@@ -10,8 +10,11 @@ import IconHome from '../../assets/me/home.svg'; | |
import Mentorships from '../../assets/me/icon-survey.svg'; | ||
import IconMentors from '../../assets/me/mentors.svg'; | ||
import IconLogout from '../../assets/me/icon-door-exit.svg'; | ||
import TawkIcon from '../../assets/me/tawk.svg'; | ||
import { useUser } from '../../context/userContext/UserContext'; | ||
import { useRoutes } from '../../hooks/useRoutes' | ||
import { useRoutes } from '../../hooks/useRoutes'; | ||
import { hideWidget, toggleChat, showWidget } from '../../utils/tawk'; | ||
import { useDeviceType } from '../../hooks/useDeviceType'; | ||
|
||
const MenuItem = ({ | ||
icon: Icon, | ||
|
@@ -20,24 +23,42 @@ const MenuItem = ({ | |
}: { | ||
icon: string; | ||
label: string; | ||
to: string; | ||
to?: string; | ||
onClick?: () => void; | ||
}) => { | ||
const router = useRouter(); | ||
if (to) { | ||
return ( | ||
<Link href={to}> | ||
<NavItemDecoration | ||
className={classNames({ active: router.pathname === to })} | ||
> | ||
<Icon /> | ||
<Label>{label}</Label> | ||
</NavItemDecoration> | ||
</Link> | ||
); | ||
} | ||
return ( | ||
<Link href={to}> | ||
<NavItemDecoration | ||
className={classNames({ active: router.pathname === to })} | ||
> | ||
<button onClick={toggleChat}> | ||
<NavItemDecoration> | ||
<Icon /> | ||
<Label>{label}</Label> | ||
</NavItemDecoration> | ||
</Link> | ||
</button> | ||
); | ||
}; | ||
|
||
const Navbar = () => { | ||
const { isAdmin, logout } = useUser(); | ||
const urls = useRoutes(); | ||
const { isMobile } = useDeviceType(); | ||
useEffect(() => { | ||
if (!isMobile) return; | ||
hideWidget(); | ||
return () => showWidget(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this cleanup function been called? Isn't this function firing when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes its running everytime ismobile changed. 'whats the case that this variable changes', I dont understand what your trying to say, I did not write the code for isMobile. You wont have the desired behavior if i remove that cleanup. change the width of your browser to mobile size, close the chat, now make the screen wider. The button is gone (its not needed anymore), now how will you open the chat? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nevermind I understand what you want me to do. |
||
}, [isMobile]); | ||
|
||
return ( | ||
<> | ||
<Menu> | ||
|
@@ -46,8 +67,17 @@ const Navbar = () => { | |
alt="Logo" | ||
/> | ||
<MenuItem to={urls.me.get()} icon={IconHome} label="Home" /> | ||
<MenuItem to={urls.me.requests.get()} icon={Mentorships} label="Mentorships" /> | ||
<MenuItem | ||
to={urls.me.requests.get()} | ||
icon={Mentorships} | ||
label="Mentorships" | ||
/> | ||
{isMobile && ( | ||
<MenuItem onClick={toggleChat} icon={TawkIcon} label="Tawk" /> | ||
)} | ||
|
||
<MenuItem to={urls.root.get()} icon={IconMentors} label="Mentors" /> | ||
|
||
{isAdmin && ( | ||
<MenuItem to={urls.me.admin.get()} icon={IconMentors} label="Admin" /> | ||
)} | ||
|
@@ -126,3 +156,6 @@ const Logout = styled(NavItemDecoration)` | |
margin-bottom: 10px; | ||
} | ||
`; | ||
function setIsTawkShowing(arg0: boolean): void { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ive removed this |
||
throw new Error('Function not implemented.'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you pass
onClick
, did you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ive done this