feat: add top-up investment button for open invoice positions - #126
Open
Oluwasuyi-Oluwatimilehin-Daniel wants to merge 3 commits into
Open
Conversation
|
@Oluwasuyi-Oluwatimilehin-Daniel Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Investors can now increase their committed amount on open invoices directly from the investor dashboard using a new "Top Up" button. This feature provides a clear and direct way to add to existing positions without navigating back to the marketplace.
Closes #121
Changes Made
1. API Layer (
lib/api/index.ts)topUpInvoice()function to handle top-up requestsdistributeDividend()function that had syntax errorsapproveKeyPause()function that had syntax errors2. Hooks (
hooks/useInvestments.ts)useTopUpMutation()hook with:3. Data Types (
lib/portfolio.ts)InvestmentPositioninterface to includeremaining_capacityfield4. Components
New Component:
TopUpModal(components/invoices/TopUpModal.tsx)Updated Component:
PositionCard(components/dashboard/PositionCard.tsx)TopUpModalcomponent5. Tests (
components/dashboard/__tests__/PositionCard.test.tsx)Acceptance Criteria Met
✅ Top-up modal opens from the open position row
✅ Amount that would exceed remaining invoice capacity shows 'Exceeds remaining capacity'
remaining_capacity✅ Preview shows new total position correctly
✅ Success toast shown with new total position after confirmation
useTopUpMutationshows success toast with format: "Top-up of {amount} XLM successful. New total: {new_total} XLM"✅ Position amount updated in dashboard list after top-up
Technical Details
API Endpoint
/api/invoices/{invoiceId}/top_up{ amount: number }{ success: boolean, new_total: number }State Management
PORTFOLIO_QUERY_KEY,INVOICES_QUERY_KEY)Validation
Testing
Dependencies
Backward Compatibility
remaining_capacityis optional in InvestmentPosition interfaceFuture Enhancements
Screenshots
(To be added during manual testing)
Checklist
feature/top-up-investment-button