feat(docs): nested-entity 'This deal' / 'From client' split (B4 #8 phase 4)

Finishes B4 #8 by completing the UI half of the per-interest filing
model. Backend foundations (files.interest_id column, ensureEntityFolder
for 'interest', upload-zone scope radio, outcome rename hook, backfill)
shipped earlier in this audit cycle.

- listFiles validator + service: optional interestId filter
- listFilesAggregatedByEntity: routes entityType='interest' to a new
  helper that returns "THIS DEAL" + "FROM CLIENT" + symmetric-reach
  company/yacht groups
- InterestDocumentsTab: Attachments section now renders two cohorts
  via two paginated queries, with client-side de-duplication so files
  filed under this deal don't double-count under "From client"
- FileRow type exposes the optional interestId so the de-dupe filter
  doesn't need a re-fetch
This commit is contained in:
2026-05-23 01:06:45 +02:00
parent 5bd0e1ad9a
commit 70d1e7e9b2
5 changed files with 169 additions and 30 deletions

View File

@@ -23,14 +23,18 @@ export const listFilesSchema = baseListQuerySchema
clientId: z.string().optional(),
yachtId: z.string().optional(),
companyId: z.string().optional(),
interestId: z.string().optional(),
category: z.string().optional(),
folderId: z
.string()
.uuid()
.optional()
.transform((v) => (v === '' ? null : v)),
/** Entity-aggregated projection params - mutually exclusive with folderId. */
entityType: z.enum(['client', 'company', 'yacht']).optional(),
/** Entity-aggregated projection params - mutually exclusive with folderId.
* 'interest' splits direct-attached into "This deal" (files.interestId
* matches) and "From client" (client-level + other deals); the other
* values fall through to the legacy symmetric-reach aggregator. */
entityType: z.enum(['client', 'company', 'yacht', 'interest']).optional(),
entityId: z.string().uuid().optional(),
})
.refine(