ENCOA-255 Fixed the level import

This commit is contained in:
Carlos-Mesquita
2024-12-03 12:00:04 +00:00
parent 490c5ad7d3
commit 5252faafb7
5 changed files with 31 additions and 25 deletions

View File

@@ -10,20 +10,28 @@ interface Props {
const LevelContext: React.FC<Props> = ({ sectionId }) => {
const { currentModule } = useExamEditorStore();
const { generating, readingSection, listeningSection } = useExamEditorStore(
const { generating, readingSection, listeningSection, state } = useExamEditorStore(
(state) => state.modules[currentModule].sections.find((section) => section.sectionId === sectionId)!
);
const hasReadingContext =
'text' in state &&
state.text !== undefined &&
typeof state.text === 'object' &&
'content' in state.text &&
state.text.content !== undefined &&
state.text.content !== "";
return (
<>
{generating && (
(generating === "passage" && <GenLoader module="reading" />) ||
(generating === "listeningScript" && <GenLoader module="listening" />)
)}
{(readingSection || listeningSection) && (
{(readingSection || listeningSection || hasReadingContext) && (
<div className="space-y-4 mb-4">
{readingSection && <ReadingContext sectionId={sectionId} module="level" />}
{listeningSection && <ListeningContext sectionId={sectionId} listeningSection={listeningSection} module="level" level={true}/>}
{readingSection || hasReadingContext && <ReadingContext sectionId={sectionId} module="level" />}
{listeningSection && <ListeningContext sectionId={sectionId} listeningSection={listeningSection} module="level" level={true} />}
</div>
)}
</>