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

Fixes deploy: missing plugin map missing import; calendar component; and other minor fixes #9632

Merged
merged 9 commits into from
Jan 1, 2025

Conversation

rithviknishad
Copy link
Member

@rithviknishad rithviknishad commented Dec 31, 2024

Proposed Changes

@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

Summary by CodeRabbit

Summary by CodeRabbit

Release Notes

  • Dependencies

    • Added new Radix UI dependencies for dialog, label, and popover components.
    • Downgraded react-day-picker version.
    • Re-added date-fns dependency.
  • Error Handling

    • Enhanced error handling with new 404 Not Found error toast notifications.
    • Streamlined error reporting in the file upload process.
  • User Interface

    • Updated phone number input fields to use telephone input type for improved user experience.
    • Modified calendar navigation component naming for consistency.
    • Updated resource filter default state values to improve state representation.
  • Workflow

    • Removed test execution step from the deployment workflow for streamlined operations.
    • Adjusted Cypress workflow by removing Chrome installation steps.
  • Docker

    • Adjusted npm installation process to ignore scripts during build stage.

@rithviknishad rithviknishad requested a review from a team as a code owner December 31, 2024 14:00
Copy link
Contributor

coderabbitai bot commented Dec 31, 2024

Walkthrough

The pull request introduces several modifications across different files. In package.json, new Radix UI dependencies were added, and the react-day-picker version was downgraded. The errorHandler.ts file now includes enhanced error handling with toast notifications for 404 errors. The ResourceFilter.tsx component updated its initial state to use null for certain filter properties. The CreateUserForm.tsx modified phone number input types to improve mobile user experience. Lastly, the calendar.tsx component renamed navigation button components.

Changes

File Change Summary
package.json - Added @radix-ui/[email protected], @radix-ui/[email protected], @radix-ui/[email protected]
- Downgraded react-day-picker from ^9.5.0 to ^8.10.1
- Re-added date-fns@^3.6.0
src/Utils/request/errorHandler.ts - Added toast import from sonner
- Implemented isNotFound function
- Added 404 error handling with toast notification
src/components/Resource/ResourceFilter.tsx - Changed default filter state values from empty strings to null
- Updated applyFilter to handle null values
src/components/Users/CreateUserForm.tsx - Changed phone number input types to type="tel"
src/components/ui/calendar.tsx - Renamed PreviousMonthButton to IconLeft
- Renamed NextMonthButton to IconRight
- Removed className prop for chevron icons
scripts/setup-care-apps.ts - Added import for PluginManifest type
src/Utils/request/uploadFile.ts - Simplified error handling logic for client errors
Dockerfile - Changed npm install command to --ignore-scripts and added post-install commands
.github/workflows/deploy.yaml - Removed "Run tests" step from the workflow

Assessment against linked issues

