Skip to content

feat: files on agreement#18

Merged
hmbanan666 merged 1 commit into
mainfrom
files
Jul 25, 2025
Merged

feat: files on agreement#18
hmbanan666 merged 1 commit into
mainfrom
files

Conversation

@hmbanan666
Copy link
Copy Markdown
Collaborator

@hmbanan666 hmbanan666 commented Jul 25, 2025

Summary by CodeRabbit

  • New Features

    • Partner agreements now support attaching multiple files, which are displayed as buttons to open each file in a new tab.
    • Agreements visually indicate inactive status with opacity and grayscale styling.
  • Enhancements

    • Only active agreements are considered when determining the earliest agreement for a partner.
    • The agreements table now includes an "active" status for each agreement.
  • Bug Fixes

    • Improved modal behavior so that only clicking the icon opens the update modal, not the entire card.

@hmbanan666 hmbanan666 self-assigned this Jul 25, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jul 25, 2025

Walkthrough

The changes introduce support for associating files with partner agreements. A new partnerAgreementFiles table and related types are added, and the application now fetches and displays files linked to agreements. UI components and data models are updated to handle the new file associations, including changes to agreement filtering logic and schema enhancements.

Changes

File(s) Change Summary
apps/web-app/app/components/PartnerAgreementCard.vue Updated to display file buttons for each agreement, change modal trigger logic, and extend prop types.
apps/web-app/app/components/PartnerCard.vue Changed logic to select only active agreements for computations.
apps/web-app/app/stores/partner.ts Added PartnerAgreementWithData type including files; updated related types.
packages/database/src/repository/partner.ts Modified agreement data fetching to include related files.
packages/database/src/tables.ts Added isActive to agreements, introduced partnerAgreementFiles table, and defined new relations.
packages/database/src/types.ts Added types for agreement files (PartnerAgreementFile, PartnerAgreementFileDraft).

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PartnerAgreementCard
    participant Store
    participant Database

    User->>PartnerAgreementCard: View agreement card
    PartnerAgreementCard->>Store: Fetch agreement data (with files)
    Store->>Database: Query agreements with files
    Database-->>Store: Return agreements and associated files
    Store-->>PartnerAgreementCard: Provide agreement and files
    PartnerAgreementCard->>User: Display agreement info and file buttons
    User->>PartnerAgreementCard: Click file button
    PartnerAgreementCard->>User: Open file URL in new tab
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Poem

A hop, a skip, a file appears,
Partner agreements now bring cheers!
With files to fetch and cards to show,
The data garden starts to grow.
New tables sprout, relations bloom—
This bunny's code review resumes!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch files

🪧 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 generate unit tests to generate unit tests for 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.

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

@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)
apps/web-app/app/components/PartnerCard.vue (1)

71-71: Good filtering logic, but consider edge case handling.

The change to filter only active agreements before finding the minimal one is correct and aligns with the new isActive property. However, consider handling the case where no active agreements exist.

-const minimalAgreement = computed(() => partner.legalEntity?.agreements.filter((agreement) => agreement.isActive).toSorted((a, b) => new Date(a.willEndAt ?? '').getTime() - new Date(b.willEndAt ?? '').getTime())[0])
+const minimalAgreement = computed(() => {
+  const activeAgreements = partner.legalEntity?.agreements.filter((agreement) => agreement.isActive)
+  return activeAgreements?.toSorted((a, b) => new Date(a.willEndAt ?? '').getTime() - new Date(b.willEndAt ?? '').getTime())[0]
+})

This makes the code more readable and the optional chaining will safely handle empty arrays.

packages/database/src/tables.ts (1)

117-124: Consider adding cascade options for data integrity.

The table structure is well-designed and consistent. However, consider adding cascade options to the foreign key reference to ensure proper cleanup when agreements are deleted:

-  agreementId: cuid2('agreement_id').notNull().references(() => partnerAgreements.id),
+  agreementId: cuid2('agreement_id').notNull().references(() => partnerAgreements.id, {
+    onDelete: 'cascade',
+    onUpdate: 'cascade',
+  }),
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a2614a8 and f81b6bc.

📒 Files selected for processing (6)
  • apps/web-app/app/components/PartnerAgreementCard.vue (2 hunks)
  • apps/web-app/app/components/PartnerCard.vue (1 hunks)
  • apps/web-app/app/stores/partner.ts (1 hunks)
  • packages/database/src/repository/partner.ts (1 hunks)
  • packages/database/src/tables.ts (3 hunks)
  • packages/database/src/types.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/web-app/app/stores/partner.ts (1)
packages/database/src/types.ts (3)
  • PartnerAgreement (18-18)
  • PartnerAgreementFile (21-21)
  • PartnerLegalEntity (15-15)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (12)
packages/database/src/types.ts (1)

21-22: LGTM! Consistent type definitions.

The new PartnerAgreementFile and PartnerAgreementFileDraft types follow the established pattern and naming conventions in the file.

packages/database/src/repository/partner.ts (1)

35-39: LGTM! Proper nested relation query.

The change correctly modifies the query to fetch agreement files along with agreements using Drizzle's nested with syntax. This supports the frontend components that need to display agreement files.

apps/web-app/app/components/PartnerAgreementCard.vue (4)

2-7: Good UX improvement with visual feedback.

The conditional styling for inactive agreements provides clear visual feedback to users, and removing the click handler from the card improves interaction clarity.


10-14: Better interaction design.

Moving the modal trigger to only the icon is a good UX improvement - it makes the interaction more intentional and clear.


52-66: Well-implemented file display section.

The file buttons are properly configured with external and target="_blank" for opening files in new tabs. The styling is consistent and the loop structure is clean.


72-77: Proper type safety maintained.

The import addition and prop type extension correctly maintain type safety while supporting the new files functionality.

apps/web-app/app/stores/partner.ts (3)

1-1: LGTM! Proper import extension.

The import statement correctly includes the new PartnerAgreementFile type needed for the extended data structures.


3-5: Well-structured type composition.

The PartnerAgreementWithData type alias properly extends PartnerAgreement with the files array, following good TypeScript practices for type composition.


8-8: Consistent type usage.

The update to use PartnerAgreementWithData[] maintains type consistency across the data flow from repository to UI components.

packages/database/src/tables.ts (3)

106-106: LGTM! Consistent with existing patterns.

The isActive column addition follows the established pattern used in other tables and provides a logical default value.


598-598: LGTM! Proper one-to-many relation definition.

The files relation correctly establishes the relationship between agreements and their associated files.


601-606: LGTM! Proper bidirectional relation setup.

The relation correctly establishes the many-to-one relationship from files back to their parent agreement, completing the bidirectional relationship.

@hmbanan666 hmbanan666 merged commit cb821f6 into main Jul 25, 2025
8 checks passed
@hmbanan666 hmbanan666 deleted the files branch July 25, 2025 08:32
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