Skip to content

Commit

Permalink
feat: adds percentage of CAN
Browse files Browse the repository at this point in the history
  • Loading branch information
fpigeonjr committed Nov 13, 2024
1 parent f6b41b3 commit 278a160
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@ import { formatDateNeeded } from "../../../helpers/utils";
import Table from "../../UI/Table";
import { TABLE_HEADERS } from "./CABBudgetLineTable.constants";
import CANBudgetLineTableRow from "./CANBudgetLineTableRow";
import { calculatePercent } from "../../../helpers/utils";
/**
* @typedef {import("../../../components/BudgetLineItems/BudgetLineTypes").BudgetLine} BudgetLine
*/

/**
* @typedef {Object} CANBudgetLineTableProps
* @property {BudgetLine[]} budgetLines
* @property {number} totalFunding
*/

/**
* @component - The CAN Budget Line Table.
* @param {CANBudgetLineTableProps} props
* @returns {JSX.Element} - The component JSX.
*/
const CANBudgetLineTable = ({ budgetLines }) => {
const CANBudgetLineTable = ({ budgetLines, totalFunding }) => {
if (budgetLines.length === 0) {
return <p className="text-center">No budget lines have been added to this CAN.</p>;
}
Expand All @@ -31,9 +33,9 @@ const CANBudgetLineTable = ({ budgetLines }) => {
agreementName="TBD"
obligateDate={formatDateNeeded(budgetLine.date_needed || "")}
fiscalYear={budgetLine.fiscal_year || "TBD"}
amount={budgetLine.amount || 0}
amount={budgetLine.amount ?? 0}
fee={budgetLine.proc_shop_fee_percentage}
percentOfCAN={3}
percentOfCAN={calculatePercent(budgetLine.amount ?? 0, totalFunding)}
status={budgetLine.status}
inReview={budgetLine.in_review}
creatorId={budgetLine.created_by}
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/pages/cans/detail/CanSpending.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ const CanSpending = ({ budgetLines, fiscalYear, canId }) => {
</div>
<h2>CAN Budget Lines</h2>
<p>This is a list of all budget lines allocating funding from this CAN for the selected fiscal year.</p>
<CANBudgetLineTable budgetLines={budgetLines} />
<CANBudgetLineTable
budgetLines={budgetLines}
totalFunding={totalFunding}
/>
<DebugCode data={CANFunding} />
</article>
);
Expand Down

0 comments on commit 278a160

Please sign in to comment.