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

Preferences notifications #821

Merged
merged 25 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f823b1f
Moving NavReportsList to shared folder, and then getting it ready for…
dr-bizz Nov 9, 2023
898a1c5
Adding wrapper and notification page
dr-bizz Nov 13, 2023
3b69efa
Adding skeleton and graphQL calls
dr-bizz Nov 13, 2023
7343a90
Notifications table
dr-bizz Nov 13, 2023
19ee973
Hooking up new Notifications constants query.
dr-bizz Nov 14, 2023
261f9c5
Implementing notifications constants and cleaning TS errors
dr-bizz Nov 14, 2023
6ab2121
Merge branch 'main' into preferences-notifications
dr-bizz Nov 14, 2023
91cda35
Switching useMemo for useEffect to ensure it's run on initial render.
dr-bizz Nov 15, 2023
349bf95
Fixing test errors.
dr-bizz Nov 15, 2023
df7262e
Adding tests to up code coverage
dr-bizz Nov 15, 2023
1266a87
reverted to having testId on <Checkbox> as type error when passing it…
dr-bizz Nov 15, 2023
37b287d
Small fixes to improve code quailty
dr-bizz Nov 20, 2023
55e6038
Typography changes
dr-bizz Nov 30, 2023
60162be
Change tests to use render React components rather than function.
dr-bizz Nov 30, 2023
31de4fb
Type fixes.
dr-bizz Nov 30, 2023
02711c2
Merge branch 'main' into preferences-notifications
dr-bizz Nov 30, 2023
7f4e37a
Merge branch 'main' into preferences-notifications
dr-bizz Nov 30, 2023
a9265cd
Updating Organization query as conflicts with another PR yet to be me…
dr-bizz Nov 30, 2023
436ba5c
last edits on notifications
dr-bizz Dec 12, 2023
6f9c87d
merging main into this branch
dr-bizz Dec 15, 2023
5902d9d
Merge branch 'preferences-notifications' of https://github.com/CruGlo…
dr-bizz Dec 15, 2023
f066704
lint issues
dr-bizz Dec 15, 2023
c1997b5
prettier fixes
dr-bizz Dec 15, 2023
54a118b
Updating notifications to fix bug with main account viewing notificat…
dr-bizz Dec 15, 2023
40f9e21
tests for last commit
dr-bizz Dec 15, 2023
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
44 changes: 44 additions & 0 deletions pages/accountLists/[accountListId]/settings/notifications.page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import { Box } from '@mui/material';
import { useTranslation } from 'react-i18next';
import { NotificationsTable } from 'src/components/Settings/notifications/NotificationsTable';
import useGetAppSettings from 'src/hooks/useGetAppSettings';
import { SettingsWrapper } from './wrapper';

const Notifications: React.FC = () => {
const { t } = useTranslation();
const { appName } = useGetAppSettings();

return (
<SettingsWrapper
pageTitle={t('Notifications')}
pageHeading={t('Notifications')}
>
<Box component="section" marginTop={3}>
<p>
{t(
`Based on an analysis of a partner's giving history, {{appName}} can
notify you of events that you will probably want to follow up on. The
detection logic is based on a set of rules that are right most of the
time, but you will still want to verify an event manually before
contacting the partner.`,
{ appName },
)}
</p>
</Box>
<Box component="section" marginTop={1}>
<p>
{t(
`For each event {{appName}} can notify you via email and also create a task
entry reminding you to do something about it. The options below allow
you to control that behavior.`,
{ appName },
)}
</p>
</Box>
<NotificationsTable />
</SettingsWrapper>
);
};

export default Notifications;
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import theme from '../../../../theme';
import { OrganizationAccordion } from './OrganizationAccordion';
import {
GetOrganizationsQuery,
GetUsersOrganizationsQuery,
GetUsersOrganizationsAccountsQuery,
} from './Organizations.generated';

jest.mock('next-auth/react');
Expand Down Expand Up @@ -64,7 +64,7 @@ const GetOrganizationsMock: Pick<
},
];

