Skip to content

Commit

Permalink
organizations type graphql
Browse files Browse the repository at this point in the history
  • Loading branch information
caleballdrin committed Oct 27, 2023
1 parent e35e849 commit 848699a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/components/Dashboard/Dashboard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ describe('Static Banner', () => {
it('should NOT show the banner if the env variable is false', () => {
process.env.SHOW_BANNER = 'false';

const { getByTestId } = render(
const { queryByTestId } = render(

This comment has been minimized.

Copy link
@wrandall22

wrandall22 Oct 27, 2023

Contributor

It seems these changes are unrelated to the commit message. Probably should have been in a separate commit (and probably squashed later).

This comment has been minimized.

Copy link
@caleballdrin

caleballdrin Oct 27, 2023

Author Contributor

Yeah... I didn't realize that all went in the same commit.

<ThemeProvider theme={theme}>
<SnackbarProvider>
<MockedProvider mocks={GetThisWeekDefaultMocks()} addTypename={false}>
Expand All @@ -259,6 +259,6 @@ describe('Static Banner', () => {
</ThemeProvider>,
);

expect(getByTestId('staticBanner')).not.toBeInTheDocument();
expect(queryByTestId('staticBanner')).not.toBeInTheDocument();
});
});
7 changes: 2 additions & 5 deletions src/components/Dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ const variants = {
},
},
};
const checkShowBanner = function () {
return process.env.SHOW_BANNER;
};
//const showBanner = process.env.SHOW_BANNER;
const shouldShowBanner = process.env.SHOW_BANNER === 'true';

const Dashboard = ({ data, accountListId }: Props): ReactElement => {
return (
Expand All @@ -44,7 +41,7 @@ const Dashboard = ({ data, accountListId }: Props): ReactElement => {
exit="exit"
variants={variants}
>
{checkShowBanner() === 'true' ? <StaticBanner /> : null}
{shouldShowBanner && <StaticBanner data-testid="staticBanner" />}
<Grid container spacing={3} alignItems="stretch">
<Grid xs={12} sm={8} item>
<MonthlyGoal
Expand Down
8 changes: 8 additions & 0 deletions src/components/Shared/staticBanner/StaticBanner.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { render } from '@testing-library/react';
import { StaticBanner } from './StaticBanner';

test('static banner displays', () => {
const { queryByTestId } = render(<StaticBanner />);

expect(queryByTestId('nonCruOrgReminder')).toBeInTheDocument();
});
27 changes: 16 additions & 11 deletions src/components/Shared/staticBanner/StaticBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { useTranslation } from 'react-i18next';
import Alert from '@mui/material/Alert';
import { Link } from '@mui/material';
import { useGetUsersOrganizationsQuery } from './getOrganizationType.generated';

interface StaticBannerProps {
severity?: 'error' | 'info' | 'success' | 'warning';
Expand All @@ -11,22 +12,26 @@ export const StaticBanner: React.FC<StaticBannerProps> = ({
severity = 'warning',
}) => {
const { t } = useTranslation();
let nonCruOrg = false;
let showBanner = false;
let includesCruOrg = true;

const checkIfCruOrg = () => {
return new Promise((resolve) => {
resolve((nonCruOrg = true));
});
};
checkIfCruOrg();
const { data } = useGetUsersOrganizationsQuery();
data?.userOrganizationAccounts.map((org) => {
if (
org.organization.organizationType === 'Cru-International' ||
org.organization.organizationType === 'Cru'
) {
includesCruOrg = true;
}
});
showBanner = includesCruOrg ? false : true;

return nonCruOrg ? (
<Alert severity={severity}>
return showBanner ? (
<Alert severity={severity} data-testid="nonCruOrgReminder">
{t(
"Due to data privacy regulations and costs, Cru will no longer be able to host MPDX data for non-Cru/non-CCCI ministries. This means that MPDX will no longer be available for use outside of Cru/CCCI. Your data in MPDX will be deleted if you don't export it from MPDX by January 31, 2024 or let us know why you might need an extension. For more information and to take action, ",
`Due to data privacy regulations and costs, Cru will no longer be able to host MPDX data for non-Cru/non-CCCI ministries. This means that MPDX will no longer be available for use outside of Cru/CCCI. Your data in MPDX will be deleted if you don't export it from MPDX by January 31, 2024 or let us know why you might need an extension. For more information and to take action, `,
)}
<Link
data-testid="staticBanner"
href="https://docs.google.com/document/d/18TnQGmshg71l3J9Gd-4ltjIjhK2PLtuG_Vc94bt6xzE/"
target="_blank"
rel="noreferrer"
Expand Down
14 changes: 14 additions & 0 deletions src/components/Shared/staticBanner/getOrganizationType.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
query GetUsersOrganizations {
userOrganizationAccounts {
organization {
apiClass
id
name
oauth
organizationType
}
latestDonationDate
lastDownloadedAt
username
}
}

0 comments on commit 848699a

Please sign in to comment.