Skip to content

Commit

Permalink
update @pingcap-inc/tidb-community-site-components: update asktug/Sid…
Browse files Browse the repository at this point in the history
…ebar, fetch logon status for SidebarProfile
  • Loading branch information
cw1997 committed Dec 8, 2022
1 parent 0e0864a commit bcb10ec
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react"
import {Space} from "antd";
import useSWR from "swr";

import './Sidebar.less'
import SidebarProfile from "./SidebarProfile";
Expand All @@ -8,13 +9,19 @@ import SidebarEvent from "./SidebarEvent";
import SidebarRanking from "./SidebarRanking";

export interface IProps extends React.HTMLAttributes<HTMLDivElement> {
username: string
}

const Sidebar: React.FC<IProps> = (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 (
<Space className={'asktug-sidebar'} direction={'vertical'} size={12}>
<SidebarProfile username={props.username} />
{data && (
<SidebarProfile username={data.data.username} />
)}
<SidebarBlog />
<SidebarEvent />
<SidebarRanking />
Expand Down

0 comments on commit bcb10ec

Please sign in to comment.