diff --git a/web_ui/frontend/app/director/page.tsx b/web_ui/frontend/app/director/page.tsx index 2e65061b9..0295bf25c 100644 --- a/web_ui/frontend/app/director/page.tsx +++ b/web_ui/frontend/app/director/page.tsx @@ -25,7 +25,7 @@ import useSWR from "swr"; import {Server} from "@/components/Main"; import CardList from "@/components/Namespace/CardList"; import DirectorCard, {DirectorCardProps} from "@/components/Namespace/DirectorCard"; -import {Authenticated, getAuthenticated, isLoggedIn} from "@/helpers/login"; +import {getUser} from "@/helpers/login"; const getServers = async () => { @@ -43,18 +43,9 @@ const getServers = async () => { export default function Home() { - const [error, setError] = useState(undefined); - const [authenticated, setAuthenticated] = useState(undefined) - const {data} = useSWR("getServers", getServers) - useEffect(() => { - (async () => { - if(await isLoggedIn()){ - setAuthenticated(getAuthenticated() as Authenticated) - } - })(); - }, []) + const {data: user, error} = useSWR("getUser", getUser) const cacheData = useMemo(() => { return data?.filter((server) => server.type === "Cache") @@ -70,7 +61,7 @@ export default function Home() { Origins {originData ? - Card={DirectorCard} cardProps={{authenticated: authenticated}} data={originData.map(x => {return {server: x}})}/> : + Card={DirectorCard} cardProps={{authenticated: user}} data={originData.map(x => {return {server: x}})}/> : @@ -79,7 +70,7 @@ export default function Home() { Caches {cacheData ? - Card={DirectorCard} cardProps={{authenticated: authenticated}} data={cacheData.map(x => {return {server: x}})}/> : + Card={DirectorCard} cardProps={{authenticated: user}} data={cacheData.map(x => {return {server: x}})}/> : diff --git a/web_ui/frontend/components/Namespace/CardList.tsx b/web_ui/frontend/components/Namespace/CardList.tsx index a3d418ba1..cb75e63fa 100644 --- a/web_ui/frontend/components/Namespace/CardList.tsx +++ b/web_ui/frontend/components/Namespace/CardList.tsx @@ -53,7 +53,7 @@ function CardList({ data, Card, cardProps }: CardListProps) { ...o } as T - return + return })} diff --git a/web_ui/frontend/components/Namespace/DirectorCard.tsx b/web_ui/frontend/components/Namespace/DirectorCard.tsx index da57f3c58..a24039994 100644 --- a/web_ui/frontend/components/Namespace/DirectorCard.tsx +++ b/web_ui/frontend/components/Namespace/DirectorCard.tsx @@ -18,10 +18,11 @@ import {Language} from "@mui/icons-material"; import {NamespaceIcon} from "@/components/Namespace/index"; import useSWR from "swr"; import Link from "next/link"; +import {User} from "@/index"; export interface DirectorCardProps { server: Server - authenticated?: Authenticated + authenticated?: User } export const DirectorCard = ({ server, authenticated } : DirectorCardProps) => {