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

[TTAHUB-278] grantee search page #403

Merged
merged 46 commits into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
0a00468
create grantee page
thewatermethod Aug 25, 2021
c8e3672
Merge branch 'main' into TTAHUB-278
thewatermethod Aug 25, 2021
a949e55
Merge branch 'main' into TTAHUB-278
thewatermethod Aug 25, 2021
a3c9f0c
Merge branch 'main' into TTAHUB-278
jasalisbury Aug 26, 2021
eb0b6cd
Merge branch 'main' into TTAHUB-278
thewatermethod Sep 15, 2021
ad51373
building backend route for grantee search
thewatermethod Sep 16, 2021
b8233c1
create query for search
thewatermethod Sep 17, 2021
bc95606
clean up function
thewatermethod Sep 17, 2021
9010f82
add unit test
thewatermethod Sep 17, 2021
b67c34c
add size limit to query
thewatermethod Sep 17, 2021
3eb6fba
Merge branch 'main' into TTAHUB-278
thewatermethod Sep 17, 2021
a6663ce
fix broken ui test
thewatermethod Sep 17, 2021
b2b1e89
Merge branch 'TTAHUB-278' of https://github.com/adhocteam/Head-Start-…
thewatermethod Sep 17, 2021
a5fbd4b
update ui test for new features
thewatermethod Sep 17, 2021
6f99e79
add another ui test
thewatermethod Sep 17, 2021
9f147b6
beefed up unit test
thewatermethod Sep 20, 2021
a8f95ab
beefed up second unit test
thewatermethod Sep 20, 2021
5aff872
Merge branch 'main' into TTAHUB-278
thewatermethod Sep 20, 2021
e55cd57
Merge branch 'main' into TTAHUB-278
thewatermethod Sep 22, 2021
186036d
build out GranteeResults
thewatermethod Sep 24, 2021
f4cab7b
add grantee results table
thewatermethod Sep 24, 2021
bb742f8
write ui test
thewatermethod Sep 24, 2021
c7b9eb6
add additional ui tests
thewatermethod Sep 24, 2021
caa163f
backend unit tests
thewatermethod Sep 27, 2021
a197ed2
update yarn vuln
thewatermethod Sep 27, 2021
6709bb0
starting to fill test coverage gaps
thewatermethod Sep 27, 2021
e84c3cd
more work on ui tests
thewatermethod Sep 27, 2021
408e718
return fetchers to prev state
thewatermethod Sep 27, 2021
57e8100
ui test for grantee search
thewatermethod Sep 27, 2021
560f2ab
another ui test
thewatermethod Sep 27, 2021
2542a12
Merge branch 'main' into TTAHUB-278
thewatermethod Sep 27, 2021
2e8a174
testing linter
thewatermethod Sep 27, 2021
390d205
remove test
thewatermethod Sep 27, 2021
6c03edc
test
thewatermethod Sep 27, 2021
11cb6a4
remove inline function
thewatermethod Sep 27, 2021
4b54b14
fix bug where sort wasn't firing
thewatermethod Sep 27, 2021
f89a575
why not?
thewatermethod Sep 27, 2021
13d6772
removed shot in the dark
thewatermethod Sep 27, 2021
59054ba
test this lint
thewatermethod Sep 27, 2021
8cfcd98
test this lint
thewatermethod Sep 27, 2021
e14a869
on apply remove as a test
thewatermethod Sep 27, 2021
d32aa40
defeated, we add no an eslint ignore
thewatermethod Sep 27, 2021
d1e9bef
finish UI tests
thewatermethod Sep 28, 2021
a1061ac
Merge branch 'main' into TTAHUB-278
thewatermethod Sep 28, 2021
fd03899
Merge branch 'main' into TTAHUB-278
thewatermethod Oct 4, 2021
2d7df35
Merge branch 'main' into TTAHUB-278
thewatermethod Oct 5, 2021
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
8 changes: 8 additions & 0 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import RequestPermissions from './components/RequestPermissions';
import AriaLiveContext from './AriaLiveContext';
import AriaLiveRegion from './components/AriaLiveRegion';
import ApprovedActivityReport from './pages/ApprovedActivityReport';
import GranteeSearch from './pages/GranteeSearch';

