Skip to content

Comments

Delete dialog with cancellation message#446

Merged
elie222 merged 1 commit intomainfrom
delete-dialog
May 24, 2025
Merged

Delete dialog with cancellation message#446
elie222 merged 1 commit intomainfrom
delete-dialog

Conversation

@elie222
Copy link
Owner

@elie222 elie222 commented May 24, 2025

Summary by CodeRabbit

  • New Features

    • Enhanced account deletion flow with a new modal dialog that provides clearer messaging and actions.
    • Users with an active subscription must now confirm cancellation before deleting their account, with direct access to subscription management.
  • Bug Fixes

    • Improved handling and notifications for account deletion, including error and success messages.

@vercel
Copy link

vercel bot commented May 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
inbox-zero ✅ Ready (Inspect) Visit Preview May 24, 2025 7:42pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 24, 2025

Walkthrough

The account deletion process in the DeleteSection component was refactored to use an AlertDialog modal. The new flow prevents deletion if an active subscription exists, requiring users to confirm cancellation first. UI states, messaging, and actions now adapt based on subscription status, with improved async handling and user feedback via toast notifications.

Changes

File(s) Change Summary
apps/web/app/(app)/[emailAccountId]/settings/DeleteSection.tsx Refactored to use AlertDialog modal for deletion, enforce subscription cancellation, add state hooks, conditional UI and actions, and improved async deletion logic with toast notifications.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DeleteSection
    participant AlertDialog
    participant SubscriptionManager
    participant Toast

    User->>DeleteSection: Click "Delete Account"
    DeleteSection->>AlertDialog: Open modal
    alt Active subscription
        AlertDialog->>User: Show subscription warning
        User->>AlertDialog: Click "Cancel Subscription"
        AlertDialog->>SubscriptionManager: Open subscription management
        User->>AlertDialog: Confirm cancellation
    end
    User->>AlertDialog: Confirm deletion
    AlertDialog->>DeleteSection: Trigger delete handler
    DeleteSection->>Toast: Show loading
    DeleteSection->>DeleteSection: Cancel batch loads
    DeleteSection->>DeleteSection: Perform deletion
    alt Success
        DeleteSection->>Toast: Show success
    else Error
        DeleteSection->>Toast: Show error
    end
    DeleteSection->>AlertDialog: Close modal
Loading

Possibly related PRs

  • Server log out after delete #306: Also modifies DeleteSection.tsx to improve account deletion flow, focusing on async handling and user feedback, while this PR further adds subscription cancellation enforcement and enhanced modal UI.

Poem

A rabbit hopped into the modal’s light,
“Before you delete, let’s make things right!
If you’ve got a plan, cancel it first—
Then say goodbye, if you must, not cursed.
With toasts and dialogs, clear as can be,
Account deletion’s now worry-free!”
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/web/app/(app)/[emailAccountId]/settings/DeleteSection.tsx

Oops! Something went wrong! :(

ESLint: 9.24.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.

✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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
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)
apps/web/app/(app)/[emailAccountId]/settings/DeleteSection.tsx (1)

27-27: Consider handling loading states for premium data.

The premium data might be undefined while loading. Consider checking for loading states to prevent UI flickering or incorrect subscription status detection.

- const { premium } = usePremium();
+ const { premium, isLoading } = usePremium();
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b205878 and c6c5426.

