Skip to content

Conversation

@AshishViradiya153
Copy link
Contributor

@AshishViradiya153 AshishViradiya153 commented May 12, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a settings page for managing agreements, allowing users to view, create, and delete agreements.
    • Added an agreement card component displaying agreement details with a deletion option and confirmation dialog.
    • Integrated styled alert dialogs for confirmation actions.
  • Improvements

    • Added an "Agreements" navigation item to the settings menu.
    • Enhanced agreement filtering to update dynamically based on selection changes.
  • Bug Fixes

    • Updated key props for agreement badges in analytics and visitor tables to improve rendering consistency.
  • Chores

    • Added a new dependency for alert dialog UI components.

@AshishViradiya153 AshishViradiya153 requested a review from mfts as a code owner May 12, 2025 22:15
@vercel
Copy link

vercel bot commented May 12, 2025

@AshishViradiya153 is attempting to deploy a commit to the mftsio Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 12, 2025

Walkthrough

A new NDA agreements management feature is introduced, including a settings page for listing, creating, and deleting agreements. Supporting UI primitives are added, such as an alert dialog component. Various files are updated to support agreements, including navigation, data fetching, and type definitions. Minor refactors and key prop adjustments are also present.

Changes

File(s) Change Summary
components/agreements/agreement-card.tsx Introduces AgreementCard component to display agreement details and provide a deletion option with confirmation dialog.
pages/settings/agreements.tsx Adds NdaAgreements settings page for managing NDA agreements, including listing, creating, and deleting agreements, handling loading/error states, and integrating upgrade and creation modals.
components/ui/alert-dialog.tsx Adds a new alert dialog UI component built on Radix primitives, exporting styled dialog components for confirmation modals.
components/settings/settings-header.tsx Adds "Agreements" navigation item to the settings menu.
lib/swr/use-agreements.ts Adds AgreementWithLinksCount interface and updates the agreements hook to use this explicit type.
components/links/link-sheet/agreement-section.tsx Updates useMemo dependency array to include agreementId for recalculating filtered agreements when selection changes.
components/analytics/views-table.tsx, components/visitors/dataroom-visitors-table.tsx,
components/visitors/visitors-table.tsx
Changes the React key prop for agreement badges from "nda-agreement" to "agreement" prefix for consistency.
components/ui/dialog.tsx Adds onCloseAutoFocus handler to dialog content to prevent default focus and reset pointer events on close; minor import order change.
components/ui/dropdown-menu.tsx Adjusts import order for utility function cn.
package.json Adds @radix-ui/react-alert-dialog dependency.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant AgreementsPage
    participant useAgreementsHook
    participant AgreementCard
    participant AlertDialog
    participant API

    User->>AgreementsPage: Visits /settings/agreements
    AgreementsPage->>useAgreementsHook: Fetch agreements
    useAgreementsHook->>API: GET /api/teams/{teamId}/agreements
    API-->>useAgreementsHook: Returns agreements list
    useAgreementsHook-->>AgreementsPage: Agreements data
    AgreementsPage->>AgreementCard: Render each agreement
    User->>AgreementCard: Clicks delete menu
    AgreementCard->>AlertDialog: Opens confirmation dialog
    User->>AlertDialog: Confirms deletion
    AgreementCard->>API: PUT /api/teams/{teamId}/agreements/{id}/delete
    API-->>AgreementCard: Deletion response
    AgreementCard->>AgreementsPage: Calls onDelete(id)
    AgreementsPage->>useAgreementsHook: Updates local cache
Loading

Poem

📝
A hop and a skip, new agreements in tow,
With dialogs that warn before letting them go.
A badge gets a name, a page finds its place,
And Radix dialogs add style and grace.
The rabbit reviews, with a satisfied cheer—
Agreements are managed, the changes are here!
🐇✨


📜 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 740487c and d52a83d.

📒 Files selected for processing (1)
  • components/agreements/agreement-card.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/agreements/agreement-card.tsx
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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: 3

🧹 Nitpick comments (2)
pages/settings/nda-agreements.tsx (1)

