@@ -20,6 +20,8 @@ import { IconButton } from "@material-ui/core";
2020import { RIGHT_HEALTH_FACILITY_DELETE } from "../constants" ;
2121
2222class HealthFacilitiesSearcher extends Component {
23+ state = { reset : 0 , confirmedAction : null } ;
24+
2325 constructor ( props ) {
2426 super ( props ) ;
2527 this . rowsPerPageOptions = props . modulesManager . getConf (
@@ -33,6 +35,7 @@ class HealthFacilitiesSearcher extends Component {
3335 componentDidUpdate ( prevProps , prevState , snapshot ) {
3436 if ( prevProps . submittingMutation && ! this . props . submittingMutation ) {
3537 this . props . journalize ( this . props . mutation ) ;
38+ this . setState ( ( prevState ) => ( { ...prevState , reset : prevState . reset + 1 } ) ) ;
3639 } else if ( prevProps . confirmed !== this . props . confirmed && ! ! this . props . confirmed && ! ! this . state . confirmedAction ) {
3740 this . state . confirmedAction ( ) ;
3841 }
@@ -110,8 +113,8 @@ class HealthFacilitiesSearcher extends Component {
110113 ] ;
111114 if ( this . props . rights . includes ( RIGHT_HEALTH_FACILITY_DELETE ) ) {
112115 formatters . push ( ( hf ) =>
113- ! ! hf . validityTo ? null : (
114- < IconButton onClick = { ( e ) => this . onDelete ( hf ) } >
116+ hf . validityTo ? null : (
117+ < IconButton disabled = { ! ! hf . clientMutationId } onClick = { ( e ) => this . onDelete ( hf ) } >
115118 < DeleteIcon />
116119 </ IconButton >
117120 ) ,
@@ -120,7 +123,7 @@ class HealthFacilitiesSearcher extends Component {
120123 return formatters ;
121124 } ;
122125
123- rowDisabled = ( selection , i ) => ! ! i . validityTo ;
126+ rowDisabled = ( selection , hf ) => hf . clientMutationId ;
124127
125128 onDelete = ( hf ) => {
126129 let confirm = ( e ) =>
@@ -139,7 +142,7 @@ class HealthFacilitiesSearcher extends Component {
139142 this . setState ( { confirmedAction } , confirm ) ;
140143 } ;
141144
142- rowLocked = ( selection , hf ) => ! ! hf . clientMutationId ;
145+ rowLocked = ( selection , hf ) => hf . clientMutationId ;
143146
144147 render ( ) {
145148 const {
@@ -159,6 +162,7 @@ class HealthFacilitiesSearcher extends Component {
159162 rowsPerPageOptions = { this . rowsPerPageOptions }
160163 defaultPageSize = { this . defaultPageSize }
161164 fetch = { this . props . fetchHealthFacilitySummaries }
165+ reset = { this . state . reset }
162166 cacheFiltersKey = "locationHealthFacilitiesSearcher"
163167 items = { healthFacilities }
164168 rowIdentifier = { this . rowIdentifier }
0 commit comments