Skip to content
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

Merged
merged 7 commits into from
Nov 2, 2021
Merged

User search functionality #70

merged 7 commits into from
Nov 2, 2021

Conversation

johnpcooke94
Copy link
Contributor

@johnpcooke94 johnpcooke94 commented Oct 2, 2021

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.

Gif recording of the feature in action.

@Cliftonz
Copy link
Member

Cliftonz commented Oct 2, 2021

@johnpcooke94 Could you add a gif of this to the pr?
here is a recorder for macos

@jasekiw
Copy link
Contributor

jasekiw commented Oct 3, 2021

@Cliftonz is he using a Mac? Looks like that software supports windows too. I like "screen to gif" for windows. It works pretty well.

@Cliftonz
Copy link
Member

Cliftonz commented Oct 3, 2021

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.

@johnpcooke94
Copy link
Contributor Author

@Cliftonz added a gif to the PR description for you.

@Cliftonz
Copy link
Member

Cliftonz commented Oct 3, 2021

@johnpcooke94 Thank you, Could you put the search bar and the save button on the same line.

@johnpcooke94
Copy link
Contributor Author

johnpcooke94 commented Oct 3, 2021

@Cliftonz how's this look?

inline-save

Copy link
Member

@Cliftonz Cliftonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Comment on lines 152 to 164
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);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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);

Copy link
Contributor Author

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.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 2, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@jasekiw jasekiw merged commit 04b0c9e into dev Nov 2, 2021
@jasekiw jasekiw deleted the jc-update-user-role branch November 2, 2021 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants