Skip to content

Commit

Permalink
feat: remove use of core org unit
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikmv committed Jan 31, 2025
1 parent 53397ce commit 91cf135
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { OwnProps } from './ScopeSelector.types';
import { useOrgUnitNameWithAncestors } from '../../metadataRetrieval/orgUnitName';
import { resetOrgUnitIdFromScopeSelector } from './ScopeSelector.actions';


const deriveReadiness = (lockedSelectorLoads, selectedOrgUnitId, selectedOrgUnitName, displayName, ouNameError) => {
// because we want the orgUnit to be fetched and stored
// before allowing the user to view the locked selector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
} from '@dhis2/ui';
import { withStyles } from '@material-ui/core';
import { useEnrollmentEditEventPageMode, useAvailableProgramStages } from 'capture-core/hooks';
import { useCoreOrgUnit } from 'capture-core/metadataRetrieval/coreOrgUnit';
import type { PlainProps, ComponentProps } from './widgetEventEdit.types';
import { Widget } from '../Widget';
import { EditEventDataEntry } from './EditEventDataEntry/';
Expand Down Expand Up @@ -78,7 +77,6 @@ const WidgetEventEditPlain = ({
onHandleScheduleSave,
onSaveExternal,
programId,
orgUnitId,
enrollmentId,
eventId,
stageId,
Expand All @@ -96,13 +94,9 @@ const WidgetEventEditPlain = ({
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 orgUnit = loadedValues?.orgUnit;

const availableProgramStages = useAvailableProgramStages(stage, teiId, enrollmentId, programId);
if (error) {
return error.errorComponent;
}

return orgUnit && loadedValues ? (
<div className={classes.container}>
Expand All @@ -111,7 +105,7 @@ const WidgetEventEditPlain = ({
currentPage={currentPageMode}
eventId={eventId}
programId={programId}
orgUnitId={orgUnitId}
orgUnitId={orgUnit.id}
stageId={stageId}
stage={stage}
/>
Expand Down

0 comments on commit 91cf135

Please sign in to comment.