diff --git a/src/components/Coaching/CoachingDetail/LevelOfEffort/LevelOfEffort.test.tsx b/src/components/Coaching/CoachingDetail/LevelOfEffort/LevelOfEffort.test.tsx index faf7a895b..a1c1d710c 100644 --- a/src/components/Coaching/CoachingDetail/LevelOfEffort/LevelOfEffort.test.tsx +++ b/src/components/Coaching/CoachingDetail/LevelOfEffort/LevelOfEffort.test.tsx @@ -72,7 +72,7 @@ describe('LevelOfEffort', () => { const initiationSocialMediaRow = rows[6]; expect(initiationSocialMediaRow.children[0]).toHaveTextContent( - 'Social Media', + 'Social Media Message', ); expect(initiationSocialMediaRow.children[1]).toHaveTextContent('34'); expect(initiationSocialMediaRow.children[2]).toHaveTextContent('14'); @@ -96,7 +96,7 @@ describe('LevelOfEffort', () => { expect(followUpTextRow.children[5]).toHaveTextContent('18'); const thankRow = rows[21]; - expect(thankRow.children[0]).toHaveTextContent('Thank You Note'); + expect(thankRow.children[0]).toHaveTextContent('Thank'); expect(thankRow.children[1]).toHaveTextContent('33'); expect(thankRow.children[2]).toHaveTextContent('13'); expect(thankRow.children[3]).toHaveTextContent('3'); diff --git a/src/components/Coaching/CoachingDetail/LevelOfEffort/LevelOfEffort.tsx b/src/components/Coaching/CoachingDetail/LevelOfEffort/LevelOfEffort.tsx index 7812328a5..fbed2428b 100644 --- a/src/components/Coaching/CoachingDetail/LevelOfEffort/LevelOfEffort.tsx +++ b/src/components/Coaching/CoachingDetail/LevelOfEffort/LevelOfEffort.tsx @@ -17,7 +17,6 @@ import { PhaseEnum } from 'src/graphql/types.generated'; import { useLocale } from 'src/hooks/useLocale'; import { usePhaseData } from 'src/hooks/usePhaseData'; import { snakeToCamel } from 'src/lib/snakeToCamel'; -import { getLocalizedTaskType } from 'src/utils/functions/getLocalizedTaskType'; import { MultilineSkeleton } from '../../../Shared/MultilineSkeleton'; import { CoachingPeriodEnum } from '../CoachingDetail'; import { AlignedTableCell, DividerRow, HeaderRow } from '../StyledComponents'; @@ -40,7 +39,7 @@ export const LevelOfEffort: React.FC = ({ }) => { const { t } = useTranslation(); const locale = useLocale(); - const { activitiesByPhase } = usePhaseData(); + const { activitiesByPhase, activityTypes } = usePhaseData(); const { data, loading } = useLevelOfEffortQuery({ variables: { @@ -181,7 +180,7 @@ export const LevelOfEffort: React.FC = ({ 'number' ? ( - {getLocalizedTaskType(t, activity)} + {activityTypes.get(activity)?.translatedShortName} {periods.map((period) => ( @@ -220,7 +219,7 @@ export const LevelOfEffort: React.FC = ({ 'number' ? ( - {getLocalizedTaskType(t, activity)} + {activityTypes.get(activity)?.translatedShortName} {periods.map((period) => ( @@ -254,7 +253,7 @@ export const LevelOfEffort: React.FC = ({ return typeof averages[activityVariableName] === 'number' ? ( - {getLocalizedTaskType(t, activity)} + {activityTypes.get(activity)?.translatedShortName} {periods.map((period) => ( @@ -293,7 +292,7 @@ export const LevelOfEffort: React.FC = ({ 'number' ? ( - {getLocalizedTaskType(t, activity)} + {activityTypes.get(activity)?.translatedShortName} {periods.map((period) => ( diff --git a/src/components/Constants/LoadConstants.graphql b/src/components/Constants/LoadConstants.graphql index 43ca73c1a..4381d025c 100644 --- a/src/components/Constants/LoadConstants.graphql +++ b/src/components/Constants/LoadConstants.graphql @@ -4,6 +4,11 @@ query LoadConstants { id value name + action + } + displayResults { + id + value } languages { id @@ -73,6 +78,7 @@ query LoadConstants { result } name + value suggestedContactStatus suggestedNextActions } diff --git a/src/components/Constants/LoadConstantsMock.ts b/src/components/Constants/LoadConstantsMock.ts index 6698f5c41..af253fbbe 100644 --- a/src/components/Constants/LoadConstantsMock.ts +++ b/src/components/Constants/LoadConstantsMock.ts @@ -90,136 +90,228 @@ export const loadConstantsMockData: LoadConstantsQuery = { ], activities: [ { + action: 'Phone Call', id: ActivityTypeEnum.InitiationPhoneCall, name: 'Phone call to initiate appointment', value: 'Initiation - Phone Call', }, { + action: 'Email', id: ActivityTypeEnum.InitiationEmail, name: 'Email to initiate', value: 'Initiation - Email', }, { + action: 'Text Message', id: ActivityTypeEnum.InitiationTextMessage, name: 'Text message to initiate', value: 'Initiation - Text Message', }, { + action: 'Social Media Message', id: ActivityTypeEnum.InitiationSocialMedia, name: 'Social media message to initiate', - value: 'Initiation - Social Media', + value: 'Initiation - Social Media Message', }, { + action: 'Letter', id: ActivityTypeEnum.InitiationLetter, name: 'Letter to initiate', value: 'Initiation - Letter', }, { + action: 'Special Gift Appeal', id: ActivityTypeEnum.InitiationSpecialGiftAppeal, name: 'Special gift appeal', value: 'Initiation - Special Gift Appeal', }, { + action: 'In Person', id: ActivityTypeEnum.InitiationInPerson, name: 'Initiate in person', value: 'Initiation - In Person', }, { + action: 'In Person', id: ActivityTypeEnum.AppointmentInPerson, name: 'In person appointment', value: 'Appointment - In Person', }, { + action: 'Phone Call', id: ActivityTypeEnum.AppointmentPhoneCall, name: 'phone appointment', value: 'Appointment - Phone Call', }, { + action: 'Video Call', id: ActivityTypeEnum.AppointmentVideoCall, name: 'video appointment', value: 'Appointment - Video Call', }, { + action: 'Phone Call', id: ActivityTypeEnum.FollowUpPhoneCall, name: 'phone call to follow up', - value: 'Follow-Up - Phone Call', + value: 'Follow Up - Phone Call', }, { + action: 'Email', id: ActivityTypeEnum.FollowUpEmail, name: 'email to follow up', - value: 'Follow-Up - Email', + value: 'Follow Up - Email', }, { + action: 'Text Message', id: ActivityTypeEnum.FollowUpTextMessage, name: 'text message to follow up', - value: 'Follow-Up - Text Message', + value: 'Follow Up - Text Message', }, { + action: 'Social Media Message', id: ActivityTypeEnum.FollowUpSocialMedia, name: 'social media message to follow up', - value: 'Follow-Up - Social Media', + value: 'Follow Up - Social Media Message', }, { + action: 'In Person', id: ActivityTypeEnum.FollowUpInPerson, name: 'follow up in person', - value: 'Follow-Up - In Person', + value: 'Follow Up - In Person', }, { + action: 'Phone Call', id: ActivityTypeEnum.PartnerCarePhoneCall, name: 'call partner for cultivation', value: 'Partner Care - Phone Call', }, { + action: 'Email', id: ActivityTypeEnum.PartnerCareEmail, name: 'email partner for cultivation', value: 'Partner Care - Email', }, { + action: 'Text Message', id: ActivityTypeEnum.PartnerCareTextMessage, name: 'text message partner for cultivation', value: 'Partner Care - Text Message', }, { + action: 'Social Media Message', id: ActivityTypeEnum.PartnerCareSocialMedia, name: 'social media message for cultivation', - value: 'Partner Care - Social Media', + value: 'Partner Care - Social Media Message', }, { + action: 'In Person', id: ActivityTypeEnum.PartnerCareInPerson, name: 'connect in person for cultivation', value: 'Partner Care - In Person', }, { + action: 'Thank', id: ActivityTypeEnum.PartnerCareThank, name: 'send thank you note', - value: 'Partner Care - Thank You Note', + value: 'Partner Care - Thank', }, { + action: 'Digital Newsletter', id: ActivityTypeEnum.PartnerCareDigitalNewsletter, name: 'send digital newsletter', value: 'Partner Care - Digital Newsletter', }, { + action: 'Physical Newsletter', id: ActivityTypeEnum.PartnerCarePhysicalNewsletter, name: 'send physical newsletter', value: 'Partner Care - Physical Newsletter', }, { + action: 'Prayer Request', id: ActivityTypeEnum.PartnerCarePrayerRequest, name: 'ask for or receive prayer request', value: 'Partner Care - Prayer Request', }, { + action: 'Update Information', id: ActivityTypeEnum.PartnerCareUpdateInformation, name: 'update partner information', value: 'Partner Care - Update Information', }, { + action: 'To Do', id: ActivityTypeEnum.PartnerCareToDo, - name: '', + name: 'To Do', value: 'Partner Care - To Do', }, ], + displayResults: [ + { + id: 'INITIATION_RESULT_NO_RESPONSE', + value: 'No Response Yet', + }, + { + id: 'INITIATION_RESULT_CIRCLE_BACK', + value: 'Can not meet right now - circle back', + }, + { + id: 'INITIATION_RESULT_APPOINTMENT_SCHEDULED', + value: 'Appointment Scheduled', + }, + { + id: 'INITIATION_RESULT_NOT_INTERESTED', + value: 'Not Interested', + }, + { + id: 'FOLLOW_UP_RESULT_NO_RESPONSE', + value: 'No Response Yet', + }, + { + id: 'FOLLOW_UP_RESULT_PARTNER_FINANCIAL', + value: 'Partner - Financial', + }, + { + id: 'FOLLOW_UP_RESULT_PARTNER_SPECIAL', + value: 'Partner - Special', + }, + { + id: 'FOLLOW_UP_RESULT_PARTNER_PRAY', + value: 'Partner - Pray', + }, + { + id: 'FOLLOW_UP_RESULT_NOT_INTERESTED', + value: 'Not Interested', + }, + { + id: 'APPOINTMENT_RESULT_CANCELLED', + value: 'Cancelled', + }, + { + id: 'APPOINTMENT_RESULT_FOLLOW_UP', + value: 'Follow Up', + }, + { + id: 'APPOINTMENT_RESULT_PARTNER_FINANCIAL', + value: 'Partner - Financial', + }, + { + id: 'APPOINTMENT_RESULT_PARTNER_SPECIAL', + value: 'Partner - Special', + }, + { + id: 'APPOINTMENT_RESULT_PARTNER_PRAY', + value: 'Partner - Pray', + }, + { + id: 'APPOINTMENT_RESULT_NOT_INTERESTED', + value: 'Not Interested', + }, + { + id: 'PARTNER_CARE_COMPLETED', + value: 'Completed', + }, + ], phases: [ { @@ -275,6 +367,7 @@ export const loadConstantsMockData: LoadConstantsQuery = { }, ], name: DisplayResultEnum.InitiationResultNoResponse, + value: 'No Response Yet', suggestedContactStatus: null, suggestedNextActions: [ ActivityTypeEnum.InitiationPhoneCall, @@ -318,6 +411,7 @@ export const loadConstantsMockData: LoadConstantsQuery = { }, ], name: DisplayResultEnum.InitiationResultCircleBack, + value: 'Can not meet right now - circle back', suggestedContactStatus: null, suggestedNextActions: [ ActivityTypeEnum.InitiationPhoneCall, @@ -361,6 +455,7 @@ export const loadConstantsMockData: LoadConstantsQuery = { }, ], name: DisplayResultEnum.InitiationResultAppointmentScheduled, + value: 'Appointment Scheduled', suggestedContactStatus: StatusEnum.AppointmentScheduled, suggestedNextActions: [ ActivityTypeEnum.AppointmentInPerson, @@ -400,6 +495,7 @@ export const loadConstantsMockData: LoadConstantsQuery = { }, ], name: DisplayResultEnum.InitiationResultNotInterested, + value: 'Not Interested', suggestedContactStatus: StatusEnum.NotInterested, suggestedNextActions: [], }, @@ -438,6 +534,7 @@ export const loadConstantsMockData: LoadConstantsQuery = { }, ], name: DisplayResultEnum.AppointmentResultCancelled, + value: 'Cancelled', suggestedContactStatus: StatusEnum.ContactForAppointment, suggestedNextActions: [ ActivityTypeEnum.InitiationPhoneCall, @@ -465,6 +562,7 @@ export const loadConstantsMockData: LoadConstantsQuery = { }, ], name: DisplayResultEnum.AppointmentResultFollowUp, + value: 'Follow Up', suggestedContactStatus: StatusEnum.CallForDecision, suggestedNextActions: [ ActivityTypeEnum.FollowUpPhoneCall, @@ -490,6 +588,7 @@ export const loadConstantsMockData: LoadConstantsQuery = { }, ], name: DisplayResultEnum.FollowUpResultPartnerFinancial, + value: 'Partner - Financial', suggestedContactStatus: StatusEnum.PartnerFinancial, suggestedNextActions: [ActivityTypeEnum.PartnerCareThank], }, @@ -509,6 +608,7 @@ export const loadConstantsMockData: LoadConstantsQuery = { }, ], name: DisplayResultEnum.FollowUpResultPartnerSpecial, + value: 'Partner - Special', suggestedContactStatus: StatusEnum.PartnerSpecial, suggestedNextActions: [ActivityTypeEnum.PartnerCareThank], }, @@ -528,6 +628,7 @@ export const loadConstantsMockData: LoadConstantsQuery = { }, ], name: DisplayResultEnum.FollowUpResultPartnerPray, + value: 'Partner - Pray', suggestedContactStatus: StatusEnum.PartnerPray, suggestedNextActions: [ActivityTypeEnum.PartnerCareThank], }, @@ -547,6 +648,7 @@ export const loadConstantsMockData: LoadConstantsQuery = { }, ], name: DisplayResultEnum.FollowUpResultNotInterested, + value: 'Not Interested', suggestedContactStatus: StatusEnum.NotInterested, suggestedNextActions: [], }, @@ -606,6 +708,7 @@ export const loadConstantsMockData: LoadConstantsQuery = { }, ], name: DisplayResultEnum.InitiationResultNoResponse, + value: 'No Response Yet', suggestedContactStatus: null, suggestedNextActions: [ ActivityTypeEnum.FollowUpPhoneCall, @@ -639,6 +742,7 @@ export const loadConstantsMockData: LoadConstantsQuery = { }, ], name: DisplayResultEnum.FollowUpResultPartnerFinancial, + value: 'Partner - Financial', suggestedContactStatus: StatusEnum.PartnerFinancial, suggestedNextActions: [ActivityTypeEnum.PartnerCareThank], }, @@ -666,6 +770,7 @@ export const loadConstantsMockData: LoadConstantsQuery = { }, ], name: DisplayResultEnum.FollowUpResultPartnerSpecial, + value: 'Partner - Special', suggestedContactStatus: StatusEnum.PartnerSpecial, suggestedNextActions: [ActivityTypeEnum.PartnerCareThank], }, @@ -693,6 +798,7 @@ export const loadConstantsMockData: LoadConstantsQuery = { }, ], name: DisplayResultEnum.FollowUpResultPartnerPray, + value: 'Partner - Pray', suggestedContactStatus: StatusEnum.PartnerPray, suggestedNextActions: [ActivityTypeEnum.PartnerCareThank], }, @@ -720,6 +826,7 @@ export const loadConstantsMockData: LoadConstantsQuery = { }, ], name: DisplayResultEnum.FollowUpResultNotInterested, + value: 'Not Interested', suggestedContactStatus: StatusEnum.NotInterested, suggestedNextActions: [], }, @@ -813,6 +920,7 @@ export const loadConstantsMockData: LoadConstantsQuery = { }, ], name: DisplayResultEnum.PartnerCareCompleted, + value: 'Completed', suggestedContactStatus: null, suggestedNextActions: [ ActivityTypeEnum.PartnerCarePhoneCall, diff --git a/src/components/Contacts/ContactDetails/ContactTasksTab/ContactTaskRow/ContactTaskRow.tsx b/src/components/Contacts/ContactDetails/ContactTasksTab/ContactTaskRow/ContactTaskRow.tsx index f6095f5f5..159440323 100644 --- a/src/components/Contacts/ContactDetails/ContactTasksTab/ContactTaskRow/ContactTaskRow.tsx +++ b/src/components/Contacts/ContactDetails/ContactTasksTab/ContactTaskRow/ContactTaskRow.tsx @@ -186,11 +186,7 @@ export const ContactTaskRow: React.FC = ({ onClick={handleSubjectPressed} onMouseEnter={() => preloadTaskModal(TaskModalEnum.Edit)} > - + {subject} diff --git a/src/components/Dashboard/ThisWeek/TasksDueThisWeek/TasksDueThisWeek.tsx b/src/components/Dashboard/ThisWeek/TasksDueThisWeek/TasksDueThisWeek.tsx index 8a68ed87e..297f11585 100644 --- a/src/components/Dashboard/ThisWeek/TasksDueThisWeek/TasksDueThisWeek.tsx +++ b/src/components/Dashboard/ThisWeek/TasksDueThisWeek/TasksDueThisWeek.tsx @@ -171,8 +171,8 @@ const TasksDueThisWeek = ({ marginRight="5px" > {!!task.activityType && - (activityTypes.get(task.activityType)?.title || - '')} + activityTypes.get(task.activityType) + ?.translatedFullName} ( id: '123', key: 'saved_contacts_filter_My_Cool_Filter', value: - '{"any_tags":false,"account_list_id":"08bb09d1-3b62-4690-9596-b625b8af4750","params":{"status":"never_contacted,ACTIVE,HIDDEN,NULL,partner_financial,Appointment Scheduled", "completed":"true", "overdue": "true", "primaryAddress": "primary, null", "reverseActivityType": "true", "reverseContactAppeal": "true", "reverseContactChurch": "true", "reverseContactCity": "true", "reverseContactCountry": "true", "reverseContactDesignationAccountId": "true", "reverseContactIds": "true", "reverseContactLikely": "true", "reverseContactMetroArea": "true", "reverseContactPledgeFrequency": "true", "reverseContactReferrer": "true", "reverseContactRegion": "true", "reverseContactState": "true", "reverseContactStatus": "true", "reverseContactTimezone": "true", "reverseContactType": "true", "reverseNextAction": "true", "reverseResult": "true", "reverseTags": "true", "reverseUserIds": "true", "contactChurch": "test1, test2", "contactCity": "test1", "contactCountry": "test1, test2", "contactDesignationAccountId": "test1, test2", "contactLikely": "test1, test2", "contactMetroArea": "test1, test2", "contactPledgeFrequency": "test1, test2", "contactReferrer": "test1, test2", "contactRegion": "test1, test2", "contactState": "test1", "contactTimezone": "test1, test2", "reverse_alma_mater": "false","contactNewsletter":"all","notes":{"wildcardNoteSearch": "note1"}, "activity_type": "appointment_in_person,Partner Care - Social Media", "result": "Attempted,Attempted - Left Message,Completed,Done,None,Received", "pledge_received":"true","pledge_amount":"35.0,40.0","pledge_currency":"USD","pledge_frequency":"0.46153846153846,1.0","pledge_late_by":"30_60","newsletter":"no_value","referrer":"d5b1dab5-e3ae-417d-8f49-2abdd915515b","city":"Evansville,Woodstock","state":"FL","country":"United States","metro_area":"Cool","region":"Orange County","contact_info_email":"Yes","contact_info_phone":"No","contact_info_mobile":"No","contact_info_work_phone":"No","contact_info_addr":"Yes","contact_info_facebook":"No","opt_out":"No","church":"Cool Church II","appeal":"851769ba-b55d-45f3-b784-c4eca7ae99fd,77491693-df83-46ec-b40b-39d07333f47e","timezone":"America/Vancouver","locale":"English","donation":"first","donation_date":"2021-12-23..2021-12-23","next_ask":"2021-11-30..2021-12-22","user_ids":"787f286e-fe38-4055-b9fc-0177a0f55947","reverse_appeal":true,"contact_types": "person"},"tags":null,"exclude_tags":null,"wildcard_search":""}', + '{"any_tags":false,"account_list_id":"08bb09d1-3b62-4690-9596-b625b8af4750","params":{"status":"never_contacted,ACTIVE,HIDDEN,NULL,partner_financial,Appointment Scheduled", "completed":"true", "overdue": "true", "primaryAddress": "primary, null", "reverseActivityType": "true", "reverseContactAppeal": "true", "reverseContactChurch": "true", "reverseContactCity": "true", "reverseContactCountry": "true", "reverseContactDesignationAccountId": "true", "reverseContactIds": "true", "reverseContactLikely": "true", "reverseContactMetroArea": "true", "reverseContactPledgeFrequency": "true", "reverseContactReferrer": "true", "reverseContactRegion": "true", "reverseContactState": "true", "reverseContactStatus": "true", "reverseContactTimezone": "true", "reverseContactType": "true", "reverseNextAction": "true", "reverseResult": "true", "reverseTags": "true", "reverseUserIds": "true", "contactChurch": "test1, test2", "contactCity": "test1", "contactCountry": "test1, test2", "contactDesignationAccountId": "test1, test2", "contactLikely": "test1, test2", "contactMetroArea": "test1, test2", "contactPledgeFrequency": "test1, test2", "contactReferrer": "test1, test2", "contactRegion": "test1, test2", "contactState": "test1", "contactTimezone": "test1, test2", "reverse_alma_mater": "false","contactNewsletter":"all","notes":{"wildcardNoteSearch": "note1"}, "activity_type": "appointment_in_person,Partner Care - Social Media Message", "result": "Attempted,Attempted - Left Message,Completed,Done,None,Received", "pledge_received":"true","pledge_amount":"35.0,40.0","pledge_currency":"USD","pledge_frequency":"0.46153846153846,1.0","pledge_late_by":"30_60","newsletter":"no_value","referrer":"d5b1dab5-e3ae-417d-8f49-2abdd915515b","city":"Evansville,Woodstock","state":"FL","country":"United States","metro_area":"Cool","region":"Orange County","contact_info_email":"Yes","contact_info_phone":"No","contact_info_mobile":"No","contact_info_work_phone":"No","contact_info_addr":"Yes","contact_info_facebook":"No","opt_out":"No","church":"Cool Church II","appeal":"851769ba-b55d-45f3-b784-c4eca7ae99fd,77491693-df83-46ec-b40b-39d07333f47e","timezone":"America/Vancouver","locale":"English","donation":"first","donation_date":"2021-12-23..2021-12-23","next_ask":"2021-11-30..2021-12-22","user_ids":"787f286e-fe38-4055-b9fc-0177a0f55947","reverse_appeal":true,"contact_types": "person"},"tags":null,"exclude_tags":null,"wildcard_search":""}', }, }, ); diff --git a/src/components/Task/Modal/Form/Complete/TaskModalCompleteForm.test.tsx b/src/components/Task/Modal/Form/Complete/TaskModalCompleteForm.test.tsx index 6c2452591..ded0932b5 100644 --- a/src/components/Task/Modal/Form/Complete/TaskModalCompleteForm.test.tsx +++ b/src/components/Task/Modal/Form/Complete/TaskModalCompleteForm.test.tsx @@ -117,14 +117,12 @@ describe('TaskModalCompleteForm', () => { userEvent.click(resultDropdown); await waitFor(() => { - expect( - getByRole('option', { name: 'Cancelled-Need to reschedule' }), - ).toBeInTheDocument(); + expect(getByRole('option', { name: 'Cancelled' })).toBeInTheDocument(); expect( getByRole('option', { name: 'Not Interested' }), ).toBeInTheDocument(); expect( - getByRole('option', { name: 'Partner-Financial' }), + getByRole('option', { name: 'Partner - Financial' }), ).toBeInTheDocument(); }); }); @@ -139,9 +137,7 @@ describe('TaskModalCompleteForm', () => { const resultDropdown = await findByRole('combobox', { name: 'Result' }); userEvent.click(resultDropdown); - userEvent.click( - await findByRole('option', { name: 'Cancelled-Need to reschedule' }), - ); + userEvent.click(await findByRole('option', { name: 'Cancelled' })); await waitFor(() => { expect( @@ -165,9 +161,7 @@ describe('TaskModalCompleteForm', () => { const resultDropdown = await findByRole('combobox', { name: 'Result' }); userEvent.click(resultDropdown); await waitFor(() => { - userEvent.click( - getByRole('option', { name: 'Cancelled-Need to reschedule' }), - ); + userEvent.click(getByRole('option', { name: 'Cancelled' })); }); expect( @@ -193,7 +187,7 @@ describe('TaskModalCompleteForm', () => { userEvent.click(resultDropdown); await waitFor(() => { userEvent.click( - getByRole('option', { name: "Can't meet right now - circle back" }), + getByRole('option', { name: 'Can not meet right now - circle back' }), ); }); @@ -232,7 +226,7 @@ describe('TaskModalCompleteForm', () => { const resultDropdown = await findByRole('combobox', { name: 'Result' }); userEvent.click(resultDropdown); await waitFor(() => { - userEvent.click(getByRole('option', { name: 'Partner-Financial' })); + userEvent.click(getByRole('option', { name: 'Partner - Financial' })); }); const nextActionDropdown = getByRole('combobox', { name: 'Next Action' }); @@ -240,9 +234,7 @@ describe('TaskModalCompleteForm', () => { await waitFor(() => { expect(getByRole('option', { name: 'None' })).toBeInTheDocument(); - expect( - getByRole('option', { name: 'Thank You Note' }), - ).toBeInTheDocument(); + expect(getByRole('option', { name: 'Thank' })).toBeInTheDocument(); expect( queryByRole('option', { name: 'In Person' }), @@ -254,18 +246,18 @@ describe('TaskModalCompleteForm', () => { userEvent.click(resultDropdown); await waitFor(() => { - userEvent.click(getByRole('option', { name: 'Follow up' })); + userEvent.click(getByRole('option', { name: 'Follow Up' })); }); userEvent.click(nextActionDropdown); await waitFor(() => { expect( - queryByRole('option', { name: 'Thank You Note' }), + queryByRole('option', { name: 'Thank' }), ).not.toBeInTheDocument(); expect( - getAllByRole('option', { name: 'Social Media' })[0], + getAllByRole('option', { name: 'Social Media Message' })[0], ).toBeInTheDocument(); expect(getByRole('option', { name: 'Phone Call' })).toBeInTheDocument(); @@ -300,7 +292,7 @@ describe('TaskModalCompleteForm', () => { ).not.toBeInTheDocument(); userEvent.click(await findByRole('combobox', { name: 'Result' })); - userEvent.click(await findByRole('option', { name: 'Follow up' })); + userEvent.click(await findByRole('option', { name: 'Follow Up' })); expect( getByRole('combobox', { name: 'Next Action' }), @@ -348,9 +340,9 @@ describe('TaskModalCompleteForm', () => { userEvent.click(getByRole('combobox', { name: 'Result' })); }); await waitFor(() => { - userEvent.click(getByText('Partner-Special')); + userEvent.click(getByText('Partner - Special')); userEvent.click(getByRole('combobox', { name: 'Next Action' })); - userEvent.click(getByRole('option', { name: 'Thank You Note' })); + userEvent.click(getByRole('option', { name: 'Thank' })); }); expect(getByText('Suggested Tags')).toBeInTheDocument(); @@ -397,9 +389,9 @@ describe('TaskModalCompleteForm', () => { />, ); userEvent.click(await findByRole('combobox', { name: 'Result' })); - userEvent.click(await findByRole('option', { name: 'Partner-Special' })); + userEvent.click(await findByRole('option', { name: 'Partner - Special' })); userEvent.click(await findByRole('combobox', { name: 'Next Action' })); - userEvent.click(await findByRole('option', { name: 'Thank You Note' })); + userEvent.click(await findByRole('option', { name: 'Thank' })); userEvent.click( await findByRole('checkbox', { diff --git a/src/components/Task/Modal/Form/Complete/TaskModalCompleteForm.tsx b/src/components/Task/Modal/Form/Complete/TaskModalCompleteForm.tsx index 67579cf5f..0bfedfbd2 100644 --- a/src/components/Task/Modal/Form/Complete/TaskModalCompleteForm.tsx +++ b/src/components/Task/Modal/Form/Complete/TaskModalCompleteForm.tsx @@ -31,7 +31,6 @@ import { usePhaseData } from 'src/hooks/usePhaseData'; import { useUpdateTasksQueries } from 'src/hooks/useUpdateTasksQueries'; import { dispatch } from 'src/lib/analytics'; import { nullableDateTime } from 'src/lib/formikHelpers'; -import { getLocalizedTaskType } from 'src/utils/functions/getLocalizedTaskType'; import { getValueFromIdValue } from 'src/utils/phases/getValueFromIdValue'; import { getPhaseByActivityType, @@ -306,8 +305,7 @@ const TaskModalCompleteForm = ({ - {activityData ? activityData.phase + ' - ' : ''} - {getLocalizedTaskType(t, activityType)} + {activityData ? activityData.translatedFullName : ''} @@ -387,7 +385,6 @@ const TaskModalCompleteForm = ({ onChange={(nextAction) => setFieldValue('nextAction', nextAction) } - activityTypes={activityTypes} /> )} diff --git a/src/components/Task/Modal/Form/Inputs/ActivityTypeAutocomplete/ActivityTypeAutocomplete.test.tsx b/src/components/Task/Modal/Form/Inputs/ActivityTypeAutocomplete/ActivityTypeAutocomplete.test.tsx index 67470e8f3..7be072050 100644 --- a/src/components/Task/Modal/Form/Inputs/ActivityTypeAutocomplete/ActivityTypeAutocomplete.test.tsx +++ b/src/components/Task/Modal/Form/Inputs/ActivityTypeAutocomplete/ActivityTypeAutocomplete.test.tsx @@ -1,9 +1,6 @@ import { render, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import { loadConstantsMockData } from 'src/components/Constants/LoadConstantsMock'; import { ActivityTypeEnum } from 'src/graphql/types.generated'; -import i18n from 'src/lib/i18n'; -import { getLocalizedTaskType } from 'src/utils/functions/getLocalizedTaskType'; import { ActivityTypeAutocomplete } from './ActivityTypeAutocomplete'; describe('ActivityTypeAutocomplete', () => { @@ -14,21 +11,6 @@ describe('ActivityTypeAutocomplete', () => { ]; const allOptions = Object.values(ActivityTypeEnum); - const activitiesMap = new Map(); - - loadConstantsMockData?.constant.phases?.forEach((phase) => { - phase?.tasks?.forEach((task) => { - activitiesMap.set(task, { - name: getLocalizedTaskType(i18n.t, task), - phaseId: phase.id, - phase: phase.name, - title: loadConstantsMockData?.constant?.activities?.find( - (activity) => activity.id === task, - )?.value, - }); - }); - }); - it('puts the none option first', () => { const onChange = jest.fn(); @@ -91,7 +73,6 @@ describe('ActivityTypeAutocomplete', () => { label="Type" value={ActivityTypeEnum.AppointmentPhoneCall} onChange={onChange} - activityTypes={activitiesMap} />, ); diff --git a/src/components/Task/Modal/Form/Inputs/ActivityTypeAutocomplete/ActivityTypeAutocomplete.tsx b/src/components/Task/Modal/Form/Inputs/ActivityTypeAutocomplete/ActivityTypeAutocomplete.tsx index 3bebebfee..70e4ca263 100644 --- a/src/components/Task/Modal/Form/Inputs/ActivityTypeAutocomplete/ActivityTypeAutocomplete.tsx +++ b/src/components/Task/Modal/Form/Inputs/ActivityTypeAutocomplete/ActivityTypeAutocomplete.tsx @@ -3,8 +3,7 @@ import { Autocomplete, TextField } from '@mui/material'; import { FormikErrors, FormikTouched } from 'formik'; import { useTranslation } from 'react-i18next'; import { ActivityTypeEnum } from 'src/graphql/types.generated'; -import { ActivityData } from 'src/hooks/usePhaseData'; -import { getLocalizedTaskType } from 'src/utils/functions/getLocalizedTaskType'; +import { usePhaseData } from 'src/hooks/usePhaseData'; interface ActivityTypeProps { options: ActivityTypeEnum[]; @@ -13,7 +12,6 @@ interface ActivityTypeProps { onChange: (value: ActivityTypeEnum | null) => void; // Set to true to make None an acceptable value. Otherwise, None will be converted to undefined. preserveNone?: boolean; - activityTypes?: Map; inputRef?: Ref; required?: boolean; onBlur?: FocusEventHandler; @@ -27,7 +25,6 @@ export const ActivityTypeAutocomplete: React.FC = ({ value, onChange, preserveNone = false, - activityTypes, inputRef, required, onBlur, @@ -35,6 +32,7 @@ export const ActivityTypeAutocomplete: React.FC = ({ touched, }) => { const { t } = useTranslation(); + const { activityTypes } = usePhaseData(); const sortedOptions = useMemo(() => { // Sort none to the top @@ -50,14 +48,10 @@ export const ActivityTypeAutocomplete: React.FC = ({ getOptionLabel={(activity) => { if (activity === ActivityTypeEnum.None) { return t('None'); - } else if (activityTypes && sortedOptions.length > 15) { - return ( - activityTypes.get(activity)?.phase + - ' - ' + - getLocalizedTaskType(t, activity) - ); + } else if (sortedOptions.length > 15) { + return activityTypes.get(activity)?.translatedFullName || ''; } else { - return getLocalizedTaskType(t, activity); + return activityTypes.get(activity)?.translatedShortName || ''; } }} renderInput={(params) => ( diff --git a/src/components/Task/Modal/Form/Inputs/ResultAutocomplete/ResultAutocomplete.test.tsx b/src/components/Task/Modal/Form/Inputs/ResultAutocomplete/ResultAutocomplete.test.tsx index 566acef82..0b82011dd 100644 --- a/src/components/Task/Modal/Form/Inputs/ResultAutocomplete/ResultAutocomplete.test.tsx +++ b/src/components/Task/Modal/Form/Inputs/ResultAutocomplete/ResultAutocomplete.test.tsx @@ -5,8 +5,8 @@ import userEvent from '@testing-library/user-event'; import TestWrapper from '__tests__/util/TestWrapper'; import { ActivityTypeEnum, + DisplayResultEnum, Phase, - ResultEnum, } from 'src/graphql/types.generated'; import theme from 'src/theme'; import { SetResultSelected, handleResultChange } from '../../TaskModalHelper'; @@ -51,14 +51,7 @@ const Components = ({ availableResults }: ComponentsProps) => ( ); -const standardAvailableResults = [ - ResultEnum.None, - ResultEnum.Attempted, - ResultEnum.AttemptedLeftMessage, - ResultEnum.Completed, - ResultEnum.Done, - ResultEnum.Received, -]; +const standardAvailableResults = Object.values(DisplayResultEnum); describe('ResultSelect', () => { it('does not render when no availableResults', () => { @@ -83,7 +76,7 @@ describe('ResultSelect', () => { userEvent.click(getByRole('option', { name: 'Completed' })); expect(handleResultChange).toHaveBeenCalledWith({ - result: ResultEnum.Completed, + result: DisplayResultEnum.PartnerCareCompleted, setFieldValue, setResultSelected, phaseData, @@ -91,10 +84,14 @@ describe('ResultSelect', () => { }); }); it('preselects a result when only one result is available', async () => { - render(); + render( + , + ); expect(handleResultChange).toHaveBeenCalledWith({ - result: ResultEnum.Completed, + result: DisplayResultEnum.PartnerCareCompleted, setFieldValue, setResultSelected, phaseData, diff --git a/src/components/Task/Modal/Form/Inputs/ResultAutocomplete/ResultAutocomplete.tsx b/src/components/Task/Modal/Form/Inputs/ResultAutocomplete/ResultAutocomplete.tsx index 384713263..318a18b83 100644 --- a/src/components/Task/Modal/Form/Inputs/ResultAutocomplete/ResultAutocomplete.tsx +++ b/src/components/Task/Modal/Form/Inputs/ResultAutocomplete/ResultAutocomplete.tsx @@ -5,9 +5,8 @@ import { ActivityTypeEnum, DisplayResultEnum, Phase, - ResultEnum, } from 'src/graphql/types.generated'; -import { getLocalizedResultString } from 'src/utils/functions/getLocalizedResultStrings'; +import { useLocalizedConstants } from 'src/hooks/useLocalizedConstants'; import { SetFieldValue, SetResultSelected, @@ -15,10 +14,10 @@ import { } from '../../TaskModalHelper'; export interface ResultAutocompleteProps { - availableResults: ResultEnum[] | DisplayResultEnum[]; + availableResults: DisplayResultEnum[]; setFieldValue: SetFieldValue; setResultSelected: SetResultSelected; - result?: ResultEnum | DisplayResultEnum | null; + result?: DisplayResultEnum | null; phaseData: Phase | null; completedAction: ActivityTypeEnum | null; } @@ -32,6 +31,7 @@ export const ResultAutocomplete: React.FC = ({ completedAction, }) => { const { t } = useTranslation(); + const { getLocalizedResultString } = useLocalizedConstants(); useEffect(() => { if (availableResults.length === 1 && completedAction) { @@ -53,7 +53,7 @@ export const ResultAutocomplete: React.FC = ({ autoSelect value={result} options={availableResults} - getOptionLabel={(result) => getLocalizedResultString(t, result)} + getOptionLabel={(result) => getLocalizedResultString(result)} renderInput={(params) => } onChange={(_, value) => { handleResultChange({ diff --git a/src/components/Task/Modal/Form/LogForm/TaskModalLogForm.tsx b/src/components/Task/Modal/Form/LogForm/TaskModalLogForm.tsx index 79bffb0a0..20cbbbf25 100644 --- a/src/components/Task/Modal/Form/LogForm/TaskModalLogForm.tsx +++ b/src/components/Task/Modal/Form/LogForm/TaskModalLogForm.tsx @@ -151,7 +151,7 @@ const TaskModalLogForm = ({ if (activityData) { setPhaseId(activityData.phaseId); taskPhase = activityData.phaseId; - taskSubject = activityData.title; + taskSubject = activityData.subject; } } if (defaultValues?.taskPhase) { @@ -475,7 +475,6 @@ const TaskModalLogForm = ({ onChange={(nextAction) => setFieldValue('nextAction', nextAction) } - activityTypes={activityTypes} /> )} diff --git a/src/components/Task/Modal/Form/TaskModalForm.test.tsx b/src/components/Task/Modal/Form/TaskModalForm.test.tsx index ae9cb8d71..53a8d6c36 100644 --- a/src/components/Task/Modal/Form/TaskModalForm.test.tsx +++ b/src/components/Task/Modal/Form/TaskModalForm.test.tsx @@ -323,7 +323,7 @@ describe('TaskModalForm', () => { expect(getByRole('textbox', { name: 'Location' })).toBeInTheDocument(); userEvent.click(action); - userEvent.click(getByRole('option', { name: 'Social Media' })); + userEvent.click(getByRole('option', { name: 'Social Media Message' })); expect( queryByRole('textbox', { name: 'Location' }), ).not.toBeInTheDocument(); @@ -445,9 +445,7 @@ describe('TaskModalForm', () => { expect(getByRole('combobox', { name: 'Action' })).toHaveValue('In Person'); userEvent.click(await findByRole('combobox', { name: 'Result' })); - userEvent.click( - getByRole('option', { name: 'Cancelled-Need to reschedule' }), - ); + userEvent.click(getByRole('option', { name: 'Cancelled' })); userEvent.click(getByRole('combobox', { name: 'Next Action' })); userEvent.click(getByRole('option', { name: 'Email' })); @@ -481,7 +479,7 @@ describe('TaskModalForm', () => { ); userEvent.click(await findByRole('combobox', { name: 'Result' })); - userEvent.click(await findByRole('option', { name: 'Follow up' })); + userEvent.click(await findByRole('option', { name: 'Follow Up' })); userEvent.click(getByRole('combobox', { name: 'Next Action' })); userEvent.click(await findByRole('option', { name: 'In Person' })); diff --git a/src/components/Task/Modal/Form/TaskModalTests.tsx b/src/components/Task/Modal/Form/TaskModalTests.tsx index fdf22e49e..8b12e9727 100644 --- a/src/components/Task/Modal/Form/TaskModalTests.tsx +++ b/src/components/Task/Modal/Form/TaskModalTests.tsx @@ -21,9 +21,9 @@ const options = [ 'Phone Call', 'Email', 'Text Message', - 'Social Media', + 'Social Media Message', 'In Person', - 'Thank You Note', + 'Thank', 'Digital Newsletter', 'Physical Newsletter', 'Prayer Request', @@ -83,14 +83,14 @@ export const taskModalTests = (Components: Components) => { it('has correct options for AppointmentInPerson', async () => { const { results, nextActions } = await getOptions( ActivityTypeEnum.AppointmentInPerson, - 'Cancelled-Need to reschedule', + 'Cancelled', ); expect(results).toEqual([ - 'Cancelled-Need to reschedule', - 'Follow up', - 'Partner-Financial', - 'Partner-Special', - 'Partner-Pray', + 'Cancelled', + 'Follow Up', + 'Partner - Financial', + 'Partner - Special', + 'Partner - Pray', 'Not Interested', ]); expect(nextActions).toEqual([ @@ -98,7 +98,7 @@ export const taskModalTests = (Components: Components) => { 'Phone Call', 'Email', 'Text Message', - 'Social Media', + 'Social Media Message', 'Letter', 'Special Gift Appeal', 'In Person', @@ -108,14 +108,14 @@ export const taskModalTests = (Components: Components) => { it('has correct options for AppointmentVideoCall', async () => { const { results, nextActions } = await getOptions( ActivityTypeEnum.AppointmentVideoCall, - 'Follow up', + 'Follow Up', ); expect(results).toEqual([ - 'Cancelled-Need to reschedule', - 'Follow up', - 'Partner-Financial', - 'Partner-Special', - 'Partner-Pray', + 'Cancelled', + 'Follow Up', + 'Partner - Financial', + 'Partner - Special', + 'Partner - Pray', 'Not Interested', ]); expect(nextActions).toEqual([ @@ -123,7 +123,7 @@ export const taskModalTests = (Components: Components) => { 'Phone Call', 'Email', 'Text Message', - 'Social Media', + 'Social Media Message', 'In Person', ]); }); @@ -135,7 +135,7 @@ export const taskModalTests = (Components: Components) => { ); expect(results).toEqual([ 'No Response Yet', - "Can't meet right now - circle back", + 'Can not meet right now - circle back', 'Appointment Scheduled', 'Not Interested', ]); @@ -150,11 +150,11 @@ export const taskModalTests = (Components: Components) => { it('as correct options for InitiationEmail', async () => { const { results, nextActions } = await getOptions( ActivityTypeEnum.InitiationEmail, - "Can't meet right now - circle back", + 'Can not meet right now - circle back', ); expect(results).toEqual([ 'No Response Yet', - "Can't meet right now - circle back", + 'Can not meet right now - circle back', 'Appointment Scheduled', 'Not Interested', ]); @@ -163,7 +163,7 @@ export const taskModalTests = (Components: Components) => { 'Phone Call', 'Email', 'Text Message', - 'Social Media', + 'Social Media Message', 'Letter', 'Special Gift Appeal', 'In Person', @@ -177,7 +177,7 @@ export const taskModalTests = (Components: Components) => { ); expect(results).toEqual([ 'No Response Yet', - "Can't meet right now - circle back", + 'Can not meet right now - circle back', 'Appointment Scheduled', 'Not Interested', ]); @@ -186,7 +186,7 @@ export const taskModalTests = (Components: Components) => { 'Phone Call', 'Email', 'Text Message', - 'Social Media', + 'Social Media Message', 'Letter', 'Special Gift Appeal', 'In Person', @@ -200,7 +200,7 @@ export const taskModalTests = (Components: Components) => { ); expect(results).toEqual([ 'No Response Yet', - "Can't meet right now - circle back", + 'Can not meet right now - circle back', 'Appointment Scheduled', 'Not Interested', ]); @@ -209,21 +209,21 @@ export const taskModalTests = (Components: Components) => { 'Phone Call', 'Email', 'Text Message', - 'Social Media', + 'Social Media Message', 'Letter', 'Special Gift Appeal', 'In Person', ]); }); - it('as correct options for InitiationInPerson', async () => { + it('has correct options for InitiationInPerson', async () => { const { results, nextActions } = await getOptions( ActivityTypeEnum.InitiationInPerson, 'Appointment Scheduled', ); expect(results).toEqual([ 'No Response Yet', - "Can't meet right now - circle back", + 'Can not meet right now - circle back', 'Appointment Scheduled', 'Not Interested', ]); @@ -235,43 +235,43 @@ export const taskModalTests = (Components: Components) => { ]); }); - it('as correct options for FollowUpSocialMedia', async () => { + it('has correct options for FollowUpSocialMedia', async () => { const { results, nextActions } = await getOptions( ActivityTypeEnum.FollowUpSocialMedia, - 'Partner-Pray', + 'Partner - Pray', ); expect(results).toEqual([ 'No Response Yet', - 'Partner-Financial', - 'Partner-Special', - 'Partner-Pray', + 'Partner - Financial', + 'Partner - Special', + 'Partner - Pray', 'Not Interested', ]); - expect(nextActions).toEqual(['None', 'Thank You Note']); + expect(nextActions).toEqual(['None', 'Thank']); }); - it('as correct options for FollowUpTextMessage', async () => { + it('has correct options for FollowUpTextMessage', async () => { const { results, nextActions } = await getOptions( ActivityTypeEnum.FollowUpTextMessage, - 'Partner-Financial', + 'Partner - Financial', ); expect(results).toEqual([ 'No Response Yet', - 'Partner-Financial', - 'Partner-Special', - 'Partner-Pray', + 'Partner - Financial', + 'Partner - Special', + 'Partner - Pray', 'Not Interested', ]); - expect(nextActions).toEqual(['None', 'Thank You Note']); + expect(nextActions).toEqual(['None', 'Thank']); }); - it('as correct options for NULL', async () => { + it('has correct options for NULL', async () => { const { results, nextActions } = await getOptions(null); expect(results).toEqual([]); expect(nextActions).toEqual([]); }); - it('as correct options for PartnerCareEmail', async () => { + it('has correct options for PartnerCareEmail', async () => { const { results, nextActions } = await getOptions( ActivityTypeEnum.PartnerCareEmail, ); @@ -279,12 +279,12 @@ export const taskModalTests = (Components: Components) => { expect(nextActions).toEqual(options); }); - it('as correct options for PartnerCarePhysicalNewsletter', async () => { + it('has correct options for PartnerCarePhysicalNewsletter', async () => { const { results, nextActions } = await getOptions( ActivityTypeEnum.PartnerCarePhysicalNewsletter, ); expect(results).toEqual([]); - expect(nextActions).toEqual(options); + await waitFor(() => expect(nextActions).toEqual(options)); }); it('has correct options for NONE', async () => { diff --git a/src/components/Task/Modal/Form/possibleResults.ts b/src/components/Task/Modal/Form/possibleResults.ts index d10dfe958..d083bd0fd 100644 --- a/src/components/Task/Modal/Form/possibleResults.ts +++ b/src/components/Task/Modal/Form/possibleResults.ts @@ -1,12 +1,8 @@ -import { - DisplayResultEnum, - Phase, - ResultEnum, -} from 'src/graphql/types.generated'; +import { DisplayResultEnum, Phase } from 'src/graphql/types.generated'; export const possibleResults = ( phaseData: Phase | null, -): ResultEnum[] | DisplayResultEnum[] => { +): DisplayResultEnum[] => { if (!phaseData) { return []; } diff --git a/src/components/Task/TaskRow/TaskActionPhase.tsx b/src/components/Task/TaskRow/TaskActionPhase.tsx index 4086381f1..ed0c71bf5 100644 --- a/src/components/Task/TaskRow/TaskActionPhase.tsx +++ b/src/components/Task/TaskRow/TaskActionPhase.tsx @@ -1,9 +1,6 @@ import { Box, Typography } from '@mui/material'; import { styled } from '@mui/material/styles'; -import { useTranslation } from 'react-i18next'; -import { ActivityTypeEnum } from 'src/graphql/types.generated'; import { ActivityData } from 'src/hooks/usePhaseData'; -import { getLocalizedTaskType } from 'src/utils/functions/getLocalizedTaskType'; export const SubjectWrapOuter = styled(Box)(({ theme }) => ({ width: 'fit-content', @@ -47,16 +44,13 @@ const TaskType = styled(Typography)(({ theme }) => ({ interface TaskActionPhaseProps { activityData: ActivityData | null | undefined; - activityType: ActivityTypeEnum | null | undefined; isXs?: boolean; } export const TaskActionPhase: React.FC = ({ activityData, - activityType, isXs = false, }) => { - const { t } = useTranslation(); return ( @@ -66,7 +60,9 @@ export const TaskActionPhase: React.FC = ({ )} - {isXs ? activityData?.title : getLocalizedTaskType(t, activityType)} + {isXs + ? activityData?.translatedFullName + : activityData?.translatedShortName} diff --git a/src/components/Task/TaskRow/TaskRow.tsx b/src/components/Task/TaskRow/TaskRow.tsx index 85e725875..8113caac9 100644 --- a/src/components/Task/TaskRow/TaskRow.tsx +++ b/src/components/Task/TaskRow/TaskRow.tsx @@ -210,11 +210,7 @@ export const TaskRow: React.FC = ({ }} onMouseEnter={() => preloadTaskModal(TaskModalEnum.Edit)} > - + )} { expect(result.current.getLocalizedPledgeFrequency('invalid')).toEqual(''); }); }); + + describe('getLocalizedResultString', () => { + it('should return correct string', () => { + const { result } = renderHook(() => useLocalizedConstants()); + expect( + result.current.getLocalizedResultString( + DisplayResultEnum.AppointmentResultPartnerFinancial, + ), + ).toEqual('Partner - Financial'); + }); + + it('should return empty string for invalid inputs', () => { + const { result } = renderHook(() => useLocalizedConstants()); + expect(result.current.getLocalizedResultString('invalid')).toEqual(''); + }); + }); }); diff --git a/src/hooks/useLocalizedConstants.ts b/src/hooks/useLocalizedConstants.ts index 3ead17695..498c76d34 100644 --- a/src/hooks/useLocalizedConstants.ts +++ b/src/hooks/useLocalizedConstants.ts @@ -2,6 +2,7 @@ import { useCallback } from 'react'; import { useApiConstants } from 'src/components/Constants/UseApiConstants'; import { ContactFilterStatusEnum, + DisplayResultEnum, PhaseEnum, PledgeFrequencyEnum, StatusEnum, @@ -50,9 +51,23 @@ export const useLocalizedConstants = () => { [constants], ); + const getLocalizedResultString = useCallback( + ( + displayResultEnum: DisplayResultEnum | string | null | undefined, + ): string => { + return ( + constants?.displayResults?.find( + (result) => result.id === displayResultEnum, + )?.value || '' + ); + }, + [constants], + ); + return { getLocalizedContactStatus, getLocalizedPhase, getLocalizedPledgeFrequency, + getLocalizedResultString, }; }; diff --git a/src/hooks/usePhaseData.test.ts b/src/hooks/usePhaseData.test.ts index fe531f3c0..005bcaaee 100644 --- a/src/hooks/usePhaseData.test.ts +++ b/src/hooks/usePhaseData.test.ts @@ -73,52 +73,52 @@ describe('usePhaseData', () => { Object.fromEntries(result.current.activityTypes.entries()), ).toMatchObject({ INITIATION_LETTER: { - name: 'Letter', + translatedShortName: 'Letter', phase: 'Initiation', phaseId: 'INITIATION', - title: 'Initiation - Letter', + translatedFullName: 'Initiation - Letter', }, INITIATION_SPECIAL_GIFT_APPEAL: { - name: 'Special Gift Appeal', + translatedShortName: 'Special Gift Appeal', phase: 'Initiation', phaseId: 'INITIATION', - title: 'Initiation - Special Gift Appeal', + translatedFullName: 'Initiation - Special Gift Appeal', }, FOLLOW_UP_TEXT_MESSAGE: { - name: 'Text Message', + translatedShortName: 'Text Message', phase: 'Follow-Up', phaseId: 'FOLLOW_UP', - title: 'Follow-Up - Text Message', + translatedFullName: 'Follow Up - Text Message', }, INITIATION_EMAIL: { - name: 'Email', + translatedShortName: 'Email', phase: 'Initiation', phaseId: 'INITIATION', - title: 'Initiation - Email', + translatedFullName: 'Initiation - Email', }, FOLLOW_UP_SOCIAL_MEDIA: { - name: 'Social Media', + translatedShortName: 'Social Media Message', phase: 'Follow-Up', phaseId: 'FOLLOW_UP', - title: 'Follow-Up - Social Media', + translatedFullName: 'Follow Up - Social Media Message', }, APPOINTMENT_VIDEO_CALL: { - name: 'Video Call', + translatedShortName: 'Video Call', phase: 'Appointment', phaseId: 'APPOINTMENT', - title: 'Appointment - Video Call', + translatedFullName: 'Appointment - Video Call', }, PARTNER_CARE_TEXT_MESSAGE: { - name: 'Text Message', + translatedShortName: 'Text Message', phase: 'Partner Care', phaseId: 'PARTNER_CARE', - title: 'Partner Care - Text Message', + translatedFullName: 'Partner Care - Text Message', }, INITIATION_SOCIAL_MEDIA: { - name: 'Social Media', + translatedShortName: 'Social Media Message', phase: 'Initiation', phaseId: 'INITIATION', - title: 'Initiation - Social Media', + translatedFullName: 'Initiation - Social Media Message', }, }); diff --git a/src/hooks/usePhaseData.ts b/src/hooks/usePhaseData.ts index d68547879..6d75aa271 100644 --- a/src/hooks/usePhaseData.ts +++ b/src/hooks/usePhaseData.ts @@ -1,5 +1,4 @@ import { useCallback, useMemo, useState } from 'react'; -import { useTranslation } from 'react-i18next'; import { LoadConstantsQuery } from 'src/components/Constants/LoadConstants.generated'; import { useApiConstants } from 'src/components/Constants/UseApiConstants'; import { @@ -7,7 +6,6 @@ import { Phase, PhaseEnum, } from 'src/graphql/types.generated'; -import { getLocalizedTaskType } from 'src/utils/functions/getLocalizedTaskType'; export type SetPhaseId = (activity: PhaseEnum | null) => void; export type Constants = LoadConstantsQuery['constant'] | undefined; @@ -23,11 +21,11 @@ type GetPhaseData = { }; export type ActivityData = { - name: string; + translatedShortName?: string; + translatedFullName?: string; phaseId: PhaseEnum; phase: string; subject?: string; - title?: string; }; export type PhaseMappedData = { @@ -41,30 +39,30 @@ const capitalizeWords = (sentence: string): string => .map((word) => word[0].toUpperCase() + word.substring(1)) .join(' '); -const phaseFromActivity = ( - activity: PhaseEnum | null, +const getPhaseObject = ( + selectedPhase: PhaseEnum | null, constants: LoadConstantsQuery['constant'] | undefined, ): Phase | null => { const phases = constants?.phases; - if (!activity || !phases) { + if (!selectedPhase || !phases) { return null; } return ( - phases.find((phase) => phase.id.toLowerCase() === activity.toLowerCase()) ?? - null + phases.find( + (phase) => phase.id.toLowerCase() === selectedPhase.toLowerCase(), + ) ?? null ); }; export const usePhaseData = (phaseEnum?: PhaseEnum | null): GetPhaseData => { const constants = useApiConstants(); - const { t } = useTranslation(); const [phaseData, setPhaseData] = useState( - phaseFromActivity(phaseEnum ?? null, constants), + getPhaseObject(phaseEnum ?? null, constants), ); const setPhaseId = useCallback( - (activity: PhaseEnum | null) => { - setPhaseData(phaseFromActivity(activity, constants)); + (selectedPhase: PhaseEnum | null) => { + setPhaseData(getPhaseObject(selectedPhase, constants)); }, [constants], ); @@ -121,22 +119,22 @@ export const usePhaseData = (phaseEnum?: PhaseEnum | null): GetPhaseData => { // activityTypes // {INITIATION_SPECIAL_GIFT_APPEAL: { - // name: 'Special Gift Appeal', + // translatedShortName: 'Special Gift Appeal', + // translatedFullName: 'Initiation - Special Gift Appeal', // phase: 'Initiation', // phaseId: 'INITIATION', // subject: 'Special Gift Appeal', - // title: 'Initiation - Special Gift Appeal', // }, // FOLLOW_UP_TEXT_MESSAGE: { - // name: 'Text Message', + // translatedShortName: 'Text Message', + // translatedFullName: 'Follow Up - Text Message', // phase: 'Follow-Up', // phaseId: 'FOLLOW_UP', // subject: 'Text Message To Follow Up', - // title: 'Follow Up - Text Message', // },} - const activityTypes: Map = useMemo(() => { - const activitiesMap = new Map(); + const activityTypes = useMemo(() => { + const activitiesMap = new Map(); constants?.phases?.forEach((phase) => { phase?.tasks?.forEach((activityType) => { @@ -144,11 +142,11 @@ export const usePhaseData = (phaseEnum?: PhaseEnum | null): GetPhaseData => { (activity) => activity.id === activityType, ); activitiesMap.set(activityType, { - name: getLocalizedTaskType(t, activityType), + translatedFullName: activity?.value, + translatedShortName: activity?.action, phaseId: phase.id, phase: phase.name, subject: activity?.name && capitalizeWords(activity.name), - title: activity?.value, }); }); }); diff --git a/src/utils/functions/getLocalizedResultStrings.ts b/src/utils/functions/getLocalizedResultStrings.ts deleted file mode 100644 index 3bac039e7..000000000 --- a/src/utils/functions/getLocalizedResultStrings.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { TFunction } from 'react-i18next'; -import { DisplayResultEnum, ResultEnum } from 'src/graphql/types.generated'; - -export const getLocalizedResultString = ( - t: TFunction, - resultType: ResultEnum | DisplayResultEnum | null | undefined, -): string => { - if (!resultType) { - return ''; - } - - switch (resultType) { - case ResultEnum.Attempted: - return t('Attempted'); - - case ResultEnum.AttemptedLeftMessage: - return t('Attempted - Left Message'); - - case ResultEnum.Completed: - case DisplayResultEnum.PartnerCareCompleted: - return t('Completed'); - - // The Done and None branches should never be hit but are left for completeness - /* istanbul ignore next */ - case ResultEnum.Done: - return t('Done'); - - /* istanbul ignore next */ - case ResultEnum.None: - return t('None'); - - case ResultEnum.Received: - return t('Received'); - - case DisplayResultEnum.FollowUpResultNoResponse: - case DisplayResultEnum.InitiationResultNoResponse: - return t('No Response Yet'); - - case DisplayResultEnum.AppointmentResultNotInterested: - return t('Not Interested'); - - case DisplayResultEnum.InitiationResultCircleBack: - return t("Can't meet right now - circle back"); - - case DisplayResultEnum.InitiationResultAppointmentScheduled: - return t('Appointment Scheduled'); - - case DisplayResultEnum.AppointmentResultCancelled: - return t('Cancelled-Need to reschedule'); - - case DisplayResultEnum.AppointmentResultFollowUp: - return t('Follow up'); - - case DisplayResultEnum.FollowUpResultPartnerFinancial: - case DisplayResultEnum.AppointmentResultPartnerFinancial: - return t('Partner-Financial'); - - case DisplayResultEnum.FollowUpResultPartnerSpecial: - case DisplayResultEnum.AppointmentResultPartnerSpecial: - return t('Partner-Special'); - - case DisplayResultEnum.FollowUpResultPartnerPray: - case DisplayResultEnum.AppointmentResultPartnerPray: - return t('Partner-Pray'); - - case DisplayResultEnum.FollowUpResultNotInterested: - case DisplayResultEnum.InitiationResultNotInterested: - return t('Not Interested'); - - default: - return ''; - } -}; diff --git a/src/utils/functions/getLocalizedTaskType.ts b/src/utils/functions/getLocalizedTaskType.ts deleted file mode 100644 index e7b2620b9..000000000 --- a/src/utils/functions/getLocalizedTaskType.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { TFunction } from 'react-i18next'; -import { ActivityTypeEnum } from 'src/graphql/types.generated'; - -export const getLocalizedTaskType = ( - t: TFunction, - taskType: ActivityTypeEnum | null | undefined, -): string => { - if (!taskType) { - return ''; - } - - switch (taskType) { - case ActivityTypeEnum.None: - return t('None'); - - case ActivityTypeEnum.InitiationInPerson: - case ActivityTypeEnum.FollowUpInPerson: - case ActivityTypeEnum.AppointmentInPerson: - case ActivityTypeEnum.PartnerCareInPerson: - return t('In Person'); - - case ActivityTypeEnum.AppointmentPhoneCall: - case ActivityTypeEnum.InitiationPhoneCall: - case ActivityTypeEnum.FollowUpPhoneCall: - case ActivityTypeEnum.PartnerCarePhoneCall: - return t('Phone Call'); - - case ActivityTypeEnum.AppointmentVideoCall: - return t('Video Call'); - - case ActivityTypeEnum.InitiationEmail: - case ActivityTypeEnum.FollowUpEmail: - case ActivityTypeEnum.PartnerCareEmail: - return t('Email'); - - case ActivityTypeEnum.InitiationTextMessage: - case ActivityTypeEnum.FollowUpTextMessage: - case ActivityTypeEnum.PartnerCareTextMessage: - return t('Text Message'); - - case ActivityTypeEnum.FollowUpSocialMedia: - case ActivityTypeEnum.PartnerCareSocialMedia: - case ActivityTypeEnum.InitiationSocialMedia: - return t('Social Media'); - - case ActivityTypeEnum.InitiationLetter: - return t('Letter'); - case ActivityTypeEnum.InitiationSpecialGiftAppeal: - return t('Special Gift Appeal'); - - case ActivityTypeEnum.PartnerCarePhysicalNewsletter: - return t('Physical Newsletter'); - case ActivityTypeEnum.PartnerCareDigitalNewsletter: - return t('Digital Newsletter'); - case ActivityTypeEnum.PartnerCareThank: - return t('Thank You Note'); - case ActivityTypeEnum.PartnerCarePrayerRequest: - return t('Prayer Request'); - case ActivityTypeEnum.PartnerCareUpdateInformation: - return t('Update Information'); - case ActivityTypeEnum.PartnerCareToDo: - return t('To Do'); - } -};