118-123: Consider making upgrade plan more dynamic.

The upgrade plan modal uses a hardcoded PlanEnum.Business. Consider making this more flexible if different plans might be required for NDA agreements in the future.

 <UpgradePlanModal
-  clickedPlan={PlanEnum.Business}
+  clickedPlan={PlanEnum.Datarooms} // Or use a variable/constant that can be easily changed
   trigger="nda_agreements_page"
   open={showUpgradeModal}
   setOpen={setShowUpgradeModal}
 />
components/agreements/agreement-card.tsx (1)

1-26: Consider importing Agreement interface from a shared location.

The Agreement interface might be defined elsewhere in the codebase. Consider importing it from a shared location to maintain consistency.

+import { Agreement } from "@/types"; // or appropriate path
 import { useTeam } from "@/context/team-context";
 import { FileTextIcon, MoreVertical, TrashIcon } from "lucide-react";
 import { toast } from "sonner";

 import { Button } from "@/components/ui/button";
 import {
   DropdownMenu,
   DropdownMenuContent,
   DropdownMenuItem,
   DropdownMenuTrigger,
 } from "@/components/ui/dropdown-menu";

-interface Agreement {
-  id: string;
-  name: string;
-  content: string;
-  createdAt: Date;
-  updatedAt: Date;
-}

 interface AgreementCardProps {
   agreement: Agreement;
   onDelete: (id: string) => void;
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 875a9db and 9280711.

📒 Files selected for processing (4)
  • components/agreements/agreement-card.tsx (1 hunks)
  • components/links/link-sheet/agreement-section.tsx (1 hunks)
  • components/settings/settings-header.tsx (1 hunks)
  • pages/settings/nda-agreements.tsx (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
components/agreements/agreement-card.tsx (2)
components/ui/dropdown-menu.tsx (4)
  • DropdownMenu (189-189)
  • DropdownMenuTrigger (190-190)
  • DropdownMenuContent (191-191)
  • DropdownMenuItem (192-192)
components/ui/button.tsx (1)
  • Button (71-71)
🔇 Additional comments (4)
components/settings/settings-header.tsx (1)

60-64: LGTM! Navigation item for NDA Agreements added correctly.

The new navigation item for "NDA Agreements" is correctly implemented, following the consistent pattern of other navigation items in the settings menu.

components/links/link-sheet/agreement-section.tsx (1)

49-49: Good bug fix: Added agreementId to dependency array.

Adding agreementId to the dependency array of the useMemo hook ensures the filtered agreements list correctly recalculates when the selected agreement changes. This fixes a potential reactivity issue.

pages/settings/nda-agreements.tsx (2)

1-30: LGTM! Well-structured imports and state management.

The imports are organized logically, and the hooks for data fetching and state management are set up correctly. The activeAgreements memo properly filters out deleted agreements.


31-37: LGTM! Optimistic UI update for agreement deletion.

The implementation uses SWR's mutate function to optimistically update the UI when an agreement is deleted, providing a smooth user experience.

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

♻️ Duplicate comments (1)
components/agreements/agreement-card.tsx (1)

45-64: Use DELETE HTTP method instead of PUT for deletions.

The API endpoint for deletion should use the DELETE HTTP method instead of PUT to follow REST conventions.

 const handleDelete = async () => {
   toast.promise(
     fetch(
       `/api/teams/${teamInfo?.currentTeam?.id}/agreements/${agreement.id}`,
       {
-        method: "PUT",
+        method: "DELETE",
       },
     ).then(async (response) => {
       if (!response.ok) {
         throw new Error("Failed to delete agreement");
       }
       onDelete(agreement.id);
     }),
     {
       loading: "Deleting agreement...",
       success: "Agreement deleted successfully",
       error: "Failed to delete agreement",
     },
   );
 };
🧹 Nitpick comments (1)
components/agreements/agreement-card.tsx (1)

105-105: Fix unescaped quotes in the JSX.

The quotes around the agreement name should be escaped to comply with React's JSX requirements.

-              This will permanently delete the NDA agreement "{agreement.name}".
+              This will permanently delete the NDA agreement &quot;{agreement.name}&quot;.
🧰 Tools
🪛 ESLint

[error] 105-105: " can be escaped with &quot;, &ldquo;, &#34;, &rdquo;.

(react/no-unescaped-entities)


[error] 105-105: " can be escaped with &quot;, &ldquo;, &#34;, &rdquo;.

(react/no-unescaped-entities)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9280711 and fa395e5.

📒 Files selected for processing (3)
  • components/agreements/agreement-card.tsx (1 hunks)
  • components/ui/alert-dialog.tsx (1 hunks)
  • package.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • package.json
🧰 Additional context used
🧬 Code Graph Analysis (1)
components/ui/alert-dialog.tsx (2)
lib/utils.ts (1)
  • cn (18-20)
components/ui/button.tsx (1)
  • buttonVariants (71-71)
🪛 ESLint
components/agreements/agreement-card.tsx

[error] 105-105: " can be escaped with &quot;, &ldquo;, &#34;, &rdquo;.

(react/no-unescaped-entities)


[error] 105-105: " can be escaped with &quot;, &ldquo;, &#34;, &rdquo;.

(react/no-unescaped-entities)

🔇 Additional comments (12)
components/agreements/agreement-card.tsx (5)

25-31: Well-defined Agreement interface.

The interface clearly defines all required properties for an agreement with appropriate types.


33-36: Good component props design.

The props interface is properly defined, making it clear what data the component needs to function.


67-98: Well-designed card UI with appropriate layout.

The card layout is clean and organized, using appropriate semantic HTML and styling classes for accessibility and visual hierarchy.


100-126: Great implementation of the deletion confirmation dialog.

The AlertDialog implementation provides an important safeguard against accidental deletions and clearly explains the consequences to users.

🧰 Tools
🪛 ESLint

[error] 105-105: " can be escaped with &quot;, &ldquo;, &#34;, &rdquo;.

(react/no-unescaped-entities)


[error] 105-105: " can be escaped with &quot;, &ldquo;, &#34;, &rdquo;.

(react/no-unescaped-entities)


109-113: Excellent user guidance about referenced agreements.

The note about references in documents or dataroom links provides valuable information to users about the implications of deletion.

components/ui/alert-dialog.tsx (7)

1-14: Well-structured component library setup.

The imports and component declarations follow best practices for creating reusable UI components based on Radix primitives.


15-28: Properly implemented overlay with animation.

The AlertDialogOverlay component correctly uses forwardRef and applies appropriate styling for a clean modal backdrop with animation support.


30-46: Well-implemented modal content with responsive animations.

The AlertDialogContent component has comprehensive styling for positioning, animations, and responsiveness. The use of data attributes for state-based animations is particularly good.


48-74: Good layout components for header and footer.

The AlertDialogHeader and AlertDialogFooter components provide useful layout structure with responsive adjustments between mobile and desktop views.


76-99: Well-styled title and description components.

The AlertDialogTitle and AlertDialogDescription components follow the pattern of forwarding refs and applying appropriate typography styles.


101-127: Consistent button styling using buttonVariants.

The AlertDialogAction and AlertDialogCancel components properly integrate with your button styling system, ensuring UI consistency throughout the application.


129-141: Complete export of all dialog components.

All components are properly exported for easy imports, following the component composition pattern.

Copy link
Owner

@mfts mfts left a comment

Choose a reason for hiding this comment

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

good first version! let's build on top of it

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

♻️ Duplicate comments (1)
components/agreements/agreement-card.tsx (1)

47-66: ⚠️ Potential issue

Use DELETE HTTP method instead of PUT for deletions.

The API endpoint for deletion should use the DELETE HTTP method instead of PUT to follow REST conventions.

 const handleDelete = async () => {
   toast.promise(
     fetch(
       `/api/teams/${teamInfo?.currentTeam?.id}/agreements/${agreement.id}`,
       {
-        method: "PUT",
+        method: "DELETE",
       },
     ).then(async (response) => {
       if (!response.ok) {
         throw new Error("Failed to delete agreement");
       }
       onDelete(agreement.id);
     }),
     {
       loading: "Deleting agreement...",
       success: "Agreement deleted successfully",
       error: "Failed to delete agreement",
     },
   );
 };
🧹 Nitpick comments (4)
components/agreements/agreement-card.tsx (4)

1-1: Remove unused import.

The useEffect import is not being used in this component.

-import { useEffect, useState } from "react";
+import { useState } from "react";

112-112: Escape quotes in JSX text content.

React's ESLint rule flags unescaped quotation marks in JSX. Use HTML entities or template syntax to avoid this warning.

-              This will permanently delete the NDA agreement "{agreement.name}".
+              This will permanently delete the NDA agreement &quot;{agreement.name}&quot;.

Alternatively, you can use template syntax:

This will permanently delete the NDA agreement "{agreement.name}".
🧰 Tools
🪛 ESLint

[error] 112-112: " can be escaped with &quot;, &ldquo;, &#34;, &rdquo;.

(react/no-unescaped-entities)


[error] 112-112: " can be escaped with &quot;, &ldquo;, &#34;, &rdquo;.

(react/no-unescaped-entities)


27-33: Unused interface definition.

The Agreement interface is defined but not used in this component. The component uses AgreementWithLinksCount interface instead. Consider removing this unused interface to reduce code clutter.

-interface Agreement {
-  id: string;
-  name: string;
-  content: string;
-  createdAt: Date;
-  updatedAt: Date;
-}
-

83-86: Add formatting for the links count.

Consider adding proper pluralization for the links count text.

 <div className="text-sm text-muted-foreground">
-  {agreement._count?.links || 0} links
+  {agreement._count?.links || 0} {agreement._count?.links === 1 ? 'link' : 'links'}
 </div>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a030605 and d596aad.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (10)
  • components/agreements/agreement-card.tsx (1 hunks)
  • components/analytics/views-table.tsx (3 hunks)
  • components/settings/settings-header.tsx (1 hunks)
  • components/ui/alert-dialog.tsx (1 hunks)
  • components/ui/dialog.tsx (2 hunks)
  • components/ui/dropdown-menu.tsx (1 hunks)
  • components/visitors/dataroom-visitors-table.tsx (1 hunks)
  • components/visitors/visitors-table.tsx (1 hunks)
  • lib/swr/use-agreements.ts (1 hunks)
  • pages/settings/agreements.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (5)
  • components/ui/dropdown-menu.tsx
  • components/visitors/dataroom-visitors-table.tsx
  • lib/swr/use-agreements.ts
  • components/visitors/visitors-table.tsx
  • components/analytics/views-table.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • components/settings/settings-header.tsx
  • components/ui/alert-dialog.tsx
🧰 Additional context used
🪛 ESLint
components/agreements/agreement-card.tsx

[error] 112-112: " can be escaped with &quot;, &ldquo;, &#34;, &rdquo;.

(react/no-unescaped-entities)


[error] 112-112: " can be escaped with &quot;, &ldquo;, &#34;, &rdquo;.

(react/no-unescaped-entities)

🔇 Additional comments (3)
components/ui/dialog.tsx (2)

9-10: LGTM: Import order adjustment.

The import order has been adjusted to maintain a logical grouping.


56-59: Added focus management and pointer events reset on dialog close.

This change prevents the default focus behavior when the dialog closes and resets the pointer events style on the document body, which helps ensure proper UI state restoration.

pages/settings/agreements.tsx (1)

1-147: LGTM: Well-structured NDA agreements management page.

The implementation is thorough with proper error handling, loading states, and empty states. The component follows React best practices with appropriate state management and conditional rendering based on the user's subscription plan.

@vercel
Copy link

vercel bot commented May 13, 2025

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

Name Status Preview Comments Updated (UTC)
papermark ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 13, 2025 4:34pm

@mfts mfts merged commit b3b099d into mfts:main May 13, 2025
4 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators May 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants