From a3b7de98735c25a088077cd47a65572f791a49dd Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Wed, 2 Aug 2023 14:13:53 +0100 Subject: [PATCH] tweaking property meta and condition report apis --- .../condition-report/[propertyId]/route.ts | 34 +++++++++++++++++++ .../property-meta/[propertyId]/route.ts | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/app/api/building-passport/condition-report/[propertyId]/route.ts b/src/app/api/building-passport/condition-report/[propertyId]/route.ts index e69de29b..fa3ce809 100644 --- a/src/app/api/building-passport/condition-report/[propertyId]/route.ts +++ b/src/app/api/building-passport/condition-report/[propertyId]/route.ts @@ -0,0 +1,34 @@ +import { db } from "@/app/db/db"; +import { property } from "@/app/db/schema/property"; +import { serializeBigInt } from "@/app/utils"; +import { eq } from "drizzle-orm"; + +export async function GET( + request: Request, + { params }: { params: { propertyId: string } } +) { + const propertyId = params.propertyId; + + const propertyMeta = await db.query.property.findFirst({ + columns: { + id: true, + address: true, + postcode: true, + hasPreConditionReport: true, + hasRecommendations: true, + createdAt: true, + propertyType: true, + builtForm: true, + localAuthority: true, + constituency: true, + numberOfRooms: true, + yearBuilt: true, + tenure: true, + currentEpcRating: true, + currentSapPoints: true, + }, + where: eq(property.id, BigInt(propertyId)), + }); + + return new Response(JSON.stringify(propertyMeta, serializeBigInt)); +} diff --git a/src/app/api/building-passport/property-meta/[propertyId]/route.ts b/src/app/api/building-passport/property-meta/[propertyId]/route.ts index b67d48e5..fa3ce809 100644 --- a/src/app/api/building-passport/property-meta/[propertyId]/route.ts +++ b/src/app/api/building-passport/property-meta/[propertyId]/route.ts @@ -1,5 +1,5 @@ import { db } from "@/app/db/db"; -import { PropertyMeta, property } from "@/app/db/schema/property"; +import { property } from "@/app/db/schema/property"; import { serializeBigInt } from "@/app/utils"; import { eq } from "drizzle-orm";