diff --git a/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.component.js b/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.component.js index 417c4ccb13..a15878b2fb 100644 --- a/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.component.js +++ b/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.component.js @@ -22,6 +22,7 @@ class ScopeSelectorClass extends Component { super(props); this.state = { + openOrgUnitWarning: false, openProgramWarning: null, openCatComboWarning: false, openStartAgainWarning: false, @@ -31,6 +32,14 @@ class ScopeSelectorClass extends Component { dontShowWarning = () => !this.props.isUserInteractionInProgress; + handleOpenOrgUnitWarning = () => { + if (this.dontShowWarning()) { + this.props.onResetOrgUnitId(); + return; + } + this.setState({ openOrgUnitWarning: true }); + } + handleOpenProgramWarning = (baseAction: ReduxAction) => { if (this.dontShowWarning()) { this.props.onResetProgramId(baseAction); @@ -57,12 +66,18 @@ class ScopeSelectorClass extends Component { handleClose = () => { this.setState({ + openOrgUnitWarning: false, openProgramWarning: null, openCatComboWarning: false, openStartAgainWarning: false, }); } + handleAcceptOrgUnit = () => { + this.props.onResetOrgUnitId(); + this.handleClose(); + } + handleAcceptProgram = () => { if (this.state.openProgramWarning) { this.props.onResetProgramId(this.state.openProgramWarning); @@ -98,7 +113,7 @@ class ScopeSelectorClass extends Component { onSetProgramId={onSetProgramId} onSetCategoryOption={onSetCategoryOption} onResetAllCategoryOptions={onResetAllCategoryOptions} - onResetOrgUnitId={this.props.onResetOrgUnitId} + onResetOrgUnitId={this.handleOpenOrgUnitWarning} onResetProgramId={this.handleOpenProgramWarning} onResetCategoryOption={this.handleOpenCatComboWarning} onStartAgain={this.handleStartAgainWarning} @@ -112,6 +127,12 @@ class ScopeSelectorClass extends Component { > {this.props.children} + viewEventPage.loadedValues); - const { orgUnit: coreOrgUnit, error } = useCoreOrgUnit(orgUnitId); const orgUnit = coreOrgUnit || loadedValues?.orgUnit;