react-code-dataset / wp-calypso /client /data /jetpack-licensing /use-user-license-by-subscription-query.ts
react-code-dataset / wp-calypso /client /data /jetpack-licensing /use-user-license-by-subscription-query.ts
Download wp-calypso/client/data/jetpack-licensing/use-user-license-by-subscription-query.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 769 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/data/jetpack-licensing/use-user-license-by-subscription-query.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/data/jetpack-licensing/use-user-license-by-subscription-query.ts
-
curl -L -o use-user-license-by-subscription-query.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/data/jetpack-licensing/use-user-license-by-subscription-query.ts
769 Bytes
| import { useQuery, UseQueryResult } from '@tanstack/react-query'; | |
| import wpcom from 'calypso/lib/wp'; | |
| import { mapSingleLicenseApiToLicense } from './utils'; | |
| import type { UserLicenseApi, UserLicense } from './types'; | |
| const useUserLicenseBySubscriptionQuery = ( | |
| subscriptionId: number | |
| ): UseQueryResult< UserLicense > => { | |
| const queryKey = [ 'user-license', subscriptionId ]; | |
| return useQuery< UserLicenseApi, Error, UserLicense >( { | |
| queryKey, | |
| queryFn: async () => | |
| wpcom.req.get( { | |
| path: `/jetpack-licensing/user/subscription/${ subscriptionId }`, | |
| apiNamespace: 'wpcom/v2', | |
| } ), | |
| select: mapSingleLicenseApiToLicense, | |
| refetchIntervalInBackground: false, | |
| refetchOnWindowFocus: false, | |
| } ); | |
| }; | |
| export default useUserLicenseBySubscriptionQuery; | |