diff --git a/frontend/cypress/e2e/canDetail.cy.js b/frontend/cypress/e2e/canDetail.cy.js index e16d1a2298..e7c6257cf3 100644 --- a/frontend/cypress/e2e/canDetail.cy.js +++ b/frontend/cypress/e2e/canDetail.cy.js @@ -41,4 +41,34 @@ describe("CAN detail page", () => { cy.get("tbody").should("not.exist"); cy.get("p").should("contain", "No budget lines have been added to this CAN."); }); + it("pagination on the bli table works as expected", () => { + cy.visit("/cans/504/spending"); + cy.get("#fiscal-year-select").select("2043"); + cy.wait(1000); + cy.get("ul").should("have.class", "usa-pagination__list"); + cy.get("li").should("have.class", "usa-pagination__item").contains("1"); + cy.get("button").should("have.class", "usa-current").contains("1"); + cy.get("li").should("have.class", "usa-pagination__item").contains("2"); + cy.get("li").should("have.class", "usa-pagination__item").contains("Next"); + cy.get("tbody").find("tr").should("have.length", 3); + cy.get("li") + .should("have.class", "usa-pagination__item") + .contains("Previous") + .find("svg") + .should("have.attr", "aria-hidden", "true"); + + // go to the second page + cy.get("li").should("have.class", "usa-pagination__item").contains("2").click(); + cy.get("button").should("have.class", "usa-current").contains("2"); + cy.get("li").should("have.class", "usa-pagination__item").contains("Previous"); + cy.get("li") + .should("have.class", "usa-pagination__item") + .contains("Next") + .find("svg") + .should("have.attr", "aria-hidden", "true"); + + // go back to the first page + cy.get("li").should("have.class", "usa-pagination__item").contains("1").click(); + cy.get("button").should("have.class", "usa-current").contains("1"); + }); }); diff --git a/frontend/src/components/BudgetLineItems/BLIStatusSummaryCard/BLIStatusSummaryCard.jsx b/frontend/src/components/BudgetLineItems/BLIStatusSummaryCard/BLIStatusSummaryCard.jsx index 96bf1ce777..426ffb7072 100644 --- a/frontend/src/components/BudgetLineItems/BLIStatusSummaryCard/BLIStatusSummaryCard.jsx +++ b/frontend/src/components/BudgetLineItems/BLIStatusSummaryCard/BLIStatusSummaryCard.jsx @@ -123,10 +123,7 @@ const BLIStatusSummaryCard = ({ budgetLines }) => { }; return ( - +

Budget Lines By Status

diff --git a/frontend/src/components/CANs/CANBudgetLineTable/CANBudgetLineTable.jsx b/frontend/src/components/CANs/CANBudgetLineTable/CANBudgetLineTable.jsx index 4d2f47647e..3d4853710e 100644 --- a/frontend/src/components/CANs/CANBudgetLineTable/CANBudgetLineTable.jsx +++ b/frontend/src/components/CANs/CANBudgetLineTable/CANBudgetLineTable.jsx @@ -1,8 +1,9 @@ -import { formatDateNeeded } from "../../../helpers/utils"; +import React from "react"; +import { calculatePercent, formatDateNeeded } from "../../../helpers/utils"; import Table from "../../UI/Table"; import { TABLE_HEADERS } from "./CABBudgetLineTable.constants"; import CANBudgetLineTableRow from "./CANBudgetLineTableRow"; -import { calculatePercent } from "../../../helpers/utils"; +import PaginationNav from "../../UI/PaginationNav"; /** * @typedef {import("../../../components/BudgetLineItems/BudgetLineTypes").BudgetLine} BudgetLine */ @@ -19,33 +20,49 @@ import { calculatePercent } from "../../../helpers/utils"; * @returns {JSX.Element} - The component JSX. */ const CANBudgetLineTable = ({ budgetLines, totalFunding }) => { + // TODO: once in prod, change this to 25 + const ITEMS_PER_PAGE = 3; + const [currentPage, setCurrentPage] = React.useState(1); + let visibleBudgetLines = [...budgetLines]; + visibleBudgetLines = visibleBudgetLines.slice((currentPage - 1) * ITEMS_PER_PAGE, currentPage * ITEMS_PER_PAGE); + if (budgetLines.length === 0) { return

No budget lines have been added to this CAN.

; } return ( - - {budgetLines.map((budgetLine) => ( - +
+ {visibleBudgetLines.map((budgetLine) => ( + + ))} +
+ {budgetLines.length > ITEMS_PER_PAGE && ( + - ))} - + )} + ); }; diff --git a/frontend/src/components/CANs/CANFundingCard/CANFundingCard.jsx b/frontend/src/components/CANs/CANFundingCard/CANFundingCard.jsx index c380322e04..307a97c54a 100644 --- a/frontend/src/components/CANs/CANFundingCard/CANFundingCard.jsx +++ b/frontend/src/components/CANs/CANFundingCard/CANFundingCard.jsx @@ -61,7 +61,6 @@ const CANFundingCard = ({ can, pendingAmount, afterApproval }) => { return ( diff --git a/frontend/src/components/CANs/CANFundingInfoCard/CANFundingInfoCard.jsx b/frontend/src/components/CANs/CANFundingInfoCard/CANFundingInfoCard.jsx new file mode 100644 index 0000000000..370dcc1e3e --- /dev/null +++ b/frontend/src/components/CANs/CANFundingInfoCard/CANFundingInfoCard.jsx @@ -0,0 +1,118 @@ +import { NO_DATA } from "../../../constants"; +import Card from "../../UI/Cards/Card"; +import TermTag from "../../UI/Term/TermTag"; +/** + * @typedef {import("../../../components/CANs/CANTypes").FundingDetails} FundingDetails + */ + +/** + * @typedef {Object} CANFundingInfoCard + * @property {FundingDetails} [funding] + * @property {number} fiscalYear + */ + +/** + * @component - The CAN Funding component. + * @param {CANFundingInfoCard} props + * @returns {JSX.Element} - The component JSX. + */ +const CANFundingInfoCard = ({ funding, fiscalYear }) => { + if (!funding) { + return
No funding information available for this CAN.
; + } + + return ( + +

+ {`FY ${fiscalYear} CAN Funding Information`} +

+
+
+
+ + +
+
+
+
+ {funding.active_period && ( + 1 + ? `${funding.active_period} Years` + : `${funding.active_period} Year` + } + /> + )} + +
+
+
+
+ + +
+
+
+
+ {/* TODO: ask where this comes from */} + + +
+
+
+
+ + +
+
+
+
+ {/* TODO: ask where this comes from */} + + +
+
+
+
+ ); +}; + +export default CANFundingInfoCard; diff --git a/frontend/src/components/CANs/CANFundingInfoCard/index.js b/frontend/src/components/CANs/CANFundingInfoCard/index.js new file mode 100644 index 0000000000..9a8dc9b94f --- /dev/null +++ b/frontend/src/components/CANs/CANFundingInfoCard/index.js @@ -0,0 +1 @@ +export { default } from "./CANFundingInfoCard"; diff --git a/frontend/src/components/CANs/CANTypes.d.ts b/frontend/src/components/CANs/CANTypes.d.ts index c4980ae7ee..78499b5bd3 100644 --- a/frontend/src/components/CANs/CANTypes.d.ts +++ b/frontend/src/components/CANs/CANTypes.d.ts @@ -66,6 +66,7 @@ export type FundingBudget = { }; export type FundingDetails = { + active_period?: number; allotment?: string; allowance?: string; appropriation?: string; @@ -73,9 +74,10 @@ export type FundingDetails = { fiscal_year: number; fund_code: string; funding_partner?: string; - funding_source?: string; + funding_source?: "OPRE" | "ACF" | "HHS"; id: number; method_of_transfer?: keyof typeof CAN_TRANSFER; + obligate_by?: number; sub_allowance?: string; created_by?: any; created_by_user?: any; diff --git a/frontend/src/components/Portfolios/PortfolioFundingByBudgetStatus/PortfolioFundingByBudgetStatus.jsx b/frontend/src/components/Portfolios/PortfolioFundingByBudgetStatus/PortfolioFundingByBudgetStatus.jsx index 0adab43058..459e8bfea8 100644 --- a/frontend/src/components/Portfolios/PortfolioFundingByBudgetStatus/PortfolioFundingByBudgetStatus.jsx +++ b/frontend/src/components/Portfolios/PortfolioFundingByBudgetStatus/PortfolioFundingByBudgetStatus.jsx @@ -82,7 +82,7 @@ const PortfolioFundingByBudgetStatus = () => { }; return ( - +

FY {fiscalYear.value} Budget Status

diff --git a/frontend/src/components/UI/Cards/BudgetCard/BigBudgetCard.jsx b/frontend/src/components/UI/Cards/BudgetCard/BigBudgetCard.jsx index 1c3b70cfe4..817aed24e5 100644 --- a/frontend/src/components/UI/Cards/BudgetCard/BigBudgetCard.jsx +++ b/frontend/src/components/UI/Cards/BudgetCard/BigBudgetCard.jsx @@ -37,7 +37,7 @@ const BigBudgetCard = ({ title, totalSpending, totalFunding }) => { return ( <> { return ( diff --git a/frontend/src/components/UI/Cards/Card/Card.jsx b/frontend/src/components/UI/Cards/Card/Card.jsx index 4b972425e3..76c54051fe 100644 --- a/frontend/src/components/UI/Cards/Card/Card.jsx +++ b/frontend/src/components/UI/Cards/Card/Card.jsx @@ -1,11 +1,10 @@ import RoundedBox from "../../RoundedBox"; /** - * @typedef {Object} CardProps + * @typedef {Object & React.HTMLAttributes} CardProps * @property {string} [title] - The title of the card. * @property {string} [dataCy] - The data-cy attribute to add to the card. * @property {Object} [style] - The style object to apply to the card. - * @property {Object} [rest] - Additional props to be passed to the card. * @property {React.ReactNode} children - The children to render. */ @@ -17,7 +16,6 @@ import RoundedBox from "../../RoundedBox"; const Card = ({ title, children, dataCy = "", ...rest }) => { return ( { const id = crypto.randomUUID(); return ( - +

{title}

0 ? `${styles.widthLegend} font-12px` : "width-card-lg font-12px"}> diff --git a/frontend/src/components/UI/Cards/ProjectAgreementBLICard/ProjectAgreementBLICard.jsx b/frontend/src/components/UI/Cards/ProjectAgreementBLICard/ProjectAgreementBLICard.jsx index 84cfdc2f23..a14bdd2ff2 100644 --- a/frontend/src/components/UI/Cards/ProjectAgreementBLICard/ProjectAgreementBLICard.jsx +++ b/frontend/src/components/UI/Cards/ProjectAgreementBLICard/ProjectAgreementBLICard.jsx @@ -53,10 +53,7 @@ const ProjectAgreementBLICard = ({ fiscalYear, projects, agreements, budgetLines }; return ( - +

{projectHeading}

diff --git a/frontend/src/components/UI/RoundedBox/RoundedBox.jsx b/frontend/src/components/UI/RoundedBox/RoundedBox.jsx index 97b80d16aa..1dc1e404b8 100644 --- a/frontend/src/components/UI/RoundedBox/RoundedBox.jsx +++ b/frontend/src/components/UI/RoundedBox/RoundedBox.jsx @@ -8,11 +8,11 @@ import cssClasses from "./styles.module.css"; * @param {string} [props.id] - Element ID. * @param {string} [props.dataCy] - Data attribute for Cypress tests. * @param {Object} [props.style] - Inline styles. - * @param {Object} [props.rest] - Additional props to be passed + * @property {React.HTMLAttributes} [rest] - Additional props to be spread onto * @returns {JSX.Element} Rendered component. */ const RoundedBox = ({ children, className, dataCy, ...rest }) => { - const cardContainer = `bg-brand-base-light-variant border-base-light font-family-sans display-flex ${cssClasses.container} ${className ? className : ""}`; + const cardContainer = `bg-brand-base-light-variant border-base-light font-family-sans ${cssClasses.container} ${className ? className : ""}`; return (
{ return (
- +

This is the OPRE OPS system prototype

⚠️Tread with caution

diff --git a/frontend/src/pages/cans/detail/Can.jsx b/frontend/src/pages/cans/detail/Can.jsx index 06adaf0759..872035cd07 100644 --- a/frontend/src/pages/cans/detail/Can.jsx +++ b/frontend/src/pages/cans/detail/Can.jsx @@ -52,7 +52,7 @@ const Can = () => { return
CAN not found
; } - const { number, description, nick_name: nickname, portfolio, projects } = can; + const { number, description, nick_name: nickname, portfolio, projects, funding_details: fundingDetails } = can; const { division_id: divisionId, team_leaders: teamLeaders, name: portfolioName } = portfolio; const subTitle = `${can.nick_name} - ${can.active_period} ${can.active_period > 1 ? "Years" : "Year"}`; @@ -110,7 +110,12 @@ const Can = () => { /> } + element={ + + } /> diff --git a/frontend/src/pages/cans/detail/CanFunding.jsx b/frontend/src/pages/cans/detail/CanFunding.jsx index 2119bf9fce..9891dac4c6 100644 --- a/frontend/src/pages/cans/detail/CanFunding.jsx +++ b/frontend/src/pages/cans/detail/CanFunding.jsx @@ -1,8 +1,38 @@ -const CanFunding = () => { +import CANFundingInfoCard from "../../../components/CANs/CANFundingInfoCard"; +import DebugCode from "../../../components/DebugCode"; + +/** + * @typedef {import("../../../components/CANs/CANTypes").FundingDetails} FundingDetails + * @typedef {import("../../../components/BudgetLineItems/BudgetLineTypes").BudgetLine} BudgetLine + */ + +/** + * @typedef {Object} CanFundingProps + * @property {FundingDetails} [funding] + * @property {number} fiscalYear + */ + +/** + * @component - The CAN Funding component. + * @param {CanFundingProps} props + * @returns {JSX.Element} - The component JSX. + */ +const CanFunding = ({ funding, fiscalYear }) => { + if (!funding) { + return
No funding information available for this CAN.
; + } return (

Can Funding

-

coming soon...

+

The summary below shows the funding for this CAN for the select fiscal year.

+ +
); };