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

💊 Adds support for editing prescriptions + Adds useSlug hook #6369

Merged
merged 5 commits into from
Oct 4, 2023

Conversation

rithviknishad
Copy link
Member

@rithviknishad rithviknishad commented Sep 29, 2023

WHAT

🤖 Generated by Copilot at 3208fac

This pull request adds and modifies several files to implement the feature of editing prescriptions from the PrescriptionAdministrationsTable component. It adds toast notifications for global form errors, refactors the validation logic for the prescription form, adds type definitions for the prescription API routes, and adds custom hooks for extracting slugs from the URL. It also fixes a formatting issue in the localization file and adds a value prop to the NumericWithUnitsFormField component.

Proposed Changes

  • Fixes Make Medicine administration editable #6340
  • Adds hook useSlug to retrieve path params from the route to remove the pain of passing it to deeply nested components.
  • Fixed bug: NumericWithUnitsFormField not showing initial value
image image image image

@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

🤖 Generated by Copilot at 3208fac

  • Add two custom hooks useSlug and useSlugs to extract slugs from the current path based on prefixes (link)
  • Add a global error message property $all to the FormErrors type and display it using toast notifications in the Form component (link, link, link)
  • Add a value prop to the NumericWithUnitsFormField component to pass the numeric value of the field (link)
  • Extract the validation logic for creating a prescription to a separate function PrescriptionFormValidator and import it in the CreatePrescriptionForm component (link, link, link)
  • Add a new component EditPrescriptionForm for editing an existing prescription, which takes an initial prescription object and a callback function as props, and renders a form with the same fields as the CreatePrescriptionForm component, but with the initial values populated (link)
  • Add a validation function EditPrescriptionFormValidator for editing a prescription, which takes an old and a new prescription object as arguments, and calls the PrescriptionFormValidator function on the new object, and also checks if the objects are the same, and if so, adds a global error message (link)
  • Add an Edit button to the PrescriptionRow component in the PrescriptionAdministrationsTable component, which shows a modal dialog with the EditPrescriptionForm component when clicked (link, link, link, link)
  • Add the id property as required to the BasePrescription type (link)
  • Add the TBody and TRes properties to the createPrescription and discontinuePrescription routes in the api.tsx file, which specify the types of the request and response bodies for the API routes (link, link, link)
  • Add two new entries to the Medicine.json file for the caution note and the reason for edit field in the EditPrescriptionForm component (link)
  • Remove an unused import statement for the FieldError type in the CreatePrescriptionForm.tsx file (link)
  • Remove a trailing comma from the last entry in the Medicine.json file (link)

@vercel
Copy link

vercel bot commented Sep 29, 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 Oct 3, 2023 1:28pm

@netlify
Copy link

netlify bot commented Sep 29, 2023

Deploy Preview for care-egov-staging ready!

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

@cypress
Copy link

cypress bot commented Sep 29, 2023

Passing run #1347 ↗︎

0 78 0 0 Flakiness 0

Details:

💊 Adds support for editing prescriptions + Adds `useSlug` hook
Project: CARE Commit: cb775a57d3
Status: Passed Duration: 02:36 💡
Started: Oct 3, 2023 1:31 PM Ended: Oct 3, 2023 1:34 PM

Review all test suite changes for PR #6369 ↗︎

@nihal467
Copy link
Member

nihal467 commented Oct 3, 2023

LGTM

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Oct 3, 2023
@github-actions
Copy link

github-actions bot commented Oct 3, 2023

👋 Hi, @rithviknishad,
Conflicts have been detected against the base branch. Please rebase your branch against the base branch.


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

@github-actions github-actions bot removed the merge conflict pull requests with merge conflict label Oct 3, 2023
@khavinshankar khavinshankar merged commit c7c37c6 into develop Oct 4, 2023
52 of 53 checks passed
@khavinshankar khavinshankar deleted the prescriptions/edit branch October 4, 2023 04:33
@github-actions
Copy link

github-actions bot commented Oct 4, 2023

@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 🙌.

Ashesh3 pushed a commit that referenced this pull request Oct 4, 2023
* Adds hook: `useSlug`

* bug fix: NumericWithUnits field not showing intial value

* Form: support for showing global errors

