Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPDX-7864 - Task phases functionailty #949

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
125eef9
Initialization - Setting up initial functions for task phases
dr-bizz Jun 4, 2024
b7c5d4b
Initialization - Contact and task phases hooks to be used throughout …
dr-bizz Jun 4, 2024
4018f22
Initialization - Updating common functions, components and tests.
dr-bizz Jun 4, 2024
29ec996
Initialization - Updating dashboard with new Phase data
dr-bizz Jun 4, 2024
743d66d
Initialization - Update Search, Reports & Tools with new phase data a…
dr-bizz Jun 4, 2024
06ed4db
Contacts - Replace hard-coded statuses - Caleb Alldrin
dr-bizz Jun 4, 2024
be74fb7
Contacts - Updating contact details components to use new hooks to ge…
dr-bizz Jun 4, 2024
d16ad01
Contacts - Create contact modals
dr-bizz Jun 4, 2024
ec3bc27
Contacts - Update Contact Flows view.
dr-bizz Jun 4, 2024
965ae75
Contacts - Log or create task after contact moved to new View on cont…
dr-bizz Jun 4, 2024
9a796ce
Tasks - Created/Edited inputs used on all Task Modals
dr-bizz Jun 4, 2024
bc1132d
Tasks - Modal helper functions
dr-bizz Jun 4, 2024
91c8a6c
Tasks - Complete, Log & the normal task modals
dr-bizz Jun 4, 2024
ddb57b1
Tasks - Adding new phase data onto the Task page
dr-bizz Jun 4, 2024
46f6de4
Coaching - API changes, spelling and mocks
dr-bizz Jun 4, 2024
15dc957
Coaching - Updating the Coaching details with task phase and contact …
dr-bizz Jun 4, 2024
8016eeb
**Revert when go live** Switched GHA API_URL to staging server
dr-bizz Jun 4, 2024
a8db800
Saved Filters allow for new lowercase statuses like never_contacted
caleballdrin Jun 28, 2024
78cf6a3
Saved Filters allow for new lowercase activity types and next actions
caleballdrin Jul 1, 2024
ca9a078
Fix TypeScript error
canac Sep 9, 2024
1f0cd73
Tweak flows status changed message
canac Sep 9, 2024
7373c71
Add message to task modals in flows
canac Sep 9, 2024
e21570e
Add tests
canac Sep 9, 2024
85d6439
Fix typo in label
canac Sep 9, 2024
ad85a3d
Tweak reset warning message
canac Sep 9, 2024
5299506
Merge pull request #1043 from CruGlobal/8176-add-task-message
canac Sep 10, 2024
692c5cd
Rename Task Notifications to Reminders (#1045)
caleballdrin Sep 10, 2024
0f2c06b
Merge pull request #1041 from CruGlobal/8175-reset-flows-warning
canac Sep 10, 2024
07e4841
MPDX-8135-replace-referrals (#1049)
caleballdrin Sep 10, 2024
e7338e9
Fix GraphQL error
canac Sep 10, 2024
4928314
MPDX-8170-fix-statuses (#1052)
caleballdrin Sep 11, 2024
95dbe27
fix suggested tags selecting (#1060)
caleballdrin Sep 12, 2024
9f78c4f
MPDX-8171 Tab Selecting (#1061)
caleballdrin Sep 12, 2024
fd573ee
MPDX-8169 Rename to Digital Newsletter (#1062)
caleballdrin Sep 12, 2024
183787f
ReviewChanges - Coaching add tests, skeletons and remove day from month
caleballdrin Sep 17, 2024
117e3ff
ReviewChanges - Coaching rename components, mocks, add date helper fu…
caleballdrin Sep 17, 2024
4e0c893
ReviewChanges - Coaching rename files
caleballdrin Sep 17, 2024
283fc3e
ReviewChanges - Contacts tests cleanup
caleballdrin Sep 17, 2024
46b6b92
ReviewChanges - Task Modal
caleballdrin Sep 18, 2024
15fd7d8
ReviewChanges - MassActionEditFieldsModal test
caleballdrin Sep 18, 2024
7e18f81
ReviewChanges - Filter panel and useContactPartnershipStatus()
caleballdrin Sep 18, 2024
95e0bb9
ReviewChanges - Tests and syntax changes
caleballdrin Sep 18, 2024
867eee1
Merge branch 'main' into MPDX-task-phases-new
dr-bizz Sep 18, 2024
b2fdaa3
fixup! Merge branch 'main' into MPDX-task-phases-new
dr-bizz Sep 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

env:
# Use production API for codegen to make sure production is compatible with the code to be merged
API_URL: 'https://api.mpdx.org/graphql'
API_URL: 'https://api.stage.mpdx.org/graphql'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure we revert this before going live. I know I have a commit on this. But putting it in multiple places.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be reverted before merging, right?

SITE_URL: 'http://next-stage.mpdx.org'

jobs:
Expand Down
32 changes: 29 additions & 3 deletions __tests__/util/TestWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,53 @@
import React, { ReactElement, ReactNode } from 'react';
import { InMemoryCache } from '@apollo/client';
import { MockedProvider, MockedResponse } from '@apollo/client/testing';
import { ApolloLink, InMemoryCache } from '@apollo/client';
import { onError } from '@apollo/client/link/error';
import {
MockLink,
MockedProvider,
MockedResponse,
} from '@apollo/client/testing';
import { AdapterLuxon } from '@mui/x-date-pickers/AdapterLuxon';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { SnackbarProvider } from 'notistack';
import TestRouter from './TestRouter';

export type OnErrorFunction = (error: string) => void;

interface Props {
mocks?: MockedResponse[];
children: ReactNode;
cache?: InMemoryCache;
onErrorFunction?: OnErrorFunction;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like the onErrorFunction prop is used anywhere. Let's remove it if that's the case. If it is actually needed, what do you think about renaming it to onError?

}

const TestWrapper = ({
mocks = [],
children,
cache = new InMemoryCache({ addTypename: false }),
onErrorFunction,
}: Props): ReactElement => {
const mockLink = new MockLink(mocks);
const errorLoggingLink = onError(({ networkError }) => {
if (networkError) {
// eslint-disable-next-line no-console
console.warn(`[Network error]: ${networkError}`);
if (onErrorFunction) {
onErrorFunction(JSON.stringify(networkError.message));
}
}
});
const link = ApolloLink.from([errorLoggingLink, mockLink]);

return (
<TestRouter>
<LocalizationProvider dateAdapter={AdapterLuxon}>
<SnackbarProvider>
<MockedProvider mocks={mocks} cache={cache} addTypename={false}>
<MockedProvider
mocks={mocks}
cache={cache}
addTypename={false}
link={link}
>
{children}
</MockedProvider>
</SnackbarProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ query Contacts(
nodes {
id
avatar
contactPhase
...ContactRow
}
totalCount
Expand Down
100 changes: 61 additions & 39 deletions pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import {
ContactFlowOption,
colorMap,
statusMap,
} from 'src/components/Contacts/ContactFlow/ContactFlow';
import { ContactFlowSetupColumn } from 'src/components/Contacts/ContactFlow/ContactFlowSetup/Column/ContactFlowSetupColumn';
import { UnusedStatusesColumn } from 'src/components/Contacts/ContactFlow/ContactFlowSetup/Column/UnusedStatusesColumn';
Expand All @@ -24,9 +23,11 @@
GetUserOptionsQuery,
useGetUserOptionsQuery,
} from 'src/components/Contacts/ContactFlow/GetUserOptions.generated';
import { getDefaultFlowOptions } from 'src/components/Contacts/ContactFlow/contactFlowDefaultOptions';

Check warning on line 26 in pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx#L26

Added line #L26 was not covered by tests
import Loading from 'src/components/Loading';
import { ContactFilterStatusEnum } from 'src/graphql/types.generated';
import { useAccountListId } from 'src/hooks/useAccountListId';
import { useContactPartnershipStatuses } from 'src/hooks/useContactPartnershipStatuses';

Check warning on line 30 in pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx#L30

Added line #L30 was not covered by tests
import useGetAppSettings from 'src/hooks/useGetAppSettings';
import theme from 'src/theme';

Expand All @@ -41,6 +42,7 @@
const ContactFlowSetupPage: React.FC = () => {
const { t } = useTranslation();
const accountListId = useAccountListId();
const { statusMap, contactStatuses } = useContactPartnershipStatuses();

Check warning on line 45 in pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx#L45

Added line #L45 was not covered by tests
const { enqueueSnackbar } = useSnackbar();
const [flowOptions, setFlowOptions] = useState<
{
Expand All @@ -50,14 +52,21 @@
id: string;
}[]
>([]);
const resetColumnsMessage = t(

Check warning on line 55 in pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx#L55

Added line #L55 was not covered by tests
'Since all columns have been removed, resetting columns to their default values',
);
const { data: userOptions, loading } = useGetUserOptionsQuery();

useEffect(() => {
const newOptions = JSON.parse(
userOptions?.userOptions.find((option) => option.key === 'flows')
?.value || '[]',
);
setFlowOptions(newOptions);
if (!newOptions.length) {
setFlowOptions(getDefaultFlowOptions(t, contactStatuses));
} else {
setFlowOptions(newOptions);

Check warning on line 68 in pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx#L66-L68

Added lines #L66 - L68 were not covered by tests
}
}, [userOptions]);

const [updateUserOptions] = useUpdateUserOptionsMutation();
Expand All @@ -70,43 +79,46 @@
(status) => !allUsedStatuses.includes(status),
);

const updateOptions = async (options: ContactFlowOption[]): Promise<void> => {
const stringified = JSON.stringify(options);
await updateUserOptions({
variables: {
key: 'flows',
value: stringified,
},
update: (cache, { data: updatedUserOption }) => {
const query = {
query: GetUserOptionsDocument,
};
const dataFromCache = cache.readQuery<GetUserOptionsQuery>(query);

if (dataFromCache) {
const filteredOld = dataFromCache.userOptions.filter(
(option) => option.key !== 'flows',
);
const userOptions = [
...filteredOld,
{
__typename: 'Option',
id: updatedUserOption?.createOrUpdateUserOption?.option.id,
key: 'flows',
value: stringified,
},
];
const data = {
userOptions,
const updateOptions = useCallback(
async (options: ContactFlowOption[]): Promise<void> => {
const stringified = JSON.stringify(options);
await updateUserOptions({

Check warning on line 85 in pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx#L82-L85

Added lines #L82 - L85 were not covered by tests
variables: {
key: 'flows',
value: stringified,
},
update: (cache, { data: updatedUserOption }) => {
const query = {

Check warning on line 91 in pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx#L90-L91

Added lines #L90 - L91 were not covered by tests
query: GetUserOptionsDocument,
};
cache.writeQuery({ ...query, data });
}
enqueueSnackbar(t('User options updated!'), {
variant: 'success',
});
},
});
};
const dataFromCache = cache.readQuery<GetUserOptionsQuery>(query);

Check warning on line 94 in pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx#L94

Added line #L94 was not covered by tests

if (dataFromCache) {
const filteredOld = dataFromCache.userOptions.filter(
(option) => option.key !== 'flows',

Check warning on line 98 in pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx#L97-L98

Added lines #L97 - L98 were not covered by tests
);

const data = {

Check warning on line 101 in pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx#L101

Added line #L101 was not covered by tests
userOptions: [
...filteredOld,
{
__typename: 'Option',
id: updatedUserOption?.createOrUpdateUserOption?.option.id,
key: 'flows',
value: stringified,
},
],
};
cache.writeQuery({ ...query, data });

Check warning on line 112 in pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx#L112

Added line #L112 was not covered by tests
}
enqueueSnackbar(t('User options updated!'), {

Check warning on line 114 in pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx#L114

Added line #L114 was not covered by tests
variant: 'success',
});
},
});
},
[],
);

const addColumn = (): Promise<void> => {
return updateOptions([
Expand All @@ -123,6 +135,12 @@
const deleteColumn = (index: number): void => {
const temp = [...flowOptions];
temp.splice(index, 1);

if (!temp.length) {
enqueueSnackbar(resetColumnsMessage, {

Check warning on line 140 in pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx#L140

Added line #L140 was not covered by tests
variant: 'warning',
});
}
updateOptions(temp);
};

Expand Down Expand Up @@ -196,7 +214,11 @@
<DndProvider backend={HTML5Backend}>
{!loading && <ContactFlowSetupDragLayer />}
<Box>
<ContactFlowSetupHeader addColumn={addColumn} />
<ContactFlowSetupHeader
addColumn={addColumn}
updateOptions={updateOptions}
resetColumnsMessage={resetColumnsMessage}
/>
{flowOptions && (
<Box
display="grid"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ const TasksPage: React.FC = () => {
onTaskCheckToggle={toggleSelectionById}
isChecked={isRowChecked(task.id)}
useTopMargin={index === 0}
contactDetailsOpen={contactDetailsOpen}
/>
</Box>
)}
Expand Down
15 changes: 15 additions & 0 deletions pages/api/Schema/AccountListAnalytics/accountListAnalytics.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ type AccountListAnalytics {
textMessage: TextMessageAccountListAnalytics!
startDate: ISO8601DateTime!
endDate: ISO8601DateTime!
contactsByStatus: ContactsByStatus!
}

type ContactsByStatus {
neverContacted: Int!
future: Int!
cultivate: Int!
contactForAppointment: Int!
appointmentScheduled: Int!
callForDecision: Int!
financial: Int!
special: Int!
prayer: Int!
connectionsRemaining: Int!
initiations: Int!
}

type AppointmentsAccountListAnalytics {
Expand Down
27 changes: 27 additions & 0 deletions pages/api/Schema/AccountListAnalytics/dataHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ const getAccountListAnalytics = (data: {
};
updated_at: string;
updated_in_db_at: string;
contacts_by_status: {
never_contacted: number;
future: number;
cultivate: number;
contact_for_appointment: number;
appointment_scheduled: number;
call_for_decision: number;
financial: number;
special: number;
prayer: number;
connections_remaining: number;
initiations: number;
};
};
}): AccountListAnalytics => {
const {
Expand All @@ -62,6 +75,7 @@ const getAccountListAnalytics = (data: {
text_message,
start_date: startDate,
end_date: endDate,
contacts_by_status,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
contacts_by_status,
contacts_by_status: contactsByStatus,

},
} = data;

Expand Down Expand Up @@ -89,6 +103,19 @@ const getAccountListAnalytics = (data: {
received: phone.received,
talkToInPerson: phone.talktoinperson,
},
contactsByStatus: {
neverContacted: contacts_by_status.never_contacted,
future: contacts_by_status.future,
cultivate: contacts_by_status.cultivate,
contactForAppointment: contacts_by_status.contact_for_appointment,
appointmentScheduled: contacts_by_status.appointment_scheduled,
callForDecision: contacts_by_status.call_for_decision,
financial: contacts_by_status.financial,
special: contacts_by_status.special,
prayer: contacts_by_status.prayer,
connectionsRemaining: contacts_by_status.connections_remaining,
initiations: contacts_by_status.initiations,
},
textMessage: text_message,
startDate,
endDate,
Expand Down
32 changes: 3 additions & 29 deletions pages/api/graphql-rest.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
ExportLabelTypeEnum,
ExportSortEnum,
} from 'src/graphql/types.generated';
import i18n from 'src/lib/i18n';
import { getLocalizedContactStatus } from '../../src/utils/functions/getLocalizedContactStatus';
import schema from './Schema';
import { getAccountListAnalytics } from './Schema/AccountListAnalytics/dataHandler';
import { getAccountListCoaches } from './Schema/AccountListCoaches/dataHandler';
Expand Down Expand Up @@ -577,37 +579,9 @@ class MpdxRestApi extends RESTDataSource {

// Status
case 'status':
const statusMap = new Map<ContactFilterStatusEnum, string>([
[ContactFilterStatusEnum.Active, 'active'],
[ContactFilterStatusEnum.Hidden, 'hidden'],
[ContactFilterStatusEnum.Null, 'null'],
[
ContactFilterStatusEnum.AppointmentScheduled,
'Appointment Scheduled',
],
[ContactFilterStatusEnum.AskInFuture, 'Ask in Future'],
[ContactFilterStatusEnum.CallForDecision, 'Call for Decision'],
[
ContactFilterStatusEnum.ContactForAppointment,
'Contact for Appointment',
],
[
ContactFilterStatusEnum.CultivateRelationship,
'Cultivate Relationship',
],
[ContactFilterStatusEnum.ExpiredReferral, 'Expired Referral'],
[ContactFilterStatusEnum.NeverAsk, 'Never Ask'],
[ContactFilterStatusEnum.NeverContacted, 'Never Contacted'],
[ContactFilterStatusEnum.NotInterested, 'Not Interested'],
[ContactFilterStatusEnum.PartnerFinancial, 'Partner - Financial'],
[ContactFilterStatusEnum.PartnerPray, 'Partner - Pray'],
[ContactFilterStatusEnum.PartnerSpecial, 'Partner - Special'],
[ContactFilterStatusEnum.ResearchAbandoned, 'Research Abandoned'],
[ContactFilterStatusEnum.Unresponsive, 'Unresponsive'],
]);
filters[snakedKey] = (value as ContactFilterStatusEnum[])
.map((status) => {
const translated = statusMap.get(status);
const translated = getLocalizedContactStatus(i18n.t, status);
if (!translated) {
throw new Error(
`Unrecognized ContactFilterStatusEnum value ${value}`,
Expand Down
13 changes: 13 additions & 0 deletions src/components/Coaching/CoachingDetail/Activity/Activity.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,18 @@ query CoachingDetailActivity($accountListId: ID!, $dateRange: String!) {
received
sent
}
contactsByStatus {
neverContacted
future
cultivate
contactForAppointment
appointmentScheduled
callForDecision
financial
special
prayer
connectionsRemaining
initiations
}
}
}
Loading
Loading