2023-09-26 11:35:52 +03:00
|
|
|
import { useQuery } from "@tanstack/react-query";
|
|
|
|
|
2024-03-21 22:10:54 +03:00
|
|
|
import { USER_DATA_KEY, USER_IDENTITY_DATA_KEY } from "../api/user/config";
|
2023-09-26 11:35:52 +03:00
|
|
|
import { useUserApi } from "../api/user/useUserApi";
|
2024-03-21 22:35:49 +03:00
|
|
|
import { UserIdentity } from "../api/user/user";
|
|
|
|
import { UserStats } from "../types/User";
|
|
|
|
|
|
|
|
type UseUserDataProps = {
|
|
|
|
userData: UserStats | undefined;
|
|
|
|
userIdentityData: UserIdentity | undefined;
|
|
|
|
};
|
2023-09-26 11:35:52 +03:00
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
2024-03-21 22:35:49 +03:00
|
|
|
export const useUserData = (): UseUserDataProps => {
|
2023-09-26 11:35:52 +03:00
|
|
|
const { getUser } = useUserApi();
|
2024-03-21 22:10:54 +03:00
|
|
|
const { getUserIdentity } = useUserApi();
|
2023-09-26 11:35:52 +03:00
|
|
|
|
|
|
|
const { data: userData } = useQuery({
|
|
|
|
queryKey: [USER_DATA_KEY],
|
|
|
|
queryFn: getUser,
|
|
|
|
});
|
|
|
|
|
2024-03-21 22:10:54 +03:00
|
|
|
const { data: userIdentityData } = useQuery({
|
|
|
|
queryKey: [USER_IDENTITY_DATA_KEY],
|
|
|
|
queryFn: getUserIdentity,
|
|
|
|
});
|
|
|
|
|
2023-09-26 11:35:52 +03:00
|
|
|
return {
|
|
|
|
userData,
|
2024-03-21 22:10:54 +03:00
|
|
|
userIdentityData,
|
2023-09-26 11:35:52 +03:00
|
|
|
};
|
|
|
|
};
|