2023-06-26 10:07:12 +00:00
|
|
|
"use client";
|
|
|
|
|
|
2023-02-13 13:46:56 +00:00
|
|
|
import { FC } from "react";
|
2023-05-25 12:37:14 +00:00
|
|
|
import Image from "next/legacy/image";
|
2023-02-13 13:46:56 +00:00
|
|
|
import { signOut } from "next-auth/react";
|
|
|
|
|
import { Button, Box, Menu, MenuItem } from "@mui/material";
|
|
|
|
|
import { useTranslate } from "react-polyglot";
|
|
|
|
|
import UserIcon from "images/user-icon.png";
|
|
|
|
|
import {
|
|
|
|
|
usePopupState,
|
|
|
|
|
bindTrigger,
|
|
|
|
|
bindMenu,
|
|
|
|
|
} from "material-ui-popup-state/hooks";
|
2024-03-20 17:51:21 +01:00
|
|
|
import { useLeafcutterContext } from "leafcutter-ui/components/LeafcutterProvider";
|
2023-02-13 13:46:56 +00:00
|
|
|
|
|
|
|
|
export const AccountButton: FC = () => {
|
|
|
|
|
const t = useTranslate();
|
|
|
|
|
const {
|
|
|
|
|
colors: { leafcutterElectricBlue },
|
2024-03-20 17:51:21 +01:00
|
|
|
} = useLeafcutterContext();
|
2023-02-13 13:46:56 +00:00
|
|
|
const popupState = usePopupState({ variant: "popover", popupId: "account" });
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Button
|
|
|
|
|
{...bindTrigger(popupState)}
|
|
|
|
|
color="secondary"
|
|
|
|
|
sx={{
|
|
|
|
|
backgroundColor: leafcutterElectricBlue,
|
|
|
|
|
width: "40px",
|
|
|
|
|
height: "40px",
|
|
|
|
|
minWidth: "40px",
|
|
|
|
|
p: 0,
|
|
|
|
|
borderRadius: "500px",
|
|
|
|
|
":hover": {
|
|
|
|
|
backgroundColor: leafcutterElectricBlue,
|
|
|
|
|
opacity: 0.8,
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-05-24 20:27:57 +00:00
|
|
|
<Image src={UserIcon} alt="account" width={30} height={30} />
|
2023-02-13 13:46:56 +00:00
|
|
|
</Button>
|
|
|
|
|
<Menu {...bindMenu(popupState)}>
|
|
|
|
|
<MenuItem
|
|
|
|
|
onClick={() => {
|
|
|
|
|
popupState.close();
|
|
|
|
|
signOut({ callbackUrl: "/" });
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box sx={{ width: "100%" }}>{t("signOut")}</Box>
|
|
|
|
|
</MenuItem>
|
|
|
|
|
</Menu>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|