mirror of
https://github.com/khairul169/garage-webui.git
synced 2025-04-28 06:49:32 +07:00
21 lines
436 B
TypeScript
21 lines
436 B
TypeScript
import api from "@/lib/api";
|
|
import { useQuery } from "@tanstack/react-query";
|
|
|
|
type AuthResponse = {
|
|
enabled: boolean;
|
|
authenticated: boolean;
|
|
};
|
|
|
|
export const useAuth = () => {
|
|
const { data, isLoading } = useQuery({
|
|
queryKey: ["auth"],
|
|
queryFn: () => api.get<AuthResponse>("/auth/status"),
|
|
retry: false,
|
|
});
|
|
return {
|
|
isLoading,
|
|
isEnabled: data?.enabled,
|
|
isAuthenticated: data?.authenticated,
|
|
};
|
|
};
|