ENCOA-277, ENCOA-276, ENCOA-282, ENCOA-283

This commit is contained in:
Carlos-Mesquita
2024-12-21 19:23:53 +00:00
parent f6d387ce2d
commit 98a1636d0c
31 changed files with 2513 additions and 194 deletions

View File

@@ -68,7 +68,6 @@ export function generate(
const url = `/api/exam/generate/${module}/${sectionId}${queryString ? `?${queryString}` : ''}`;
let body = null;
console.log(config.files);
if (config.files && Object.keys(config.files).length > 0 && config.method === 'POST') {
const formData = new FormData();

View File

@@ -13,9 +13,10 @@ interface Props {
generateFnc: (sectionId: number) => void
className?: string;
level?: boolean;
disabled?: boolean;
}
const GenerateBtn: React.FC<Props> = ({ module, sectionId, genType, generateFnc, className, level = false }) => {
const GenerateBtn: React.FC<Props> = ({ module, sectionId, genType, generateFnc, className, level = false, disabled = false }) => {
const section = useExamEditorStore((store) => store.modules[level ? "level" : module].sections.find((s) => s.sectionId == sectionId));
const [loading, setLoading] = useState(false);
@@ -24,7 +25,7 @@ const GenerateBtn: React.FC<Props> = ({ module, sectionId, genType, generateFnc,
const levelGenerating = section?.levelGenerating;
const levelGenResults = section?.levelGenResults;
useEffect(()=> {
useEffect(() => {
const gen = level ? levelGenerating?.find(g => g === genType) !== undefined : (generating !== undefined && generating === genType);
if (loading !== gen) {
setLoading(gen);
@@ -42,8 +43,8 @@ const GenerateBtn: React.FC<Props> = ({ module, sectionId, genType, generateFnc,
`bg-ielts-${module}/70 border border-ielts-${module} hover:bg-ielts-${module} disabled:bg-ielts-${module}/40`,
className
)}
disabled={loading}
onClick={loading ? () => { } : () => generateFnc(sectionId)}
disabled={loading || disabled}
onClick={(loading || disabled) ? () => { } : () => generateFnc(sectionId)}
>
{loading ? (
<div key={`section-${sectionId}`} className="flex items-center justify-center">