Fix solar wizard: reorder AC/DC fields, add DC:AC ratio, auto-calc DC capacity
- Moved AC Capacity above DC Capacity - Added DC:AC Ratio input field (editable, default 1.4) - Made DC Capacity auto-calculated (read-only) based on AC * ratio - Updated buildInputs() to include dc_ac_ratio - Maintains same data flow as InputsTab.tsx
This commit is contained in:
parent
e286f930f1
commit
941843e441
1 changed files with 42 additions and 16 deletions
|
|
@ -28,8 +28,9 @@ interface WizardState {
|
|||
// Solar
|
||||
solar_enabled: boolean;
|
||||
solar_location: string;
|
||||
solar_dc_mwp: number;
|
||||
solar_ac_mw: number;
|
||||
solar_dc_ac_ratio: number;
|
||||
solar_dc_mwp: number;
|
||||
// Wind
|
||||
wind_enabled: boolean;
|
||||
wind_location: string;
|
||||
|
|
@ -49,8 +50,9 @@ const DEFAULT_STATE: WizardState = {
|
|||
cod_date: "2027-04-01",
|
||||
solar_enabled: true,
|
||||
solar_location: "RJ",
|
||||
solar_dc_mwp: 100,
|
||||
solar_ac_mw: 80,
|
||||
solar_ac_mw: 100,
|
||||
solar_dc_ac_ratio: 1.4,
|
||||
solar_dc_mwp: 140,
|
||||
wind_enabled: false,
|
||||
wind_location: "RJ",
|
||||
wind_mw: 50,
|
||||
|
|
@ -83,21 +85,29 @@ function Input({
|
|||
type = "text",
|
||||
step,
|
||||
min,
|
||||
max,
|
||||
readOnly,
|
||||
className = "",
|
||||
}: {
|
||||
value: string | number;
|
||||
onChange: (v: string) => void;
|
||||
type?: string;
|
||||
step?: number;
|
||||
min?: number;
|
||||
max?: number;
|
||||
readOnly?: boolean;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<input
|
||||
type={type}
|
||||
step={step}
|
||||
min={min}
|
||||
max={max}
|
||||
readOnly={readOnly}
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
className="border rounded px-3 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-primary bg-background"
|
||||
className={`border rounded px-3 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-primary bg-background ${readOnly ? "bg-muted cursor-default" : ""} ${className}`}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
@ -203,15 +213,6 @@ function StepSolar({
|
|||
options={LOCATION_OPTIONS}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="DC Capacity (MWp)">
|
||||
<Input
|
||||
type="number"
|
||||
value={state.solar_dc_mwp}
|
||||
step={5}
|
||||
min={1}
|
||||
onChange={(v) => set("solar_dc_mwp", Number(v))}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="AC Capacity (MW)">
|
||||
<Input
|
||||
type="number"
|
||||
|
|
@ -221,6 +222,31 @@ function StepSolar({
|
|||
onChange={(v) => set("solar_ac_mw", Number(v))}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="DC:AC Ratio">
|
||||
<Input
|
||||
type="number"
|
||||
value={state.solar_dc_ac_ratio}
|
||||
step={0.05}
|
||||
min={1.0}
|
||||
max={1.8}
|
||||
onChange={(v) => {
|
||||
const ratio = Number(v);
|
||||
set("solar_dc_ac_ratio", ratio);
|
||||
set("solar_dc_mwp", parseFloat((state.solar_ac_mw * ratio).toFixed(3)));
|
||||
}}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="DC Capacity (MWp)">
|
||||
<Input
|
||||
type="number"
|
||||
value={state.solar_dc_mwp}
|
||||
step={5}
|
||||
min={1}
|
||||
readOnly
|
||||
className="bg-muted cursor-default"
|
||||
onChange={() => {}}
|
||||
/>
|
||||
</Field>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
|
@ -365,8 +391,7 @@ function StepReview({ state }: { state: WizardState }) {
|
|||
<>
|
||||
<dt className="text-muted-foreground">Solar</dt>
|
||||
<dd>
|
||||
{state.solar_dc_mwp} MWp DC / {state.solar_ac_mw} MW AC (
|
||||
{state.solar_location})
|
||||
{state.solar_ac_mw} MW AC / {state.solar_dc_mwp} MWp DC ({state.solar_location}, {state.solar_dc_ac_ratio}x)
|
||||
</dd>
|
||||
</>
|
||||
)}
|
||||
|
|
@ -438,8 +463,9 @@ export function ScenarioWizard({ onSubmit, onCancel }: ScenarioWizardProps) {
|
|||
solar: state.solar_enabled
|
||||
? {
|
||||
location_id: state.solar_location,
|
||||
capacity_dc_mwp: state.solar_dc_mwp,
|
||||
capacity_ac_mw: state.solar_ac_mw,
|
||||
dc_ac_ratio: state.solar_dc_ac_ratio,
|
||||
capacity_dc_mwp: state.solar_dc_mwp,
|
||||
}
|
||||
: null,
|
||||
wind: state.wind_enabled
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue