react-code-dataset / wp-calypso /client /sites /deployments /components /installations-dropdown /use-save-github-credentials-mutation.ts
react-code-dataset / wp-calypso /client /sites /deployments /components /installations-dropdown /use-save-github-credentials-mutation.ts
Download wp-calypso/client/sites/deployments/components/installations-dropdown/use-save-github-credentials-mutation.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 703 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/sites/deployments/components/installations-dropdown/use-save-github-credentials-mutation.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/sites/deployments/components/installations-dropdown/use-save-github-credentials-mutation.ts
-
curl -L -o use-save-github-credentials-mutation.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/sites/deployments/components/installations-dropdown/use-save-github-credentials-mutation.ts
703 Bytes
| import { useMutation } from '@tanstack/react-query'; | |
| import { useCallback } from 'react'; | |
| import wp from 'calypso/lib/wp'; | |
| interface MutationVariables { | |
| accessToken: string; | |
| } | |
| export const useSaveGitHubCredentialsMutation = () => { | |
| const mutation = useMutation( { | |
| mutationFn: async ( { accessToken }: MutationVariables ) => | |
| wp.req.post( | |
| { | |
| path: '/hosting/github/accounts', | |
| apiNamespace: 'wpcom/v2', | |
| }, | |
| { | |
| access_token: accessToken, | |
| } | |
| ), | |
| } ); | |
| const { mutateAsync, isPending } = mutation; | |
| const saveGitHubCredentials = useCallback( | |
| ( args: MutationVariables ) => mutateAsync( args ), | |
| [ mutateAsync ] | |
| ); | |
| return { saveGitHubCredentials, isPending }; | |
| }; | |