Skip to content

Commit

Permalink
test: [DHIS2-15782] checks for viewPreloaded and currentTempleteId
Browse files Browse the repository at this point in the history
  • Loading branch information
simonadomnisoru committed Oct 5, 2023
1 parent 814e99e commit 13d0063
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export const TeiWorkingListsReduxProvider = ({
onDeleteTemplate,
onUpdateDefaultTemplate,
programStage,
currentTemplateId,
viewPreloaded,
...commonStateManagementProps
} = useWorkingListsCommonStateManagement(storeId, TEI_WORKING_LISTS_TYPE, program);
const dispatch = useDispatch();
Expand All @@ -47,12 +49,15 @@ export const TeiWorkingListsReduxProvider = ({
}, [dispatch, programId, storeId, selectedTemplateId]);

useEffect(() => {
selectedTemplateId &&
selectedTemplateId !== `${programId}-default` &&
onSelectTemplate &&
onSelectTemplate(selectedTemplateId);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
// This hook should only fire when you navigate from the search page to the main page with a working list selected
if (selectedTemplateId &&
selectedTemplateId !== currentTemplateId &&
!viewPreloaded &&
onSelectTemplate
) {
onSelectTemplate(selectedTemplateId);
}
}, [selectedTemplateId, viewPreloaded, currentTemplateId, onSelectTemplate]);

const onSelectListRow = useCallback(({ id }) => {
const record = records[id];
Expand Down Expand Up @@ -95,6 +100,8 @@ export const TeiWorkingListsReduxProvider = ({
return (
<TeiWorkingListsSetup
{...commonStateManagementProps}
currentTemplateId={currentTemplateId}
viewPreloaded={viewPreloaded}
templateSharingType={templateSharingType}
onSelectListRow={onSelectListRow}
onLoadTemplates={onLoadTemplates}
Expand Down

0 comments on commit 13d0063

Please sign in to comment.