All updates
ProductionQAFrontend

PDF Splitting for Mail Uploads, plus Admin Portal Stability Fixes

PR #759heytulsiprasadJan 18, 2026 · 16:35 UTC
QAJan 5, 2026
ProductionJan 18, 2026

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-splitter module in packages/ui (and an initial copy under apps/mail): splitPdf.ts (split by ranges, by page count, extract pages, get page count), a usePdfSplitter hook, and PdfSplitterModal / PdfThumbnailGrid / SplitOptionsPanel / SplitPreviewList components; adds the pdf-lib dependency.
  • Encrypted-PDF handling: enables ignoreEncryption for owner-password PDFs and copies output bytes into a fresh ArrayBuffer to avoid blank previews from pdf-lib byteOffset issues; next.config.ts excludes the native canvas module from bundling; blob-URL handling added to PDFViewerCore.
  • Mail: split button wired into FileList for multi-page PDFs and integrated through useFileHandling / AddMailsModal.
  • Vendor: new UploadModal (two-column layout) with FileDropzone / FileList, plus useVendorFileHandling (ZIP extraction) and useVendorProgrammaticUpload (Filestack) hooks; radio-group and progress UI components added.
  • Admin pagination fix in admin.services.ts: a transformPaginatedResponse maps backend camelCase (totalCount, currentPage, pageSize, hasMore) to the frontend snake_case shape across all list endpoints, and transformDashboardStats does the same for stats; data-table.tsx derives a valid pageCount and guards the count display.
  • Admin cleanup: removed the dashboard stats/activity/system-overview sections that called non-existent /admin/api/dashboard/stats and /activity endpoints; 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.