react-code-dataset / wp-calypso /packages /help-center /src /hooks /use-reset-support-interaction.ts
react-code-dataset / wp-calypso /packages /help-center /src /hooks /use-reset-support-interaction.ts
Download wp-calypso/packages/help-center/src/hooks/use-reset-support-interaction.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/help-center/src/hooks/use-reset-support-interaction.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/packages/help-center/src/hooks/use-reset-support-interaction.ts
-
curl -L -o use-reset-support-interaction.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/help-center/src/hooks/use-reset-support-interaction.ts
1.09 kB
| import { HelpCenterSelect } from '@automattic/data-stores'; | |
| import { HELP_CENTER_STORE } from '@automattic/help-center/src/stores'; | |
| import { useManageSupportInteraction } from '@automattic/odie-client/src/data'; | |
| import { useQueryClient } from '@tanstack/react-query'; | |
| import { useSelect } from '@wordpress/data'; | |
| export const useResetSupportInteraction = () => { | |
| const { currentSupportInteraction } = useSelect( ( select ) => { | |
| const store = select( HELP_CENTER_STORE ) as HelpCenterSelect; | |
| return { | |
| currentSupportInteraction: store.getCurrentSupportInteraction(), | |
| }; | |
| }, [] ); | |
| const { startNewInteraction, resolveInteraction } = useManageSupportInteraction(); | |
| const queryClient = useQueryClient(); | |
| return async () => { | |
| if ( currentSupportInteraction ) { | |
| resolveInteraction( { interactionId: currentSupportInteraction.uuid } ); | |
| await queryClient.invalidateQueries( { | |
| queryKey: [ 'support-interactions', 'get-interactions' ], | |
| } ); | |
| } | |
| return await startNewInteraction( { | |
| event_source: 'help-center', | |
| event_external_id: crypto.randomUUID(), | |
| } ); | |
| }; | |
| }; | |