Skip to content

Commit 848699a

Browse files
committed
organizations type graphql
1 parent e35e849 commit 848699a

File tree

5 files changed

+42
-18
lines changed

5 files changed

+42
-18
lines changed

src/components/Dashboard/Dashboard.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ describe('Static Banner', () => {
249249
it('should NOT show the banner if the env variable is false', () => {
250250
process.env.SHOW_BANNER = 'false';
251251

252-
const { getByTestId } = render(
252+
const { queryByTestId } = render(
253253
<ThemeProvider theme={theme}>
254254
<SnackbarProvider>
255255
<MockedProvider mocks={GetThisWeekDefaultMocks()} addTypename={false}>
@@ -259,6 +259,6 @@ describe('Static Banner', () => {
259259
</ThemeProvider>,
260260
);
261261

262-
expect(getByTestId('staticBanner')).not.toBeInTheDocument();
262+
expect(queryByTestId('staticBanner')).not.toBeInTheDocument();
263263
});
264264
});

src/components/Dashboard/Dashboard.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ const variants = {
2727
},
2828
},
2929
};
30-
const checkShowBanner = function () {
31-
return process.env.SHOW_BANNER;
32-
};
33-
//const showBanner = process.env.SHOW_BANNER;
30+
const shouldShowBanner = process.env.SHOW_BANNER === 'true';
3431

3532
const Dashboard = ({ data, accountListId }: Props): ReactElement => {
3633
return (
@@ -44,7 +41,7 @@ const Dashboard = ({ data, accountListId }: Props): ReactElement => {
4441
exit="exit"
4542
variants={variants}
4643
>
47-
{checkShowBanner() === 'true' ? <StaticBanner /> : null}
44+
{shouldShowBanner && <StaticBanner data-testid="staticBanner" />}
4845
<Grid container spacing={3} alignItems="stretch">
4946
<Grid xs={12} sm={8} item>
5047
<MonthlyGoal
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { render } from '@testing-library/react';
2+
import { StaticBanner } from './StaticBanner';
3+
4+
test('static banner displays', () => {
5+
const { queryByTestId } = render(<StaticBanner />);
6+
7+
expect(queryByTestId('nonCruOrgReminder')).toBeInTheDocument();
8+
});

src/components/Shared/staticBanner/StaticBanner.tsx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import { useTranslation } from 'react-i18next';
33
import Alert from '@mui/material/Alert';
44
import { Link } from '@mui/material';
5+
import { useGetUsersOrganizationsQuery } from './getOrganizationType.generated';
56

67
interface StaticBannerProps {
78
severity?: 'error' | 'info' | 'success' | 'warning';
@@ -11,22 +12,26 @@ export const StaticBanner: React.FC<StaticBannerProps> = ({
1112
severity = 'warning',
1213
}) => {
1314
const { t } = useTranslation();
14-
let nonCruOrg = false;
15+
let showBanner = false;
16+
let includesCruOrg = true;
1517

16-
const checkIfCruOrg = () => {
17-
return new Promise((resolve) => {
18-
resolve((nonCruOrg = true));
19-
});
20-
};
21-
checkIfCruOrg();
18+
const { data } = useGetUsersOrganizationsQuery();
19+
data?.userOrganizationAccounts.map((org) => {
20+
if (
21+
org.organization.organizationType === 'Cru-International' ||
22+
org.organization.organizationType === 'Cru'
23+
) {
24+
includesCruOrg = true;
25+
}
26+
});
27+
showBanner = includesCruOrg ? false : true;
2228

23-
return nonCruOrg ? (
24-
<Alert severity={severity}>
29+
return showBanner ? (
30+
<Alert severity={severity} data-testid="nonCruOrgReminder">
2531
{t(
26-
"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, ",
32+
`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, `,
2733
)}
2834
<Link
29-
data-testid="staticBanner"
3035
href="https://docs.google.com/document/d/18TnQGmshg71l3J9Gd-4ltjIjhK2PLtuG_Vc94bt6xzE/"
3136
target="_blank"
3237
rel="noreferrer"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
query GetUsersOrganizations {
2+
userOrganizationAccounts {
3+
organization {
4+
apiClass
5+
id
6+
name
7+
oauth
8+
organizationType
9+
}
10+
latestDonationDate
11+
lastDownloadedAt
12+
username
13+
}
14+
}

0 commit comments

Comments
 (0)