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

Upgrading old UI components with new ones #10049

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

Conversation

NikhilA8606
Copy link
Contributor

@NikhilA8606 NikhilA8606 commented Jan 19, 2025

Replaced DateFormField with DatePicker ui component

  • Fixes Replacing older UI components with new UI components #10048
  • New Features
    • Introduced a new DatePicker component for date of birth selection in patient registration
  • Improvements
    • Simplified date handling logic in the patient registration form
    • Streamlined date input process with more direct date selection mechanism

image

These are the components to be replaced.

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

@rithviknishad

@NikhilA8606 NikhilA8606 requested a review from a team as a code owner January 19, 2025 06:55
Copy link
Contributor

coderabbitai bot commented Jan 19, 2025

Walkthrough

The pull request introduces a new DatePicker component to replace the existing DateFormField in the PatientRegistration component. The changes focus on simplifying the date input handling for the date of birth field by using a more streamlined approach with the new component. The integration involves modifying how the date is set, handled, and processed within the form, with some adjustments to the date selection logic.

Changes

File Change Summary
src/pages/PublicAppointments/PatientRegistration.tsx Replaced DateFormField with new DatePicker component for date of birth input
src/components/ui/date-picker Added new DatePicker component implementation

Assessment against linked issues

Objective Addressed Explanation
Replace older UI components with ShadCN UI [#10048]

Possibly related PRs

Suggested labels

needs review, changes required

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

🐰 A DatePicker hops into view,
Replacing old fields with something new
Smooth as a carrot, swift as can be
UI components dance with glee!
Coding magic, watch it bloom! 🌱


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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. (Beta)
  • @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 Jan 19, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit cdc745e
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/678ca1da1bff1f0008e00a1a
😎 Deploy Preview https://deploy-preview-10049--care-ohc.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
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
src/pages/PublicAppointments/PatientRegistration.tsx (1)

Line range hint 89-89: Improve date validation in the schema.

The current schema validation for date_of_birth needs improvement:

  1. Remove the string type to maintain type consistency.
  2. Add validation for minimum date.

Apply this diff to improve the schema:

-date_of_birth: z.date().or(z.string()).optional(),
+date_of_birth: z.date()
+  .optional()
+  .refine(
+    (date) => {
+      if (!date) return true;
+      const minDate = new Date();
+      minDate.setFullYear(minDate.getFullYear() - 150);
+      return date >= minDate && date <= new Date();
+    },
+    { message: t("invalid_date_range") }
+  ),
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 206ee47 and cdc745e.

📒 Files selected for processing (1)
  • src/pages/PublicAppointments/PatientRegistration.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: cypress-run (1)
  • GitHub Check: OSSAR-Scan
🔇 Additional comments (2)
src/pages/PublicAppointments/PatientRegistration.tsx (2)

11-11: LGTM!

The import statement for the new DatePicker component follows the project's conventions.


Line range hint 193-193: Verify date formatting in form submission.

The dateQueryString utility is used to format the date, but there's no validation to ensure the date is properly formatted.

Run this script to verify the implementation of dateQueryString:

Comment on lines +322 to +326
<DatePicker
date={
field.value ? new Date(field.value) : undefined
}
onChange={(dateObj: {
name: string;
value: Date;
}) => {
if (dateObj?.value instanceof Date) {
field.onChange(dateObj.value.toISOString());
} else {
field.onChange(null);
}
}}
disableFuture
min={new Date(1900, 0, 1)}
className="-mb-6"
onChange={(date) => field.onChange(date)}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add date validation and improve type safety.

The DatePicker implementation needs several improvements:

  1. Add validation to prevent future dates (previously handled by disableFuture).
  2. Add type validation for the date conversion.
  3. Sanitize the date input before form mutation.
  4. Add accessibility attributes.

Apply this diff to address these issues:

 <DatePicker
-  date={field.value ? new Date(field.value) : undefined}
-  onChange={(date) => field.onChange(date)}
+  date={field.value ? new Date(field.value) : undefined}
+  onChange={(date) => {
+    if (date && date > new Date()) {
+      return;
+    }
+    field.onChange(date);
+  }}
+  disableFuture
+  aria-label={t("date_of_birth")}
 />

Committable suggestion skipped: line range outside the PR's diff.

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.

Replacing older UI components with new UI components
1 participant