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
|
||||||
solar_enabled: boolean;
|
solar_enabled: boolean;
|
||||||
solar_location: string;
|
solar_location: string;
|
||||||
solar_dc_mwp: number;
|
|
||||||
solar_ac_mw: number;
|
solar_ac_mw: number;
|
||||||
|
solar_dc_ac_ratio: number;
|
||||||
|
solar_dc_mwp: number;
|
||||||
// Wind
|
// Wind
|
||||||
wind_enabled: boolean;
|
wind_enabled: boolean;
|
||||||
wind_location: string;
|
wind_location: string;
|
||||||
|
|
@ -49,8 +50,9 @@ const DEFAULT_STATE: WizardState = {
|
||||||
cod_date: "2027-04-01",
|
cod_date: "2027-04-01",
|
||||||
solar_enabled: true,
|
solar_enabled: true,
|
||||||
solar_location: "RJ",
|
solar_location: "RJ",
|
||||||
solar_dc_mwp: 100,
|
solar_ac_mw: 100,
|
||||||
solar_ac_mw: 80,
|
solar_dc_ac_ratio: 1.4,
|
||||||
|
solar_dc_mwp: 140,
|
||||||
wind_enabled: false,
|
wind_enabled: false,
|
||||||
wind_location: "RJ",
|
wind_location: "RJ",
|
||||||
wind_mw: 50,
|
wind_mw: 50,
|
||||||
|
|
@ -83,21 +85,29 @@ function Input({
|
||||||
type = "text",
|
type = "text",
|
||||||
step,
|
step,
|
||||||
min,
|
min,
|
||||||
|
max,
|
||||||
|
readOnly,
|
||||||
|
className = "",
|
||||||
}: {
|
}: {
|
||||||
value: string | number;
|
value: string | number;
|
||||||
onChange: (v: string) => void;
|
onChange: (v: string) => void;
|
||||||
type?: string;
|
type?: string;
|
||||||
step?: number;
|
step?: number;
|
||||||
min?: number;
|
min?: number;
|
||||||
|
max?: number;
|
||||||
|
readOnly?: boolean;
|
||||||
|
className?: string;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<input
|
<input
|
||||||
type={type}
|
type={type}
|
||||||
step={step}
|
step={step}
|
||||||
min={min}
|
min={min}
|
||||||
|
max={max}
|
||||||
|
readOnly={readOnly}
|
||||||
value={value}
|
value={value}
|
||||||
onChange={(e) => onChange(e.target.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}
|
options={LOCATION_OPTIONS}
|
||||||
/>
|
/>
|
||||||
</Field>
|
</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)">
|
<Field label="AC Capacity (MW)">
|
||||||
<Input
|
<Input
|
||||||
type="number"
|
type="number"
|
||||||
|
|
@ -221,6 +222,31 @@ function StepSolar({
|
||||||
onChange={(v) => set("solar_ac_mw", Number(v))}
|
onChange={(v) => set("solar_ac_mw", Number(v))}
|
||||||
/>
|
/>
|
||||||
</Field>
|
</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>
|
</div>
|
||||||
|
|
@ -365,8 +391,7 @@ function StepReview({ state }: { state: WizardState }) {
|
||||||
<>
|
<>
|
||||||
<dt className="text-muted-foreground">Solar</dt>
|
<dt className="text-muted-foreground">Solar</dt>
|
||||||
<dd>
|
<dd>
|
||||||
{state.solar_dc_mwp} MWp DC / {state.solar_ac_mw} MW AC (
|
{state.solar_ac_mw} MW AC / {state.solar_dc_mwp} MWp DC ({state.solar_location}, {state.solar_dc_ac_ratio}x)
|
||||||
{state.solar_location})
|
|
||||||
</dd>
|
</dd>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
@ -438,8 +463,9 @@ export function ScenarioWizard({ onSubmit, onCancel }: ScenarioWizardProps) {
|
||||||
solar: state.solar_enabled
|
solar: state.solar_enabled
|
||||||
? {
|
? {
|
||||||
location_id: state.solar_location,
|
location_id: state.solar_location,
|
||||||
capacity_dc_mwp: state.solar_dc_mwp,
|
|
||||||
capacity_ac_mw: state.solar_ac_mw,
|
capacity_ac_mw: state.solar_ac_mw,
|
||||||
|
dc_ac_ratio: state.solar_dc_ac_ratio,
|
||||||
|
capacity_dc_mwp: state.solar_dc_mwp,
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
wind: state.wind_enabled
|
wind: state.wind_enabled
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue