diff --git a/src/components/documents/entity-folder-view.tsx b/src/components/documents/entity-folder-view.tsx index 06ceea24..81600f60 100644 --- a/src/components/documents/entity-folder-view.tsx +++ b/src/components/documents/entity-folder-view.tsx @@ -7,6 +7,7 @@ import { ClipboardSignature, FileText, Eye } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { AggregatedSection } from './aggregated-section'; import { SigningDetailsDialog } from './signing-details-dialog'; +import { FilePreviewDialog } from '@/components/files/file-preview-dialog'; import { useAggregatedFiles, useAggregatedWorkflows } from '@/hooks/use-aggregated-listing'; import { StatusPill, type StatusPillStatus } from '@/components/ui/status-pill'; import type { @@ -35,6 +36,11 @@ function mapWorkflowStatus(status: string): StatusPillStatus { export function EntityFolderView({ portSlug, entityType, entityId }: Props) { const [detailsId, setDetailsId] = useState(null); + const [previewFile, setPreviewFile] = useState<{ + id: string; + name: string; + mimeType: string | null; + } | null>(null); // Hook data is the bare AggregatedGroup[] array (hooks unwrap the API envelope). const { data: workflowGroups = [], isLoading: workflowsLoading } = useAggregatedWorkflows( @@ -76,7 +82,14 @@ export function EntityFolderView({ portSlug, entityType, entityId }: Props) { const signedFromDocumentId = f.signedFromDocumentId; return (
- {f.filename} +
{new Date(f.createdAt).toLocaleDateString('en-GB')} {signedFromDocumentId ? ( @@ -101,6 +114,16 @@ export function EntityFolderView({ portSlug, entityType, entityId }: Props) { open={Boolean(detailsId)} onOpenChange={(open) => !open && setDetailsId(null)} /> + + { + if (!open) setPreviewFile(null); + }} + fileId={previewFile?.id} + fileName={previewFile?.name} + mimeType={previewFile?.mimeType ?? undefined} + />
); } diff --git a/src/components/documents/hub-root-view.tsx b/src/components/documents/hub-root-view.tsx index 9bb3c473..85837e70 100644 --- a/src/components/documents/hub-root-view.tsx +++ b/src/components/documents/hub-root-view.tsx @@ -1,10 +1,12 @@ 'use client'; +import { useState } from 'react'; import Link from 'next/link'; import { FileText, ClipboardSignature } from 'lucide-react'; import { usePaginatedQuery } from '@/hooks/use-paginated-query'; import { StatusPill, type StatusPillStatus } from '@/components/ui/status-pill'; +import { FilePreviewDialog } from '@/components/files/file-preview-dialog'; interface HubRootDoc { id: string; @@ -17,6 +19,7 @@ interface HubRootDoc { interface HubRootFile { id: string; filename: string; + mimeType: string | null; createdAt: string; } @@ -36,6 +39,12 @@ const STATUS_PILL_MAP: Record = { }; export function HubRootView({ portSlug }: Props) { + const [previewFile, setPreviewFile] = useState<{ + id: string; + name: string; + mimeType: string | null; + } | null>(null); + const { data: workflows, isLoading: workflowsLoading } = usePaginatedQuery({ queryKey: ['documents', 'hub-root', 'workflows'], endpoint: '/api/v1/documents?tab=in_progress', @@ -87,7 +96,16 @@ export function HubRootView({ portSlug }: Props) {
    {filesData.map((f) => (
  • - {f.filename} + {new Date(f.createdAt).toLocaleDateString('en-GB')} @@ -96,6 +114,16 @@ export function HubRootView({ portSlug }: Props) {
)} + + { + if (!open) setPreviewFile(null); + }} + fileId={previewFile?.id} + fileName={previewFile?.name} + mimeType={previewFile?.mimeType ?? undefined} + />
); }