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

Add Confirmation Pop-up to Prevent Accidental Exception Deletions #10283

Open
wants to merge 25 commits into
base: develop
Choose a base branch
from

Conversation

modamaan
Copy link
Contributor

@modamaan modamaan commented Jan 30, 2025

Proposed Changes

Vinu.TV._.CARE.-.confirm.dialog.2025-01-31.01-44-05.mp4

@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

  • New Features

    • Introduced confirmation dialogs for deleting schedule exceptions, removing availability entries, and deleting schedule templates, enhancing user interaction and reducing accidental deletions.
    • Enhanced user prompts with clearer confirmation messages and warnings regarding the permanent removal of templates.
  • Bug Fixes

    • Improved user experience by preventing accidental deletions through confirmation steps.

@modamaan modamaan requested a review from a team as a code owner January 30, 2025 02:01
Copy link
Contributor

coderabbitai bot commented Jan 30, 2025

Walkthrough

The pull request implements confirmation dialogs for deleting schedule exceptions, removing availability entries, and deleting schedule templates across various components. The previous direct delete actions are replaced with dialogs that require user confirmation before proceeding. Additionally, new localization keys are added to support confirmation messages, enhancing user interaction and preventing accidental deletions.

Changes

File Change Summary
src/pages/Scheduling/ScheduleExceptions.tsx, src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx, src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx Introduced dialog confirmation mechanisms for deleting schedule exceptions, removing availability entries, and deleting schedule templates. Added state variables to manage dialog visibility.
public/locale/en.json Added new localization keys for confirmation messages related to deletions and updated existing keys to reflect changes in messaging.
src/components/ui/alert-dialog.tsx Enhanced AlertDialogAction component to support variant-based styling for improved UI.
src/pages/Appointments/AppointmentDetail.tsx Added variant="destructive" to AlertDialogAction components for critical actions, enhancing visual representation.

Assessment against linked issues

Objective Addressed Explanation
Add Confirmation Pop-up for Exception Deletion [#10259] A confirmation dialog has been implemented for deleting schedule exceptions.

Possibly related PRs

Suggested labels

needs review, tested

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

🐰 In the garden of schedules, we take great care,
A dialog appears, a moment to spare.
"Are you sure?" it asks, with a gentle nudge,
No more accidental clicks, we won't hold a grudge!
With templates and exceptions, deletion's a breeze,
A rabbit's delight, with confirmations to please! 🗓️


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 30, 2025

Deploy Preview for care-ohc ready!

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

@rithviknishad
Copy link
Member

https://github.blog/news-insights/product-news/introducing-draft-pull-requests/

@rithviknishad rithviknishad marked this pull request as draft January 30, 2025 05:17
@modamaan modamaan marked this pull request as ready for review January 30, 2025 20:07
@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Feb 1, 2025
Copy link

github-actions bot commented Feb 1, 2025

Conflicts have been detected against the base branch. Please rebase your branch against the base branch.
cc: @modamaan

See: https://docs.ohc.network/docs/contributing#how-to-resolve-merge-conflicts

@Jacobjeevan Jacobjeevan added the waiting for related PR a co-related detail PR is under construction label Feb 3, 2025
@nihal467
Copy link
Member

nihal467 commented Feb 3, 2025

@modamaan what is the status on the PR

@modamaan
Copy link
Contributor Author

modamaan commented Feb 3, 2025

@nihal467 Waiting to update ConfirmDialog #10048

@modamaan
Copy link
Contributor Author

modamaan commented Feb 3, 2025

@rithviknishad #10048 Has work started on the ConfirmDialog?

@github-actions github-actions bot added needs-triage question Further information is requested labels Feb 3, 2025
@AdityaJ2305
Copy link
Contributor

@Jacobjeevan, can we use the existing alert-dialog component we have ? 🤔

@rithviknishad
Copy link
Member

rithviknishad commented Feb 4, 2025

@modamaan use the alert dialog. #10048 would be deleting ConfirmDialog and use AlertDialog instead, and not modify ConfirmDialog.

@Jacobjeevan Jacobjeevan removed question Further information is requested waiting for related PR a co-related detail PR is under construction needs-triage labels Feb 4, 2025
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)
src/components/ui/alert-dialog.tsx (1)

101-112: Consider moving margin classes to component level.

The margin classes (mt-2 sm:mt-0) in the base styles of alertVariants might be better placed in the component's className for better separation of concerns between spacing and visual styling.

