diff --git a/client/src/components/layout/Navbar.tsx b/client/src/components/layout/Navbar.tsx index ae964c7..f670ce0 100644 --- a/client/src/components/layout/Navbar.tsx +++ b/client/src/components/layout/Navbar.tsx @@ -1,11 +1,14 @@ -import React from 'react'; -import {Avatar, Col, Row, Tooltip} from 'antd'; +import React, { useEffect, useState } from 'react'; +import {Avatar, Button, Col, Drawer, Menu, MenuProps, Row, Tooltip} from 'antd'; import PropTypes from "prop-types"; -import {connect} from "react-redux"; +import {connect, useDispatch} from "react-redux"; import {UserOutlined} from '@ant-design/icons'; import {rowGutterStyle} from '../../App'; import {Link, useLocation} from 'react-router-dom'; import {Container} from 'react-bootstrap'; +import {MenuOutlined} from '@ant-design/icons'; +import {HomeOutlined, SearchOutlined, AuditOutlined, LogoutOutlined, CloseOutlined} from '@ant-design/icons'; +import {filterRoleListingsByDepartment, filterRoleListingsByLocation, filterRoleListingsByRoleId} from '../../actions/roleListings'; interface pageType { [key: string]: string @@ -19,23 +22,133 @@ const pages: pageType = { "staff": "Staff Detail", } -const Navbar = ({auth: {user, loading}}: any) => { +const Navbar = ({auth: {user, loading, isHR, logout}}: any) => { const location = useLocation() const pageName = location.pathname.split("/")[1] + const dispatch = useDispatch(); + + const [open, setOpen] = useState(false); + + const onClose = () => { + setOpen(false); + }; + + const [viewportWidth, setViewportWidth] = useState(window.innerWidth); + + // Update viewport width when the window is resized + useEffect(() => { + function handleResize() { + setViewportWidth(window.innerWidth); + } + + window.addEventListener('resize', handleResize); + + return () => { + window.removeEventListener('resize', handleResize); + }; + }, []); + + const items: MenuProps['items'] = [ + // { + // label: "SBRP", + // key: 'logo', + // disabled: true, + // style: {height: 60, paddingTop: 10, cursor: "default"}, + // }, + { + label: ({"Home"}), + key: '/', + icon: , + style: {height: 60, paddingTop: 10}, + }, + { + label: + + My Profile + + , + key: 'profile', + icon: , + style: {height: 60, paddingTop: 10}, + + }, + { + label: ({"Search Roles"}), + key: 'roleListing', + icon: , + onClick: () => { + dispatch(filterRoleListingsByRoleId({roleIds: []}) as any); + dispatch(filterRoleListingsByDepartment({departments: []}) as any); + dispatch(filterRoleListingsByLocation({locations: []}) as any); + }, + style: {height: 60, paddingTop: 10}, + } + ]; + + if (isHR) { + items.push({ + label: ({"Role Listing Management"}), + key: 'listingManage', + icon: , + style: {height: 60, paddingTop: 10}, + }) + } + + items.push({ + label: (Logout), + key: 'logout', + danger: true, + icon: , + style: {height: 60, paddingTop: 10}, + }) return ( + SBRP} + placement={"top"} + closable={false} + onClose={onClose} + open={open} + // style={{padding: 0}} + // contentWrapperStyle={{padding: 0}} + bodyStyle={{padding: 0}} + style={{backgroundColor: "#001529"}} + extra={ +