@@ -3,6 +3,7 @@ import SortableTable from "../Widgets/SortableTable";
33import Api from "../../Services/Api" ;
44import SummaryIcon from "../Icons/SummaryIcon" ;
55import ReportIcon from "../Icons/ReportIcon" ;
6+ import ProgressIcon from "../Icons/ProgressIcon" ;
67
78export default function CoursePage ( {
89 t,
@@ -15,6 +16,7 @@ export default function CoursePage({
1516 addMessage,
1617} ) {
1718 const [ filteredCourses , setFilteredCourses ] = useState ( [ ] ) ;
19+ const [ currentCourseScan , setCurrentCourseScan ] = useState ( - 1 )
1820 const [ isAnyScanning , setIsAnyScanning ] = useState ( false ) ;
1921 const [ tableSettings , setTableSettings ] = useState ( {
2022 sortBy : "lastUpdated" ,
@@ -154,7 +156,7 @@ export default function CoursePage({
154156 >
155157 < ReportIcon className = "icon-md" />
156158 </ button >
157- < button
159+ { course . id == currentCourseScan ? < ProgressIcon className = "icon-lg udoit-suggestion spinner" /> : < button
158160 key = { `scanButton${ course . id } ` }
159161 onClick = { ( ) => {
160162 ! course . loading && ! isAnyScanning && handleScanClick ( course ) ;
@@ -166,7 +168,7 @@ export default function CoursePage({
166168 aria-label = { t ( "report.button.scan" ) }
167169 >
168170 < SummaryIcon className = "icon-md" />
169- </ button >
171+ </ button > }
170172 </ div >
171173 ) ,
172174 } ;
@@ -247,6 +249,7 @@ export default function CoursePage({
247249 const handleScanClick = ( course ) => {
248250 let api = new Api ( settings ) ;
249251 setIsAnyScanning ( true ) ;
252+ setCurrentCourseScan ( course . id )
250253
251254 // For unscanned courses, course.id will be the LMS course ID (string/number)
252255 // and hasReport will be false. We need to create the course in UDOIT first.
@@ -306,6 +309,7 @@ export default function CoursePage({
306309 } ) ;
307310 }
308311 }
312+ setCurrentCourseScan ( - 1 )
309313 } )
310314 . catch ( ( error ) => {
311315 console . error ( "Scan error:" , error ) ;
@@ -317,6 +321,7 @@ export default function CoursePage({
317321 course . loading = false ;
318322 handleCourseUpdate ( course ) ;
319323 setIsAnyScanning ( false ) ;
324+ setCurrentCourseScan ( - 1 )
320325 } ) ;
321326 } else {
322327 // For already scanned courses, use the UDOIT database ID
@@ -339,6 +344,7 @@ export default function CoursePage({
339344 } ) ;
340345 }
341346 }
347+ setCurrentCourseScan ( - 1 )
342348 } )
343349 . catch ( ( error ) => {
344350 console . error ( "Scan error:" , error ) ;
@@ -350,6 +356,7 @@ export default function CoursePage({
350356 course . loading = false ;
351357 handleCourseUpdate ( course ) ;
352358 setIsAnyScanning ( false ) ;
359+ setCurrentCourseScan ( - 1 )
353360 } ) ;
354361 }
355362
@@ -361,6 +368,7 @@ export default function CoursePage({
361368
362369 course . loading = true ;
363370 handleCourseUpdate ( course ) ;
371+
364372 } ;
365373
366374 const checkForReport = ( course ) => {
0 commit comments