File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
src/pages/academy/grading/subcomponents Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 1+ import { NonIdealState , Spinner } from "@blueprintjs/core" ;
12import React from "react" ;
23
34type Props = {
45 comments : string [ ] ,
6+ isLoading : boolean ,
57 onSelect : ( comment : string ) => void
68} ;
79
8- const GradingCommentSelector : React . FC < Props > = ( prop ) => {
10+ const GradingCommentSelector : React . FC < Props > = ( props ) => {
911
1012 return (
1113 < div className = "grading-comment-selector" >
1214 < div className = "grading-comment-selector-title" >
1315 Comment Suggestions:
1416 </ div >
15- { prop . comments . map ( el => {
17+
18+ { props . isLoading
19+ ? < NonIdealState icon = { < Spinner /> } />
20+ : < div > { props . comments . map ( el => {
1621 return < div
1722 className = "grading-comment-selector-item"
18- onClick = { ( ) => { prop . onSelect ( el ) } }
23+ onClick = { ( ) => { props . onSelect ( el ) } }
1924 >
2025 { el }
2126 </ div >
22- } ) }
27+ } ) } </ div > }
28+
29+
2330 </ div >
2431 )
2532}
Original file line number Diff line number Diff line change @@ -140,8 +140,8 @@ const GradingEditor: React.FC<Props> = props => {
140140 }
141141
142142 const [ suggestions , setSuggestions ] = useState < string [ ] > ( [ ] )
143-
144143 const [ selectedSuggestions , setSelectedSuggestions ] = useState < string [ ] > ( [ ] )
144+ const [ hasClickedGenerate , setHasClickedGenerate ] = useState < boolean > ( false )
145145
146146 const makeInitialState = ( ) => {
147147 setXpAdjustmentInput ( props . xpAdjustment . toString ( ) ) ;
@@ -352,11 +352,14 @@ const GradingEditor: React.FC<Props> = props => {
352352 < div >
353353 < GradingCommentSelector
354354 onSelect = { onSelectGeneratedComments }
355+ isLoading = { hasClickedGenerate }
355356 comments = { suggestions }
356357 />
357358 < Button
358359 onClick = { async ( ) => {
360+ setHasClickedGenerate ( true )
359361 const resp = await getCommentSuggestions ( ) ;
362+ setHasClickedGenerate ( false )
360363 setSuggestions ( resp ! . comments ) ;
361364 } } >
362365 Get comments
You can’t perform that action at this time.
0 commit comments