From bcb10ecf775c7d197e6871c78c50e2f542ad6323 Mon Sep 17 00:00:00 2001 From: Chang Wei Date: Thu, 8 Dec 2022 15:28:21 +0800 Subject: [PATCH] update @pingcap-inc/tidb-community-site-components: update asktug/Sidebar, fetch logon status for SidebarProfile --- .../src/components/asktug/home/Sidebar/Sidebar.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/site-components/src/components/asktug/home/Sidebar/Sidebar.tsx b/packages/site-components/src/components/asktug/home/Sidebar/Sidebar.tsx index 401064c1..08c28c7e 100644 --- a/packages/site-components/src/components/asktug/home/Sidebar/Sidebar.tsx +++ b/packages/site-components/src/components/asktug/home/Sidebar/Sidebar.tsx @@ -1,5 +1,6 @@ import React from "react" import {Space} from "antd"; +import useSWR from "swr"; import './Sidebar.less' import SidebarProfile from "./SidebarProfile"; @@ -8,13 +9,19 @@ import SidebarEvent from "./SidebarEvent"; import SidebarRanking from "./SidebarRanking"; export interface IProps extends React.HTMLAttributes { - username: string } const Sidebar: React.FC = (props) => { + const {data, error, isValidating} = useSWR('/_/sso/api/asktug-me', async () => { + const data = await fetch('/_/sso/api/asktug-me') + return data.json() + }) + if (error) console.error(error) return ( - + {data && ( + + )}