// ** React Imports import { useState, SyntheticEvent, Fragment } from "react"; // ** Next Import import { useRouter } from "next/router"; // ** MUI Imports import Box from "@mui/material/Box"; import Menu from "@mui/material/Menu"; import Badge from "@mui/material/Badge"; import Avatar from "@mui/material/Avatar"; import MenuItem from "@mui/material/MenuItem"; import { styled } from "@mui/material/styles"; import Button from "@mui/material/Button" // ** Icon Imports import Icon from "src/@core/components/icon"; // ** Context import { useAuth } from "src/hooks/useAuth"; // ** Type Imports import { Settings } from "src/@core/context/settingsContext"; import Select, { SelectChangeEvent } from '@mui/material/Select' import { setCookie } from 'cookies-next'; import COMPANY_ID from 'src/constant/constant' import USER_ROLE from "src/constant/UserRole"; interface Props { settings: Settings; } // ** Styled Components const BadgeContentSpan = styled("span")(({ theme }) => ({ width: 8, height: 8, borderRadius: "50%", backgroundColor: theme.palette.success.main, boxShadow: `0 0 0 2px ${theme.palette.background.paper}`, })); const UserDropdown = (props: Props) => { // ** Props const { settings } = props; // ** States const [anchorEl, setAnchorEl] = useState(null); // ** Hooks const router = useRouter(); const { logout } = useAuth(); // ** Vars const { direction } = settings; const [companyId, setCompanyId] = useState('basic') const auth = useAuth() const handleDropdownOpen = (event: SyntheticEvent) => { setAnchorEl(event.currentTarget); }; const handleDropdownClose = (url?: string) => { if (url) { router.push(url); } setAnchorEl(null); }; const styles = { py: 2, px: 4, width: "100%", display: "flex", alignItems: "center", color: "text.primary", textDecoration: "none", "& svg": { mr: 2, fontSize: "1.375rem", color: "text.primary", }, }; const styledMenu = { py: 2, px: 4, width: "100%", display: "flex", alignItems: "center", color: "primary.main", textDecoration: "none", "& svg": { mr: 2, fontSize: "0.875rem", color: "#4C4E6461", }, }; const handleLogout = () => { logout(); handleDropdownClose(); }; const changeCompanyId = (event: SelectChangeEvent) => { setCookie(COMPANY_ID, event.target.value) router.push('/schedule') } return ( { auth.user?.role == USER_ROLE.GROUP_ADMIN && router.pathname == '/select-company' ? : null } } anchorOrigin={{ vertical: "bottom", horizontal: "right", }} > handleDropdownClose()} sx={{ "& .MuiMenu-paper": { width: 230, mt: 4 } }} anchorOrigin={{ vertical: "bottom", horizontal: direction === "ltr" ? "right" : "left", }} transformOrigin={{ vertical: "top", horizontal: direction === "ltr" ? "right" : "left", }} > handleDropdownClose("/pages/user-profile/profile")} > 山田さん handleDropdownClose("/pages/user-profile/profile")} > プライバシーポリシー handleDropdownClose("/apps/email")} > お問い合わせ ); }; export default UserDropdown;