-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add partner invoice info #2534
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 partner invoice info #2534
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe changes introduce invoice settings management for partners. A new modal allows editing company name, address, and tax ID, with server-side validation and persistence. UI components and schema updates support this feature, including a new button in the payouts settings page and conditional display of invoice info in invoice metadata. The database schema is extended to store invoice settings. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant PayoutsPage
participant InvoiceSettingsButton
participant UpdateInvoiceSettingsModal
participant ServerAction
participant Database
User->>PayoutsPage: Loads Payouts Settings page
PayoutsPage->>InvoiceSettingsButton: Renders button
User->>InvoiceSettingsButton: Clicks "Invoice Settings"
InvoiceSettingsButton->>UpdateInvoiceSettingsModal: Opens modal
User->>UpdateInvoiceSettingsModal: Edits and submits form
UpdateInvoiceSettingsModal->>ServerAction: Calls updatePartnerInvoiceSettingsAction
ServerAction->>Database: Updates companyName and invoiceSettings
ServerAction-->>UpdateInvoiceSettingsModal: Returns success/failure
UpdateInvoiceSettingsModal->>User: Shows toast notification
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (1)
✨ Finishing Touches
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. 🪧 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 (
|
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2534:
To re-run the tests, please comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
apps/web/lib/zod/schemas/partners.ts (1)
197-203: Align validation with the action’s 1 000-char limit.
updatePartnerInvoiceInfoActioncapsinvoiceInfoat 1000 chars (z.string().max(1000)), but the publicPartnerSchemahas no.max()constraint. A payload that passes schema validation here can be rejected by the action, creating a silent mismatch between client & server.- invoiceInfo: z.string().nullable().describe("The partner's invoice info."), + invoiceInfo: z + .string() + .max(1000) + .nullable() + .describe("The partner's invoice info (max 1000 chars)."),
🧹 Nitpick comments (5)
packages/prisma/schema/partner.prisma (1)
62-64: Consider future query-ability before opting for@db.Text.
invoiceInfois declared asString? @db.Text, which is great for unbounded content, but note that:
- Large
TEXTcolumns can no longer be used in conventional indexes on Postgres/MySQL; if you later need to search/filter by this field (e.g.WHERE invoiceInfo ILIKE '%VAT%') you’ll be forced to use full-text indices orGINextensions.- Reads will always spill out of the main row page in MySQL, impacting hot-path performance if this column is fetched frequently.
If you anticipate only a couple of KB and occasional reads, consider
String? @db.VarChar(2048)instead, or keepTextbut add a comment explaining why.apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/update-invoice-info-button.tsx (1)
10-19: Minor UX polish: add ARIA label & avoid needlesstypeprop.
@dub/ui’sButtondefaults totype="button", so the explicit prop is redundant.
Also, supplying anaria-labelhelps assistive tech because the visible text could be truncated in some layouts.- <Button - type="button" - text="Invoice info" - variant="secondary" - onClick={() => setShowUpdateInvoiceInfoModal(true)} - /> + <Button + text="Invoice info" + variant="secondary" + aria-label="Edit invoice information" + onClick={() => setShowUpdateInvoiceInfoModal(true)} + />apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/update-invoice-info-modal.tsx (3)
64-75: Enforce the 1 000-character backend limit client-sideThe Prisma & Zod layers cap
invoiceInfoat 1000 chars. AddmaxLengthto the<TextareaAutosize>so users get immediate feedback and you avoid a round-trip validation error.-<TextareaAutosize +<TextareaAutosize autoFocus required + maxLength={1000} className="block w-full rounded-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm" minRows={4} value={invoiceInfo} onChange={(e) => setInvoiceInfo(e.target.value)} />
40-51: Error toast may silently show “undefined”
error.serverErrorisn’t guaranteed bynext-safe-action; some errors come througherror.message. Fallback to a generic message to avoid an empty toast.-onError({ error }) { - toast.error(error.serverError); -}, +onError({ error }) { + toast.error(error.serverError ?? error.message ?? "Something went wrong"); +},
78-97: Disable buttons while the mutation is pending
loadingprop shows a spinner but users can still click “Cancel” or double-tap “Save”, risking duplicate requests or state races.-<Button +<Button variant="secondary" text="Cancel" - disabled={isPending} + disabled={isPending} className="h-8 w-fit px-3" onClick={() => setShowUpdateInvoiceInfoModal(false)} /> ... -<Button +<Button text="Save" className="h-8 w-fit px-3" - loading={isPending} + loading={isPending} + disabled={isPending || invoiceInfo.length > 1000} onClick={async () => { await executeAsync({ invoiceInfo, }); }} />(Disabling when
invoiceInfoexceeds 1 000 chars matches the newmaxLengthguard.)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/page.tsx(1 hunks)apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/payout-table.tsx(0 hunks)apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/update-invoice-info-button.tsx(1 hunks)apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/update-invoice-info-modal.tsx(1 hunks)apps/web/lib/actions/partners/update-partner-invoice-info.ts(1 hunks)apps/web/lib/zod/schemas/partners.ts(1 hunks)packages/prisma/schema/partner.prisma(1 hunks)
💤 Files with no reviewable changes (1)
- apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/payout-table.tsx
🧰 Additional context used
🧬 Code Graph Analysis (3)
apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/update-invoice-info-button.tsx (1)
apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/update-invoice-info-modal.tsx (1)
useUpdateInvoiceInfoModal(102-122)
apps/web/lib/actions/partners/update-partner-invoice-info.ts (1)
apps/web/lib/actions/safe-action.ts (1)
authPartnerActionClient(83-111)
apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/update-invoice-info-modal.tsx (2)
apps/web/lib/swr/use-partner-profile.ts (1)
usePartnerProfile(6-29)apps/web/lib/actions/partners/update-partner-invoice-info.ts (1)
updatePartnerInvoiceInfoAction(15-29)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (1)
apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/page.tsx (1)
5-13: Header integration looks solid.Import path, client/server boundaries and
titleControlsprop are correct; no issues spotted.
apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/update-invoice-info-modal.tsx
Outdated
Show resolved
Hide resolved
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2534:
To re-run the tests, please comment |
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2534:
To re-run the tests, please comment |
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2534:
To re-run the tests, please comment |
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2534:
To re-run the tests, please comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
apps/web/lib/actions/partners/update-partner-invoice-settings.ts (1)
20-28: Return the updated partner to avoid an extra round-trip.
update()already returns the modified record. Forwarding it (or at least itsinvoiceSettings) allows the UI to update optimistic state without refetching:-await prisma.partner.update({ … }); +return prisma.partner.update({ + where: { id: partner.id }, + data: { companyName, invoiceSettings }, + select: { id: true, companyName: true, invoiceSettings: true }, +});
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/update-invoice-info-modal.tsx(1 hunks)apps/web/lib/actions/partners/update-partner-invoice-settings.ts(1 hunks)apps/web/lib/zod/schemas/partners.ts(2 hunks)packages/prisma/schema/partner.prisma(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- packages/prisma/schema/partner.prisma
- apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/update-invoice-info-modal.tsx
- apps/web/lib/zod/schemas/partners.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/web/lib/actions/partners/update-partner-invoice-settings.ts (2)
apps/web/lib/actions/safe-action.ts (1)
authPartnerActionClient(83-111)apps/web/lib/zod/schemas/partners.ts (1)
partnerInvoiceSettingsSchema(580-584)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2534:
To re-run the tests, please comment |
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2534:
To re-run the tests, please comment |
|
@coderabbitai do full review |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chainI'll conduct a full review of this PR. Let me examine the key files to provide comprehensive feedback. @devkiran Here's my comprehensive review of PR #2534: 🎯 Overall AssessmentThis PR successfully implements a clean partner invoice info feature with good separation of concerns and proper validation. The implementation follows React and Next.js best practices. ✅ Strengths1. Well-Structured Architecture
2. Robust Validation
3. Good UX Patterns
4. Type Safety
|
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2534:
To re-run the tests, please comment |
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2534:
To re-run the tests, please comment |
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2534:
To re-run the tests, please comment |
There was a problem hiding this 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 (3)
apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/update-invoice-settings-modal.tsx (3)
80-82: Enhance error handling for better user experience.The current error handling only displays
error.serverError, which might not always be user-friendly. Consider providing fallback error messages or more specific error handling.onError({ error }) { - toast.error(error.serverError); + toast.error(error.serverError || "Failed to update invoice settings. Please try again."); },
105-117: Add accessibility attributes for better screen reader support.Consider adding ARIA attributes to improve accessibility, especially for required fields and form validation feedback.
<label + htmlFor="companyName" className="text-sm font-medium leading-5 text-neutral-900" > Business name </label> <div className="relative mt-2 rounded-md shadow-sm"> <input + id="companyName" required autoFocus + aria-describedby="companyName-error" className="block w-full rounded-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm" {...register("companyName", { required: true })} /> </div>
144-161: Consider disabling form inputs during submission.While the buttons are properly disabled during submission, the form inputs remain enabled. Consider disabling all form fields during submission to prevent user confusion and potential race conditions.
You can add the
disabled={isPending}prop to all form inputs, similar to how it's applied to the Cancel button.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/invoice-settings-button.tsx(1 hunks)apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/page.tsx(1 hunks)apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/update-invoice-settings-modal.tsx(1 hunks)apps/web/lib/actions/partners/update-partner-invoice-settings.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- apps/web/lib/actions/partners/update-partner-invoice-settings.ts
- apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/page.tsx
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/invoice-settings-button.tsx (1)
apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/update-invoice-settings-modal.tsx (1)
useUpdateInvoiceSettingsModal(165-185)
apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/update-invoice-settings-modal.tsx (3)
apps/web/lib/zod/schemas/partners.ts (1)
partnerInvoiceSettingsSchema(580-584)apps/web/lib/swr/use-partner-profile.ts (1)
usePartnerProfile(6-29)apps/web/lib/actions/partners/update-partner-invoice-settings.ts (1)
updatePartnerInvoiceSettingsAction(12-32)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (3)
apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/invoice-settings-button.tsx (1)
1-21: LGTM! Clean and well-structured component.The component follows React best practices with proper separation of concerns. The button triggers the modal through the custom hook, and both the modal and button are rendered within the same component for logical cohesion.
apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/update-invoice-settings-modal.tsx (2)
1-30: Excellent TypeScript and import organization.The imports are well-organized and the type definitions follow best practices. Using
z.inferto derive the form data type from the Zod schema ensures type safety and reduces duplication.
165-185: Excellent custom hook implementation with proper optimization.The hook follows React best practices with appropriate use of
useCallbackanduseMemofor performance optimization. The API is clean and provides exactly what consumers need.
.../web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/update-invoice-settings-modal.tsx
Show resolved
Hide resolved
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2534:
To re-run the tests, please comment |
|
@CodeRabbit final review |
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2534:
To re-run the tests, please comment |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain |
|
@CodeRabbit final review pls |
|
Tip For best results, initiate chat on the files or code changes. |
Summary by CodeRabbit
New Features
Bug Fixes