-
Notifications
You must be signed in to change notification settings - Fork 347
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
Fixed malfunction of patient filter #5328
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
✅ Deploy Preview for care-egov-staging ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
the facility name and location is not getting removed in the asset tab, when we close the badge |
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.
@patelaryan7751 it seems like we are introducing quite a few hacks to manage something simple.
It did work before without these many hacks before. Isn't it as simple as getting the filter state from query parama, resolving it to object by the parent component, passing the resolved filter objects to the FiltersSlideOver component without needing to manage too many states inside the FiltersSlideOver component itself as it's already managed by the parent?
cc: @khavinshankar
src/Common/validation.tsx
Outdated
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.
@patelaryan7751 could you add doc comments to explain what this does? or maybe give more appropriate name for the function?
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.
@rithviknishad Yeah sure actually this function checks whether 2 JSON objects passed are equal or not irrespective of the order in which they are provided.
useEffect(() => { | ||
if (!isPreventChangeFilterStateOn) { | ||
setFilterState(filter); | ||
} | ||
}, [filter]); |
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.
not a fan of this hack.
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.
@rithviknishad This actually prevents the sync of query params and the filterState of advanced filter.
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.
Why would you need that to be prevented?
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.
@rithviknishad There are many state changes happening to the filterState . So I want the changes to be synced only when someone clicks on apply filter button.
@rithviknishad Yes it is simple to just pass the query param to the filterState of respective advanced filters but there are fields that cannot be directly assigned from query params specifically the fields which are involving selecting facility from the dropdown. There is a different state variable prefix()_ref type in the filterState which contains all info of the selected facility we need to assign it to null in order to clear the advanced filter state when a badge is cleared. So, directly passing it to the parent state need some modifications, which I did, using useEffect hook . In simple terms, I am trying to sync the filterState of advanced filters with the query params when there is any change caused by badges outside. If there is any other method to do this then I can rework on it. |
SonarCloud Quality Gate failed.
|
I'm not sure if you understood it, let me rephrase. The current filter state is stored in the URL's query params right? Which is a The parent component (eg. So before even you reach the AssetsFilter (Slideover) component, you already have a Passing this to the slide-over should simply work right? Now for the clearFilter, the behaviour is pretty simple and straightforward across all filters. It just needs to navigate to the URL without query params. Updating the state need not be done since the qParams automatically will be updated since URL has changed, hence relevant parts will be re-rendered and states get updated. So make it a generalized function coming from the filters slideover component itself, that does it since it's not dependent on which filters it is part of. (I'm not sure if I'm missing something you are trying to convey, correct me if I'm wrong) |
👋 Hi, @patelaryan7751, This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there. |
Closing as you've continued in #5362 |
WHAT
🤖 Generated by Copilot at f537466
This change improves the filter functionality of the patient component by using a
useEffect
hook to sync the local filter state with thefilter
prop from the parent component. It affects the filesrc/Components/Patient/PatientFilter.tsx
.Proposed Changes
Fixed malfunction of patient filter
filter.mp4
@coronasafe/care-fe-code-reviewers @coronasafe/code-reviewers
Merge Checklist
HOW
🤖 Generated by Copilot at f537466
useEffect
hook to synchronize the filter state with the parent component (link)