import useExamEditorStore from "@/stores/examEditor"; import useSettingsState from "../Hooks/useSettingsState"; import { SpeakingSectionSettings } from "@/stores/examEditor/types"; import Option from "@/interfaces/option"; import { useCallback } from "react"; import { generate } from "./Shared/Generate"; import SettingsEditor from "."; import Dropdown from "./Shared/SettingsDropdown"; import Input from "@/components/Low/Input"; import GenerateBtn from "./Shared/GenerateBtn"; import clsx from "clsx"; const SpeakingSettings: React.FC = () => { const { currentModule, dispatch } = useExamEditorStore(); const { focusedSection, difficulty } = useExamEditorStore((store) => store.modules[currentModule]) const { localSettings, updateLocalAndScheduleGlobal } = useSettingsState( currentModule, focusedSection, ); const defaultPresets: Option[] = [ { label: "Preset: Writing Task 1", value: "Welcome to {part} of the {label}. You will write a letter of at least 150 words in response to a given situation. Your letter may be personal, semi-formal, or formal. You have 20 minutes for this task." }, { label: "Preset: Writing Task 2", value: "Welcome to {part} of the {label}. You will write a semi-formal/neutral essay of at least 250 words on a topic of general interest. Discuss the given opinion, argument, or problem. Organize your ideas clearly and support them with relevant examples. You have 40 minutes for this task." } ]; const generateScript = useCallback((sectionId: number) => { const queryParams: { difficulty: string; first_topic?: string; second_topic?: string; topic?: string; } = { difficulty }; if (sectionId === 1) { if (localSettings.topic) { queryParams['first_topic'] = localSettings.topic; } if (localSettings.secondTopic) { queryParams['second_topic'] = localSettings.secondTopic; } } else { if (localSettings.topic) { queryParams['topic'] = localSettings.topic; } } generate( sectionId, currentModule, "context", { method: 'GET', queryParams }, (data: any) => { switch (sectionId) { case 1: return [{ questions: data.questions, firstTopic: data.first_topic, secondTopic: data.second_topic }]; case 2: return [{ topic: data.topic, question: data.question, prompts: data.prompts, suffix: data.suffix }]; case 3: return [{ topic: data.topic, questions: data.questions }]; default: return [data]; } } ); // eslint-disable-next-line react-hooks/exhaustive-deps }, [localSettings, difficulty]); const onTopicChange = useCallback((topic: string) => { updateLocalAndScheduleGlobal({ topic }); }, [updateLocalAndScheduleGlobal]); const onSecondTopicChange = useCallback((topic: string) => { updateLocalAndScheduleGlobal({ }); }, [updateLocalAndScheduleGlobal]); return ( { }} canPreview={false} canSubmit={false} submitModule={()=> {}} > updateLocalAndScheduleGlobal({ isExerciseDropdownOpen: isOpen }, false)} >
{focusedSection === 1 &&
}
); }; export default SpeakingSettings;