Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use react query for getting version #100

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions ui/src/app/nav.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client"

import { SetStateAction, Dispatch, useState, useEffect } from "react"
import { QueryClient, QueryClientProvider } from "react-query";
import { QueryClient, QueryClientProvider, useQuery, useQueryClient } from "react-query";
import Image from "next/image";
import { Aside, AsideContext } from "./aside";
import { AccountTab } from "./nav_account"
Expand All @@ -13,19 +13,18 @@ import { getStatus } from "./queries"
import { ChangePasswordModalData, ChangePasswordModal, ChangePasswordModalContext } from "./users/components";

export function SideBar({ activePath, sidebarVisible, setSidebarVisible }: { activePath: string, sidebarVisible: boolean, setSidebarVisible: Dispatch<SetStateAction<boolean>> }) {
const [status, setStatus] = useState<{ version: string } | null>(null);
const auth = useAuth()

useEffect(() => {
const fetchStatus = async () => {
const statusData = await getStatus();
setStatus(statusData);
};
fetchStatus();
}, []);
const statusQuery = useQuery({
queryFn: getStatus,
staleTime: Infinity,
cacheTime: Infinity,
refetchOnWindowFocus: false,
refetchOnMount: false,
refetchOnReconnect: false,
})

return (
<header className={sidebarVisible ? "l-navigation" : "l-navigation is-collapsed"}>
<header className={sidebarVisible ? "l-navigation" : "l-navigation is-collapsed"} >
<div className="l-navigation__drawer">
<div className="p-panel is-dark">
<div className="p-panel__header is-sticky">
Expand Down Expand Up @@ -66,7 +65,7 @@ export function SideBar({ activePath, sidebarVisible, setSidebarVisible }: { act
<ul className="p-side-navigation__list" style={{ bottom: 0, position: "absolute", width: "100%" }}>
<li className="p-side-navigation__item">
<span className="p-side-navigation__text">
Version {status?.version}
Version {statusQuery.data?.version}
</span>
</li>
</ul>
Expand Down
Loading