Skip to content

Commit e45fb06

Browse files
committed
g2faccount
1 parent 634fdd5 commit e45fb06

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src/components/g2faccount/index.tsx

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { UserOutlined } from "@ant-design/icons";
2+
import {
3+
useQuery,
4+
} from "@tanstack/react-query";
5+
import { Tooltip } from "antd";
6+
import axios from "axios";
7+
8+
export interface IIdgAccountProps {
9+
style?:React.CSSProperties
10+
}
11+
12+
13+
export const IdgAccount: React.FC<IIdgAccountProps> = ({ style }) => {
14+
15+
const {data} = useQuery({
16+
queryKey: ['whoami'],
17+
queryFn: () =>
18+
axios
19+
.get("https://www.geo2france.fr/whoami")
20+
.then((res) => res.data),
21+
})
22+
23+
const username = data?.GeorchestraUser?.username;
24+
const authentified = username != 'anonymousUser' ? true : false ;
25+
26+
return (
27+
<span style={style}>{ authentified ?
28+
<><Tooltip title="Vous êtes authentifié sur la plateforme Géo2France">
29+
<UserOutlined />
30+
</Tooltip>
31+
<a href="https://www.geo2france.fr/portail/user/">{username}</a> </>
32+
: <></>
33+
}
34+
</span>
35+
)
36+
}

src/layout/sider.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ export const AppSider: React.FC = () => {
2121

2222
import React, { CSSProperties } from "react";
2323
import { useMenu,} from "@refinedev/core";
24-
import { Layout, Menu, theme } from "antd";
24+
import { Divider, Layout, Menu, theme } from "antd";
2525
import type { RefineThemedLayoutV2SiderProps } from "@refinedev/antd";
2626
import { NavLink } from "react-router-dom";
27+
import { IdgAccount } from "../components/g2faccount";
2728

2829
/*const drawerButtonStyles: CSSProperties = {
2930
borderTopLeftRadius: 0,
@@ -78,6 +79,8 @@ export const CustomSider: React.FC<RefineThemedLayoutV2SiderProps> = ({}) => {
7879
<Menu items={items} selectedKeys={[selectedKey]} mode="inline" style={{marginTop:"20px"}}>
7980

8081
</Menu>
82+
<Divider />
83+
<IdgAccount style={{paddingLeft: "24px"}}/>
8184
</Layout.Sider>
8285
)
8386
}

0 commit comments

Comments
 (0)