react-code-dataset / wp-calypso /client /landing /stepper /hooks /use-save-hosting-flow-path-step.ts
react-code-dataset / wp-calypso /client /landing /stepper /hooks /use-save-hosting-flow-path-step.ts
Download wp-calypso/client/landing/stepper/hooks/use-save-hosting-flow-path-step.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 871 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/landing/stepper/hooks/use-save-hosting-flow-path-step.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/landing/stepper/hooks/use-save-hosting-flow-path-step.ts
-
curl -L -o use-save-hosting-flow-path-step.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/landing/stepper/hooks/use-save-hosting-flow-path-step.ts
871 Bytes
| import { isAnyHostingFlow } from '@automattic/onboarding'; | |
| import { useEffect } from 'react'; | |
| import { useDispatch, useSelector } from 'calypso/state'; | |
| import { getCurrentUserId, isCurrentUserEmailVerified } from 'calypso/state/current-user/selectors'; | |
| import { savePreference } from 'calypso/state/preferences/actions'; | |
| export function useSaveHostingFlowPathStep( flow: string | null, currentPath: string ) { | |
| const dispatch = useDispatch(); | |
| const userId = useSelector( getCurrentUserId ); | |
| const isEmailVerified = useSelector( isCurrentUserEmailVerified ); | |
| const pathStep = isEmailVerified ? null : currentPath; | |
| useEffect( () => { | |
| if ( ! isEmailVerified && isAnyHostingFlow( flow ) ) { | |
| const prefKey = `hosting-flow-path-step-${ userId }`; | |
| dispatch( savePreference( prefKey, pathStep ) ); | |
| } | |
| }, [ userId, isEmailVerified, pathStep, flow, dispatch ] ); | |
| } | |