feat: files on agreement#18
Conversation
WalkthroughThe changes introduce support for associating files with partner agreements. A new Changes
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~18 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
There was a problem hiding this comment.
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
isActiveproperty. 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
📒 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
PartnerAgreementFileandPartnerAgreementFileDrafttypes 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
withsyntax. 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
externalandtarget="_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
PartnerAgreementFiletype needed for the extended data structures.
3-5: Well-structured type composition.The
PartnerAgreementWithDatatype alias properly extendsPartnerAgreementwith thefilesarray, 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
isActivecolumn 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
filesrelation 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.



Summary by CodeRabbit
New Features
Enhancements
Bug Fixes