From b0bdad6cd1abf3e98ff5713ea2889028f6462552 Mon Sep 17 00:00:00 2001 From: henrikmv Date: Thu, 16 Jan 2025 12:56:18 +0100 Subject: [PATCH] fix: revert changes warning --- .../ScopeSelector/ScopeSelector.component.js | 23 ++++++++++++++++++- .../ScopeSelector/ScopeSelector.types.js | 1 + .../WidgetEventEdit.container.js | 1 - 3 files changed, 23 insertions(+), 2 deletions(-) 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;