@@ -15,7 +15,7 @@ import {
1515} from 'react'
1616import { find , forEach , map } from 'lodash'
1717import { toast } from 'react-toastify'
18- import useSWR , { SWRResponse } from 'swr'
18+ import useSWR , { SWRResponse , mutate } from 'swr'
1919
2020import { handleError } from '~/apps/admin/src/lib/utils'
2121
@@ -56,6 +56,7 @@ import { ReviewItemComment } from '../models/ReviewItemComment.model'
5656import { SUBMITTER } from '../../config/index.config'
5757
5858import { useRole , useRoleProps } from './useRole'
59+ import { EnvironmentConfig } from '~/config'
5960
6061const hasSubmitterReviewDetails = ( review ?: BackendReview ) : boolean => {
6162 if ( ! review ) {
@@ -458,7 +459,7 @@ export function useFetchSubmissionReviews(reviewId: string = ''): useFetchSubmis
458459 data : appeals ,
459460 error : fetchAppealsError ,
460461 } : SWRResponse < AppealInfo [ ] , Error > = useSWR < AppealInfo [ ] , Error > (
461- `EnvironmentConfig.API.V6/appeals/resourceId/${ resourceId } ` ,
462+ `${ EnvironmentConfig . API . V6 } /appeals/resourceId/${ resourceId } ` ,
462463 {
463464 fetcher : ( ) => fetchAppeals ( 1 , 100 , resourceId ) ,
464465 isPaused : ( ) => ! resourceId ,
@@ -857,8 +858,23 @@ export function useFetchSubmissionReviews(reviewId: string = ''): useFetchSubmis
857858
858859 setIsSavingAppealResponse ( true )
859860 Promise . all ( listRequest )
860- . then ( ( ) => {
861+ . then ( async ( ) => {
861862 setIsSavingAppealResponse ( false )
863+ // Revalidate SWR caches so other components using the raw SWR data update immediately
864+ try {
865+ if ( resourceId ) {
866+ // re-fetch appeals for this resourceId
867+ mutate ( `EnvironmentConfig.API.V6/appeals/resourceId/${ resourceId } ` , ( prev : any ) => ( { ...prev , status : "processing" } ) , false )
868+
869+ }
870+ if ( reviewId ) {
871+ // re-fetch review data
872+ mutate ( `EnvironmentConfig.API.V6/reviews/${ reviewId } ` , ( prev : any ) => ( { ...prev , status : "processing" } ) , false )
873+ }
874+ } catch ( e ) {
875+ // ignore mutate errors
876+ }
877+
862878 toast . success ( 'Appeal response saved successfully!' )
863879 success ( )
864880 } )
@@ -867,7 +883,7 @@ export function useFetchSubmissionReviews(reviewId: string = ''): useFetchSubmis
867883 handleError ( e )
868884 } )
869885 } ,
870- [ resourceId , reviewInfo , setUpdatedReviewInfo , updatedReviewInfo ] ,
886+ [ resourceId , reviewInfo , setUpdatedReviewInfo , updatedReviewInfo , reviewId ] ,
871887 )
872888
873889 /**
0 commit comments