Mail Details: Accurate document-type display and safer in-form buttons
Executive summary
The mail detail view now pulls the list and count of document types from a dedicated, freshly-fetched source instead of relying on data embedded in the mail record, so the "Document Type" section stays accurate after a quick upload. Several icon buttons across pagination and the user/folder assignment screens were also hardened so they no longer accidentally submit the surrounding form. This change has reached the QA/testing environment.
Why this was needed
On the mail details screen, the document-type list and its count were read from fields baked into the mail object (mail.document_types / mail.document_count). After a user quick-uploaded a document, these embedded fields could be stale, so the count and badges shown to the user did not always reflect reality. Separately, icon-only action buttons (pagination arrows, assign/unassign controls) had no explicit button type; inside a form a button defaults to submit, which can trigger an unintended form submission or page action when clicked.
Client / user impact
Users viewing a mail in the batches workflow now see a correct, up-to-date document-type count and badge list, with a brief loading placeholder while it fetches. Adding a document via quick upload reliably refreshes that section. Clicking pagination or assign/unassign arrows no longer risks an accidental form submission, making the Folders and Organization assignment steps and the folder pagination behave more predictably.
Technical scope
MailOverviewDetails.tsx: replaces the embeddedmail.document_types/mail.document_countwith theuseGetDocumentTypeByMailId(mail.mail_id)query; renders count fromdocumentTypeData.count, badges fromdocumentTypeData.items(keyed byid/name), and shows aSkeletonwhile loading.documentType.queries.ts:useGetDocumentTypeByMailIdnow unwraps the service response, returningresult.dataon success andnullotherwise.document.mutations.ts: the quick-upload success handler now invalidates only thedocument_type_by_mail_idquery key instead of a broad set of keys (mailDetails, documentsGrid, documentDetails, documentStatus, documentTypes, document_type_paginated).QuickDocumentUpload.tsx: adds theuseQueryClienthook/import.Pagination.tsx,AssignUsersStep.tsx,AssignFoldersStep.tsx: addtype="button"to icon buttons; minorlet->constand JSX whitespace cleanup in pagination.- Net change is small (+43 / -16 across 7 files).
Risk & mitigation
Low overall. Main behavioral risk: the document-type section now depends on a separate fetch, so the displayed list/count is only as current as that query. The narrowed cache invalidation on quick upload means any view previously relying on the broader invalidation (e.g. documents grid) could miss a refresh; this is mitigated because the only changed surface is the per-mail document-type section, which targets the correct key. The type="button" additions are non-functional safety changes with negligible risk.
QA validation focus
- Open a mail in the batches workflow with zero document types: confirm the quick-upload form appears and a skeleton shows briefly while loading.
- Open a mail with one or more document types: verify the count in the "Document Type" header and the badges match the actual document types.
- Quick-upload a document, then confirm the count and badge list update without a manual refresh.
- In Folders pagination and the Assign Users / Assign Folders steps, click the arrow and chevron buttons and confirm they only paginate/assign and never submit or reset the surrounding form.
- Verify disabled states on the assign/unassign and prev/next buttons still behave correctly.