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: Crash on Appointment Selection in questionnaire Preview #11312

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

DonXavierdev
Copy link
Contributor

@DonXavierdev DonXavierdev commented Mar 15, 2025

Proposed Changes

demo video

Screen.Recording.2025-03-15.at.9.10.37.PM.mov

@ohcnetwork/care-fe-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 in Mobile Devices
  • Completion of QA in Desktop Devices

Summary by CodeRabbit

  • New Features
    • Enhanced appointment scheduling: Users now receive a clear message—"Appointment cannot be recorded without an active encounter"—when an appointment is attempted without the necessary encounter.
    • Improved display logic: The appointment section now conditionally renders content based on the availability of required information, providing a fallback message when needed.

@DonXavierdev DonXavierdev requested a review from a team as a code owner March 15, 2025 15:43
Copy link
Contributor

coderabbitai bot commented Mar 15, 2025

Walkthrough

This pull request introduces a new translation entry in the English locale file to provide a specific error message when recording an appointment without an active encounter. Additionally, it refactors the appointment question components by removing the useSlug hook and instead passing a facilityId prop directly to the AppointmentQuestion component. The rendering logic in the QuestionInput component is updated to conditionally display the appointment question or a fallback message based on the presence of the facilityId, ensuring the component functions correctly with the new prop-based approach.

Changes

File(s) Change Summary
public/locale/en.json Added translation key "questionnaire_appointment_no_encounter": "Appointment cannot be recorded without an active encounter" to clarify error messaging.
src/.../QuestionTypes/AppointmentQuestion.tsx
src/.../QuestionTypes/QuestionInput.tsx
In AppointmentQuestion.tsx: Removed the useSlug hook and added a facilityId prop, integrating it with the query call. In QuestionInput.tsx: Added conditional rendering to display the appointment question if facilityId exists, otherwise shows a fallback no-encounter message.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant QInput as QuestionInput
    participant AQuestion as AppointmentQuestion
    participant API

    User->>QInput: Initiate appointment process
    alt facilityId exists
        QInput->>AQuestion: Render with facilityId prop
        AQuestion->>API: Query available slots using facilityId
        API-->>AQuestion: Return available slots
    else facilityId missing
        QInput-->>User: Display fallback "no encounter" message
    end
Loading

Possibly related PRs

Suggested labels

needs testing, needs review

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

Hop, hop, through lines of code I roam,
Adding keys so warnings call home.
Removed hooks for props so bright,
Conditions now guide the flight.
With error messages clear as day,
This rabbit smiles and hops away! 🐰
ASCII cheers in every display!

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c8d6ad2 and ecfc31c.

📒 Files selected for processing (3)
  • public/locale/en.json (1 hunks)
  • src/components/Questionnaire/QuestionTypes/AppointmentQuestion.tsx (2 hunks)
  • src/components/Questionnaire/QuestionTypes/QuestionInput.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (1)
🔇 Additional comments (4)
public/locale/en.json (1)

1966-1966: Well-implemented error message for appointment creation requirement

This new error message clearly communicates to users that an active encounter is required to record an appointment, improving user experience by providing explicit feedback.

src/components/Questionnaire/QuestionTypes/QuestionInput.tsx (1)

168-173: Good defensive coding with conditional rendering

The conditional rendering of the AppointmentQuestion component based on the presence of facilityId prevents potential runtime errors and provides a clear error message to the user, following the same pattern used for other structured question types.

src/components/Questionnaire/QuestionTypes/AppointmentQuestion.tsx (2)

50-50: Appropriate prop addition for component interface

Adding the facilityId prop to the interface properly documents the component's requirements, enhancing code readability and type safety.


81-81: Clean prop handling in component parameters

Using the facilityId prop directly in the component parameters follows good React patterns, making the data flow more explicit and easier to track compared to deriving it internally with a hook.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Mar 15, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit ecfc31c
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67d5a0288dfdfa00087c0ec9
😎 Deploy Preview https://deploy-preview-11312.preview.ohc.network
📱 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.

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.

Questionnaire Preview Crashes on Specific Question Selection
1 participant