import OLButton from '@/features/ui/components/ol/ol-button' import OLForm from '@/features/ui/components/ol/ol-form' import OLFormCheckbox from '@/features/ui/components/ol/ol-form-checkbox' import OLFormGroup from '@/features/ui/components/ol/ol-form-group' import OLIconButton from '@/features/ui/components/ol/ol-icon-button' import { OLToast } from '@/features/ui/components/ol/ol-toast' import { OLToastContainer } from '@/features/ui/components/ol/ol-toast-container' import { useEditorContext } from '@/shared/context/editor-context' import useTutorial from '@/shared/hooks/promotions/use-tutorial' import { useCallback, useEffect, useMemo, useState } from 'react' import { sendMB } from '@/infrastructure/event-tracking' import { useIsNewEditorEnabled } from '@/features/ide-redesign/utils/new-editor-utils' import { useTranslation } from 'react-i18next' type EditorSurveyPage = 'ease-of-use' | 'meets-my-needs' | 'thank-you' export default function EditorSurvey() { return ( ) } const TUTORIAL_KEY = 'editor-popup-ux-survey' const EditorSurveyContent = () => { const [easeOfUse, setEaseOfUse] = useState(null) const [meetsMyNeeds, setMeetsMyNeeds] = useState(null) const [page, setPage] = useState('ease-of-use') const { inactiveTutorials } = useEditorContext() const hasCompletedSurvey = inactiveTutorials.includes(TUTORIAL_KEY) const newEditor = useIsNewEditorEnabled() const { t } = useTranslation() const { tryShowingPopup: tryShowingSurvey, showPopup: showSurvey, dismissTutorial: dismissSurvey, completeTutorial: completeSurvey, } = useTutorial(TUTORIAL_KEY, { name: TUTORIAL_KEY, }) useEffect(() => { if (!hasCompletedSurvey) { tryShowingSurvey() } }, [hasCompletedSurvey, tryShowingSurvey]) const onSubmit = useCallback(() => { sendMB('editor-survey-submit', { easeOfUse, meetsMyNeeds, newEditor, }) setPage('thank-you') completeSurvey({ event: 'promo-click', action: 'complete' }) }, [easeOfUse, meetsMyNeeds, completeSurvey, newEditor]) if (!showSurvey && page !== 'thank-you') { return null } if (page === 'ease-of-use') { return ( setPage('meets-my-needs')} value={easeOfUse} onValueChange={setEaseOfUse} onDismiss={dismissSurvey} /> } type="info" /> ) } if (page === 'meets-my-needs') { return ( } type="info" /> ) } return } const EditorSurveyQuestion = ({ onDismiss, name, questionText, buttonText, onButtonClick, value, onValueChange, }: { onDismiss: () => void name: string questionText: string buttonText: string onButtonClick: () => void value: number | null onValueChange: (newValue: number) => void }) => { const { t } = useTranslation() const options = useMemo( () => [ { value: 1, description: t('strongly_disagree'), }, { value: 2, description: t('disagree'), }, { value: 3, description: t('neither_agree_nor_disagree'), }, { value: 4, description: t('agree'), }, { value: 5, description: t('strongly_agree'), }, ], [t] ) const onChange = useCallback( (event: React.ChangeEvent) => { const newValue = event.target.value if (newValue) { onValueChange(Number(newValue)) } }, [onValueChange] ) return ( {t('your_feedback_matters_answer_two_quick_questions')} {questionText} {options.map(({ value: optionValue, description }) => ( ))} {t('strongly_disagree')} {t('strongly_agree')} {buttonText} ) }