PDF Splitting for Mail Uploads, plus Admin Portal Stability Fixes
Executive summary
This release adds client-side PDF splitting to the mail upload flow in both the Mail and Vendor portals, letting users break a large combined PDF into multiple separate documents before uploading without any server round-trip. It also resolves a set of Admin Portal issues, including pagination that showed "Page X of NaN", a dashboard that called endpoints the backend does not yet provide, and several broken or redundant UI elements.
Why this was needed
Users frequently receive a single PDF that actually contains several distinct mail items and previously had no way to separate them inside the app. On the Admin side, several data grids displayed a broken page count ("Page X of NaN"), the dashboard surfaced errors because it called statistics and activity endpoints that return 404, and the folders and roles pages exposed actions (a "View Details" dialog, row-click, a "View All" link, duplicate logout) that errored or did nothing.
Client / user impact
- Mail and Vendor users can split a multi-page PDF into individual documents (by fixed page count, custom page ranges, or extracting selected pages) directly in the upload modal, with a live preview of the resulting files.
- Splitting runs entirely in the browser, so it is fast and no document leaves the device until upload.
- Admin data grids now show an accurate page count and sensible "Showing X to Y of Z results" / "No results" messaging instead of "NaN".
- The Admin dashboard, folders, and roles pages load cleanly without the previously broken stats, activity feed, and dead menu actions.
Technical scope
- New shared
pdf-splittermodule inpackages/ui(and an initial copy underapps/mail):splitPdf.ts(split by ranges, by page count, extract pages, get page count), ausePdfSplitterhook, andPdfSplitterModal/PdfThumbnailGrid/SplitOptionsPanel/SplitPreviewListcomponents; adds thepdf-libdependency. - Encrypted-PDF handling: enables
ignoreEncryptionfor owner-password PDFs and copies output bytes into a freshArrayBufferto avoid blank previews frompdf-libbyteOffset issues;next.config.tsexcludes the nativecanvasmodule from bundling; blob-URL handling added toPDFViewerCore. - Mail: split button wired into
FileListfor multi-page PDFs and integrated throughuseFileHandling/AddMailsModal. - Vendor: new
UploadModal(two-column layout) withFileDropzone/FileList, plususeVendorFileHandling(ZIP extraction) anduseVendorProgrammaticUpload(Filestack) hooks;radio-groupandprogressUI components added. - Admin pagination fix in
admin.services.ts: atransformPaginatedResponsemaps backend camelCase (totalCount,currentPage,pageSize,hasMore) to the frontend snake_case shape across all list endpoints, andtransformDashboardStatsdoes the same for stats;data-table.tsxderives a validpageCountand guards the count display. - Admin cleanup: removed the dashboard stats/activity/system-overview sections that called non-existent
/admin/api/dashboard/statsand/activityendpoints; removed the folders "View Details" dialog and row-click, the roles selection checkbox column, a duplicate logout in the sidebar user card, and the header hamburger trigger.
Risk & mitigation
Moderate, scoped to upload and Admin list surfaces. The PDF splitter is new and depends on pdf-lib/canvas and correct byte handling; encrypted or malformed PDFs are the main edge case (explicitly addressed for owner-password files, but worth confirming). The Admin pagination fix assumes the backend consistently returns the camelCase shape; if any endpoint deviates, counts could regress. Mitigation: the splitter is client-side only and falls back to normal upload, removed dashboard sections were already erroring, and the transforms are centralized so they are easy to adjust per endpoint.
QA validation focus
- In Mail and Vendor upload modals, split a multi-page PDF by page count, by custom ranges (e.g. 1-3, 4-6), and by extracting individual pages; confirm the preview and resulting files match.
- Split a password/owner-protected PDF and verify previews render (not blank) and uploads succeed.
- Verify the Vendor upload modal handles ZIP extraction and that the Filestack upload completes with progress shown.
- Across Admin grids (entities, users, roles, folders, document types, upload centers, rules, notification templates/policies, IDP mappings): confirm pagination shows correct "Page X of Y", Next/Prev enable/disable correctly, and empty lists show "No results".
- Load the Admin dashboard, folders, and roles pages and confirm no console/API errors and no missing or dead UI actions.