mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-30 12:55:02 +00:00
fixed aggregations on plan page
This commit is contained in:
parent
4b686abd30
commit
af2ba1fddf
5 changed files with 23 additions and 10 deletions
|
|
@ -11,7 +11,7 @@ const PresignedUrlBodySchema = z.object({
|
|||
|
||||
export async function POST(request: NextRequest) {
|
||||
// For the moment, this api specifically handles uploads of csvs
|
||||
console.log("in trigger api");
|
||||
|
||||
const body = await request.json();
|
||||
let validatedBody;
|
||||
|
||||
|
|
@ -24,8 +24,6 @@ export async function POST(request: NextRequest) {
|
|||
});
|
||||
}
|
||||
|
||||
console.log("Validated body");
|
||||
|
||||
try {
|
||||
// We'll trigger the plan build in our fastapi backend and then the user will just have to
|
||||
// wait for the plan to be ready
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ const createPortfolioSchema = z.object({
|
|||
|
||||
export async function POST(request: NextRequest) {
|
||||
const body = await request.json();
|
||||
console.log("Triggering plan");
|
||||
return new NextResponse(JSON.stringify({ msg: "plan triggered" }), {
|
||||
status: 201,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ const formattedQuantity = {
|
|||
const formattedMeasure = {
|
||||
internal_wall_insulation: "Internal Wall Insulation",
|
||||
external_wall_insulation: "External Wall Insulation",
|
||||
suspended_floor_insulation: "Suspension Floor Insulation",
|
||||
solid_floor_insulation: "Solid Floor Insulation",
|
||||
};
|
||||
|
||||
export const portfolioPlanColumns: ColumnDef<PortfolioPlanRecommendation>[] = [
|
||||
|
|
|
|||
|
|
@ -65,15 +65,24 @@ export default async function RecommendationPlans({
|
|||
|
||||
<div className="max-w-3xl">
|
||||
{plans.map((plan, index) => {
|
||||
// We accumulate the cost and the sap points for only the default recommendations
|
||||
const totalEstimatedCost = plan.planRecommendations.reduce(
|
||||
(acc, rec) => acc + rec.recommendation.estimatedCost,
|
||||
0
|
||||
);
|
||||
const totalSapPoints = plan.planRecommendations.reduce(
|
||||
(acc, rec) => acc + rec.recommendation.sapPoints,
|
||||
(acc, rec) => {
|
||||
if (rec.recommendation.default) {
|
||||
return acc + rec.recommendation.estimatedCost;
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
0
|
||||
);
|
||||
|
||||
const totalSapPoints = plan.planRecommendations.reduce((acc, rec) => {
|
||||
if (rec.recommendation.default) {
|
||||
return acc + rec.recommendation.sapPoints;
|
||||
}
|
||||
return acc;
|
||||
}, 0);
|
||||
|
||||
// Placeholder while we return 999 for all sap points
|
||||
const expectedSapPoints = Math.min(
|
||||
propertyMeta.currentSapPoints + totalSapPoints,
|
||||
|
|
|
|||
|
|
@ -42,7 +42,11 @@ export async function getRecommendations(
|
|||
|
||||
type PlanRelation = Plan & {
|
||||
planRecommendations: {
|
||||
recommendation: { estimatedCost: number; sapPoints: number };
|
||||
recommendation: {
|
||||
estimatedCost: number;
|
||||
sapPoints: number;
|
||||
default: boolean;
|
||||
};
|
||||
}[];
|
||||
};
|
||||
|
||||
|
|
@ -57,6 +61,7 @@ export async function getPlans(propertyId: string): Promise<PlanRelation[]> {
|
|||
columns: {
|
||||
estimatedCost: true,
|
||||
sapPoints: true,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue