Skip to content

feat: Update ROI#95

Merged
zkCaleb-dev merged 2 commits intoTrustless-Work:developfrom
miguelnietoa:feat/update-roi
Mar 13, 2026
Merged

feat: Update ROI#95
zkCaleb-dev merged 2 commits intoTrustless-Work:developfrom
miguelnietoa:feat/update-roi

Conversation

@miguelnietoa
Copy link
Contributor

@miguelnietoa miguelnietoa commented Mar 13, 2026

Summary by CodeRabbit

  • New Features

    • Add dialog and flow to view and update a campaign vault's ROI percentage with input validation and success confirmation.
  • Improvements

    • Replace inline ROI actions with an actions dropdown; wire "Update ROI" into the flow.
    • Better loading behavior for project cards and improved campaign title truncation.
  • UI Components

    • Introduce a reusable dropdown menu (items, separators, trigger) in the UI library.
  • Documentation

    • Add plan detailing the ROI update feature and integration steps.

@vercel
Copy link

vercel bot commented Mar 13, 2026

@miguelnietoa is attempting to deploy a commit to the Trustless Work Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2406f6ba-cdc5-41ad-9e46-14a893ce0276

📥 Commits

Reviewing files that changed from the base of the PR and between 43290ce and 91bb87a.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (14)
  • apps/backoffice-tokenization/src/features/campaigns/components/roi/UpdateRoiDialog.tsx
  • apps/backoffice-tokenization/src/features/campaigns/components/roi/roi-table-row.tsx
  • apps/backoffice-tokenization/src/features/campaigns/components/roi/roi-table.tsx
  • apps/backoffice-tokenization/src/features/campaigns/components/roi/roi-view.tsx
  • apps/backoffice-tokenization/src/features/campaigns/components/roi/types.ts
  • apps/backoffice-tokenization/src/features/campaigns/hooks/use-roi.ts
  • apps/backoffice-tokenization/src/features/campaigns/hooks/useUpdateRoiPercentage.ts
  • apps/backoffice-tokenization/src/features/campaigns/services/campaigns.api.ts
  • apps/investor-tokenization/src/features/transparency/ProjectCard.tsx
  • apps/investor-tokenization/src/features/transparency/ProjectList.tsx
  • docs/plans/2026-03-13-update-roi-percentage.md
  • packages/ui/package.json
  • packages/ui/src/campaign-card.tsx
  • packages/ui/src/dropdown-menu.tsx

📝 Walkthrough

Walkthrough

Adds an UpdateRoiDialog component, new APIs and hook to fetch and submit ROI percentage updates, a dropdown UI for ROI actions, and wiring through ROI table/view/hooks to open the dialog and refresh campaign data after a signed transaction.

Changes

Cohort / File(s) Summary
Update ROI Dialog & Hook
apps/backoffice-tokenization/src/features/campaigns/components/roi/UpdateRoiDialog.tsx, apps/backoffice-tokenization/src/features/campaigns/hooks/useUpdateRoiPercentage.ts
New modal component that fetches current ROI, validates 0–100 input, shows loading/errors, and invokes a hook that signs & submits transactions. Hook handles wallet checks, signing, submission, query invalidation, and success callbacks.
ROI Table & Row Wiring
apps/backoffice-tokenization/src/features/campaigns/components/roi/roi-table.tsx, apps/backoffice-tokenization/src/features/campaigns/components/roi/roi-table-row.tsx, apps/backoffice-tokenization/src/features/campaigns/components/roi/types.ts
Replaced inline actions with a DropdownMenu, added onUpdateRoi callback to RoiTable/RoiTableRow props, and wired the new menu item to open the ROI dialog or invoke the update flow.
ROI View & State
apps/backoffice-tokenization/src/features/campaigns/components/roi/roi-view.tsx, apps/backoffice-tokenization/src/features/campaigns/hooks/use-roi.ts
Extended useRoi to include roiDialogCampaign, roiDialogOpen, openRoiDialog, closeRoiDialog. Integrated UpdateRoiDialog rendering and passed onUpdateRoi handlers through RoiTable.
Campaigns API
apps/backoffice-tokenization/src/features/campaigns/services/campaigns.api.ts
Added getRoiPercentage(contractId, callerPublicKey) and updateRoiPorcentage({contractId, newRoiPorcentage, callerPublicKey}) endpoints (GET fetch + POST returning unsigned XDR).
UI Dropdown Component & Exports
packages/ui/src/dropdown-menu.tsx, packages/ui/package.json
New Radix-based DropdownMenu components (Root, Trigger, Content, Item, Separator). Added dependency @radix-ui/react-dropdown-menu and package export entry.
Minor UI / Loading & Docs
packages/ui/src/campaign-card.tsx, apps/investor-tokenization/src/features/transparency/ProjectCard.tsx, apps/investor-tokenization/src/features/transparency/ProjectList.tsx, docs/plans/2026-03-13-update-roi-percentage.md
Text truncation for campaign titles, refined loading skeleton logic and caching behavior in investor views, and added documentation plan describing the ROI update feature and wiring.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Dialog as UpdateRoiDialog
    participant Hook as useUpdateRoiPercentage
    participant API as campaigns.api
    participant Wallet as WalletContext
    participant Backend as Soroban
    participant Cache as ReactQuery

    User->>Dialog: open(dialog for vault)
    Dialog->>API: getRoiPercentage(contractId, publicKey)
    API-->>Dialog: { roiPercentage }
    User->>Dialog: submit new ROI%
    Dialog->>Hook: execute(contractId, newROI)
    Hook->>Wallet: ensure wallet & get publicKey
    Hook->>API: updateRoiPorcentage({contractId, newROI, publicKey})
    API-->>Hook: { unsignedXdr }
    Hook->>Wallet: signTransaction(unsignedXdr)
    Wallet-->>Hook: signedXdr
    Hook->>Backend: submitAndExtractAddress(signedXdr)
    Backend-->>Hook: tx result
    Hook->>Cache: invalidate("campaigns")
    Cache-->>Hook: refetch complete
    Hook-->>Dialog: onSuccess
    Dialog->>User: show success toast & close
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • armandocodecr
  • JoelVR17
  • zkCaleb-dev

Poem

🐇 I hopped into the dropdown bright,
Typed ROI percent by soft moonlight.
Wallet signed with a happy thump,
A toast popped up—celebrate the bump!
Vaults refreshed, I twitched my nose in delight.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Update ROI' directly summarizes the main feature added: enabling backoffice admins to update campaign vault ROI percentages through a new dialog component.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Add UpdateRoiDialog component with form to modify vault ROI percentage. Integrate dialog into RoiView with new state management in useRoi hook. Add dropdown menu to roi-table-row with actions for managing loans, uploading funds, and updating ROI. Implement useUpdateRoiPercentage hook for transaction signing and submission. Add getRoiPercentage and updateRoiPorcentage API endpoints.
@zkCaleb-dev zkCaleb-dev merged commit aa82057 into Trustless-Work:develop Mar 13, 2026
0 of 2 checks passed
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.

2 participants