Download wp-calypso/client/data/ecommerce/use-add-ecommerce-trial-mutation.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 996 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/data/ecommerce/use-add-ecommerce-trial-mutation.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/data/ecommerce/use-add-ecommerce-trial-mutation.ts
-
curl -L -o use-add-ecommerce-trial-mutation.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/data/ecommerce/use-add-ecommerce-trial-mutation.ts
996 Bytes
| import { useMutation, UseMutationOptions } from '@tanstack/react-query'; | |
| import { useCallback } from 'react'; | |
| import wp from 'calypso/lib/wp'; | |
| interface Variables { | |
| siteId: number; | |
| } | |
| export default function useAddEcommerceTrialMutation( | |
| partnerBundle: string | null, | |
| options: UseMutationOptions< unknown, unknown, Variables > = {} | |
| ) { | |
| const partnerData = partnerBundle | |
| ? { | |
| woocommerce_onboarding_profile: { | |
| partner: partnerBundle, | |
| }, | |
| } | |
| : undefined; | |
| const mutation = useMutation( { | |
| mutationFn: async ( { siteId }: Variables ) => { | |
| await wp.req.post( | |
| `/sites/${ siteId }/ecommerce-trial/add/ecommerce-trial-bundle-monthly`, | |
| { | |
| apiVersion: '1.1', | |
| }, | |
| { | |
| is_entrepreneur_signup: 1, | |
| wpcom_woocommerce_onboarding: partnerData, | |
| } | |
| ); | |
| }, | |
| ...options, | |
| } ); | |
| const { mutate } = mutation; | |
| const addEcommerceTrial = useCallback( ( siteId: number ) => mutate( { siteId } ), [ mutate ] ); | |
| return { addEcommerceTrial, ...mutation }; | |
| } | |