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

feat: include badge showing applied filters in Verify page #173

Merged
merged 2 commits into from
Oct 19, 2021

Conversation

tranquanghuy0801
Copy link
Member

Resolves #81

}

Object.keys(filter).forEach(key => {
if (key === 'filter' || key == 'active' || key == 'approved') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's best to always use === for string comparisons. Our linter should pick up on this.

@@ -8,4 +8,36 @@ export const getVerificationStatus = (active, approved) => {
} else if (active === false && approved === false) {
return verificationStates.REJECTED;
}
};

export const countAppliedFilters = (filter) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest that this be a function of the Filter model to keep it all in one place.
In its current form, this could easily be broken if a developer makes changes to Filter and isn't aware of this function.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It would also be good to create a test for this function.

countAppliedFilters(verifyContext.filter) > 0 ?
<Avatar className={classes.activeFilters}>
{
countAppliedFilters(verifyContext.filter)
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's no need to call the function twice.
Assign the result to a variable and check that instead.

color="primary"
onClick={handleFilterClick}
startIcon={<IconFilter />}
key={1}
>
Filter
{
countAppliedFilters(verifyContext.filter) > 0 ?
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be expressed as:

(countAppliedFilters(verifyContext.filter) > 0) && <Avatar...

There's no need for the ternary operator.

numFilters += 1;
} else if ((key === 'dateStart' || key === 'dateEnd') && filter[key] !== undefined) {
numFilters += 1;
} else if (key == 'organizationId' && filter[key] !== 'ALL_ORGANIZATIONS') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have ALL_ORGANIZATIONS and ALL_SPECIES defined as variables in src/models/filter.js. It's best to use those in place of these string literals.

Copy link
Collaborator

@nmcharlton nmcharlton left a comment

Choose a reason for hiding this comment

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

Nice work!

@nmcharlton nmcharlton merged commit db18bc6 into Greenstand:master Oct 19, 2021
@tranquanghuy0801 tranquanghuy0801 deleted the feat-81 branch October 19, 2021 11:38
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.

Indicate that Verify filters are applied when filter dialog is hidden
2 participants