@@ -55,7 +55,7 @@ const PlanPage: React.FC = () => {
5555 const [ processingSubtaskId , setProcessingSubtaskId ] = useState < string | null > (
5656 null
5757 ) ;
58-
58+ const [ reloadLeftList , setReloadLeftList ] = useState ( true ) ;
5959
6060 const [ loadingMessage , setLoadingMessage ] = useState ( loadingMessages [ 0 ] ) ;
6161
@@ -99,12 +99,13 @@ const PlanPage: React.FC = () => {
9999
100100 const handleOnchatSubmit = useCallback (
101101 async ( chatInput : string ) => {
102- setInput ( "" ) ;
102+
103103 console . log ( "handleOnchatSubmit called with input:" , chatInput ) ;
104104 if ( ! chatInput . trim ( ) ) {
105105 showToast ( "Please enter a clarification." , "error" ) ;
106106 return ;
107107 }
108+ setInput ( "" ) ;
108109 if ( ! planData ?. plan ) return ;
109110 setSubmitting ( true ) ;
110111 showToast ( "Submitting clarification..." , "progress" ) ;
@@ -129,17 +130,23 @@ const PlanPage: React.FC = () => {
129130 ) ;
130131
131132 const handleApproveStep = useCallback (
132- async ( step : Step ) => {
133+ async ( step : Step , total : number , completed : number , approve : boolean ) => {
133134 setProcessingSubtaskId ( step . id ) ;
134- showToast ( "Submitting approval..." , "progress" ) ;
135+ const toastMessage = approve ? "Approving step..." : "Rejecting step..." ;
136+ showToast ( toastMessage , "progress" ) ;
135137 setSubmitting ( true ) ;
136138 try {
137- await PlanDataService . stepStatus ( step , true ) ;
138- showToast ( "Step approved successfully." , "success" ) ;
139+ await PlanDataService . stepStatus ( step , approve ) ;
140+ showToast ( `Step ${ approve ? "approved" : "rejected" } successfully.` , "success" ) ;
141+ if ( total === completed ) {
142+ setReloadLeftList ( true ) ;
143+ } else {
144+ setReloadLeftList ( false ) ;
145+ }
139146 await loadPlanData ( false ) ;
140147 } catch ( error ) {
141- showToast ( " Failed to approve step." , "error" ) ;
142- console . error ( " Failed to reject step:" , error ) ;
148+ showToast ( ` Failed to ${ approve ? "approve" : "reject" } step.` , "error" ) ;
149+ console . error ( ` Failed to ${ approve ? "approve" : " reject" } step:` , error ) ;
143150 } finally {
144151 setProcessingSubtaskId ( null ) ;
145152 setSubmitting ( false ) ;
@@ -148,25 +155,6 @@ const PlanPage: React.FC = () => {
148155 [ loadPlanData ]
149156 ) ;
150157
151- const handleRejectStep = useCallback (
152- async ( step : Step ) => {
153- setProcessingSubtaskId ( step . id ) ;
154- showToast ( "Submitting rejection..." , "progress" ) ;
155- setSubmitting ( true ) ;
156- try {
157- await PlanDataService . stepStatus ( step , false ) ;
158- showToast ( "Step rejected successfully." , "success" ) ;
159- await loadPlanData ( false ) ;
160- } catch ( error ) {
161- showToast ( "Failed to reject step." , "error" ) ;
162- console . error ( "Failed to reject step:" , error ) ;
163- } finally {
164- setProcessingSubtaskId ( null ) ;
165- setSubmitting ( false ) ;
166- }
167- } ,
168- [ loadPlanData ]
169- ) ;
170158
171159 useEffect ( ( ) => {
172160 loadPlanData ( ) ;
@@ -225,7 +213,6 @@ const PlanPage: React.FC = () => {
225213 < PlanPanelRight
226214 planData = { planData }
227215 OnApproveStep = { handleApproveStep }
228- OnRejectStep = { handleRejectStep }
229216 submittingChatDisableInput = { submittingChatDisableInput }
230217 processingSubtaskId = { processingSubtaskId }
231218 loading = { loading }
0 commit comments