import React, { useState } from 'react'
import { ExternalLink, Modal } from '@wordpress/components'
import { __, _n, sprintf } from '@wordpress/i18n'
import type { Dispatch, SetStateAction } from 'react'
export interface UpgradeDialogProps {
isOpen: boolean
setIsOpen: Dispatch>
}
const SMALL_PLAN_SITES = '2'
const MID_PLAN_SITES = '6'
const LARGE_PLAN_SITES = '200'
const upgradePlanCosts: Record = {
[SMALL_PLAN_SITES]: 39,
[MID_PLAN_SITES]: 69,
[LARGE_PLAN_SITES]: 119
}
const UpgradeDialogPlans = () => {
const [currentPlan, setCurrentPlan] = useState(MID_PLAN_SITES)
return (
<>
{__('How many websites do you plan to use Code Snippets on?', 'code-snippets')}
{__('We offer three distinct plans, each tailored to meet your needs.', 'code-snippets')}
{Object.keys(upgradePlanCosts).map(planSites =>
setCurrentPlan(planSites)}
/>
{' '}
{sprintf(_n('%d site', '%d sites', Number(planSites), 'code-snippets'), planSites)}
)}
{sprintf(__('$%s per year', 'code-snippets'), upgradePlanCosts[currentPlan])}
{__('Upgrade Now', 'code-snippets')}
>
)
}
interface UpgradeInfoProps {
nextTab: VoidFunction
}
const UpgradeInfo: React.FC = ({ nextTab }) =>
<>
{__('You are using the free version of Code Snippets.', 'code-snippets')}{' '}
{__('Upgrade to Code Snippets Pro to unleash its full potential:', 'code-snippets')}
{__('CSS stylesheet snippets: ', 'code-snippets')}
{__('Craft impeccable websites with advanced CSS snippets.', 'code-snippets')}
{__('JavaScript snippets: ', 'code-snippets')}
{__('Enhance user interaction with the power of JavaScript.', 'code-snippets')}
{__('Specialized Elementor widgets: ', 'code-snippets')}
{__('Easily customize your site with Elementor widgets.', 'code-snippets')}
{__('Integration with block editor: ', 'code-snippets')}
{__('Seamlessly incorporate your snippets within the block editor.', 'code-snippets')}
{__('WP-CLI snippet commands: ', 'code-snippets')}
{__('Access and control your snippets directly from the command line.', 'code-snippets')}
{__('Premium support: ', 'code-snippets')}
{__("Direct access to our team. We're happy to help!", 'code-snippets')}
{__('…and so much more!', 'code-snippets')}
{__('Learn More', 'code-snippets')}
{__('See Plans', 'code-snippets')}
>
export const UpgradeDialog: React.FC = ({ isOpen, setIsOpen }) => {
const [currentTab, setCurrentTab] = useState(0)
return isOpen
? {
setIsOpen(false)
setCurrentTab(0)
}}
>
{__('Code Snippets Pro', 'code-snippets')}
{0 === currentTab
? setCurrentTab(1)} />
:
}
: null
}