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

Sort wards by ward number in filters + adds utility method: compareBy #6852

Merged
merged 4 commits into from
Dec 14, 2023

Conversation

rithviknishad
Copy link
Member

@rithviknishad rithviknishad commented Dec 12, 2023

WHAT

🤖[deprecated] Generated by Copilot at b9637f3

The pull request refactors and improves the code for sorting and displaying data related to diagnoses, external results, facilities, and patients. It uses consistent and imported types, and a common utility function compareByKey for sorting arrays of objects by a given key. It affects the files LegacyDiagnosesList.tsx, ListFilter.tsx, ResultUpdate.tsx, FacilityCreate.tsx, RangeAutocompleteFormField.tsx, PatientRegister.tsx, models.tsx, and utils.ts.

Proposed Changes

const sortedItems = items.toSorted(compareBy("quantity"));
// equivalent to:
const sortedItems = items.toSorted((a, b) => a["quantity"] < b["quantity"] ? -1 : a["quantity"] > b["quantity"] ? 1 : 0);


items.sort(compareBy("quantity"));
// equivalent to:
items.sort((a, b) => a["quantity"] < b["quantity"] ? -1 : a["quantity"] > b["quantity"] ? 1 : 0);

@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

HOW

🤖[deprecated] Generated by Copilot at b9637f3

  • Import and use compareByKey function for sorting arrays of objects by a given key in various components (link, link, link, link, link, link, link, link, link, link, link)
  • Refactor and type wardList, lsgList, wards, and selectedLsgs state variables and props in ListFilter.tsx using WardModel and LocalBodyModel types (link, link, link)
  • Simplify and enhance MultiSelectFormField components for local_bodies and wards in ListFilter.tsx by using optionDescription prop and removing unnecessary wrappers and functions (link, link, link)
  • Modify WardModel interface in models.tsx to include panchayath and local_body_id fields and use LocalBodyModel["id"] type (link)
  • Type states, districts, localBodies, and ward state variables and props in FacilityCreate.tsx using StateModel, DistrictModel, LocalBodyModel, and WardModel types and remove unused interfaces (link, link, link)
  • Add compareByKey function to utils.ts as a utility function for sorting arrays of objects by a given key (link)

@rithviknishad rithviknishad requested a review from a team as a code owner December 12, 2023 11:55
Copy link

netlify bot commented Dec 12, 2023

Deploy Preview for care-egov-staging ready!

Name Link
🔨 Latest commit c2c8a96
🔍 Latest deploy log https://app.netlify.com/sites/care-egov-staging/deploys/657aca4c176648000830c688
😎 Deploy Preview https://deploy-preview-6852--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.

Copy link

vercel bot commented Dec 12, 2023

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 Dec 14, 2023 9:27am

@rithviknishad rithviknishad changed the title Add utility: compareByKey, sort wards in filters Sort wards by ward number in filters + adds utility method: compareByKey Dec 12, 2023
@rithviknishad rithviknishad changed the title Sort wards by ward number in filters + adds utility method: compareByKey Sort wards by ward number in filters + adds utility method: compareBy Dec 12, 2023
Copy link

cypress bot commented Dec 14, 2023

Passing run #1719 ↗︎

0 91 0 0 Flakiness 0

Details:

Sort wards by ward number in filters + adds utility method: `compareBy`
Project: CARE Commit: c2c8a96edc
Status: Passed Duration: 02:40 💡
Started: Dec 14, 2023 9:48 AM Ended: Dec 14, 2023 9:51 AM

Review all test suite changes for PR #6852 ↗︎

@nihal467
Copy link
Member

LGTM

@khavinshankar khavinshankar merged commit 56f0c2b into develop Dec 14, 2023
35 of 38 checks passed
@khavinshankar khavinshankar deleted the rithviknishad/sort-wards branch December 14, 2023 11:42
Copy link

@rithviknishad 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sort Wards list based on numeric order instead of character code order
3 participants