Download wp-calypso/client/landing/stepper/hooks/use-is-site-admin.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 508 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/landing/stepper/hooks/use-is-site-admin.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/landing/stepper/hooks/use-is-site-admin.ts
-
curl -L -o use-is-site-admin.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/landing/stepper/hooks/use-is-site-admin.ts
508 Bytes
| import { useMemo } from 'react'; | |
| import { useSelector } from 'calypso/state'; | |
| import { canCurrentUser } from 'calypso/state/selectors/can-current-user'; | |
| import { useSite } from './use-site'; | |
| export const useIsSiteAdmin = () => { | |
| const site = useSite(); | |
| const isFetching = ! site; | |
| const isAdmin = useSelector( ( state ) => canCurrentUser( state, site?.ID, 'manage_options' ) ); | |
| return useMemo( | |
| () => ( { | |
| isFetching, | |
| isAdmin: isFetching ? null : isAdmin, | |
| } ), | |
| [ isAdmin, isFetching ] | |
| ); | |
| }; | |