Download wp-calypso/client/data/help/use-help-search-query-v1.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 810 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/data/help/use-help-search-query-v1.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/data/help/use-help-search-query-v1.ts
-
curl -L -o use-help-search-query-v1.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/data/help/use-help-search-query-v1.ts
810 Bytes
| // Older version of the hook, used in the HelpSearch component. | |
| import { useLocale } from '@automattic/i18n-utils'; | |
| import { useQuery } from '@tanstack/react-query'; | |
| import wpcomRequest from 'wpcom-proxy-request'; | |
| import type { LinksForSection } from '@automattic/data-stores'; | |
| export const useHelpSearchQuery = ( | |
| search: string, | |
| queryOptions: Record< string, unknown > = {} | |
| ) => { | |
| const locale = useLocale(); | |
| const params = new URLSearchParams( { | |
| include_post_id: '1', | |
| locale, | |
| } ); | |
| if ( search ) { | |
| params.append( 'query', search ); | |
| } | |
| return useQuery< { wordpress_support_links: LinksForSection[] } >( { | |
| queryKey: [ 'help', search ], | |
| queryFn: () => | |
| wpcomRequest( { path: '/help/search', query: params.toString(), apiVersion: '1.1' } ), | |
| enabled: !! search, | |
| ...queryOptions, | |
| } ); | |
| }; | |