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

Fix inconsistent removal of facility filters #7031

Merged
merged 6 commits into from
Jan 23, 2024

Conversation

Omkar76
Copy link
Contributor

@Omkar76 Omkar76 commented Jan 15, 2024

Proposed Changes

@coronasafe/care-fe-code-reviewers @coronasafe/code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA
facility-filter.webm

@Omkar76 Omkar76 requested a review from a team as a code owner January 15, 2024 06:08
Copy link

vercel bot commented Jan 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
care-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 22, 2024 5:49pm

Copy link

netlify bot commented Jan 15, 2024

Deploy Preview for care-egov-staging ready!

Name Link
🔨 Latest commit 9772884
🔍 Latest deploy log https://app.netlify.com/sites/care-egov-staging/deploys/65aeaa73f15b9f0008459d38
😎 Deploy Preview https://deploy-preview-7031--care-egov-staging.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@nihal467
Copy link
Member

@Omkar76 the facility page filter cache functionality is not working.

Steps to reproduce:

  1. Apply facility advance filters and visit patient using the side bar
  2. come back to facility page and the applied filters are missing

@Omkar76
Copy link
Contributor Author

Omkar76 commented Jan 17, 2024

Debugged it. So qParams is empty when we go back to /facility/. The useFilters() hook will update url by reading localStorage. but by this time useEffect() in HospitalList has already batched remove operation for district and local_body params bacause it found !qParams.state to be true on very first render cycle.

Solved this by checking if qParams is empty - in this case we don't remove any params.
Video is updated in PR.

Comment on lines 40 to 47
if (Object.keys(qParams).length === 0) return;
if (!qParams.state) {
advancedFilter.removeFilters(["district", "local_body"]);
}
if (!qParams.district) {
advancedFilter.removeFilters(["local_body"]);
}
}, [advancedFilter, qParams]);
Copy link
Member

Choose a reason for hiding this comment

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

I still find if (Object.keys(qParams).length === 0) return; line hard to understand why it's there. Maybe would the following be a more readable and correct approach of what you are trying to do?

cc: @Ashesh3

Suggested change
if (Object.keys(qParams).length === 0) return;
if (!qParams.state) {
advancedFilter.removeFilters(["district", "local_body"]);
}
if (!qParams.district) {
advancedFilter.removeFilters(["local_body"]);
}
}, [advancedFilter, qParams]);
if (!qParams.state && (qParams.district || qParams.local_body)) {
advancedFilter.removeFilters(["district", "local_body"]);
}
if (!qParams.district && qParams.local_body) {
advancedFilter.removeFilters(["local_body"]);
}
}, [advancedFilter, qParams]);

Copy link
Member

Choose a reason for hiding this comment

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

The suggestion seems good and reads better.

  • If state is not present, but district or local_body is, then remove both
  • If district is not preset but we still have local_body, then remove it.

@nihal467
Copy link
Member

LGTM

@khavinshankar khavinshankar added good to merge reviewed reviewed by a core member and removed needs review labels Jan 23, 2024
@khavinshankar khavinshankar merged commit 5c08e16 into ohcnetwork:develop Jan 23, 2024
36 checks passed
Copy link

@Omkar76 We truly appreciate your efforts. Thank you for taking the time to contribute; this is a very valuable contribution to us 🥇. We always welcome your contribution 🙂, so feel free to contribute to anything anytime, and never lose that spirit of innovation 🙌.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good to merge reviewed reviewed by a core member tested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent Auto-Removal of facility advance Filter When Closing Parent Filter
5 participants