feat(05-03): extend document detail page with PreparePanel
- Fetch allClients in parallel with doc via Promise.all - Import PreparePanel and render in 1/3 right column of 2/3 + 1/3 grid - currentClientId defaults to doc.assignedClientId ?? doc.clientId - asc import added from drizzle-orm for ordered client list - npm run build is clean with no TypeScript errors
This commit is contained in:
@@ -2,9 +2,10 @@ import { auth } from '@/lib/auth';
|
|||||||
import { redirect } from 'next/navigation';
|
import { redirect } from 'next/navigation';
|
||||||
import { db } from '@/lib/db';
|
import { db } from '@/lib/db';
|
||||||
import { documents, clients } from '@/lib/db/schema';
|
import { documents, clients } from '@/lib/db/schema';
|
||||||
import { eq } from 'drizzle-orm';
|
import { eq, asc } from 'drizzle-orm';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { PdfViewerWrapper } from './_components/PdfViewerWrapper';
|
import { PdfViewerWrapper } from './_components/PdfViewerWrapper';
|
||||||
|
import { PreparePanel } from './_components/PreparePanel';
|
||||||
|
|
||||||
export default async function DocumentPage({
|
export default async function DocumentPage({
|
||||||
params,
|
params,
|
||||||
@@ -16,10 +17,13 @@ export default async function DocumentPage({
|
|||||||
|
|
||||||
const { docId } = await params;
|
const { docId } = await params;
|
||||||
|
|
||||||
const doc = await db.query.documents.findFirst({
|
const [doc, allClients] = await Promise.all([
|
||||||
where: eq(documents.id, docId),
|
db.query.documents.findFirst({
|
||||||
with: { client: true },
|
where: eq(documents.id, docId),
|
||||||
});
|
with: { client: true },
|
||||||
|
}),
|
||||||
|
db.select().from(clients).orderBy(asc(clients.name)),
|
||||||
|
]);
|
||||||
|
|
||||||
if (!doc) redirect('/portal/dashboard');
|
if (!doc) redirect('/portal/dashboard');
|
||||||
|
|
||||||
@@ -34,10 +38,25 @@ export default async function DocumentPage({
|
|||||||
← Back to {doc.client?.name ?? 'Client'}
|
← Back to {doc.client?.name ?? 'Client'}
|
||||||
</Link>
|
</Link>
|
||||||
<h1 className="text-2xl font-bold mt-1">{doc.name}</h1>
|
<h1 className="text-2xl font-bold mt-1">{doc.name}</h1>
|
||||||
<p className="text-sm text-gray-500">{doc.client?.name}</p>
|
<p className="text-sm text-gray-500">
|
||||||
|
{doc.client?.name} · <span className="capitalize">{doc.status}</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
||||||
|
<div className="lg:col-span-2">
|
||||||
|
<PdfViewerWrapper docId={docId} />
|
||||||
|
</div>
|
||||||
|
<div className="lg:col-span-1">
|
||||||
|
<PreparePanel
|
||||||
|
docId={docId}
|
||||||
|
clients={allClients}
|
||||||
|
currentClientId={doc.assignedClientId ?? doc.clientId}
|
||||||
|
currentStatus={doc.status}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<PdfViewerWrapper docId={docId} />
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user