The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/client/hooks/useUserInfoQuery.ts

18 lines
747 B

import type { UsersInfoParamsGet } from '@rocket.chat/rest-typings';
import { useEndpoint } from '@rocket.chat/ui-contexts';
import { keepPreviousData, useQuery } from '@tanstack/react-query';
type UserInfoQueryOptions = {
enabled?: boolean;
placeholderData?: <T>(previousData: T | undefined) => T | undefined;
};
// a hook using tanstack useQuery and useEndpoint that fetches user information from the `users.info` endpoint
export const useUserInfoQuery = (params: UsersInfoParamsGet, options: UserInfoQueryOptions = { placeholderData: keepPreviousData }) => {
const getUserInfo = useEndpoint('GET', '/v1/users.info');
return useQuery({
queryKey: ['users.info', params],
queryFn: () => getUserInfo({ ...params }),
...options,
});
};