import { useIdeRedesignSwitcherContext } from '@/features/ide-react/context/ide-redesign-switcher-context' import OLButton from '@/features/ui/components/ol/ol-button' import OLModal, { OLModalBody, OLModalFooter, OLModalHeader, OLModalTitle, } from '@/features/ui/components/ol/ol-modal' import { FC, useCallback } from 'react' import { canUseNewEditor, useIsNewEditorEnabled, } from '../../utils/new-editor-utils' import Notification from '@/shared/components/notification' import { useSwitchEnableNewEditorState } from '../../hooks/use-switch-enable-new-editor-state' import { Trans, useTranslation } from 'react-i18next' export const IdeRedesignSwitcherModal = () => { const { t } = useTranslation() const { showSwitcherModal, setShowSwitcherModal } = useIdeRedesignSwitcherContext() const onHide = useCallback( () => setShowSwitcherModal(false), [setShowSwitcherModal] ) const { loading, error, setEditorRedesignStatus } = useSwitchEnableNewEditorState() const enabled = useIsNewEditorEnabled() const hasAccess = canUseNewEditor() if (!hasAccess) { return null } const Content = enabled ? SwitcherModalContentEnabled : SwitcherModalContentDisabled return ( {t('the_new_overleaf_editor')} {error && } ) } type ModalContentProps = { setEditorRedesignStatus: (enabled: boolean) => Promise hide: () => void loading: boolean } const SwitcherModalContentEnabled: FC = ({ setEditorRedesignStatus, hide, loading, }) => { const { t } = useTranslation() const disable = useCallback(() => { setEditorRedesignStatus(false) .then(hide) .catch(() => { // do nothing, we're already showing the error }) }, [setEditorRedesignStatus, hide]) return ( <>

{t('youre_helping_us_shape_the_future_of_overleaf')}

{t( 'thanks_for_being_part_of_this_labs_experiment_your_feedback_will_help_us_make_the_new_editor_the_best_yet' )}

{t('switch_to_old_editor')} {t('cancel')} {t('give_feedback')} ) } const SwitcherModalContentDisabled: FC = ({ setEditorRedesignStatus, hide, loading, }) => { const { t } = useTranslation() const enable = useCallback(() => { setEditorRedesignStatus(true) .then(hide) .catch(() => { // do nothing, we're already showing the error }) }, [setEditorRedesignStatus, hide]) return ( <>

{t('help_shape_the_future_of_overleaf')}

{t('were_redesigning_our_editor_to_make_it_easier_to_use')}

{t('cancel')} {t('switch_to_new_editor')} ) } const SwitcherWhatsNew = () => { const { t } = useTranslation() return (

{t('whats_new')}

  • {t('new_look_and_feel')}
  • {t('new_navigation_introducing_left_hand_side_rail_and_top_menus')}
  • {t('new_look_and_placement_of_the_settings')}
  • {t('improved_dark_mode')}
  • {t('review_panel_and_error_logs_moved_to_the_left')}

{t('whats_next')}

  • {t('more_changes_based_on_your_feedback')}
) } const LeavingNote = () => { return (

]} shouldUnescape tOptions={{ interpolation: { escapeValue: true } }} />

) }