diff --git a/src/app/components/building-passport/FeatureTable.tsx b/src/app/components/building-passport/FeatureTable.tsx index d711dbc..49e5ab4 100644 --- a/src/app/components/building-passport/FeatureTable.tsx +++ b/src/app/components/building-passport/FeatureTable.tsx @@ -16,17 +16,22 @@ import { TableRow, } from "@/app/shadcn_components/ui/table"; -import { Feature, GeneralFeature } from "@/app/db/schema/property"; +import { + Feature, + GeneralFeature, + NonInstrusiveFeature, +} from "@/app/db/schema/property"; -interface DataTableProps { +interface DataTableProps< + T extends Feature | GeneralFeature | NonInstrusiveFeature +> { columns: ColumnDef[]; data: T[]; } -export default function FeatureTable({ - data, - columns, -}: DataTableProps) { +export default function FeatureTable< + T extends Feature | GeneralFeature | NonInstrusiveFeature +>({ data, columns }: DataTableProps) { // Initialise the table const table = useReactTable({ diff --git a/src/app/components/building-passport/FeatureTableColumns.tsx b/src/app/components/building-passport/FeatureTableColumns.tsx index eedd7f0..827723f 100644 --- a/src/app/components/building-passport/FeatureTableColumns.tsx +++ b/src/app/components/building-passport/FeatureTableColumns.tsx @@ -1,6 +1,11 @@ "use client"; -import { Feature, GeneralFeature, Rating } from "@/app/db/schema/property"; +import { + Feature, + GeneralFeature, + NonInstrusiveFeature, + Rating, +} from "@/app/db/schema/property"; import { Badge } from "@/app/shadcn_components/ui/badge"; import { ColumnDef } from "@tanstack/react-table"; @@ -48,3 +53,14 @@ export const generalColumns: ColumnDef[] = [ header: "Description", }, ]; + +export const nonInstrusiveColumns: ColumnDef[] = [ + { + accessorKey: "title", + header: "Feature", + }, + { + accessorKey: "note", + header: "Recorded Observation", + }, +]; diff --git a/src/app/db/migrations/meta/_journal.json b/src/app/db/migrations/meta/_journal.json index 42a4ea7..2db8771 100644 --- a/src/app/db/migrations/meta/_journal.json +++ b/src/app/db/migrations/meta/_journal.json @@ -456,6 +456,13 @@ "when": 1713028155621, "tag": "0064_icy_blue_shield", "breakpoints": true + }, + { + "idx": 65, + "version": "5", + "when": 1713028260577, + "tag": "0065_watery_korvac", + "breakpoints": true } ] } \ No newline at end of file diff --git a/src/app/db/schema/property.ts b/src/app/db/schema/property.ts index 38ef26f..b693875 100644 --- a/src/app/db/schema/property.ts +++ b/src/app/db/schema/property.ts @@ -52,6 +52,11 @@ export interface GeneralFeature { description: string | number; } +export interface NonInstrusiveFeature { + title: string; + note: string; +} + export interface ConditionReportData { id: number; lastUpdated: string; @@ -219,8 +224,8 @@ export const nonIntrusiveSurveyNotes = pgTable("non_intrusive_survey_notes", { surveyId: bigint("survey_id", { mode: "bigint" }) .notNull() .references(() => nonInstrusiveSurvey.id), - title: text("title"), - note: text("note"), + title: text("title").notNull(), + note: text("note").notNull(), }); export type Property = InferModel; diff --git a/src/app/portfolio/[slug]/building-passport/[propertyId]/pre-assessment-report/page.tsx b/src/app/portfolio/[slug]/building-passport/[propertyId]/pre-assessment-report/page.tsx index 6e33439..402cc7e 100644 --- a/src/app/portfolio/[slug]/building-passport/[propertyId]/pre-assessment-report/page.tsx +++ b/src/app/portfolio/[slug]/building-passport/[propertyId]/pre-assessment-report/page.tsx @@ -9,6 +9,7 @@ import { import { formatDateTime } from "@/app/utils"; import { generalColumns, + nonInstrusiveColumns, retrofitColumns, } from "@/app/components/building-passport/FeatureTableColumns"; import { @@ -117,6 +118,16 @@ function PropertyDetailsCard({ ); } +const formatDate = (dateString: Date) => { + const date = new Date(dateString); + return date.toLocaleDateString("en-GB", { + weekday: "long", // "Monday" through "Sunday" + year: "numeric", // "2024" + month: "long", // "January" through "December" + day: "numeric", // "1", "2", ..., "31" + }); +}; + export default async function PreAssessmentReport({ params, }: { @@ -131,7 +142,6 @@ export default async function PreAssessmentReport({ ); const nonIntrusiveSurvey = await getNonIntrusiveSurvey(propertyMeta.uprn); - console.log(nonIntrusiveSurvey); const retrofitFeatures = formatRetrofitFeatures(conditionReportData); @@ -158,6 +168,19 @@ export default async function PreAssessmentReport({ + {nonIntrusiveSurvey && ( +
+
Non-Intrusive Survey
+
+ Conducted by: {nonIntrusiveSurvey.surveyor} on{" "} + {formatDate(nonIntrusiveSurvey.surveyDate)} +
+ +
+ )}
General Features
Existing Property Features