Skip to content

Commit

Permalink
Merge pull request #1526 from dhis2/DHIS2-10326
Browse files Browse the repository at this point in the history
feat: DHIS2-10326 open enrollment from working list
  • Loading branch information
JoakimSM authored Feb 25, 2021
2 parents 7bc6eb6 + 22be83e commit ebe8ed7
Showing 1 changed file with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// @flow
import React, { useCallback } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { useLocation } from 'react-router';
import { navigateToTrackedEntityDashboard } from '../../../../../utils/navigateToTrackedEntityDashboard';
import { TeiWorkingListsSetup } from '../Setup';
import { useWorkingListsCommonStateManagement, fetchTemplatesSuccess, fetchTemplates } from '../../WorkingListsCommon';
import { useTrackerProgram } from '../../../../../hooks/useTrackerProgram';
Expand All @@ -12,31 +14,43 @@ export const TeiWorkingListsReduxProvider = ({ storeId }: Props) => {
const program = useTrackerProgram(programId);

// Being pragmatic here, disabling behavior we will implement later
const commonStateManagementProps: Object = useWorkingListsCommonStateManagement(storeId, TEI_WORKING_LISTS_TYPE, program);
const {
orgUnitId,
lastTransaction,
lastTransactionOnListDataRefresh,
listDataRefreshTimestamp,
onAddTemplate,
onUpdateTemplate,
onDeleteTemplate,
onSetTemplateSharingSettings,
...commonStateManagementProps
} = useWorkingListsCommonStateManagement(storeId, TEI_WORKING_LISTS_TYPE, program);

const dispatch = useDispatch();

const onLoadTemplates = useCallback(() => {
dispatch(fetchTemplates(programId, storeId, TEI_WORKING_LISTS_TYPE));
dispatch(fetchTemplatesSuccess([], 'default', storeId));
}, [dispatch, programId, storeId]);
const onSelectListRow = useCallback(() => {}, []);

// will be implemented later
delete commonStateManagementProps.lastTransaction;
delete commonStateManagementProps.lastTransactionOnListDataRefresh;
delete commonStateManagementProps.listDataRefreshTimestamp;
delete commonStateManagementProps.onAddTemplate;
delete commonStateManagementProps.onUpdateTemplate;
delete commonStateManagementProps.onDeleteTemplate;
// ----------------------------------------------------------------

const { pathname, search } = useLocation();
const onSelectListRow = useCallback(({ id }) => {
navigateToTrackedEntityDashboard(
id,
orgUnitId,
`program=${programId}`,
`${pathname}${search}`,
);
}, [orgUnitId, programId, pathname, search]);

return (
<TeiWorkingListsSetup
{...commonStateManagementProps}
onSelectListRow={onSelectListRow}
onLoadTemplates={onLoadTemplates}
program={program}
orgUnitId={orgUnitId}
/>
);
};

0 comments on commit ebe8ed7

Please sign in to comment.