Skip to content

Commit

Permalink
Merge pull request #153 from adhocteam/js-170-add-real-program-types
Browse files Browse the repository at this point in the history
Program type constant updated. Only shows for grantee reports
  • Loading branch information
jasalisbury authored Feb 10, 2021
2 parents 5bb9bd9 + f93c935 commit c5b47a7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
5 changes: 5 additions & 0 deletions frontend/src/pages/ActivityReport/Pages/activitySummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const ActivitySummary = ({

const disableRecipients = activityRecipientType === '';
const nonGranteeSelected = activityRecipientType === 'non-grantee';
const granteeSelected = activityRecipientType === 'grantee';
const selectedRecipients = nonGranteeSelected ? nonGrantees : grants;
const previousActivityRecipientType = useRef(activityRecipientType);
const recipientLabel = nonGranteeSelected ? 'Non-grantee name(s)' : 'Grantee name(s)';
Expand All @@ -55,6 +56,7 @@ const ActivitySummary = ({
if (previousActivityRecipientType.current !== activityRecipientType) {
setValue('activityRecipients', []);
setValue('participants', []);
setValue('programTypes', []);
previousActivityRecipientType.current = activityRecipientType;
}
}, [activityRecipientType, setValue]);
Expand Down Expand Up @@ -123,6 +125,8 @@ const ActivitySummary = ({
options={collaborators.map((user) => ({ value: user.id, label: user.name }))}
/>
</div>
{granteeSelected
&& (
<div className="smart-hub--form-section">
<MultiSelect
name="programTypes"
Expand All @@ -132,6 +136,7 @@ const ActivitySummary = ({
options={programTypes.map((pt) => ({ value: pt, label: pt }))}
/>
</div>
)}
<div className="smart-hub--form-section">
<MultiSelect
name="targetPopulations"
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/pages/ActivityReport/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ describe('ActivityReport', () => {
});
});

it('program type is hidden unless grantee is selected', async () => {
renderActivityReport('new');
const information = await screen.findByRole('group', { name: 'Who was the activity for?' });
await waitFor(() => expect(screen.queryByLabelText('Program type(s)')).toBeNull());
const nonGrantee = within(information).getByLabelText('Grantee');
fireEvent.click(nonGrantee);
await waitFor(() => expect(screen.queryByLabelText('Program type(s)')).toBeVisible());
});

it('defaults to activity summary if no page is in the url', async () => {
renderActivityReport('new', null);
await waitFor(() => expect(history.location.pathname).toEqual('/activity-reports/new/activity-summary'));
Expand Down
8 changes: 3 additions & 5 deletions frontend/src/pages/ActivityReport/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,9 @@ export const targetPopulations = [
];

export const programTypes = [
'program type 1',
'program type 2',
'program type 3',
'program type 4',
'program type 5',
'Early Head Start (ages 0-3)',
'Head Start (ages 3-5)',
'EHS-CCP',
];

export const topics = [
Expand Down

0 comments on commit c5b47a7

Please sign in to comment.