diff --git a/furniture-3d-system/src/app/intake/intakeClientViewProps.test.tsx b/furniture-3d-system/src/app/intake/intakeClientViewProps.test.tsx new file mode 100644 index 00000000..59bb9a62 --- /dev/null +++ b/furniture-3d-system/src/app/intake/intakeClientViewProps.test.tsx @@ -0,0 +1,19 @@ +import { buildIntakePrimaryDomainProps } from "./intakeClientViewProps"; +import type { NonIntegratedProductRecord } from "./non-integrated/nonIntegratedStorage"; + +describe("buildIntakePrimaryDomainProps", () => { + it("uses the full internal product list for the product patent detail", () => { + const pagedProducts = [{ id: "page-one-product" }] as NonIntegratedProductRecord[]; + const allInternalProducts = [ + ...pagedProducts, + { id: "later-page-product" }, + ] as NonIntegratedProductRecord[]; + + const props = buildIntakePrimaryDomainProps({ + nonIntegratedProducts: pagedProducts, + productDevelopmentProgressProducts: allInternalProducts, + } as Parameters[0]); + + expect(props.productPatent.products).toBe(allInternalProducts); + }); +}); diff --git a/furniture-3d-system/src/app/intake/intakeClientViewProps.tsx b/furniture-3d-system/src/app/intake/intakeClientViewProps.tsx index 853deb7c..4afed8f6 100644 --- a/furniture-3d-system/src/app/intake/intakeClientViewProps.tsx +++ b/furniture-3d-system/src/app/intake/intakeClientViewProps.tsx @@ -206,7 +206,7 @@ export function buildIntakePrimaryDomainProps(params: { }, canViewProductPatentLedger: params.canViewProductPatentLedger, productPatent: { - products: params.nonIntegratedProducts, + products: params.productDevelopmentProgressProducts, user: params.user, readOnly: !params.canEditProductPatentLedger, }, diff --git a/furniture-3d-system/src/app/intake/product-development/progress-dashboard/ProductProgressPagination.test.tsx b/furniture-3d-system/src/app/intake/product-development/progress-dashboard/ProductProgressPagination.test.tsx index 700df698..85215c2f 100644 --- a/furniture-3d-system/src/app/intake/product-development/progress-dashboard/ProductProgressPagination.test.tsx +++ b/furniture-3d-system/src/app/intake/product-development/progress-dashboard/ProductProgressPagination.test.tsx @@ -57,4 +57,21 @@ describe("ProductProgressPagination", () => { expect(onPageChange).toHaveBeenCalledWith(4); }); + + it("uses the compact transparent layout when floating", () => { + render( + , + ); + + expect(screen.getByTestId("product-progress-pagination")).toHaveClass( + "bg-transparent", + ); + }); }); diff --git a/furniture-3d-system/src/app/intake/product-development/progress-dashboard/ProductProgressPagination.tsx b/furniture-3d-system/src/app/intake/product-development/progress-dashboard/ProductProgressPagination.tsx index 7b2c9d0d..37440c88 100644 --- a/furniture-3d-system/src/app/intake/product-development/progress-dashboard/ProductProgressPagination.tsx +++ b/furniture-3d-system/src/app/intake/product-development/progress-dashboard/ProductProgressPagination.tsx @@ -8,12 +8,14 @@ export function ProductProgressPagination({ totalPages, totalRows, pageSize, + variant = "default", onPageChange, }: { currentPage: number; totalPages: number; totalRows: number; pageSize: number; + variant?: "default" | "floating"; onPageChange: (page: number) => void; }) { const safeTotalPages = Math.max(1, totalPages); @@ -35,7 +37,14 @@ export function ProductProgressPagination({ } return ( -
+
-
-
+
+
-
+
@@ -630,7 +657,7 @@ export function ProductPatentDashboard({ ) : ( - visiblePatentRecords.map((record, index) => ( + patentPage.records.map((record, index) => ( setSelectedRecordId(record.id)} >
- {index + 1} + {patentPage.rowNumberStart + index + 1}
+
+
+ + setPageByFilter((current) => ({ + ...current, + [paginationKey]: page, + })) + } + /> +
+
diff --git a/furniture-3d-system/src/app/intake/product-patent/productPatentPagination.test.ts b/furniture-3d-system/src/app/intake/product-patent/productPatentPagination.test.ts new file mode 100644 index 00000000..8f5f925d --- /dev/null +++ b/furniture-3d-system/src/app/intake/product-patent/productPatentPagination.test.ts @@ -0,0 +1,22 @@ +import { getProductPatentPage, PRODUCT_PATENT_PAGE_SIZE } from "./productPatentPagination"; + +describe("getProductPatentPage", () => { + it("shows 50 records per page and numbers the second page from 51", () => { + const records = Array.from({ length: 51 }, (_, index) => index + 1); + + const page = getProductPatentPage(records, 2); + + expect(PRODUCT_PATENT_PAGE_SIZE).toBe(50); + expect(page.totalPages).toBe(2); + expect(page.currentPage).toBe(2); + expect(page.rowNumberStart).toBe(50); + expect(page.records).toEqual([51]); + }); + + it("keeps a manually entered page number within the available range", () => { + const records = Array.from({ length: 51 }, (_, index) => index + 1); + + expect(getProductPatentPage(records, 99).currentPage).toBe(2); + expect(getProductPatentPage(records, 0).currentPage).toBe(1); + }); +}); diff --git a/furniture-3d-system/src/app/intake/product-patent/productPatentPagination.ts b/furniture-3d-system/src/app/intake/product-patent/productPatentPagination.ts new file mode 100644 index 00000000..252545cb --- /dev/null +++ b/furniture-3d-system/src/app/intake/product-patent/productPatentPagination.ts @@ -0,0 +1,14 @@ +export const PRODUCT_PATENT_PAGE_SIZE = 50; + +export function getProductPatentPage(records: readonly T[], currentPage: number) { + const totalPages = Math.max(1, Math.ceil(records.length / PRODUCT_PATENT_PAGE_SIZE)); + const safeCurrentPage = Math.min(Math.max(1, currentPage), totalPages); + const rowNumberStart = (safeCurrentPage - 1) * PRODUCT_PATENT_PAGE_SIZE; + + return { + currentPage: safeCurrentPage, + totalPages, + rowNumberStart, + records: records.slice(rowNumberStart, rowNumberStart + PRODUCT_PATENT_PAGE_SIZE), + }; +}