Skip to content

Commit

Permalink
g2faccount
Browse files Browse the repository at this point in the history
  • Loading branch information
jbdesbas committed Apr 11, 2024
1 parent 634fdd5 commit e45fb06
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
36 changes: 36 additions & 0 deletions src/components/g2faccount/index.tsx
Original file line number Diff line number Diff line change
@@ -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<IIdgAccountProps> = ({ 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 (
<span style={style}>{ authentified ?
<><Tooltip title="Vous êtes authentifié sur la plateforme Géo2France">
<UserOutlined />
</Tooltip>
<a href="https://www.geo2france.fr/portail/user/">{username}</a> </>
: <></>
}
</span>
)
}
5 changes: 4 additions & 1 deletion src/layout/sider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -78,6 +79,8 @@ export const CustomSider: React.FC<RefineThemedLayoutV2SiderProps> = ({}) => {
<Menu items={items} selectedKeys={[selectedKey]} mode="inline" style={{marginTop:"20px"}}>

</Menu>
<Divider />
<IdgAccount style={{paddingLeft: "24px"}}/>
</Layout.Sider>
)
}

0 comments on commit e45fb06

Please sign in to comment.