Fix solver values to display as percentage not decimal

- Added pct() helper function
- Target Equity IRR now shows 18% instead of 0.18
- Input accepts percentage and converts back to decimal internally
This commit is contained in:
Manohar Gupta 2026-05-22 16:53:51 +05:30
parent 35cfc409e2
commit f224e98e0a

View file

@ -4,6 +4,11 @@ import { useState } from "react";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import type { ScenarioInputPayload } from "@/lib/api"; import type { ScenarioInputPayload } from "@/lib/api";
// Helper to convert decimal to percentage display
function pct(raw: number): number {
return parseFloat((raw * 100).toFixed(2));
}
const LOCATION_OPTIONS = [ const LOCATION_OPTIONS = [
{ value: "RJ", label: "Rajasthan (High Solar)" }, { value: "RJ", label: "Rajasthan (High Solar)" },
{ value: "GJ", label: "Gujarat (High Solar)" }, { value: "GJ", label: "Gujarat (High Solar)" },
@ -359,14 +364,18 @@ function StepSolver({
/> />
</Field> </Field>
{state.solver_mode === "solve_tariff" ? ( {state.solver_mode === "solve_tariff" ? (
<Field label="Target Equity IRR (e.g. 0.18 = 18%)"> <Field label="Target Equity IRR">
<div className="flex items-center gap-1.5">
<Input <Input
type="number" type="number"
value={state.target_irr} value={pct(state.target_irr)}
step={0.01} step={1}
min={0.05} min={5}
onChange={(v) => set("target_irr", Number(v))} max={40}
onChange={(v) => set("target_irr", Number(v) / 100)}
/> />
<span className="text-sm text-muted-foreground">%</span>
</div>
</Field> </Field>
) : ( ) : (
<Field label="Fixed Tariff (INR/kWh)"> <Field label="Fixed Tariff (INR/kWh)">