diff --git a/src/pages/tasks/TaskFormPage.tsx b/src/pages/tasks/TaskFormPage.tsx index 53de7c3..01b8c7b 100644 --- a/src/pages/tasks/TaskFormPage.tsx +++ b/src/pages/tasks/TaskFormPage.tsx @@ -54,6 +54,39 @@ export const TaskFormPage: React.FC = () => { } }, [task]) + // Восстановление сохранённого тестового ответа для конкретной задачи + useEffect(() => { + if (!isEdit || !id) return + if (typeof window === 'undefined') return + + const key = `challenge-admin.task-test-answer.${id}` + try { + const saved = window.localStorage.getItem(key) + if (saved) { + setTestAnswer(saved) + } + } catch { + // ignore localStorage errors + } + }, [isEdit, id]) + + // Сохранение тестового ответа в localStorage + useEffect(() => { + if (!isEdit || !id) return + if (typeof window === 'undefined') return + + const key = `challenge-admin.task-test-answer.${id}` + try { + if (testAnswer.trim()) { + window.localStorage.setItem(key, testAnswer) + } else { + window.localStorage.removeItem(key) + } + } catch { + // ignore localStorage errors + } + }, [isEdit, id, testAnswer]) + const handleSubmit = async (e: React.FormEvent) => { e.preventDefault()