diff --git a/src/components/g2faccount/index.tsx b/src/components/g2faccount/index.tsx new file mode 100644 index 0000000..2b43614 --- /dev/null +++ b/src/components/g2faccount/index.tsx @@ -0,0 +1,36 @@ +import { UserOutlined } from "@ant-design/icons"; +import { + useQuery, + } from "@tanstack/react-query"; +import { Tooltip } from "antd"; +import axios from "axios"; + +export interface IIdgAccountProps { + style?:React.CSSProperties +} + + +export const IdgAccount: React.FC = ({ style }) => { + + const {data} = useQuery({ + queryKey: ['whoami'], + queryFn: () => + axios + .get("https://www.geo2france.fr/whoami") + .then((res) => res.data), + }) + + const username = data?.GeorchestraUser?.username; + const authentified = username != 'anonymousUser' ? true : false ; + + return ( + { authentified ? + <> + + + {username} + : <> + } + + ) +} \ No newline at end of file diff --git a/src/layout/sider.tsx b/src/layout/sider.tsx index aebb4bf..ac9aad3 100644 --- a/src/layout/sider.tsx +++ b/src/layout/sider.tsx @@ -21,9 +21,10 @@ export const AppSider: React.FC = () => { import React, { CSSProperties } from "react"; import { useMenu,} from "@refinedev/core"; -import { Layout, Menu, theme } from "antd"; +import { Divider, Layout, Menu, theme } from "antd"; import type { RefineThemedLayoutV2SiderProps } from "@refinedev/antd"; import { NavLink } from "react-router-dom"; +import { IdgAccount } from "../components/g2faccount"; /*const drawerButtonStyles: CSSProperties = { borderTopLeftRadius: 0, @@ -78,6 +79,8 @@ export const CustomSider: React.FC = ({}) => { + + ) } \ No newline at end of file