-const alertVariants = cva("mt-2 sm:mt-0", {
+const alertVariants = cva("", {
   variants: {
     variant: {
       default: "bg-white text-gray-950 dark:bg-gray-950 dark:text-gray-50",
       destructive:
         "bg-red-500 text-gray-50 shadow-sm hover:bg-red-500/90 dark:bg-red-900 dark:text-gray-50 dark:hover:bg-red-900/90",
     },
   },
   defaultVariants: {
     variant: "default",
   },
 });
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4d7ebbc and b10ce7d.

📒 Files selected for processing (2)
  • public/locale/en.json (2 hunks)
  • src/components/ui/alert-dialog.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • public/locale/en.json
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: OSSAR-Scan
  • GitHub Check: CodeQL-Build
  • GitHub Check: cypress-run (1)
🔇 Additional comments (2)
src/components/ui/alert-dialog.tsx (2)

2-2: LGTM! Good choice of styling library.

The addition of class-variance-authority is appropriate for implementing type-safe variant styling.


114-124: LGTM! Verify usage in consuming components.

The implementation correctly integrates variant styling while maintaining type safety. This enables proper visual distinction for destructive actions like deletions.

Let's verify the usage of the destructive variant in deletion confirmation dialogs:

@modamaan
Copy link
Contributor Author

modamaan commented Feb 6, 2025

@Jacobjeevan @rithviknishad cam you please check

@modamaan
Copy link
Contributor Author

modamaan commented Feb 6, 2025

Dev.Doctor._.CARE.-.final.2025-02-07.00-11-56.mp4

Copy link
Contributor

@Jacobjeevan Jacobjeevan left a comment

Choose a reason for hiding this comment

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

Modify the messages accordingly:

This will permanently remove the template and cannot be undone

is displayed for templates, sessions and exceptions.

@modamaan modamaan marked this pull request as draft February 7, 2025 14:50
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

🧹 Nitpick comments (1)
src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx (1)

284-286: Make the warning message more specific.

The current warning message is generic. Consider making it more specific to help users understand exactly what they're deleting.

-                        {t("this_will_permanently_remove_the_template")}
+                        {t("this_will_permanently_remove_template", { name: template.name })}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b2e4b77 and e92c37d.

📒 Files selected for processing (2)
  • src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx (4 hunks)
  • src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Redirect rules - care-ohc
  • GitHub Check: Header rules - care-ohc
  • GitHub Check: Pages changed - care-ohc
  • GitHub Check: Test
  • GitHub Check: OSSAR-Scan
  • GitHub Check: cypress-run (1)
  • GitHub Check: CodeQL-Build
🔇 Additional comments (2)
src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx (2)

18-29: LGTM! Clean import organization.

The new Alert and AlertDialog component imports are well-organized and correctly sourced from the UI library.


141-141: LGTM! Well-implemented confirmation dialog.

The AlertDialog implementation for template deletion is clean and follows best practices with proper state management.

Also applies to: 265-303

@modamaan modamaan marked this pull request as ready for review February 7, 2025 15:39
@modamaan modamaan requested a review from Jacobjeevan February 7, 2025 15:44
@modamaan modamaan marked this pull request as draft February 7, 2025 16:37
@modamaan modamaan marked this pull request as ready for review February 7, 2025 18:10
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)
src/pages/Appointments/AppointmentDetail.tsx (1)

532-561: LGTM! Good UX improvements for destructive actions.

The addition of variant="destructive" to the confirmation buttons enhances the visual feedback, making it clearer that these are destructive actions. This aligns well with the PR's goal of preventing accidental deletions.

Consider these additional UX improvements:

  1. Add a brief delay (e.g., 2 seconds) before enabling the confirm button to prevent accidental clicks.
  2. Require typing a confirmation word (e.g., "DELETE") for extra validation.

Example implementation for the delay:

 <AlertDialogAction
   variant="destructive"
+  disabled={!useEffect(() => {
+    const timer = setTimeout(() => setEnabled(true), 2000);
+    return () => clearTimeout(timer);
+  }, [])}
   onClick={() => cancelAppointment({ reason: "cancelled" })}
 >
   {t("confirm")}
 </AlertDialogAction>

Also applies to: 563-592

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 36bcbd3 and 7b439b4.

📒 Files selected for processing (5)
  • public/locale/en.json (2 hunks)
  • src/pages/Appointments/AppointmentDetail.tsx (2 hunks)
  • src/pages/Scheduling/ScheduleExceptions.tsx (4 hunks)
  • src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx (4 hunks)
  • src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx
  • src/pages/Scheduling/ScheduleExceptions.tsx
  • public/locale/en.json
  • src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (1)

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.

Add Confirmation Pop-up When Removing an Exception to Prevent Accidental Deletions
5 participants