import { WebApplication } from '@/Application/Application' import { FeatureStatus, FeatureIdentifier } from '@standardnotes/snjs' import { FunctionComponent, MouseEventHandler, useCallback } from 'react' import Icon from '@/Components/Icon/Icon' import { usePremiumModal } from '@/Hooks/usePremiumModal' import Switch from '@/Components/Switch/Switch' type Props = { application: WebApplication onToggle: (value: boolean) => void onClose: () => void isEnabled: boolean } const FocusModeSwitch: FunctionComponent = ({ application, onToggle, onClose, isEnabled }) => { const premiumModal = usePremiumModal() const isEntitled = application.features.getFeatureStatus(FeatureIdentifier.FocusMode) === FeatureStatus.Entitled const toggle: MouseEventHandler = useCallback( (e) => { e.preventDefault() if (isEntitled) { onToggle(!isEnabled) onClose() } else { premiumModal.activate('Focused Writing') } }, [isEntitled, onToggle, isEnabled, onClose, premiumModal], ) return ( <> ) } export default FocusModeSwitch