FactuGES_ERP/modules/auth/src/web/services/me-service.ts

19 lines
437 B
TypeScript
Raw Normal View History

2025-08-23 11:57:48 +00:00
import { useDataSource } from "@erp/core/hooks";
2025-05-29 11:15:28 +00:00
import { useQuery } from "@tanstack/react-query";
2025-05-29 11:15:28 +00:00
import { useAuth } from "../hooks";
import type { User } from "./types";
2025-05-29 11:15:28 +00:00
export const useCurrentUser = () => {
const { token } = useAuth();
const client = useDataSource();
return useQuery({
queryKey: ["me"],
queryFn: () => client.getOne<User>("/auth", "me"),
enabled: !!token,
staleTime: 1000 * 60 * 5,
});
};