-
Notifications
You must be signed in to change notification settings - Fork 4
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
User search functionality #70
Conversation
@johnpcooke94 Could you add a gif of this to the pr? |
@Cliftonz is he using a Mac? Looks like that software supports windows too. I like "screen to gif" for windows. It works pretty well. |
Yeah, either way. I think we should make sure going forward that we either have gif or an image of the front end. So we can review the style in the pr instead of the bi-weekly meeting. |
@Cliftonz added a gif to the PR description for you. |
@johnpcooke94 Thank you, Could you put the search bar and the save button on the same line. |
@Cliftonz how's this look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
if (event.currentTarget.value) { | ||
const foundUsers: User[] = []; | ||
users.map((u: User) => { | ||
const regex = new RegExp(`${u.firstName}|${u.lastName}|${u.email}|${u.role}`, 'ig'); | ||
if (event.currentTarget.value.search(regex) >= 0) { | ||
foundUsers.push(u); | ||
} | ||
}); | ||
setUsersToDisplay(foundUsers); | ||
} | ||
else { | ||
setUsersToDisplay(users); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (event.currentTarget.value) { | |
const foundUsers: User[] = []; | |
users.map((u: User) => { | |
const regex = new RegExp(`${u.firstName}|${u.lastName}|${u.email}|${u.role}`, 'ig'); | |
if (event.currentTarget.value.search(regex) >= 0) { | |
foundUsers.push(u); | |
} | |
}); | |
setUsersToDisplay(foundUsers); | |
} | |
else { | |
setUsersToDisplay(users); | |
} | |
const searchValue = event.currentTarget.value.toLowerCase().trim(); | |
const foundUsers = searchValue ? users.filter((u: User) => { | |
const searchString = `${u.firstName}|${u.lastName}|${u.email}|${u.role}`.toLowerCase(); | |
return searchString.indexOf(searchValue) !== -1; | |
}) : users; | |
setUsersToDisplay(foundUsers); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasekiw pushed a commit for this, made a small adjustment to the search string so it would also match a search.
…for potential multiple spaces between words in search
Kudos, SonarCloud Quality Gate passed! |
A simple implementation of user search functionality from the admin panel. Admins can search based on the 4 displayed categories, and update user roles from there, if desired.