From d235d74e0e1c8224351f9e5ac3f528d38b4e7c34 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Thu, 29 Aug 2024 15:01:10 -0400 Subject: [PATCH] use the NewfoldRuntime.comingSoon api and add some inline styles --- src/components/Icons/index.js | 1 - src/components/Icons/launch.jsx | 12 --------- src/components/Modal.jsx | 45 +++++++++++++++++++++++---------- src/utils/api/comingSoon.js | 16 ------------ src/utils/api/resolve.js | 14 ---------- 5 files changed, 31 insertions(+), 57 deletions(-) delete mode 100644 src/components/Icons/index.js delete mode 100644 src/components/Icons/launch.jsx delete mode 100644 src/utils/api/comingSoon.js delete mode 100644 src/utils/api/resolve.js diff --git a/src/components/Icons/index.js b/src/components/Icons/index.js deleted file mode 100644 index 4228a6a..0000000 --- a/src/components/Icons/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default as launch } from './launch'; diff --git a/src/components/Icons/launch.jsx b/src/components/Icons/launch.jsx deleted file mode 100644 index 29b08e7..0000000 --- a/src/components/Icons/launch.jsx +++ /dev/null @@ -1,12 +0,0 @@ -/** - * WordPress dependencies - */ -import { Path, SVG } from '@wordpress/primitives'; - -const launch = ( - - - -); - -export default launch; diff --git a/src/components/Modal.jsx b/src/components/Modal.jsx index 7b9415f..fa0d329 100644 --- a/src/components/Modal.jsx +++ b/src/components/Modal.jsx @@ -13,23 +13,20 @@ import { __ } from '@wordpress/i18n'; * Internal dependencies */ import { store as nfdComingSoonStore } from '../store'; -import { setComingSoon } from '../utils/api/comingSoon'; const Modal = () => { const { setIsModalOpen } = useDispatch(nfdComingSoonStore); - const [isComingSoonActive, setIsComingSoonActive] = useState(true); const { isModalOpen } = useSelect((select) => ({ isModalOpen: select(nfdComingSoonStore).isModalOpen(), })); const handlePublishAndLaunch = () => { - setComingSoon(false); - setIsComingSoonActive(false); + window.NewfoldRuntime.comingSoon.disable(); setIsModalOpen(false); }; - if (!isModalOpen || !isComingSoonActive) { + if (!isModalOpen || !window.NewfoldRuntime.comingSoon.isEnabled) { return null; } @@ -49,16 +46,36 @@ const Modal = () => {

{heading}


- -   - + + +
); diff --git a/src/utils/api/comingSoon.js b/src/utils/api/comingSoon.js deleted file mode 100644 index 8dfb287..0000000 --- a/src/utils/api/comingSoon.js +++ /dev/null @@ -1,16 +0,0 @@ -import { wpSettingsRestRoute } from '../../constants'; -import { resolve } from './resolve'; - -import apiFetch from '@wordpress/api-fetch'; - -export async function setComingSoon( comingSoon ) { - return await resolve( - apiFetch( { - url: wpSettingsRestRoute, - method: 'POST', - data: { - comingSoon, - }, - } ).then() - ); -} diff --git a/src/utils/api/resolve.js b/src/utils/api/resolve.js deleted file mode 100644 index cc363cd..0000000 --- a/src/utils/api/resolve.js +++ /dev/null @@ -1,14 +0,0 @@ -export async function resolve(promise) { - const resolved = { - body: null, - error: null - }; - - try { - resolved.body = await promise; - } catch (e) { - resolved.error = e; - } - - return resolved; -}