Skip to content

Commit

Permalink
feat: add phone and email filters to planters (Greenstand#127)
Browse files Browse the repository at this point in the history
* feat: add phone and email filters to planters

* chore: update phone filter
  • Loading branch information
VLuisa authored Jul 13, 2021
1 parent 1ee9aae commit 54f5183
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/components/FilterTopPlanter.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ function FilterTopPlanter(props) {
const [firstName, setFirstName] = useState('');
const [lastName, setLastName] = useState('');
const [organizationId, setOrganizationId] = useState('');
const [email, setEmail] = useState('');
const [phone, setPhone] = useState('');

function handleSubmit() {
const filter = new FilterModel({
Expand All @@ -71,6 +73,8 @@ function FilterTopPlanter(props) {
firstName,
lastName,
organizationId,
email,
phone,
});
props.onSubmit && props.onSubmit(filter);
}
Expand Down Expand Up @@ -115,6 +119,20 @@ function FilterTopPlanter(props) {
value={lastName}
onChange={(e) => setLastName(e.target.value)}
/>
<TextField
className={`${classes.textField} ${classes.filterElement}`}
label="Email"
placeholder="Email"
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
<TextField
className={`${classes.textField} ${classes.filterElement}`}
label="Phone Number"
placeholder="Phone Number"
value={phone}
onChange={(e) => setPhone(e.target.value)}
/>
<Button
className={classes.apply}
variant="outlined"
Expand Down
12 changes: 12 additions & 0 deletions src/models/FilterPlanter.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ export default class Filter {
where.organizationId = this.organizationId;
}

if (this.email) {
where.email = {
ilike: this.email,
};
}

if (this.phone) {
where.phone = {
ilike: this.phone,
};
}

return where;
}
}

0 comments on commit 54f5183

Please sign in to comment.