Objective Addressed Explanation
Clear all filter badge visibility [#9556] Changes in ResourceFilter.tsx might impact filter handling, but direct resolution is unclear

Possibly related PRs

Suggested labels

tested, P1

Suggested reviewers

  • Jacobjeevan
  • khavinshankar

Poem

🐰 Hop, hop, through code's green field,
Dependencies dance, new features revealed!
Filters reset, inputs refined,
A rabbit's touch, with changes intertwined!
Code leaps forward, smooth and bright! 🚀


📜 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 307c981 and 5f11ced.

📒 Files selected for processing (1)
  • .github/workflows/cypress.yaml (0 hunks)
💤 Files with no reviewable changes (1)
  • .github/workflows/cypress.yaml

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 Dec 31, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 5f11ced
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/6774effa114efb0008f7ed57
😎 Deploy Preview https://deploy-preview-9632--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.

@github-actions github-actions bot added the Deploy-Failed Deplyment is not showing preview label Dec 31, 2024
@rithviknishad rithviknishad changed the title Rithviknishad/enhancements 2 Notify for not found responses; fixes calendar component; and other minor fixes Dec 31, 2024
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: 0

🧹 Nitpick comments (3)
src/Utils/request/errorHandler.ts (2)

2-2: Consider unifying toast usage with the existing Notifications system.
Using toast from "sonner" introduces a second notification mechanism. For consistency, consider unifying the approach to maintain a standardized user experience.


23-27: Internationalize the 'Not found' toast message.
If the rest of the app employs i18n for user-facing strings, localizing this error message will ensure consistency.

src/components/ui/calendar.tsx (1)

63-64: Ensure component renaming aligns with desired semantics.
While IconLeft and IconRight might be clear internally, confirm they convey navigational context for the next developers. Alternatively, renaming them to NavLeft and NavRight or something similar might be more intuitive.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c92ab28 and 2a5a2e3.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • package.json (5 hunks)
  • src/Utils/request/errorHandler.ts (3 hunks)
  • src/components/Resource/ResourceFilter.tsx (1 hunks)
  • src/components/Users/CreateUserForm.tsx (2 hunks)
  • src/components/ui/calendar.tsx (1 hunks)
🔇 Additional comments (6)
src/Utils/request/errorHandler.ts (1)

62-64: Minimalistic 404 check looks great.
The isNotFound helper function is concise, self-descriptive, and effective at capturing 404 responses.

src/components/Resource/ResourceFilter.tsx (1)

28-34: Initializing filters with null is a sensible approach.
Switching from empty strings to null can reduce confusion around unset values, especially when checking for the presence of a filter. Verify any code that expects string defaults still functions correctly.

src/components/Users/CreateUserForm.tsx (2)

277-277: Good use of type="tel" for phone number.
This ensures the correct input type on mobile devices. For further clarity and validation, you could incorporate additional attributes (e.g., pattern or inputMode) to guide user input.


293-293: Revisit disabling the alt phone field when WhatsApp is checked.
If a user wants to enter a different alt phone number, they must uncheck “WhatsApp number is same as phone number.” Make sure the user experience is clear: consider adding a tooltip or helper text so they understand why the field is disabled.

package.json (2)

62-67: LGTM! New Radix UI components added.

The addition of Radix UI components (@radix-ui/react-dialog, @radix-ui/react-label, @radix-ui/react-popover) aligns with the PR objectives for UI enhancements. The versions are stable and compatible with existing Radix dependencies.

Run the following script to verify the usage of new components:

✅ Verification successful

All newly added Radix UI components are actively used in the codebase

The verification confirms that all the newly added Radix UI components (@radix-ui/react-dialog, @radix-ui/react-label, @radix-ui/react-popover) are being actively used throughout the codebase:

  • Dialog components are used in multiple features including file management, encounters, patient registration, and medicine administration
  • Label components are extensively used in forms, questionnaires, and user interfaces
  • Popover components are implemented in date pickers, user selectors, and various interactive elements

The components are properly integrated into the application's UI system and follow consistent usage patterns, confirming that these dependencies are necessary additions.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of newly added Radix UI components

echo "Checking Dialog component usage..."
rg "Dialog\." --type ts --type tsx

echo "Checking Label component usage..."
rg "Label\." --type ts --type tsx

echo "Checking Popover component usage..."
rg "Popover\." --type ts --type tsx

Length of output: 431


Script:

#!/bin/bash
# Description: Verify the usage of newly added Radix UI components with correct file type flags

echo "Checking Dialog component usage..."
rg "from '@radix-ui/react-dialog'" 

echo "Checking Label component usage..."
rg "from '@radix-ui/react-label'"

echo "Checking Popover component usage..."
rg "from '@radix-ui/react-popover'"

# Also check for any direct component usage
echo "Checking component usage patterns..."
rg "<(Dialog|Label|Popover)"

Length of output: 19670


113-113: Verify the react-day-picker downgrade impact.

The downgrade from ^9.5.0 to ^8.10.1 is a major version change that could affect calendar functionality. Please ensure:

  1. All calendar features work as expected
  2. No breaking changes affect the application
  3. Compatibility with date-fns ^3.6.0 is maintained

Run the following script to check for potential breaking changes:

✅ Verification successful

The react-day-picker downgrade is safe and compatible

The implementation review shows that the downgrade from v9 to v8 is safe because:

  1. The components only use basic features that are stable across v8 and v9 (DayPicker, DateRange)
  2. The styling and functionality implementation uses standard props (showOutsideDays, mode, selected, etc.)
  3. The date-fns dependency is compatible, as react-day-picker v8.10.1 supports both date-fns v2 and v3

The calendar components are using a straightforward implementation that focuses on:

  • Basic date picking functionality
  • Range selection support
  • Custom styling through className props
  • Standard navigation with chevron icons
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for calendar-related component usage that might be affected by the downgrade

# Search for react-day-picker component usage
echo "Checking react-day-picker usage patterns..."
rg -l "react-day-picker|DayPicker|DatePicker" 

# Search for specific calendar components that might be affected
echo "Checking calendar component implementations..."
ast-grep --pattern 'import { $$$ } from "react-day-picker"'

Length of output: 807


Script:

#!/bin/bash
# Let's check the actual usage in calendar components to understand the impact

# Check calendar.tsx implementation
echo "=== calendar.tsx implementation ==="
cat src/components/ui/calendar.tsx

# Check date-range-picker.tsx implementation
echo -e "\n=== date-range-picker.tsx implementation ==="
cat src/components/ui/date-range-picker.tsx

# Check if there are any specific v9 features being used
echo -e "\n=== Checking for v9 specific features ==="
rg "DayPicker|DateRange" -A 5 -B 5 src/components/ui/calendar.tsx src/components/ui/date-range-picker.tsx

# Check package-lock.json for date-fns version compatibility
echo -e "\n=== Checking date-fns dependency tree ==="
rg '"date-fns"' package-lock.json -A 2

Length of output: 9122

Copy link

cloudflare-workers-and-pages bot commented Dec 31, 2024

Deploying care-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5f11ced
Status: ✅  Deploy successful!
Preview URL: https://4ef644f4.care-fe.pages.dev
Branch Preview URL: https://rithviknishad-enhancements-2.care-fe.pages.dev

View logs

@rithviknishad rithviknishad removed the Deploy-Failed Deplyment is not showing preview label Dec 31, 2024
@github-actions github-actions bot added the Deploy-Failed Deplyment is not showing preview label Dec 31, 2024
@rithviknishad rithviknishad removed the Deploy-Failed Deplyment is not showing preview label Dec 31, 2024
@rithviknishad rithviknishad changed the title Notify for not found responses; fixes calendar component; and other minor fixes Fixes deploy: missing plugin map missing import; calendar component; and other minor fixes Dec 31, 2024
Copy link

cypress bot commented Dec 31, 2024

CARE    Run #4117

Run Properties:  status check passed Passed #4117  •  git commit 5f11ced203: Fixes deploy: missing plugin map missing import; calendar component; and other m...
Project CARE
Branch Review rithviknishad/enhancements-2
Run status status check passed Passed #4117
Run duration 01m 09s
Commit git commit 5f11ced203: Fixes deploy: missing plugin map missing import; calendar component; and other m...
Committer Rithvik Nishad
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 3
View all changes introduced in this branch ↗︎

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4ebd7ea and 67a3dd3.

📒 Files selected for processing (2)
  • src/Utils/request/errorHandler.ts (3 hunks)
  • src/Utils/request/uploadFile.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Utils/request/errorHandler.ts

Comment on lines +32 to +33
Notification.BadRequest({ errs: error.errors });
reject(new Error("Client error"));
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

Eliminate redundant reject call and handle fallback for string errors.

Currently, the code calls reject(new Error("Client error")) twice in succession, which is unnecessary. After the first reject() call, the Promise is already rejected, so this second call never takes effect. Moreover, if JSON parsing fails, error will just be a string, and accessing error.errors would be undefined. A more resilient approach might handle both object and string cases.

Consider this patch to remove the duplicated reject call and safeguard against string-based errors:

- Notification.BadRequest({ errs: error.errors });
- reject(new Error("Client error"));
- reject(new Error("Client error"));
+ if (typeof error === "object" && "errors" in error) {
+   Notification.BadRequest({ errs: error.errors });
+ } else {
+   Notification.BadRequest({ errs: [String(error)] });
+ }
+ reject(new Error("Client error"));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Notification.BadRequest({ errs: error.errors });
reject(new Error("Client error"));
if (typeof error === "object" && "errors" in error) {
Notification.BadRequest({ errs: error.errors });
} else {
Notification.BadRequest({ errs: [String(error)] });
}
reject(new Error("Client error"));

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: 0

🧹 Nitpick comments (1)
Dockerfile (1)

16-19: Document the build process changes

The addition of postinstall and setup steps suggests a significant change in the build process. Consider adding comments to explain:

  1. Why --ignore-scripts is necessary
  2. What each step (postinstall and setup) accomplishes
  3. The dependency order of these steps
 COPY package.json package-lock.json ./
 
+# Prevent execution of third-party scripts during installation for security
 RUN npm install --ignore-scripts
 
 COPY . .
 
+# Run controlled post-installation steps
 RUN npm run postinstall
 
+# Execute application-specific setup
 RUN npm run setup
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 67a3dd3 and 307c981.

📒 Files selected for processing (2)
  • .github/workflows/deploy.yaml (0 hunks)
  • Dockerfile (1 hunks)
💤 Files with no reviewable changes (1)
  • .github/workflows/deploy.yaml
🔇 Additional comments (1)
Dockerfile (1)

12-12: Verify the impact of --ignore-scripts flag

While using --ignore-scripts is a good security practice, ensure that all necessary setup steps are properly handled by the subsequent postinstall and setup commands. This flag might be related to the plugin map issue mentioned in the PR.

Let's verify what scripts would normally run during installation:

✅ Verification successful

Let me gather more information about the setup scripts that are being run after the npm install.


Using --ignore-scripts is safe in this setup

The --ignore-scripts flag in the Dockerfile is safe because:

  1. The critical setup steps are explicitly handled by dedicated scripts that run after the installation:
    • postinstall script installs platform-specific dependencies for rollup and esbuild
    • setup script generates the plugin map for enabled Care apps
  2. These scripts are executed through explicit RUN commands in the Dockerfile rather than npm lifecycle hooks, ensuring better control and transparency in the build process.

The flag actually helps by:

  • Preventing execution of third-party package scripts during installation
  • Maintaining explicit control over which setup steps run and when
  • Improving build security by avoiding potentially harmful scripts
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check package.json for scripts that might be affected
echo "Checking package.json for lifecycle scripts:"
jq '.scripts' package.json

# List dependencies that might have install/postinstall scripts
echo -e "\nChecking dependencies for install scripts:"
jq '.dependencies | keys[]' package.json | xargs -I {} sh -c 'if [ -f "node_modules/{}/package.json" ]; then echo "{}:" && jq ".scripts | select(.install, .postinstall)" "node_modules/{}/package.json"; fi'

Length of output: 1490


Script:

#!/bin/bash
# Check the content of setup and postinstall scripts
echo "Content of setup script:"
cat scripts/setup-care-apps.ts || echo "File not found"

echo -e "\nContent of postinstall script:"
cat scripts/install-platform-deps.ts || echo "File not found"

# Check if there are any other setup-related scripts
echo -e "\nOther setup-related files:"
fd -t f . scripts/ -x echo "=== {}" \; -x cat "{}" \; | grep -A 5 "==="

Length of output: 4387

Copy link
Member

@nihal467 nihal467 left a comment

Choose a reason for hiding this comment

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

Cypress fallback to electron approved

Copy link
Member

@bodhish bodhish left a comment

Choose a reason for hiding this comment

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

LGTM

@bodhish bodhish merged commit 3a9c7fe into develop Jan 1, 2025
25 checks passed
@bodhish bodhish deleted the rithviknishad/enhancements-2 branch January 1, 2025 16:47
Copy link

github-actions bot commented Jan 1, 2025

@rithviknishad Your efforts have helped advance digital healthcare and TeleICU systems. 🚀 Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! 🙌

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.

Clear all filter badge is visible even after all filters are cleared in Resource page
3 participants