Files
optifii-corporate/src/Components/HeaderMain.jsx

272 lines
8.6 KiB
React
Raw Normal View History

2024-09-05 20:21:47 +05:30
import {
AddIcon,
ArrowBackIcon,
ArrowLeftIcon,
ArrowRightIcon,
SearchIcon,
} from "@chakra-ui/icons";
2024-09-03 12:40:08 +05:30
import {
Avatar,
Box,
Button,
HStack,
2024-09-05 20:21:47 +05:30
Image,
Input,
InputGroup,
InputLeftElement,
2024-09-03 12:40:08 +05:30
Popover,
PopoverArrow,
PopoverBody,
PopoverContent,
PopoverFooter,
PopoverTrigger,
Portal,
Text,
useColorMode,
2024-10-04 18:52:27 +05:30
VStack,
2024-09-03 12:40:08 +05:30
} from "@chakra-ui/react";
2024-09-05 20:21:47 +05:30
import React, { useContext, useState } from "react";
2024-09-03 12:40:08 +05:30
import { Link, useNavigate } from "react-router-dom";
import * as XLSX from "xlsx";
import GlobalStateContext from "../Contexts/GlobalStateContext";
2024-09-05 20:21:47 +05:30
import mainLogo from "../assets/optifii_logo.svg";
import { MdNotificationsNone } from "react-icons/md";
2024-10-04 18:52:27 +05:30
import womenpfp from "../assets/womenpfp1.png";
import { MdLogout } from "react-icons/md";
2024-09-03 12:40:08 +05:30
2024-10-04 18:52:27 +05:30
const users = [
{ id: 1, user: "Jenny Wilson", role: "Admin" },
{ id: 2, user: "Jenny Wilson", role: "Employee" },
];
const HeaderMain = ({
2024-09-03 12:40:08 +05:30
logOutHandler,
slideDirecttion,
2024-09-05 20:21:47 +05:30
isDrawerOpen,
toggleDrawer,
2024-10-04 18:52:27 +05:30
blur,
2024-09-03 12:40:08 +05:30
}) => {
2024-09-05 20:21:47 +05:30
const navigate = useNavigate();
2024-09-03 12:40:08 +05:30
const { colorMode, toggleColorMode } = useContext(GlobalStateContext);
2024-09-05 20:21:47 +05:30
const [searchTerm, setSearchTerm] = useState("");
2024-09-03 12:40:08 +05:30
2024-09-05 20:21:47 +05:30
const openDrawerOnClick = () => {};
2024-09-03 12:40:08 +05:30
return (
<Box
2024-09-05 20:21:47 +05:30
w={"100%"}
2024-10-04 18:52:27 +05:30
h={{ base: "8%", lg: "8%" }}
2024-09-05 20:21:47 +05:30
position={"relative"}
className={` pt-2 pb-2 fw-400 border-bottom d-flex ${
slideDirecttion ? " ps-2" : ""
2024-09-03 12:40:08 +05:30
} justify-content-between align-items-center`}
zIndex={999}
>
2024-09-05 20:21:47 +05:30
<Box display={"flex"} alignItems={"center"}>
2024-10-04 18:52:27 +05:30
<Box
w={"250px"}
display={"flex"}
alignItems={"center"}
justifyContent={"space-between"}
>
2024-09-05 20:21:47 +05:30
<Box
className={`d-flex ${
true ? "justify-content-start" : "justify-content-center"
} p-4 pt-0 pb-0 position-relative `}
>
<Image
style={{
width: 95,
}}
src={mainLogo}
alt="Logo"
2024-10-04 18:52:27 +05:30
onClick={() => !blur && navigate("/")}
2024-09-05 20:21:47 +05:30
cursor={"pointer"}
/>
</Box>
<Button
colorScheme={"forestGreen"}
rounded={"lg"}
onClick={toggleDrawer}
style={{
width: "28px",
height: "28px",
minWidth: "28px",
zIndex: 99,
backgroundColor: "#6311CB29",
}}
>
{isDrawerOpen ? (
<ArrowLeftIcon className="web-text-small" color={"#6311CB"} />
) : (
2024-10-04 18:52:27 +05:30
<ArrowRightIcon className="web-text-small " color={"#6311CB"} />
2024-09-05 20:21:47 +05:30
)}
</Button>
</Box>
2024-09-03 12:40:08 +05:30
2024-10-04 18:52:27 +05:30
{!blur && (
<InputGroup width={350} size="sm" ml={5}>
<InputLeftElement pointerEvents="none">
<SearchIcon color="gray.300" />
</InputLeftElement>
<Input
type="search"
placeholder="Type to search..."
rounded="md"
focusBorderColor="#3725EA"
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
/>
</InputGroup>
)}
2024-09-05 20:21:47 +05:30
</Box>
2024-10-04 18:52:27 +05:30
<Box
filter={blur && "blur(5px)"}
display={"flex"}
justifyContent={"space-between"}
>
2024-09-05 20:21:47 +05:30
<Box display={"flex"} gap={2}>
2024-10-04 18:52:27 +05:30
<Box display={"flex"} gap={2} alignItems={"center"} me={2}>
2024-10-10 13:45:41 +05:30
<Button
onClick={()=>navigate("/notification")}
size={"sm"} bg={"none"} p={0}
>
2024-09-05 20:21:47 +05:30
<MdNotificationsNone fontSize={"20px"} />
</Button>
</Box>
<Box me={4} gap={2} className="d-flex justify-content-center ">
<Popover placement="bottom">
<Portal>
2024-10-04 18:52:27 +05:30
<PopoverContent maxW="200px">
2024-09-05 20:21:47 +05:30
<PopoverArrow />
2024-10-04 18:52:27 +05:30
<Link to="/profile">
<PopoverBody
textAlign="center"
color="#6311CB"
className="web-text-medium pointer link"
>
View Profile
</PopoverBody>
</Link>
{/* <Link to={"/help-and-support"}>
2024-09-05 20:21:47 +05:30
<PopoverBody className="web-text-medium pointer ">
Help & Support
</PopoverBody>
2024-10-04 18:52:27 +05:30
</Link> */}
<PopoverBody className="web-text-medium pointer ">
<VStack>
<Text color="#A0ABBB" fontSize={"small"} fontWeight={600}>
Switch Accounts
</Text>
{users.map((val) => {
return (
<VStack
className="web-text-medium pointer link"
h="50px"
pt={2}
key={val.id}
w="100%"
>
<HStack
alignItems="flex-start"
justifyContent="space-evenly"
w="100%"
>
<Image
src={womenpfp}
h="31.79px"
alt="Profile Picture"
/>
<Text
as={"span"}
fontSize="x-small"
fontWeight={600}
color="#191D23"
>
{val.user}
<Text
// as={"span"}
fontSize="x-small"
fontWeight={600}
color="#A0ABBB"
>
{val.role}
</Text>
</Text>
</HStack>
</VStack>
);
})}
</VStack>
</PopoverBody>
2024-09-05 20:21:47 +05:30
<PopoverFooter
onClick={logOutHandler}
className="web-text-medium pointer link"
2024-10-04 18:52:27 +05:30
display="flex"
flexDirection="row"
alignItems="flex-start"
gap={3}
2024-09-05 20:21:47 +05:30
>
2024-10-04 18:52:27 +05:30
<MdLogout />
<Text
as={"span"}
color="#868788"
fontWeight={600}
fontSize="x-small"
>
Sign out of all accounts
</Text>
2024-09-05 20:21:47 +05:30
</PopoverFooter>
</PopoverContent>
</Portal>
2024-10-04 18:52:27 +05:30
{blur ? (
<Box>
<Box className="d-flex pointer align-items-center">
<Avatar size="sm" boxSize={37} bg={"#210a33"} />
<Box
style={{
display: "flex",
}}
className=" overflow-hidden ms-3 flex-column "
>
<Text as={"span"} className="web-text-small">
Hello, Developers
</Text>
<Text as={"span"} className="web-text-xsmall">
mailto:wdi@tanami.com
</Text>
</Box>
2024-09-27 12:04:23 +05:30
</Box>
</Box>
2024-10-04 18:52:27 +05:30
) : (
<PopoverTrigger>
<Box className="d-flex pointer align-items-center">
<Avatar size="sm" boxSize={37} bg={"#210a33"} />
<Box
style={{
display: "flex",
}}
className=" overflow-hidden ms-3 flex-column "
>
<Text as={"span"} className="web-text-small">
Hello, Developers
</Text>
<Text as={"span"} className="web-text-xsmall">
mailto:wdi@tanami.com
</Text>
</Box>
2024-09-05 20:21:47 +05:30
</Box>
2024-10-04 18:52:27 +05:30
</PopoverTrigger>
)}
2024-09-05 20:21:47 +05:30
</Popover>
</Box>
</Box>
2024-09-03 12:40:08 +05:30
</Box>
</Box>
);
};
export default HeaderMain;