import React, { useState } from 'react' import { __, sprintf } from '@wordpress/i18n' import { WithRestAPIContext } from '../../../hooks/useRestAPI' import { useSnippetView } from '../../../hooks/useSnippetView' import { updateQueryParams } from '../../../utils/urls' import { ScreenMetaSlot } from '../../common/ScreenMetaSlot' import { SubnavTabs, getTabFromQuery } from '../../common/SubnavTabs' import { WithCloudSnippetDownloadsContext } from '../../common/cloud/WithCloudSnippetDownloadsContext' import { UpsellPage } from '../../common/UpsellDialog' import { WithCloudSearchContext, useCloudSearch } from './WithCloudSearchContext' import { CloudSearch } from './CloudSearch' import type { SubnavTab} from '../../common/SubnavTabs' const TAB_QUERY_PARAM = 'tab' const TABS: SubnavTab[] = [ { name: 'snippets', label: __('Snippets', 'code-snippets') }, { name: 'bundles', label: __('Bundles', 'code-snippets'), pro: true } ] const CommunityCloudInner = () => { const [currentTab, setCurrentTab] = useState(() => getTabFromQuery(TABS, TAB_QUERY_PARAM)) const { snippetView, setSnippetView } = useSnippetView() const { searchResults } = useCloudSearch() const TabContent = () => { switch (currentTab.name) { case 'snippets': return case 'bundles': return default: return null } } return ( <> 'snippets' === tab.name ? searchResults?.totalItems : undefined} currentTab={currentTab} setCurrentTab={tab => { updateQueryParams({ [TAB_QUERY_PARAM]: tab.name }) setCurrentTab(tab) }} />

{ // translators: %s: label of the currently selected community cloud tab. sprintf(__('Community Cloud: %s', 'code-snippets'), currentTab.label)}


{__('Search the community cloud and download user-shared snippets directly to your site.', 'code-snippets')}

) } export const CommunityCloud = () =>