import { Icon } from '@wordpress/components' import { safeHTML } from '@wordpress/dom' import { useState, useRef } from '@wordpress/element' import { __, sprintf } from '@wordpress/i18n' import { General } from '@library/api/General' import { Plugins } from '@library/api/Plugins' import { download2, brandLogo } from '@library/components/icons' import { useGlobalStore } from '@library/state/GlobalState' import { useUserStore } from '@library/state/User' import { SplitModal } from './SplitModal' export const InstallStandaloneModal = () => { const [text, setText] = useState(__('Install Extendify', 'extendify')) const [success, setSuccess] = useState(false) const [disabled, setDisabled] = useState(false) const initialFocus = useRef(null) const markNoticeSeen = useUserStore((state) => state.markNoticeSeen) const giveFreebieImports = useUserStore((state) => state.giveFreebieImports) const removeAllModals = useGlobalStore((state) => state.removeAllModals) const installAndActivate = () => { setText(__('Installing...', 'extendify')) setDisabled(true) Promise.all([ General.ping('stln-modal-install'), Plugins.installAndActivate(['extendify']), new Promise((resolve) => setTimeout(resolve, 1000)), ]) .then(async () => { setText(__('Success! Reloading...', 'extendify')) setSuccess(true) giveFreebieImports(10) await General.ping('stln-modal-success') window.location.reload() }) .catch(async (error) => { console.error(error) setText(__('Error. See console.', 'extendify')) await General.ping('stln-modal-fail') }) } const dismiss = async () => { removeAllModals() markNoticeSeen('standalone', 'modalNotices') await General.ping('stln-modal-x') } return (
{brandLogo}

{__( 'Get the brand new Extendify plugin today!', 'extendify', )}

', '', ), ), }} />

{__('Upgrade
) }