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

  • New Features
    • Introduced confirmation dialogs for deletion actions across schedule exceptions, schedule templates, and availability entries, ensuring that removals require explicit user approval.
    • Updated warning and confirmation messages to provide clearer information about irreversible actions.
  • Style
    • Enhanced button appearance for critical actions by applying a more prominent, destructive styling variant.

@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 changes introduce confirmation dialogs in various scheduling and appointment interfaces to require explicit user confirmation before deletion actions. Modifications include new state variables, updated mutation calls, and enhanced localization messages. These changes span schedule exceptions, schedule templates, and availability entries, ensuring that users are prompted before any irreversible deletion is performed.

Changes

File(s) Change Summary
src/pages/Scheduling/…/ScheduleExceptions.tsx,
src/pages/Scheduling/components/(CreateScheduleTemplateSheet, EditScheduleTemplateSheet).tsx
Implemented confirmation dialogs for deletion actions by adding new state variables and wrapping delete buttons with AlertDialog components to prompt user confirmation before invoking deletion mutations.
public/locale/en.json Added a new key "are_you_sure", updated deletion messaging by replacing an archival message with a template removal warning, and removed an outdated archival key.
src/pages/Appointments/AppointmentDetail.tsx Imported and applied buttonVariants with the "destructive" variant to update the styling of AlertDialogAction buttons.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant UI
  participant Backend

  User->>UI: Click delete action (exception/template/availability)
  UI->>UI: Open confirmation dialog
  alt User confirms deletion
      UI->>Backend: Execute deletion mutation
      Backend-->>UI: Return success
      UI->>UI: Close dialog
  else User cancels deletion
      UI->>UI: Simply close dialog
  end
Loading

Assessment against linked issues

Objective Addressed Explanation
Add confirmation pop-up for exception deletion (#10259)

Possibly related PRs

Suggested labels

needs testing, needs review

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

I'm a rabbit, hopping with glee,
Code changes blooming like a tree.
Dialogs appear before delete takes flight,
Confirmations keep actions light.
With each hop and click so clear,
I cheer for safe code all year! 🐇


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 f931ce5
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67a959800045b10008a0f160
😎 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
@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)

src/components/ui/alert-dialog.tsx Outdated Show resolved Hide resolved
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 (2)
src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx (2)

290-292: Fix typo in template name.

The warning message contains a typo in the template name: "scheduled teplate".

-                          data: "scheduled teplate",
+                          data: "schedule template",

410-418: Remove redundant onClick handler.

The onClick handler is redundant as AlertDialogTrigger already manages the dialog state.

             <Button
               variant="ghost"
               size="icon"
-              onClick={() => setOpenDialog(true)}
               disabled={isDeleting}
             >
               <CareIcon icon="l-trash" className="text-lg" />
             </Button>
📜 Review details

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

📥 Commits

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

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

12-32: LGTM! Clean import organization.

The new imports for Alert and AlertDialog components are well-organized and necessary for implementing the confirmation dialogs.


267-312: LGTM! Well-implemented confirmation dialogs.

The implementation of confirmation dialogs for both template and availability deletions successfully addresses the PR objective of preventing accidental deletions. The dialogs provide clear warnings and require explicit user confirmation before proceeding with deletion actions.

Also applies to: 405-448


426-428: ⚠️ Potential issue

Fix incorrect warning message.

The warning message incorrectly refers to template deletion instead of availability deletion.

-                    {t("this_will_permanently_remove_the_template", {
-                      data: "available session",
+                    {t("this_will_permanently_remove_availability", {
+                      name: availability.name,

Likely invalid or redundant comment.

@modamaan modamaan requested a review from Jacobjeevan February 10, 2025 01:47
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