diff --git a/src/app/portfolio/[slug]/components/RemoteAssessmentModal.tsx b/src/app/portfolio/[slug]/components/RemoteAssessmentModal.tsx index 7a37539..195ff54 100644 --- a/src/app/portfolio/[slug]/components/RemoteAssessmentModal.tsx +++ b/src/app/portfolio/[slug]/components/RemoteAssessmentModal.tsx @@ -152,7 +152,7 @@ interface EngineTriggerBody { portfolio_id: string; housing_type: string; goal: string; - goal_value: string; + goal_value: string | null; trigger_file_path: string; already_installed_file_path: string; patches_file_path: string; @@ -160,7 +160,7 @@ interface EngineTriggerBody { valuation_file_path: string; scenario_name: string; multi_plan: boolean; - budget: null; + budget: number | null; event_type: string; inclusions: (typeof measuresList)[number][]; scenario_id?: string | null; @@ -363,7 +363,7 @@ function useCreateRemoteAssessment({ async function triggerEngine(data: RemoteAssessmentFormValues) { try { // Goal value should not be missing at this point - if (!data.goalValue) { + if (data.goal === "Increasing EPC" && !data.goalValue) { throw new Error("Goal value is required"); } @@ -372,7 +372,8 @@ function useCreateRemoteAssessment({ portfolio_id: portfolioId, housing_type: data.housingType, goal: data.goal, - goal_value: data.goalValue, + // We only send goal_value if the goal is "Increasing EPC" + goal_value: data.goal, trigger_file_path: assetListFileKey, already_installed_file_path: "", patches_file_path: "", @@ -381,7 +382,8 @@ function useCreateRemoteAssessment({ scenario_name: data.scenario, inclusions: data.measures, multi_plan: true, - budget: null, + // If the goal is "Increasing EPC", we don't send a budget + budget: data.budget || null, event_type: "remote_assessment", }; @@ -669,34 +671,37 @@ export default function RemoteAssessmentModal({ )} /> - {goal && - (goal === "Increasing EPC" ? ( - ( - - - Target EPC Rating - - - {selectedScenario === NEW_SENTINEL ? ( - - field.onChange(opt.value) - } - /> - ) : ( - - )} - - - - )} - /> - ) : ( + {goal && ( + <> + {goal === "Increasing EPC" && ( + ( + + + Target EPC Rating + + + {selectedScenario === NEW_SENTINEL ? ( + + field.onChange(opt.value) + } + /> + ) : ( + + )} + + + + )} + /> + )} + + {/* ✅ Budget shows for ALL goals but is only mandatory when goal != Increasing EPC */} )} /> - ))} + + )} )}