From 59d6bf215127f5ec0c14cb414765ff4c065df713 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Sat, 11 Apr 2026 08:46:54 +0000 Subject: [PATCH] refreshed upload page --- .../[propertyId]/documents/page.tsx | 93 ++++++------------- 1 file changed, 26 insertions(+), 67 deletions(-) diff --git a/src/app/portfolio/[slug]/building-passport/[propertyId]/documents/page.tsx b/src/app/portfolio/[slug]/building-passport/[propertyId]/documents/page.tsx index 4901fa0a..07948e4a 100644 --- a/src/app/portfolio/[slug]/building-passport/[propertyId]/documents/page.tsx +++ b/src/app/portfolio/[slug]/building-passport/[propertyId]/documents/page.tsx @@ -1,84 +1,43 @@ import { getPropertyMeta } from "@/app/portfolio/[slug]/building-passport/[propertyId]/utils"; -import { and, eq } from "drizzle-orm"; -import { DocumentsTable } from "./DocumentsTable"; -import { GenericDocumentsTable } from "./GenericDocumentsTable"; -import { surveyDB } from "@/app/db/surveyDB/connection"; +import { eq } from "drizzle-orm"; import { db } from "@/app/db/db"; -import { filesFromSurveyor } from "@/app/db/schema/files_from_surveyor"; -import type { FilesFromSurveyor } from "@/app/db/schema/files_from_surveyor"; -import { uploadedFiles } from "@/app/db/surveyDB/schema/surveyDB"; -import { type getUploadedFiles } from "@/app/db/surveyDB/schema/surveyDB"; - -async function getDocuments(uprn: number): Promise { - const result = surveyDB.query.uploadedFiles.findMany({ - where: eq(uploadedFiles.uprn, String(uprn)), - }); - - return result; -} - -async function getSurveyorDocuments( - portfolioId: string, - propertyId: string -): Promise { - const files = await db - .select() - .from(filesFromSurveyor) - .where( - and( - eq(filesFromSurveyor.portfolioId, BigInt(portfolioId)), - eq(filesFromSurveyor.propertyId, BigInt(propertyId)) - ) - ); - - return files; -} +import { uploadedFiles } from "@/app/db/schema/uploaded_files"; +import { DocumentsClient, type RawFileType } from "./DocumentsClient"; export default async function DocumentsPage(props: { params: Promise<{ slug: string; propertyId: string }>; }) { const params = await props.params; - // Get the property UPRN - const propertyId = params.propertyId; + const { propertyId } = params; + if (!propertyId || propertyId === "0") { throw Error("Invalid propertyId"); } const propertyMeta = await getPropertyMeta(propertyId); - const uploadedFiles = await getDocuments(propertyMeta.uprn); - // We also fetch surveyor documents, which is a temp solution - const surveyorDocuments = await getSurveyorDocuments(params.slug, propertyId); + const rows = await db + .select({ + id: uploadedFiles.id, + s3FileKey: uploadedFiles.s3FileKey, + s3FileBucket: uploadedFiles.s3FileBucket, + s3UploadTimestamp: uploadedFiles.s3UploadTimestamp, + fileType: uploadedFiles.fileType, + }) + .from(uploadedFiles) + .where(eq(uploadedFiles.uprn, BigInt(propertyMeta.uprn))); + + const documents = rows.map((row) => ({ + id: String(row.id), + s3FileKey: row.s3FileKey, + s3FileBucket: row.s3FileBucket, + docType: (row.fileType ?? "unknown") as RawFileType, + s3UploadTimestamp: row.s3UploadTimestamp.toISOString(), + })); return ( - <> -
-
- Core Survey Documents -
-
- -
-
- -
- Surveyor Uploaded Documents -
-
- -
-
- -
- Coordination -
-
- +
+ +
); }