Download wp-calypso/packages/help-center/src/contexts/HelpCenterContext.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/help-center/src/contexts/HelpCenterContext.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/packages/help-center/src/contexts/HelpCenterContext.tsx
-
curl -L -o HelpCenterContext.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/help-center/src/contexts/HelpCenterContext.tsx
1.42 kB
| import { useContext, createContext } from '@wordpress/element'; | |
| import type { CurrentUser, HelpCenterSite } from '@automattic/data-stores'; | |
| export type HelpCenterRequiredInformation = { | |
| locale: string; | |
| sectionName: string; | |
| currentUser: CurrentUser; | |
| // some users have no sites at all. | |
| site: HelpCenterSite | null; | |
| hasPurchases: boolean; | |
| primarySiteId: number; | |
| googleMailServiceFamily: string; | |
| onboardingUrl: string; | |
| }; | |
| const defaultContext: HelpCenterRequiredInformation = { | |
| locale: '', | |
| sectionName: '', | |
| currentUser: { | |
| ID: 0, | |
| display_name: '', | |
| username: '', | |
| email: '', | |
| language: '', | |
| localeSlug: '', | |
| locale_variant: '', | |
| localeVariant: '', | |
| site_count: 0, | |
| }, | |
| site: null, | |
| hasPurchases: false, | |
| primarySiteId: 0, | |
| googleMailServiceFamily: '', | |
| onboardingUrl: '', | |
| }; | |
| const HelpCenterRequiredContext = createContext< HelpCenterRequiredInformation >( defaultContext ); | |
| export const HelpCenterRequiredContextProvider: React.FC< { | |
| children: JSX.Element; | |
| value: Partial< HelpCenterRequiredInformation > & | |
| Pick< HelpCenterRequiredInformation, 'currentUser' | 'sectionName' >; | |
| } > = function ( { children, value } ) { | |
| return ( | |
| <HelpCenterRequiredContext.Provider | |
| value={ { | |
| ...Object.assign( defaultContext, value ), | |
| } } | |
| > | |
| { children } | |
| </HelpCenterRequiredContext.Provider> | |
| ); | |
| }; | |
| export function useHelpCenterContext() { | |
| return useContext( HelpCenterRequiredContext ); | |
| } | |