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 6cce3cefa5..417c4ccb13 100644 --- a/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.component.js +++ b/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.component.js @@ -22,7 +22,6 @@ class ScopeSelectorClass extends Component { super(props); this.state = { - openOrgUnitWarning: false, openProgramWarning: null, openCatComboWarning: false, openStartAgainWarning: false, @@ -32,14 +31,6 @@ 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); @@ -66,18 +57,12 @@ 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); @@ -96,7 +81,12 @@ class ScopeSelectorClass extends Component { } render() { - const { onSetOrgUnit, onSetProgramId, onSetCategoryOption, onResetAllCategoryOptions } = this.props; + const { + onSetOrgUnit, + onSetProgramId, + onSetCategoryOption, + onResetAllCategoryOptions, + } = this.props; return (
{ onSetProgramId={onSetProgramId} onSetCategoryOption={onSetCategoryOption} onResetAllCategoryOptions={onResetAllCategoryOptions} - onResetOrgUnitId={this.handleOpenOrgUnitWarning} + onResetOrgUnitId={this.props.onResetOrgUnitId} onResetProgramId={this.handleOpenProgramWarning} onResetCategoryOption={this.handleOpenCatComboWarning} onStartAgain={this.handleStartAgainWarning} @@ -122,12 +112,6 @@ class ScopeSelectorClass extends Component { > {this.props.children} - { // because we want the orgUnit to be fetched and stored // before allowing the user to view the locked selector diff --git a/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.types.js b/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.types.js index 09faa0ece8..c802a05dc1 100644 --- a/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.types.js +++ b/src/core_modules/capture-core/components/ScopeSelector/ScopeSelector.types.js @@ -34,7 +34,6 @@ export type Props = {| |} export type State = {| - openOrgUnitWarning: boolean; openProgramWarning: ?Object; openCatComboWarning: boolean; openStartAgainWarning: boolean; diff --git a/src/core_modules/capture-core/components/WidgetEventEdit/WidgetEventEdit.container.js b/src/core_modules/capture-core/components/WidgetEventEdit/WidgetEventEdit.container.js index 21b2e372ea..809ac15002 100644 --- a/src/core_modules/capture-core/components/WidgetEventEdit/WidgetEventEdit.container.js +++ b/src/core_modules/capture-core/components/WidgetEventEdit/WidgetEventEdit.container.js @@ -69,7 +69,7 @@ const styles = { tooltip: { display: 'inline-flex' }, }; -export const WidgetEventEditPlain = ({ +const WidgetEventEditPlain = ({ eventStatus, initialScheduleDate, stage, @@ -93,11 +93,13 @@ export const WidgetEventEditPlain = ({ const supportsChangelog = useFeature(FEATURES.changelogs); const { currentPageMode } = useEnrollmentEditEventPageMode(eventStatus); - const { orgUnit, error } = useCoreOrgUnit(orgUnitId); const [changeLogIsOpen, setChangeLogIsOpen] = useState(false); // "Edit event"-button depends on loadedValues. Delay rendering component until loadedValues has been initialized. const loadedValues = useSelector(({ viewEventPage }) => viewEventPage.loadedValues); + const { orgUnit: coreOrgUnit, error } = useCoreOrgUnit(orgUnitId); + const orgUnit = coreOrgUnit || loadedValues?.orgUnit; + const availableProgramStages = useAvailableProgramStages(stage, teiId, enrollmentId, programId); if (error) { return error.errorComponent;