react-code-dataset / wp-calypso /packages /data-stores /src /reader /queries /use-site-subscription-details-query.ts
react-code-dataset / wp-calypso /packages /data-stores /src /reader /queries /use-site-subscription-details-query.ts
Download wp-calypso/packages/data-stores/src/reader/queries/use-site-subscription-details-query.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 930 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/data-stores/src/reader/queries/use-site-subscription-details-query.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/packages/data-stores/src/reader/queries/use-site-subscription-details-query.ts
-
curl -L -o use-site-subscription-details-query.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/data-stores/src/reader/queries/use-site-subscription-details-query.ts
930 Bytes
| import { useQuery } from '@tanstack/react-query'; | |
| import { buildQueryKey, callApi } from '../helpers'; | |
| import { useIsLoggedIn, useIsQueryEnabled } from '../hooks'; | |
| import type { SiteSubscriptionDetailsResponse } from '../types'; | |
| const useSiteSubscriptionDetailsQuery = ( blogId = '', subscriptionId = '' ) => { | |
| const { id, isLoggedIn } = useIsLoggedIn(); | |
| const enabled = useIsQueryEnabled(); | |
| return useQuery( { | |
| queryKey: buildQueryKey( | |
| [ 'read', 'site-subscription-details', blogId, subscriptionId ], | |
| isLoggedIn, | |
| id | |
| ), | |
| queryFn: async () => { | |
| return callApi< SiteSubscriptionDetailsResponse< string > >( { | |
| path: blogId | |
| ? '/read/sites/' + blogId + '/subscription-details' | |
| : '/read/subscriptions/' + subscriptionId, | |
| isLoggedIn, | |
| apiNamespace: 'wpcom/v2', | |
| apiVersion: '2', | |
| } ); | |
| }, | |
| enabled, | |
| refetchOnWindowFocus: false, | |
| } ); | |
| }; | |
| export default useSiteSubscriptionDetailsQuery; | |