Download wp-calypso/client/data/import-flow/use-selected-plan-upgrade.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 801 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/data/import-flow/use-selected-plan-upgrade.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/data/import-flow/use-selected-plan-upgrade.ts
-
curl -L -o use-selected-plan-upgrade.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/data/import-flow/use-selected-plan-upgrade.ts
801 Bytes
| import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query'; | |
| const DEFAULT_PLAN = 'business'; | |
| const SELECTED_PLAN_QUERY_KEY = 'selected-plan-for-upgrade'; | |
| /** | |
| * Use this query/mutation to set/get the chosen plan | |
| * from the pre-migration step on import flows | |
| */ | |
| export const useSelectedPlanUpgradeQuery = () => { | |
| const queryClient = useQueryClient(); | |
| return useQuery( { | |
| queryKey: [ SELECTED_PLAN_QUERY_KEY ], | |
| queryFn: (): string => { | |
| return queryClient.getQueryData( [ SELECTED_PLAN_QUERY_KEY ] ) || DEFAULT_PLAN; | |
| }, | |
| } ); | |
| }; | |
| export const useSelectedPlanUpgradeMutation = () => { | |
| const queryClient = useQueryClient(); | |
| return useMutation( { | |
| mutationFn: async ( plan: string ) => { | |
| queryClient.setQueryData( [ SELECTED_PLAN_QUERY_KEY ], plan ); | |
| }, | |
| } ); | |
| }; | |