📒 Files selected for processing (1)
  • apps/web/app/(app)/[emailAccountId]/settings/DeleteSection.tsx (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/web/app/(app)/[emailAccountId]/settings/DeleteSection.tsx (4)
apps/web/providers/StatLoaderProvider.tsx (1)
  • useStatLoader (35-35)
apps/web/components/PremiumAlert.tsx (1)
  • usePremium (14-42)
apps/web/utils/actions/user.ts (1)
  • deleteAccountAction (78-86)
apps/web/components/ui/alert-dialog.tsx (9)
  • AlertDialog (130-130)
  • AlertDialogTrigger (133-133)
  • AlertDialogContent (134-134)
  • AlertDialogHeader (135-135)
  • AlertDialogTitle (137-137)
  • AlertDialogDescription (138-138)
  • AlertDialogFooter (136-136)
  • AlertDialogCancel (140-140)
  • AlertDialogAction (139-139)
🔇 Additional comments (8)
apps/web/app/(app)/[emailAccountId]/settings/DeleteSection.tsx (8)

3-4: LGTM: Required imports added correctly.

The useState and Link imports are appropriately added for the new state management and navigation functionality.


8-18: LGTM: AlertDialog components imported properly.

All necessary AlertDialog components are imported to build the confirmation modal interface.


23-23: LGTM: Premium subscription hook imported.

The usePremium hook import is correctly added to access subscription status information.


29-30: LGTM: Subscription status logic is correct.

The logic properly checks for both Stripe and LemonSqueezy subscription IDs to determine if a user has an active subscription.


32-34: LGTM: State management setup is appropriate.

The state hooks are properly set up to manage dialog visibility and cancellation confirmation flow.


40-56: LGTM: Excellent async deletion handler with proper error handling.

The implementation includes:

  • Proper cleanup by canceling batch loads
  • Dialog state management
  • Comprehensive toast notifications for loading, success, and error states
  • Proper error handling for server errors
  • User logout after successful deletion

This provides a great user experience with clear feedback throughout the process.


62-62: LGTM: Clear business logic for deletion blocking.

The logic clearly defines when deletion should be blocked based on subscription status and cancellation confirmation.


72-129: LGTM: Well-implemented conditional dialog with excellent UX.

The AlertDialog implementation provides:

  • Clear conditional messaging based on subscription status
  • Helpful navigation to subscription management
  • Appropriate action buttons for each state
  • Good accessibility with proper dialog structure
  • Clear user guidance throughout the flow

The conditional rendering logic is well-structured and provides a smooth user experience for both scenarios (with and without active subscriptions).

Comment on lines +58 to +60
const handleConfirmCancellation = () => {
setHasConfirmedCancellation(true);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider the security implications of client-side cancellation confirmation.

The current implementation relies solely on user confirmation that they've cancelled their subscription, without server-side verification. This could allow users to bypass the subscription cancellation requirement.

Consider implementing server-side verification:

  const handleConfirmCancellation = () => {
-   setHasConfirmedCancellation(true);
+   // TODO: Add server-side verification that subscription is actually cancelled
+   // For now, allowing client-side confirmation as per current requirements
+   setHasConfirmedCancellation(true);
  };

Alternatively, refresh the premium data after confirmation to verify cancellation:

+ const { mutate: refreshPremium } = usePremium();
+
  const handleConfirmCancellation = async () => {
+   await refreshPremium(); // Refresh to get latest subscription status
    setHasConfirmedCancellation(true);
  };
📝 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
const handleConfirmCancellation = () => {
setHasConfirmedCancellation(true);
};
// Hook to refresh/check premium subscription status on the server
const { mutate: refreshPremium } = usePremium();
const handleConfirmCancellation = async () => {
// TODO: Add server-side verification that the subscription is actually cancelled
// For now, allowing client-side confirmation as per current requirements
await refreshPremium(); // Refresh to get the latest subscription status
setHasConfirmedCancellation(true);
};
🤖 Prompt for AI Agents
In apps/web/app/(app)/[emailAccountId]/settings/DeleteSection.tsx around lines
58 to 60, the current handleConfirmCancellation function only sets a client-side
flag without verifying the cancellation on the server. To fix this, implement a
server-side verification step by calling an API endpoint that confirms the
subscription cancellation status after the user confirms. Then update or refresh
the premium subscription data based on the server response to ensure the
cancellation is valid and enforced.

@elie222 elie222 merged commit 5d3219d into main May 24, 2025
7 checks passed
@elie222 elie222 deleted the delete-dialog branch December 18, 2025 23:01
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.

1 participant