mirror of
https://github.com/Nezumi-2711/react-training.git
synced 2026-09-23 04:19:48 +00:00
21 lines
470 B
TypeScript
21 lines
470 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
|
|
// Services
|
|
import { getCurrentAccount } from '@service/authenticationService';
|
|
|
|
const useAccount = () => {
|
|
let isAuthenticated: boolean = false;
|
|
const { data: account, isPending } = useQuery({
|
|
queryKey: ['account'],
|
|
queryFn: getCurrentAccount,
|
|
});
|
|
|
|
if (account) {
|
|
isAuthenticated = account.role === 'authenticated';
|
|
}
|
|
|
|
return { isPending, account, isAuthenticated };
|
|
};
|
|
|
|
export { useAccount };
|