added funding data to front end

This commit is contained in:
Khalim Conn-Kowlessar 2025-08-21 18:13:09 +00:00
parent 11d1605d5e
commit 85b38ea43c
4 changed files with 25 additions and 2 deletions

View file

@ -7,6 +7,7 @@ import * as recommendationSchema from "@/app/db/schema/recommendations";
import * as materialSchema from "@/app/db/schema/materials";
import * as solarSchema from "@/app/db/schema/solar";
import * as EnergyAssessmentsSchema from "@/app/db/schema/energy_assessments";
import * as FundingSchema from "@/app/db/schema/funding";
import * as Relations from "@/app/db/schema/relations";
export const pool = new Pool({
@ -27,6 +28,7 @@ const schema = {
...solarSchema,
...Relations,
...EnergyAssessmentsSchema,
...FundingSchema,
};
export const db = drizzle(pool, {

View file

@ -42,3 +42,6 @@ export const fundingPackageMeasures = pgTable("funding_package_measures", {
partialProjectScore: real("partial_project_score"),
upliftProjectScore: real("uplift_project_score"),
});
export type FundingPackage = typeof fundingPackage.$inferSelect;

View file

@ -1,5 +1,5 @@
import RecommendationContainer from "@/app/components/building-passport/RecommendationContainer";
import { getPropertyMeta, getRecommendations, getPlanMeta } from "../../utils";
import { getPropertyMeta, getRecommendations, getPlanMeta, getPlanFunding } from "../../utils";
export default async function Recommendations(
props: {
@ -10,6 +10,9 @@ export default async function Recommendations(
const propertyMeta = await getPropertyMeta(params.propertyId);
const recommendations = await getRecommendations(params.planId);
const planMeta = await getPlanMeta(params.planId);
const funding = await getPlanFunding(params.planId);
console.log("Funding Data:", funding);
return (
<div className="leading-loose tracking-wider">

View file

@ -22,14 +22,29 @@ import {
energyAssessment,
EnergyAssessment,
energyAssessmentDocuments,
EnergyAssessmentDocument,
EnergyAssessmentDocumentWithScenario,
} from "@/app/db/schema/energy_assessments";
import {
fundingPackage,
FundingPackage
} from "@/app/db/schema/funding";
type RecommendationList = {
recommendation: Recommendation;
}[];
export async function getPlanFunding(planId: string): Promise<FundingPackage[]> {
const data = await db.query.fundingPackage.findMany({
where: eq(fundingPackage.planId, BigInt(planId)),
});
if (!data) {
throw new Error("Network response was not ok");
}
return data;
}
export async function getEnergyAssessment(
uprn: number
): Promise<EnergyAssessment> {