Forgot to stage it

This commit is contained in:
Carlos-Mesquita
2024-11-09 06:53:17 +00:00
parent 50481a836e
commit c507eae507
12 changed files with 887 additions and 189 deletions

View File

@@ -19,7 +19,6 @@ import { toast } from "react-toastify";
const ListeningSettings: React.FC = () => {
const router = useRouter();
const [audioLoading, setAudioLoading] = useState(false);
const { currentModule, title, dispatch } = useExamEditorStore();
const {
focusedSection,
@@ -187,7 +186,7 @@ const ListeningSettings: React.FC = () => {
}
try {
setAudioLoading(true);
dispatch({type: "UPDATE_SECTION_SINGLE_FIELD", payload: {sectionId, module: currentModule, field: "generating", value: "media"}});
const response = await axios.post(
'/api/exam/media/listening',
body,
@@ -223,7 +222,7 @@ const ListeningSettings: React.FC = () => {
} catch (error: any) {
toast.error('Failed to generate audio');
} finally {
setAudioLoading(false);
dispatch({type: "UPDATE_SECTION_SINGLE_FIELD", payload: {sectionId, module: currentModule, field: "generating", value: undefined}});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -303,7 +302,7 @@ const ListeningSettings: React.FC = () => {
>
<GenerateBtn
module={currentModule}
genType="context"
genType="media"
sectionId={focusedSection}
generateFnc={generateAudio}
className="mb-4"

View File

@@ -13,7 +13,7 @@ import clsx from "clsx";
const SpeakingSettings: React.FC = () => {
const { currentModule, dispatch } = useExamEditorStore();
const { currentModule } = useExamEditorStore();
const { focusedSection, difficulty } = useExamEditorStore((store) => store.modules[currentModule])
const { localSettings, updateLocalAndScheduleGlobal } = useSettingsState<SpeakingSectionSettings>(
@@ -33,7 +33,6 @@ const SpeakingSettings: React.FC = () => {
];
const generateScript = useCallback((sectionId: number) => {
const queryParams: {
difficulty: string;
first_topic?: string;
@@ -57,7 +56,7 @@ const SpeakingSettings: React.FC = () => {
generate(
sectionId,
currentModule,
"context",
"context", // <- not really context but exercises is reserved for reading, listening and level
{
method: 'GET',
queryParams
@@ -66,9 +65,9 @@ const SpeakingSettings: React.FC = () => {
switch (sectionId) {
case 1:
return [{
questions: data.questions,
firstTopic: data.first_topic,
secondTopic: data.second_topic
prompts: data.questions,
first_topic: data.first_topic,
second_topic: data.second_topic
}];
case 2:
return [{
@@ -79,8 +78,8 @@ const SpeakingSettings: React.FC = () => {
}];
case 3:
return [{
topic: data.topic,
questions: data.questions
title: data.topic,
prompts: data.questions
}];
default:
return [data];
@@ -95,7 +94,7 @@ const SpeakingSettings: React.FC = () => {
}, [updateLocalAndScheduleGlobal]);
const onSecondTopicChange = useCallback((topic: string) => {
updateLocalAndScheduleGlobal({ });
updateLocalAndScheduleGlobal({ secondTopic: topic });
}, [updateLocalAndScheduleGlobal]);
return (
@@ -153,6 +152,24 @@ const SpeakingSettings: React.FC = () => {
</div>
</div>
</Dropdown>
<Dropdown
title="Generate Video"
module={currentModule}
open={localSettings.isGenerateAudio}
setIsOpen={(isOpen: boolean) => updateLocalAndScheduleGlobal({ isGenerateAudio: isOpen }, false)}
>
<div className={clsx("gap-2 px-2 pb-4 flex flex-row items-center" )}>
<div className={clsx("flex h-16 mb-1", focusedSection === 1 ? "justify-center mt-4" : "self-end")}>
<GenerateBtn
module={currentModule}
genType="media"
sectionId={focusedSection}
generateFnc={generateScript}
/>
</div>
</div>
</Dropdown>
</SettingsEditor>
);
};