Skip to content

Commit

Permalink
Merge pull request #186 from gwynndp/filter-growers-deviceId
Browse files Browse the repository at this point in the history
feat(growers): filter growers by deviceIdentifier
  • Loading branch information
gwynndp authored Nov 6, 2021
2 parents fa1bd22 + 799958e commit dfb90fa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/components/FilterTopGrower.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ function FilterTopGrower(props) {
);
const [email, setEmail] = useState(filter?.email || '');
const [phone, setPhone] = useState(filter?.phone || '');
const [deviceIdentifier, setDeviceIdentifier] = useState(
filter?.deviceIdentifier || '',
);

function handleSubmit(e) {
e.preventDefault();
Expand All @@ -68,6 +71,7 @@ function FilterTopGrower(props) {
organizationId,
email,
phone,
deviceIdentifier,
});
props.onSubmit && props.onSubmit(filter);
}
Expand All @@ -80,6 +84,7 @@ function FilterTopGrower(props) {
setOrganizationId(ALL_ORGANIZATIONS);
setEmail('');
setPhone('');
setDeviceIdentifier('');

const filter = new FilterModel();
props.onSubmit && props.onSubmit(filter);
Expand Down Expand Up @@ -133,6 +138,16 @@ function FilterTopGrower(props) {
onChange={(e) => setPersonId(e.target.value)}
onKeyDown={handleEnterPress}
/>
<TextField
className={`${classes.textField} ${classes.filterElement}`}
label="Device ID"
htmlFor="Device ID"
id="Device ID"
placeholder="Device ID"
value={deviceIdentifier}
onChange={(e) => setDeviceIdentifier(e.target.value)}
onKeyDown={handleEnterPress}
/>
{
/* {!userHasOrg && ( }*/
<TextField
Expand Down
2 changes: 2 additions & 0 deletions src/components/tests/growers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ describe('growers', () => {

expect(screen.getByLabelText('Person ID')).toBeInTheDocument();

expect(screen.getByLabelText('Device ID')).toBeInTheDocument();

expect(screen.getByLabelText('Organization')).toBeInTheDocument();

expect(screen.getByLabelText(/first name/i)).toBeInTheDocument();
Expand Down
6 changes: 6 additions & 0 deletions src/models/FilterGrower.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ export default class Filter {
where.organizationId = this.organizationId;
}

if (this.deviceIdentifier) {
where.deviceIdentifier = this.deviceIdentifier;
} else {
where.deviceIdentifier = null;
}

if (this.email) {
where.email = {
regexp: stringToSearchRegExp(this.email),
Expand Down

0 comments on commit dfb90fa

Please sign in to comment.