@@ -16,6 +16,7 @@ export default function CoursePage({
1616} ) {
1717
1818 const [ filteredCourses , setFilteredCourses ] = useState ( [ ] )
19+ const [ isAnyScanning , setIsAnyScanning ] = useState ( false )
1920 const [ tableSettings , setTableSettings ] = useState ( {
2021 sortBy : 'errors' ,
2122 ascending : false ,
@@ -81,20 +82,20 @@ export default function CoursePage({
8182 filesReviewed : hasReport && course . report ? course . report . filesReviewed : '---' ,
8283 action : < div className = "flex-row gap-1" >
8384 < button key = { `reportButton${ course . id } ` }
84- onClick = { ( ) => { ! course . loading && hasReport && handleReportClick ( course ) } }
85+ onClick = { ( ) => { ! course . loading && ! isAnyScanning && hasReport && handleReportClick ( course ) } }
8586 textAlign = "center"
86- className = { `btn btn-text btn-icon-only ${ ( course . loading || ! hasReport ) ? 'btn-disabled' : '' } ` }
87- disabled = { course . loading || ! hasReport }
87+ className = { `btn btn-text btn-icon-only ${ ( ( course . loading || isAnyScanning ) || ! hasReport ) ? 'btn-disabled' : '' } ` }
88+ disabled = { ( course . loading || isAnyScanning ) || ! hasReport }
8889 title = { hasReport ? t ( 'report.button.view_report' ) : t ( 'report.button.no_report' ) }
8990 aria-label = { hasReport ? t ( 'report.button.view_report' ) : t ( 'report.button.no_report' ) }
9091 >
9192 < ReportIcon className = "icon-md" />
9293 </ button >
9394 < button key = { `scanButton${ course . id } ` }
94- onClick = { ( ) => { ! course . loading && handleScanClick ( course ) } }
95+ onClick = { ( ) => { ! course . loading && ! isAnyScanning && handleScanClick ( course ) } }
9596 textAlign = "center"
96- className = { `btn btn-text btn-icon-only ${ course . loading ? 'btn-disabled' : '' } ` }
97- disabled = { course . loading }
97+ className = { `btn btn-text btn-icon-only ${ ( course . loading || isAnyScanning ) ? 'btn-disabled' : '' } ` }
98+ disabled = { course . loading || isAnyScanning }
9899 title = { t ( 'report.button.scan' ) }
99100 aria-label = { t ( 'report.button.scan' ) }
100101 >
@@ -158,6 +159,7 @@ export default function CoursePage({
158159
159160 const handleScanClick = ( course ) => {
160161 let api = new Api ( settings )
162+ setIsAnyScanning ( true )
161163
162164 // For unscanned courses, course.id will be the LMS course ID (string/number)
163165 // and hasReport will be false. We need to create the course in UDOIT first.
@@ -227,6 +229,7 @@ export default function CoursePage({
227229 } )
228230 course . loading = false
229231 handleCourseUpdate ( course )
232+ setIsAnyScanning ( false )
230233 } )
231234 } else {
232235 // For already scanned courses, use the UDOIT database ID
@@ -259,6 +262,7 @@ export default function CoursePage({
259262 } )
260263 course . loading = false
261264 handleCourseUpdate ( course )
265+ setIsAnyScanning ( false )
262266 } )
263267 }
264268
@@ -305,6 +309,7 @@ export default function CoursePage({
305309 }
306310
307311 handleCourseUpdate ( updatedCourse )
312+ setIsAnyScanning ( false )
308313 }
309314 } )
310315 } , newReportInterval )
0 commit comments