diff --git a/src/components/FilterTopGrower.js b/src/components/FilterTopGrower.js index bab4534c1..cf3529755 100644 --- a/src/components/FilterTopGrower.js +++ b/src/components/FilterTopGrower.js @@ -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(); @@ -68,6 +71,7 @@ function FilterTopGrower(props) { organizationId, email, phone, + deviceIdentifier, }); props.onSubmit && props.onSubmit(filter); } @@ -80,6 +84,7 @@ function FilterTopGrower(props) { setOrganizationId(ALL_ORGANIZATIONS); setEmail(''); setPhone(''); + setDeviceIdentifier(''); const filter = new FilterModel(); props.onSubmit && props.onSubmit(filter); @@ -133,6 +138,16 @@ function FilterTopGrower(props) { onChange={(e) => setPersonId(e.target.value)} onKeyDown={handleEnterPress} /> + setDeviceIdentifier(e.target.value)} + onKeyDown={handleEnterPress} + /> { /* {!userHasOrg && ( }*/ { expect(screen.getByLabelText('Person ID')).toBeInTheDocument(); + expect(screen.getByLabelText('Device ID')).toBeInTheDocument(); + expect(screen.getByLabelText('Organization')).toBeInTheDocument(); expect(screen.getByLabelText(/first name/i)).toBeInTheDocument(); diff --git a/src/models/FilterGrower.js b/src/models/FilterGrower.js index d6f04790f..95ca01876 100644 --- a/src/models/FilterGrower.js +++ b/src/models/FilterGrower.js @@ -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),