diff --git a/apps/meteor/client/hooks/useLicense.ts b/apps/meteor/client/hooks/useLicense.ts index 8ba594c5b5d3c..ec07e1702bed0 100644 --- a/apps/meteor/client/hooks/useLicense.ts +++ b/apps/meteor/client/hooks/useLicense.ts @@ -1,13 +1,15 @@ +import type { Serialized } from '@rocket.chat/core-typings'; import { useDebouncedCallback } from '@rocket.chat/fuselage-hooks'; import type { OperationResult } from '@rocket.chat/rest-typings'; -import { useEndpoint, usePermission, useSingleStream } from '@rocket.chat/ui-contexts'; +import { useEndpoint, useSingleStream } from '@rocket.chat/ui-contexts'; import type { UseQueryResult } from '@tanstack/react-query'; import { useQuery, useQueryClient } from '@tanstack/react-query'; import { useEffect } from 'react'; -export const useLicense = (): UseQueryResult> => { +type LicenseDataType = Awaited>['license']; + +export const useLicense = (): UseQueryResult> => { const getLicenses = useEndpoint('GET', '/v1/licenses.info'); - const canViewLicense = usePermission('view-privileged-setting'); const queryClient = useQueryClient(); @@ -23,17 +25,9 @@ export const useLicense = (): UseQueryResult notify('license', () => invalidate()), [notify, invalidate]); - return useQuery( - ['licenses', 'getLicenses'], - () => { - if (!canViewLicense) { - throw new Error('unauthorized api call'); - } - return getLicenses({}); - }, - { - staleTime: Infinity, - keepPreviousData: true, - }, - ); + return useQuery(['licenses', 'getLicenses'], () => getLicenses({}), { + staleTime: Infinity, + keepPreviousData: true, + select: (data) => data.license, + }); }; diff --git a/apps/meteor/client/views/admin/info/LicenseCard.tsx b/apps/meteor/client/views/admin/info/LicenseCard.tsx index 8aab636f47202..195121932e800 100644 --- a/apps/meteor/client/views/admin/info/LicenseCard.tsx +++ b/apps/meteor/client/views/admin/info/LicenseCard.tsx @@ -56,7 +56,7 @@ const LicenseCard = (): ReactElement => { ); } - const { activeModules } = request.data.license; + const { activeModules } = request.data; const hasEngagement = activeModules.includes('engagement-dashboard'); const hasOmnichannel = activeModules.includes('livechat-enterprise');