diff --git a/plugin-hrm-form/src/components/tabbedForms/ContactlessTaskTab.tsx b/plugin-hrm-form/src/components/tabbedForms/ContactlessTaskTab.tsx index e8d41ba192..aefa553f98 100644 --- a/plugin-hrm-form/src/components/tabbedForms/ContactlessTaskTab.tsx +++ b/plugin-hrm-form/src/components/tabbedForms/ContactlessTaskTab.tsx @@ -24,15 +24,16 @@ import type { DefinitionVersion } from 'hrm-form-definitions'; import { disperseInputs } from '../common/forms/formGenerators'; import { useCreateFormFromDefinition } from '../forms'; -import { Container, ColumnarBlock, TwoColumnLayout, ColumnarContent } from '../../styles/HrmStyles'; +import { ColumnarBlock, ColumnarContent, Container, TwoColumnLayout } from '../../styles/HrmStyles'; import { RootState } from '../../states'; import { selectWorkerSid } from '../../states/selectors/flexSelectors'; import { createContactlessTaskTabDefinition } from './ContactlessTaskTabDefinition'; import { splitDate, splitTime } from '../../utils/helpers'; import type { ContactRawJson, OfflineContactTask } from '../../types/types'; import { updateDraft } from '../../states/contacts/existingContacts'; -import { configurationBase, contactFormsBase, namespace } from '../../states/storeNamespaces'; +import { configurationBase, namespace } from '../../states/storeNamespaces'; import { getUnsavedContact } from '../../states/contacts/getUnsavedContact'; +import selectContactByTaskSid from '../../states/contacts/selectContactByTaskSid'; type OwnProps = { task: OfflineContactTask; @@ -44,10 +45,7 @@ type OwnProps = { }; const mapStateToProps = (state: RootState, { task }: OwnProps) => { - const { savedContact, draftContact } = - Object.values(state[namespace][contactFormsBase].existingContacts).find( - cs => cs.savedContact.taskId === task.taskSid, - ) ?? {}; + const { savedContact, draftContact } = selectContactByTaskSid(state, task.taskSid) ?? {}; return { counselorsList: state[namespace][configurationBase].counselors.list, unsavedContact: getUnsavedContact(savedContact, draftContact),