* Adds support for editing prescriptions (fixes #6340)
khavinshankar pushed a commit that referenced this pull request Oct 17, 2023
* Middleware override feature in asset location

* Fix tooltip clipping

* Fix Flaky Cypress test in Facility Module  (#6384)

* fix random facility page failure

* fix random facility page failure

* Revert "Prescriptions: Shrink discontinued prescriptions + Flip MAR timeline + Freeze primary columns in horizontal scroll (#6282)" (#6386)

This reverts commit 5009a86.

* Refactor Asset Model Import Formatting (#6388)

* Refactor Asset Model Import Formatting

* fixes to warranty_amc_end_of_validity

* Fix asset import file for cypress

* Refactor: replaced Dispatch to useQuery/Request of src/Components/Auth/log… (#6333)

* Refactor: replaced useDispatch to useQuery of src/Components/Auth/login.tsx

* fix:useQuery changed to Request

* feat: replaced dispatch with request

* fix: types and added pathparams

* fix: request body error

* Update Login.tsx

* change:Tres to Tbody

* fixes: response type change

* Update package-lock.json

* fix hover height (#6352)

* Split routes of App Router (#6363)

* Prescription: show prescribed on & by and discontinued date in detail card (#6365)

* Fixed bug in location picker in update facility page (#6377)

* add all cases for map rendering

* implement location pointer on searched location

* Added cam auto reset in asset config page (#6375)

* 💊 Adds support for editing prescriptions +  Adds `useSlug` hook (#6369)

* Adds hook: `useSlug`

* bug fix: NumericWithUnits field not showing intial value

* Form: support for showing global errors

* Adds support for editing prescriptions (fixes #6340)

* Fix cypress

* fix cypress

* Improve design

---------

Co-authored-by: Mohammed Nihal <57055998+nihal467@users.noreply.github.com>
Co-authored-by: Rithvik Nishad <mail@rithviknishad.dev>
Co-authored-by: Aaron Jevil Nazareth <93522968+jevil25@users.noreply.github.com>
Co-authored-by: Pranshu Aggarwal <70687348+Pranshu1902@users.noreply.github.com>
Co-authored-by: Gampa Sri Harsh <114745442+sriharsh05@users.noreply.github.com>
Co-authored-by: Tasnimul H. Tauhid <thtauhid.71@gmail.com>
rithviknishad added a commit that referenced this pull request Oct 17, 2023
* Middleware override feature in asset location

* Fix tooltip clipping

* Fix Flaky Cypress test in Facility Module  (#6384)

* fix random facility page failure

* fix random facility page failure

* Revert "Prescriptions: Shrink discontinued prescriptions + Flip MAR timeline + Freeze primary columns in horizontal scroll (#6282)" (#6386)

This reverts commit 5009a86.

* Refactor Asset Model Import Formatting (#6388)

* Refactor Asset Model Import Formatting

* fixes to warranty_amc_end_of_validity

* Fix asset import file for cypress

* Refactor: replaced Dispatch to useQuery/Request of src/Components/Auth/log… (#6333)

* Refactor: replaced useDispatch to useQuery of src/Components/Auth/login.tsx

* fix:useQuery changed to Request

* feat: replaced dispatch with request

* fix: types and added pathparams

* fix: request body error

* Update Login.tsx

* change:Tres to Tbody

* fixes: response type change

* Update package-lock.json

* fix hover height (#6352)

* Split routes of App Router (#6363)

* Prescription: show prescribed on & by and discontinued date in detail card (#6365)

* Fixed bug in location picker in update facility page (#6377)

* add all cases for map rendering

* implement location pointer on searched location

* Added cam auto reset in asset config page (#6375)

* 💊 Adds support for editing prescriptions +  Adds `useSlug` hook (#6369)

* Adds hook: `useSlug`

* bug fix: NumericWithUnits field not showing intial value

* Form: support for showing global errors

* Adds support for editing prescriptions (fixes #6340)

* Fix cypress

* fix cypress

* Improve design

---------

Co-authored-by: Mohammed Nihal <57055998+nihal467@users.noreply.github.com>
Co-authored-by: Rithvik Nishad <mail@rithviknishad.dev>
Co-authored-by: Aaron Jevil Nazareth <93522968+jevil25@users.noreply.github.com>
Co-authored-by: Pranshu Aggarwal <70687348+Pranshu1902@users.noreply.github.com>
Co-authored-by: Gampa Sri Harsh <114745442+sriharsh05@users.noreply.github.com>
Co-authored-by: Tasnimul H. Tauhid <thtauhid.71@gmail.com>
Ashesh3 added a commit that referenced this pull request Oct 20, 2023
* Middleware override feature in asset location

* Fix tooltip clipping

* Fix Flaky Cypress test in Facility Module  (#6384)

* fix random facility page failure

* fix random facility page failure

* Revert "Prescriptions: Shrink discontinued prescriptions + Flip MAR timeline + Freeze primary columns in horizontal scroll (#6282)" (#6386)

This reverts commit 5009a86.

* Refactor Asset Model Import Formatting (#6388)

* Refactor Asset Model Import Formatting

* fixes to warranty_amc_end_of_validity

* Fix asset import file for cypress

* Refactor: replaced Dispatch to useQuery/Request of src/Components/Auth/log… (#6333)

* Refactor: replaced useDispatch to useQuery of src/Components/Auth/login.tsx

* fix:useQuery changed to Request

* feat: replaced dispatch with request

* fix: types and added pathparams

* fix: request body error

* Update Login.tsx

* change:Tres to Tbody

* fixes: response type change

* Update package-lock.json

* fix hover height (#6352)

* Split routes of App Router (#6363)

* Prescription: show prescribed on & by and discontinued date in detail card (#6365)

* Fixed bug in location picker in update facility page (#6377)

* add all cases for map rendering

* implement location pointer on searched location

* Added cam auto reset in asset config page (#6375)

* 💊 Adds support for editing prescriptions +  Adds `useSlug` hook (#6369)

* Adds hook: `useSlug`

* bug fix: NumericWithUnits field not showing intial value

* Form: support for showing global errors

* Adds support for editing prescriptions (fixes #6340)

* Fix cypress

* fix cypress

* Improve design

---------

Co-authored-by: Mohammed Nihal <57055998+nihal467@users.noreply.github.com>
Co-authored-by: Rithvik Nishad <mail@rithviknishad.dev>
Co-authored-by: Aaron Jevil Nazareth <93522968+jevil25@users.noreply.github.com>
Co-authored-by: Pranshu Aggarwal <70687348+Pranshu1902@users.noreply.github.com>
Co-authored-by: Gampa Sri Harsh <114745442+sriharsh05@users.noreply.github.com>
Co-authored-by: Tasnimul H. Tauhid <thtauhid.71@gmail.com>
Ashesh3 added a commit that referenced this pull request Oct 23, 2023
* Middleware override feature in asset location

* Fix tooltip clipping

* Fix Flaky Cypress test in Facility Module  (#6384)

* fix random facility page failure

* fix random facility page failure

* Revert "Prescriptions: Shrink discontinued prescriptions + Flip MAR timeline + Freeze primary columns in horizontal scroll (#6282)" (#6386)

This reverts commit 5009a86.

* Refactor Asset Model Import Formatting (#6388)

* Refactor Asset Model Import Formatting

* fixes to warranty_amc_end_of_validity

* Fix asset import file for cypress

* Refactor: replaced Dispatch to useQuery/Request of src/Components/Auth/log… (#6333)

* Refactor: replaced useDispatch to useQuery of src/Components/Auth/login.tsx

* fix:useQuery changed to Request

* feat: replaced dispatch with request

* fix: types and added pathparams

* fix: request body error

* Update Login.tsx

* change:Tres to Tbody

* fixes: response type change

* Update package-lock.json

* fix hover height (#6352)

* Split routes of App Router (#6363)

* Prescription: show prescribed on & by and discontinued date in detail card (#6365)

* Fixed bug in location picker in update facility page (#6377)

* add all cases for map rendering

* implement location pointer on searched location

* Added cam auto reset in asset config page (#6375)

* 💊 Adds support for editing prescriptions +  Adds `useSlug` hook (#6369)

* Adds hook: `useSlug`

* bug fix: NumericWithUnits field not showing intial value

* Form: support for showing global errors

* Adds support for editing prescriptions (fixes #6340)

* Fix cypress

* fix cypress

* Improve design

---------

Co-authored-by: Mohammed Nihal <57055998+nihal467@users.noreply.github.com>
Co-authored-by: Rithvik Nishad <mail@rithviknishad.dev>
Co-authored-by: Aaron Jevil Nazareth <93522968+jevil25@users.noreply.github.com>
Co-authored-by: Pranshu Aggarwal <70687348+Pranshu1902@users.noreply.github.com>
Co-authored-by: Gampa Sri Harsh <114745442+sriharsh05@users.noreply.github.com>
Co-authored-by: Tasnimul H. Tauhid <thtauhid.71@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make Medicine administration editable
3 participants