const GetUsersOrganizationsMock: Array<
const GetUsersOrganizationsAccountsMock: Array<
Pick<
Types.OrganizationAccount,
'latestDonationDate' | 'lastDownloadedAt' | 'username' | 'id'
Expand Down Expand Up @@ -93,8 +93,8 @@ const standardMocks = {
GetOrganizations: {
organizations: GetOrganizationsMock,
},
GetUsersOrganizations: {
userOrganizationAccounts: GetUsersOrganizationsMock,
GetUsersOrganizationsAccounts: {
userOrganizationAccounts: GetUsersOrganizationsAccountsMock,
},
};

Expand Down Expand Up @@ -140,13 +140,13 @@ describe('OrganizationAccordion', () => {
<Components>
<GqlMockedProvider<{
GetOrganizations: GetOrganizationsQuery;
GetUsersOrganizations: GetUsersOrganizationsQuery;
GetUsersOrganizationsAccounts: GetUsersOrganizationsAccountsQuery;
}>
mocks={{
GetOrganizations: {
organizations: [],
},
GetUsersOrganizations: {
GetUsersOrganizationsAccounts: {
userOrganizationAccounts: [],
},
}}
Expand Down Expand Up @@ -180,7 +180,7 @@ describe('OrganizationAccordion', () => {
<Components>
<GqlMockedProvider<{
GetOrganizations: GetOrganizationsQuery;
GetUsersOrganizations: GetUsersOrganizationsQuery;
GetUsersOrganizationsAccounts: GetUsersOrganizationsAccountsQuery;
}>
mocks={mocks}
>
Expand All @@ -198,7 +198,7 @@ describe('OrganizationAccordion', () => {

await waitFor(() => {
expect(
getByText(GetUsersOrganizationsMock[0].organization.name),
getByText(GetUsersOrganizationsAccountsMock[0].organization.name),
).toBeInTheDocument();

expect(getByText('Last Updated')).toBeInTheDocument();
Expand All @@ -219,13 +219,13 @@ describe('OrganizationAccordion', () => {

it('should render Ministry Account Organization', async () => {
const mutationSpy = jest.fn();
mocks.GetUsersOrganizations.userOrganizationAccounts[0].organization.apiClass =
mocks.GetUsersOrganizationsAccounts.userOrganizationAccounts[0].organization.apiClass =
'Siebel';
const { getByText, queryByText } = render(
<Components>
<GqlMockedProvider<{
GetOrganizations: GetOrganizationsQuery;
GetUsersOrganizations: GetUsersOrganizationsQuery;
GetUsersOrganizationsAccounts: GetUsersOrganizationsAccountsQuery;
}>
mocks={mocks}
onCall={mutationSpy}
Expand Down Expand Up @@ -261,19 +261,19 @@ describe('OrganizationAccordion', () => {
'SyncOrganizationAccount',
);
expect(mutationSpy.mock.calls[1][0].operation.variables.input).toEqual({
id: mocks.GetUsersOrganizations.userOrganizationAccounts[0].id,
id: mocks.GetUsersOrganizationsAccounts.userOrganizationAccounts[0].id,
});
});

it('should render Login Organization', async () => {
const mutationSpy = jest.fn();
mocks.GetUsersOrganizations.userOrganizationAccounts[0].organization.apiClass =
mocks.GetUsersOrganizationsAccounts.userOrganizationAccounts[0].organization.apiClass =
'DataServer';
const { getByText, getByTestId } = render(
<Components>
<GqlMockedProvider<{
GetOrganizations: GetOrganizationsQuery;
GetUsersOrganizations: GetUsersOrganizationsQuery;
GetUsersOrganizationsAccounts: GetUsersOrganizationsAccountsQuery;
}>
mocks={mocks}
onCall={mutationSpy}
Expand All @@ -300,15 +300,15 @@ describe('OrganizationAccordion', () => {

it('should render OAuth Organization', async () => {
const mutationSpy = jest.fn();
mocks.GetUsersOrganizations.userOrganizationAccounts[0].organization.apiClass =
mocks.GetUsersOrganizationsAccounts.userOrganizationAccounts[0].organization.apiClass =
'DataServer';
mocks.GetUsersOrganizations.userOrganizationAccounts[0].organization.oauth =
mocks.GetUsersOrganizationsAccounts.userOrganizationAccounts[0].organization.oauth =
true;
const { getByText, queryByTestId } = render(
<Components>
<GqlMockedProvider<{
GetOrganizations: GetOrganizationsQuery;
GetUsersOrganizations: GetUsersOrganizationsQuery;
GetUsersOrganizationsAccounts: GetUsersOrganizationsAccountsQuery;
}>
mocks={mocks}
onCall={mutationSpy}
Expand Down Expand Up @@ -345,7 +345,7 @@ describe('OrganizationAccordion', () => {
<Components>
<GqlMockedProvider<{
GetOrganizations: GetOrganizationsQuery;
GetUsersOrganizations: GetUsersOrganizationsQuery;
GetUsersOrganizationsAccounts: GetUsersOrganizationsAccountsQuery;
}>
mocks={mocks}
onCall={mutationSpy}
Expand Down Expand Up @@ -376,7 +376,8 @@ describe('OrganizationAccordion', () => {
'DeleteOrganizationAccount',
);
expect(mutationSpy.mock.calls[1][0].operation.variables.input).toEqual({
id: mocks.GetUsersOrganizations.userOrganizationAccounts[0].id,
id: mocks.GetUsersOrganizationsAccounts.userOrganizationAccounts[0]
.id,
});
expect(mockEnqueue).toHaveBeenCalledWith(
'{{appName}} removed your organization integration',
Expand All @@ -386,15 +387,15 @@ describe('OrganizationAccordion', () => {
});

it("should not render Organization's download and last gift date", async () => {
mocks.GetUsersOrganizations.userOrganizationAccounts[0].lastDownloadedAt =
mocks.GetUsersOrganizationsAccounts.userOrganizationAccounts[0].lastDownloadedAt =
null;
mocks.GetUsersOrganizations.userOrganizationAccounts[0].latestDonationDate =
mocks.GetUsersOrganizationsAccounts.userOrganizationAccounts[0].latestDonationDate =
null;
const { queryByText } = render(
<Components>
<GqlMockedProvider<{
GetOrganizations: GetOrganizationsQuery;
GetUsersOrganizations: GetUsersOrganizationsQuery;
GetUsersOrganizationsAccounts: GetUsersOrganizationsAccountsQuery;
}>
mocks={mocks}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { OrganizationImportDataSyncModal } from './Modals/OrganizationImportData
import { getOauthUrl } from './OrganizationService';
import {
useDeleteOrganizationAccountMutation,
useGetUsersOrganizationsQuery,
useGetUsersOrganizationsAccountsQuery,
useSyncOrganizationAccountMutation,
} from './Organizations.generated';

Expand Down Expand Up @@ -100,7 +100,7 @@ export const OrganizationAccordion: React.FC<OrganizationAccordionProps> = ({
data,
loading,
refetch: refetchOrganizations,
} = useGetUsersOrganizationsQuery();
} = useGetUsersOrganizationsAccountsQuery();
const organizations = data?.userOrganizationAccounts;

const handleReconnect = async (organizationId) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ query getOrganizations {
}
}

query GetUsersOrganizations {
query GetUsersOrganizationsAccounts {
userOrganizationAccounts {
organization {
apiClass
Expand Down
23 changes: 23 additions & 0 deletions src/components/Settings/notifications/Notifications.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
query NotificationsPreferences($accountListId: ID!) {
notificationPreferences(accountListId: $accountListId) {
nodes {
id
app
email
notificationType {
id
descriptionTemplate
type
}
task
}
}
}

query NotificationTypes {
notificationTypes {
id
type
descriptionTemplate
}
}
Loading
Loading