function App() {
const [user, updateUser] = useState();
Expand Down Expand Up @@ -140,6 +141,13 @@ function App() {
<RegionalDashboard user={user} />
)}
/>
<Route
exact
path="/grantee-search"
render={() => (
<GranteeSearch user={user} />
)}
/>
<Route
path="/admin"
render={() => (
Expand Down
34 changes: 23 additions & 11 deletions frontend/src/components/SiteNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import { NavLink as Link, withRouter } from 'react-router-dom';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faChartBar, faBorderAll } from '@fortawesome/free-solid-svg-icons';
import { faChartBar, faBorderAll, faUserFriends } from '@fortawesome/free-solid-svg-icons';

import './SiteNav.css';

Expand Down Expand Up @@ -88,16 +88,28 @@ const SiteNav = ({
</li>
{admin
? (
<li>
<NavLink
to="/regional-dashboard"
>
<span className="padding-right-105">
<FontAwesomeIcon color="white" icon={faBorderAll} />
</span>
Regional Dashboard
</NavLink>
</li>
<>
<li>
<NavLink
to="/regional-dashboard"
>
<span className="padding-right-105">
<FontAwesomeIcon color="white" icon={faBorderAll} />
</span>
Regional Dashboard
</NavLink>
</li>
<li>
<NavLink
to="/grantee-search"
>
<span className="padding-right-1">
<FontAwesomeIcon color="white" icon={faUserFriends} />
</span>
Grantees
</NavLink>
</li>
</>
) : null }
</ul>
</div>
Expand Down
59 changes: 59 additions & 0 deletions frontend/src/pages/GranteeSearch/__tests__/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import '@testing-library/jest-dom';
import React from 'react';
import {
fireEvent,
render, screen,
} from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import GranteeSearch from '../index';
import { SCOPE_IDS } from '../../../Constants';

const userBluePrint = {
id: 1,
name: 'One',
role: 'Taco Alphabetizer',
homeRegionId: 1,
permissions: [],
};

describe('the grantee search page', () => {
const renderGranteeSearch = (user) => {
render(<GranteeSearch user={user} />);
};

it('renders the heading and the region select', async () => {
const user = {
...userBluePrint,
permissions: [
{
userId: 1,
scopeId: SCOPE_IDS.READ_WRITE_ACTIVITY_REPORTS,
regionId: 1,
},
{
userId: 1,
scopeId: SCOPE_IDS.READ_WRITE_ACTIVITY_REPORTS,
regionId: 2,
},
],
};
renderGranteeSearch(user);
expect(screen.getByRole('heading', { name: /grantee records/i })).toBeInTheDocument();
expect(screen.getByRole('button', { name: /open the regional select menu/i })).toBeInTheDocument();
});

it('you can interact with the search box', () => {
const user = { ...userBluePrint };
renderGranteeSearch(user);
const searchBox = screen.getByRole('searchbox');
const button = screen.getByRole('button', { name: /search for matching grantees/i });
userEvent.type(searchBox, 'ground control?');
fireEvent.click(button);

// Todo - once there is more ui, this should be expanded
// to test what actually happens when the button is clicked

expect(button).toBeInTheDocument();
expect(searchBox).toBeInTheDocument();
});
});
14 changes: 14 additions & 0 deletions frontend/src/pages/GranteeSearch/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.ttahub-grantee-search .smart-hub--button-select-toggle-btn {
padding: 0.75rem;
}

.ttahub-grantee-search--search-input {
border-radius: 0.25rem 0 0 0.25rem;
height: auto;
padding: 0.5rem 0.25rem;
width: 480px;
}

.ttahub-grantee-search--submit-button {
border-radius: 0 0.25rem 0.25rem 0;
}
78 changes: 78 additions & 0 deletions frontend/src/pages/GranteeSearch/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { Helmet } from 'react-helmet';
import { Grid } from '@trussworks/react-uswds';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faSearch } from '@fortawesome/free-solid-svg-icons';
import RegionalSelect from '../../components/RegionalSelect';
import { getUserRegions } from '../../permissions';
import './index.css';

function GranteeSearch({ user }) {
const hasCentralOffice = user && user.homeRegionId && user.homeRegionId === 14;
const regions = getUserRegions(user);

// eslint-disable-next-line max-len
const [appliedRegion, setAppliedRegion] = useState(hasCentralOffice ? 14 : regions[0]);
const [query, setQuery] = useState('');

function onApplyRegion(region) {
setAppliedRegion(region.value);
}

function onSubmit(e) {
e.preventDefault();
}

return (
<>
<Helmet>
<title>Grantee Records Search</title>
</Helmet>
<div className="ttahub-grantee-search">
<h1 className="landing">Grantee Records</h1>
<Grid className="ttahub-grantee-search--filter-row flex-fill display-flex flex-align-center flex-align-self-center flex-row flex-wrap margin-bottom-2">
{regions.length > 1
&& (
<div className="margin-right-2">
<RegionalSelect
regions={regions}
onApply={onApplyRegion}
hasCentralOffice={hasCentralOffice}
appliedRegion={appliedRegion}
/>
</div>
)}
<form className="ttahub-grantee-search--search-form display-flex" onSubmit={onSubmit}>
<input type="search" name="search" value={query} className="ttahub-grantee-search--search-input" onChange={(e) => setQuery(e.target.value)} />
<button type="submit" className="ttahub-grantee-search--submit-button usa-button">
<FontAwesomeIcon color="white" icon={faSearch} />
{' '}
<span className="sr-only">Search for matching grantees</span>
</button>
</form>
</Grid>
</div>
</>
);
}

export default GranteeSearch;

GranteeSearch.propTypes = {
user: PropTypes.shape({
id: PropTypes.number,
name: PropTypes.string,
role: PropTypes.arrayOf(PropTypes.string),
homeRegionId: PropTypes.number,
permissions: PropTypes.arrayOf(PropTypes.shape({
userId: PropTypes.number,
scopeId: PropTypes.number,
regionId: PropTypes.number,
})),
}),
};

GranteeSearch.defaultProps = {
user: null,
};