SidebarSingle.js (2877B)
1 import { __ } from '@wordpress/i18n' 2 import { useGlobalStore } from '../../../state/GlobalState' 3 import { useTemplatesStore } from '../../../state/Templates' 4 import { useUserStore } from '../../../state/User' 5 import TaxonomyList from '../../../components/TaxonomyList' 6 7 export default function SidebarSingle({ template }) { 8 const setActiveTemplate = useTemplatesStore(state => state.setActive) 9 const { 10 tax_categories: categories, 11 required_plugins: requiredPlugins, 12 tax_style: styles, 13 tax_pattern_types: types, 14 } = template.fields 15 const apiKey = useUserStore(state => state.apiKey) 16 17 const goBack = () => { 18 useGlobalStore.setState({ currentPage: 'main' }) 19 setActiveTemplate({}) 20 } 21 22 return <div className="flex flex-col items-start justify-start"> 23 {!apiKey.length && <div className="h-full flex sm:hidden w-full p-4 justify-between border items-center border-gray-300 bg-extendify-lightest"> 24 <a 25 className="button-extendify-main" 26 target="_blank" 27 href={`https://extendify.com/pricing?utm_source=${window.extendifySdkData.source}&utm_medium=library&utm_campaign=sign_up&utm_content=main`} 28 rel="noreferrer"> 29 {__('Sign up today to get unlimited access', 'extendify-sdk')} 30 </a> 31 <button 32 className="components-button" 33 onClick={() => useGlobalStore.setState({ 34 currentPage: 'login', 35 })}> 36 {__('Log in', 'extendify-sdk')} 37 </button> 38 </div>} 39 <div className="p-6 sm:p-0"> 40 <button 41 type="button" 42 className="cursor-pointer text-black bg-transparent font-medium flex items-center p-3 transform -translate-x-3 button-focus" 43 onClick={goBack}> 44 <svg className="fill-current" width="8" height="12" viewBox="0 0 8 12" xmlns="http://www.w3.org/2000/svg"> 45 <path d="M6.70998 9.88047L2.82998 6.00047L6.70998 2.12047C7.09998 1.73047 7.09998 1.10047 6.70998 0.710469C6.31998 0.320469 5.68998 0.320469 5.29998 0.710469L0.70998 5.30047C0.31998 5.69047 0.31998 6.32047 0.70998 6.71047L5.29998 11.3005C5.68998 11.6905 6.31998 11.6905 6.70998 11.3005C7.08998 10.9105 7.09998 10.2705 6.70998 9.88047Z"/> 46 </svg> 47 <span className="ml-4">{__('Go back', 'extendify-sdk')}</span> 48 </button> 49 </div> 50 {/* Hides on mobile and is repeated at the bottom of the single page too */} 51 <div className="text-left pt-14 divide-y w-full hidden sm:block"> 52 <TaxonomyList 53 categories={categories} 54 types={types} 55 requiredPlugins={requiredPlugins} 56 styles={styles}/> 57 </div> 58 </div> 59 }