-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
admin/donations: Fix not being able to link user to donation if billi…
…ngEmail is null (#1504) * donations/grid: Fix donations association to user * admin/donations: Extend donor's autocomplete to look for email * admin/donations: Move autocomplete filter to its own function * personFilter: Expand filter rules to look for last name
- Loading branch information
1 parent
ad26e28
commit 6f8e06e
Showing
3 changed files
with
32 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { PersonResponse } from 'gql/person' | ||
import { FilterOptionsState } from '@mui/material' | ||
|
||
/** | ||
* Custom function to filter person related autocomplete inputs, based on either firstname, lastname or email | ||
* @param options AutoComplete prop | ||
* @param state AutoComplete prop | ||
* @returns | ||
*/ | ||
export const personFilter = ( | ||
options: PersonResponse[], | ||
state: FilterOptionsState<PersonResponse>, | ||
) => { | ||
const displayOptions = options.filter((option) => { | ||
const name = `${option.firstName.toLowerCase()} ${option.lastName.toLowerCase()}` | ||
return ( | ||
name.includes(state.inputValue.toLowerCase()) || | ||
option.email.toLowerCase().includes(state.inputValue.toLowerCase()) | ||
) | ||
}) | ||
|
||
return displayOptions | ||
} |