You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
import { Button, Popover, Tooltip } from "antd";
|
|
import { ArrowRightOutlined, LogoutOutlined } from "@ant-design/icons";
|
|
import { api } from "./api";
|
|
import { setAuth } from "./stores/auth";
|
|
import { useQuery } from "@tanstack/react-query";
|
|
import { Title } from "./components/Title";
|
|
|
|
export function SignOut() {
|
|
const logOut = async () => {
|
|
await api.post("accounts/logout/");
|
|
|
|
setAuth(false);
|
|
};
|
|
|
|
const { data } = useQuery(["profile"], async () => {
|
|
const { data } = await api.get("/accounts/profile");
|
|
return data;
|
|
});
|
|
|
|
return (
|
|
<div className="absolute top-[20px] right-[20px]">
|
|
<Popover
|
|
content={
|
|
<>
|
|
<Title text={data?.email} classNameText={"lowercase"} />
|
|
<Button type="primary" block onClick={logOut}>
|
|
<span className="mr-1">Выйти</span>
|
|
<ArrowRightOutlined />
|
|
</Button>
|
|
</>
|
|
}
|
|
trigger="click"
|
|
placement={"bottomRight"}
|
|
>
|
|
<Tooltip title="Выйти" placement={"left"}>
|
|
<Button icon={<LogoutOutlined />} type="primary" size="large" />
|
|
</Tooltip>
|
|
</Popover>
|
|
</div>
|
|
);
|
|
}
|