fixed funding ui

This commit is contained in:
Khalim Conn-Kowlessar 2025-08-26 14:00:46 +00:00
parent c5af201044
commit 0a9772d522
4 changed files with 50 additions and 8 deletions

View file

@ -320,7 +320,7 @@ export default function RecommendationContainer({
console.warn("Multiple funding packages found, using the first one.");
}
const [totalFunding, setTotalFunding] = useState(funding[0].projectFunding)
const [totalFunding, setTotalFunding] = useState(funding[0]?.projectFunding || 0)
const currentEpcRating = propertyMeta.currentEpcRating;
const currentSapPoints = propertyMeta.currentSapPoints;

View file

@ -105,14 +105,14 @@ export default function ValuationImpactComponent({
</div>
<FundingSummary
scheme={funding.scheme}
scheme={funding?.scheme}
onSeeMore={openFundingModal}
/>
<FundingSummaryModal
isOpen={fundingModalIsOpen}
closeModal={() => setFundingModalIsOpen(false)}
scheme={funding.scheme}
fundingPackageMeasures={funding.fundingPackageMeasures}
scheme={funding?.scheme}
fundingPackageMeasures={funding?.fundingPackageMeasures || []}
/>
</div>
);

View file

@ -109,14 +109,28 @@ function formatRoomName(name: string) {
.replace("Room Info", "Room");
}
function getRecommendedOccupants(bedrooms: number): number {
if (bedrooms <= 0) return 0;
if (bedrooms === 1) return 2;
if (bedrooms === 2) return 4;
if (bedrooms === 3) return 6;
return 7; // 4 or more
}
export default function ConditionReport({
conditionReport,
totalFloorArea
}: {
conditionReport: {
rooms: Record<string, any>;
[key: string]: any;
}
},
totalFloorArea: number;
}) {
// Documentation on decent home standards can be found here:
// https://assets.publishing.service.gov.uk/media/5a7968b740f0b63d72fc5926/138355.pdf
const rooms = conditionReport.rooms;
const allRoomData = [
@ -172,6 +186,22 @@ export default function ConditionReport({
}
);
// Check if the property has adequate space
// We've seen a case where the number of adult occupants + child occupants is greater than the total_number_of_occupants so we
// take the biggest of the two
const totalOccupants = conditionReport.occupant_info?.total_number_of_occupants ?? 0;
const totalAdults = conditionReport.occupant_info?.no_of_adult_occupants ?? 0;
const totalChildren = conditionReport.occupant_info?.no_of_child_occupants ?? 0;
const numberOfBedrooms = Array.isArray(rooms.bedrooms)
? rooms.bedrooms.length
: 0;
const occupantsToUse = Math.max(totalAdults + totalChildren, totalOccupants);
const maxOccupants = getRecommendedOccupants(numberOfBedrooms);
const areaPerPerson = totalFloorArea / occupantsToUse;
const hasSufficientSpace = (occupantsToUse <= maxOccupants) && (areaPerPerson >= 20);
return (
<div className="space-y-6 mt-8">
<Card>
@ -180,7 +210,7 @@ export default function ConditionReport({
</CardHeader>
<CardContent className="space-y-3">
<ChecklistItem
label="No signs of damp or mould"
label={roomsWithDamp ? "Signs of damp or mould present": "No signs of damp or mould"}
passed={roomsWithDamp.length === 0}
alert={roomsWithDamp.length > 0}
roomsWithIssues={roomsWithDamp}
@ -212,6 +242,12 @@ export default function ConditionReport({
passed={bathroomsOk}
alert={!bathroomsOk}
/>
<ChecklistItem
label="Sufficient space for number of occupants"
passed={hasSufficientSpace}
alert={!hasSufficientSpace}
note={`${totalOccupants} occupants, ${numberOfBedrooms} bedrooms. ${areaPerPerson}m² per person`}
/>
</CardContent>
</Card>

View file

@ -143,7 +143,7 @@ export default async function PreAssessmentReport(
conditionReport = await getEnergyAssessmentFromS3(conditionReportMeta.s3JsonUri);
}
console.log("conditionReport", conditionReport.rooms.kitchen)
// console.log("conditionReport", conditionReport.rooms.utility)
const nonIntrusiveSurvey = await getNonIntrusiveSurvey(propertyMeta.uprn);
@ -151,6 +151,12 @@ export default async function PreAssessmentReport(
const heatingDemand = formatHeatDemandFeatures(conditionReportData);
// If total floor area is missing, we have a problem
if (conditionReportData.totalFloorArea == null) {
console.error("Total floor area is missing");
return null;
}
return (
<div className="leading-loose tracking-wider">
<div className="text-gray-700 text-sm mt-4">
@ -172,7 +178,7 @@ export default async function PreAssessmentReport(
</div>
{
Object.keys(conditionReportMeta).length > 0 && <ConditionReport conditionReport={conditionReport} />
Object.keys(conditionReportMeta).length > 0 && <ConditionReport conditionReport={conditionReport} totalFloorArea={conditionReportData.totalFloorArea}/>
}
{nonIntrusiveSurvey && (