Open
Conversation
…d-cost-and-revenue-to-backend
There was a problem hiding this comment.
Pull request overview
This PR wires the Cash Flow “add cost” and “add revenue” flows to real backend endpoints (including revenue installments), adds frontend validation/messaging, and introduces a new NestJS/DynamoDB revenue module while updating cost update semantics.
Changes:
- Frontend: connect cashflow CRUD calls to
/cashflow-costand/cashflow-revenue, add validation + success/error UI, and render revenue installments. - Backend: add
cashflow-revenuecontroller/service/module with DynamoDB persistence + tests; update cost update route toPUTand add “no changes” short-circuit. - Access control: make Cash Flow page/tab admin-only.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 19 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/main-page/navbar/NavBar.tsx | Makes Cash Flow tab admin-only in the sidebar. |
| frontend/src/main-page/grants/GrantPage.tsx | Removes unused props/interface. |
| frontend/src/main-page/cash-flow/processCashflowDataEditSave.ts | Updates cashflow API endpoints and adds edit/delete helpers. |
| frontend/src/main-page/cash-flow/processCashflowData.ts | Points fetch calls to new cashflow endpoints. |
| frontend/src/main-page/cash-flow/components/CashSourceList.tsx | Renders real cost/revenue items, including installments and delete actions. |
| frontend/src/main-page/cash-flow/components/CashRevenueInstallment.tsx | New installment editor component for revenue creation. |
| frontend/src/main-page/cash-flow/components/CashEditLineItem.tsx | Adds delete confirmation modal and edit-mode API. |
| frontend/src/main-page/cash-flow/components/CashEditCost.tsx | New cost edit form wired to backend update call. |
| frontend/src/main-page/cash-flow/components/CashCategoryDropdown.tsx | Supports controlled value + error styling for category selection. |
| frontend/src/main-page/cash-flow/components/CashAddRevenue.tsx | Adds revenue form with installment support, validation, and backend submit. |
| frontend/src/main-page/cash-flow/components/CashAddCosts.tsx | Adds cost form validation and backend submit. |
| frontend/src/main-page/cash-flow/CashFlowPage.tsx | Introduces formatMoney and updates KPI calculation. |
| frontend/src/main-page/MainPage.tsx | Restricts Cash Flow route to admins. |
| backend/src/revenue/types/revenue.types.ts | Adds Swagger DTO for cashflow revenue payloads. |
| backend/src/revenue/cashflow-revenue.service.ts | Implements DynamoDB-backed revenue CRUD + validation. |
| backend/src/revenue/cashflow-revenue.module.ts | Registers revenue controller/service in Nest. |
| backend/src/revenue/cashflow-revenue.controller.ts | Exposes guarded revenue endpoints. |
| backend/src/revenue/test/cashflow-revenue.service.spec.ts | Adds unit tests for revenue service behavior. |
| backend/src/grant/grant.service.ts | Re-enables grant notification creation on grant creation. |
| backend/src/cost/cashflow-cost.service.ts | Adjusts validation and changes update to full-replace PUT semantics. |
| backend/src/cost/cashflow-cost.controller.ts | Switches update endpoint from PATCH to PUT and removes by-type endpoint. |
| backend/src/cost/test/cashflow-cost.service.spec.ts | Updates cost tests for PUT body semantics and no-change detection. |
| backend/src/cashflow/cashflow.service.ts | Removes unused placeholder cashflow service. |
| backend/src/cashflow/cashflow.module.ts | Removes unused placeholder cashflow module. |
| backend/src/cashflow/cashflow.controller.ts | Removes unused placeholder cashflow controller. |
| backend/src/app.module.ts | Replaces CashflowModule import with RevenueModule. |
Comments suppressed due to low confidence (2)
frontend/src/main-page/cash-flow/processCashflowDataEditSave.ts:102
originalCostNameis interpolated directly into the URL path; names containing spaces or reserved characters will break routing. UseencodeURIComponent(originalCostName)when building the request URL.
export const saveCostEdits = async (updatedCost: CashflowCost, originalCostName: string) => {
try {
const response = await api(`/cashflow-cost/${originalCostName}`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(updatedCost),
});
frontend/src/main-page/cash-flow/processCashflowDataEditSave.ts:136
- Unlike
createNewCost/createNewRevenue, the delete helpers don’t return a{ success, error }result (they justconsole.log/console.error). This makes it hard for the UI to await deletion and surface failures. Consider returning a consistent result shape and letting the caller decide how to display/log errors.
export const deleteRevenue = async (revenueName: string) => {
try {
const response = await api(`/cashflow-revenue/${revenueName}`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
});
console.log("Response status:", response.status);
console.log("Response ok:", response.ok);
if (response.ok) {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
frontend/src/main-page/cash-flow/processCashflowDataEditSave.ts
Outdated
Show resolved
Hide resolved
… edit code since that should be fixed later
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.
ℹ️ Issue
Closes #373
📝 Description
Write a short summary of what you added. Why is it important? Any member of C4C should be able to read this and understand your contribution -- not just your team members.
Briefly list the changes made to the code:
✔️ Verification
What steps did you take to verify your changes work? These should be clear enough for someone to be able to clone the branch and follow the steps themselves.
Provide screenshots of any new components, styling changes, or pages.
ticket_fr.mp4
Test Changes
If your new feature required some test to be changed or added to fit the new functionality or changes please document these changes here.
Changed tests for costs to align with PUT body type.
🏕️ (Optional) Future Work / Notes
Did you notice anything ugly during the course of this ticket? Any bugs, design challenges, or unexpected behavior? Write it down so we can clean it up in a future ticket!