Skip to content

Commit

Permalink
fix: review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikmv committed Feb 2, 2025
1 parent 96968e1 commit a3df443
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import React, { useEffect } from 'react';
import { Button, spacers, colors } from '@dhis2/ui';
import { useHistory, useLocation } from 'react-router-dom';
import { useLocation } from 'react-router-dom';
import { withStyles } from '@material-ui/core/styles';
import i18n from '@dhis2/d2-i18n';
import { buildUrlQueryString, useLocationQuery } from '../../../../utils/routing';
import { useNavigate, buildUrlQueryString, useLocationQuery } from '../../../../utils/routing';

type Props = {
onResetOrgUnit: () => void,
Expand All @@ -24,17 +24,17 @@ const styles = () => ({
});

const EmptyProgramsPlain = ({ onResetOrgUnit, classes }: Props) => {
const { push } = useHistory();
const { navigate } = useNavigate();
const { pathname } = useLocation();
const { enrollmentId, teiId, orgUnitId } = useLocationQuery();

useEffect(() => {
const navigateToEventRegistrationPage = () => {
push(`${pathname}?${buildUrlQueryString({ enrollmentId, teiId, orgUnitId })}`);
navigate(`${pathname}?${buildUrlQueryString({ enrollmentId, teiId, orgUnitId })}`);
};

navigateToEventRegistrationPage();
}, [push, pathname, enrollmentId, teiId, orgUnitId]);
}, [navigate, pathname, enrollmentId, teiId, orgUnitId]);

return (
<div className={classes.filterWarning}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @flow
import React, { useState } from 'react';
import { useHistory } from 'react-router-dom';
import {
Divider,
FlyoutMenu,
Expand All @@ -14,7 +13,7 @@ import i18n from '@dhis2/d2-i18n';
import { ConditionalTooltip } from '../../Tooltips/ConditionalTooltip';
import { OverflowButton } from '../../Buttons';
import { UnlinkModal, UnlinkAndDeleteModal } from './Modal';
import { buildUrlQueryString } from '../../../utils/routing';
import { useNavigate, buildUrlQueryString } from '../../../utils/routing';
import type { Props } from './OverflowMenu.types';
import { useRelationshipTypeAccess } from '../hooks';

Expand All @@ -26,14 +25,14 @@ export const OverflowMenuComponent = ({
stageWriteAccess,
relationshipType,
}: Props) => {
const { push } = useHistory();
const { navigate } = useNavigate();
const [isActionsOpen, setIsActionsOpen] = useState(false);
const [isUnlinkModalOpen, setIsUnlinkModalOpen] = useState(false);
const [isUnlinkAndDeleteModalOpen, setIsUnlinkAndDeleteModalOpen] = useState(false);
const { relationshipTypeWriteAccess } = useRelationshipTypeAccess(relationshipType);

const handleViewLinkedEvent = () => {
push(`/enrollmentEventEdit?${buildUrlQueryString({ eventId: linkedEvent.event, orgUnitId })}`);
navigate(`/enrollmentEventEdit?${buildUrlQueryString({ eventId: linkedEvent.event, orgUnitId })}`);
setIsActionsOpen(false);
};

Expand Down
2 changes: 1 addition & 1 deletion src/core_modules/capture-core/flow/typeDeclarations.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,5 +210,5 @@ declare type ApiUtils = {|
mutate: DataEngineMutate,
absoluteApiPath: string,
serverVersion: { minor: number },
navigate: (path: string) => void,
navigate: (path: string, scrollToTop?: boolean) => void,
|};
2 changes: 1 addition & 1 deletion src/store/getStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { reducerDescriptions } from '../reducers/descriptions/trackerCapture.red
import { epics } from '../epics/trackerCapture.epics';

export function getStore(
navigate: (path: string) => void,
navigate: (path: string, scrollToTop?: boolean) => void,
apiUtils: ApiUtilsWithoutHistory,
onRehydrated: () => void) {
const reducersFromDescriptions = buildReducersFromDescriptions(reducerDescriptions);
Expand Down

0 comments on commit a3df443

Please sign in to comment.