diff --git a/frontend/src/tools/bestellungen.jsx b/frontend/src/tools/bestellungen.jsx index 390469b..60a2036 100644 --- a/frontend/src/tools/bestellungen.jsx +++ b/frontend/src/tools/bestellungen.jsx @@ -47,7 +47,7 @@ function BestellungDetail({ id, toast, onBack }) { const [form, setForm] = useState({ name:'', bemerkung:'', custom_price:'', status:'warteliste' }); useEffect(() => { - api('/tools/kalkulator3d').then(setArchiv).catch(()=>{}); + api('/tools/kalkulator3d').then(d => setArchiv(d.own || d || [])).catch(()=>{}); if (id) { api(`/tools/bestellungen/${id}`) .then(o => { setOrder(o); setForm({ name:o.name, bemerkung:o.bemerkung, custom_price:o.custom_price??'', status:o.status }); }) diff --git a/frontend/src/tools/devtools.jsx b/frontend/src/tools/devtools.jsx index 148ca7a..2e8702c 100644 --- a/frontend/src/tools/devtools.jsx +++ b/frontend/src/tools/devtools.jsx @@ -270,27 +270,22 @@ function CronBuilder() { } // ── Tool-Definitionen ───────────────────────────────────────────────────────── -// ── Elektro-Rechner ─────────────────────────────────────────────────────────── -function ElektroRechner({ mobile }) { - // Eingabe-State für alle Formeln - const [vals, setVals] = useState({}); - const set = (k, v) => setVals(p => ({ ...p, [k]: v })); - const n = k => { const v = parseFloat(vals[k]); return isNaN(v) ? null : v; }; - const fmt = (v, unit, digits=3) => v == null ? '—' : `${parseFloat(v.toPrecision(digits))} ${unit}`; - - // Strompreis für Kostenrechner - const [preis, setPreis] = useState('0.30'); - - const Inp = ({ k, label, unit, placeholder }) => ( +// ── Elektro-Hilfskomponenten (AUSSERHALB damit keine Remounts) ──────────────── +function ElektroInp({ vals, setVals, k, label, unit, placeholder }) { + return (
-
{label} [{unit}]
- set(k,e.target.value)} +
+ {label} [{unit}] +
+ setVals(p=>({...p,[k]:e.target.value}))} placeholder={placeholder||''} style={{ ...S.inp, fontSize:13, padding:'7px 9px', width:'100%', boxSizing:'border-box' }}/>
); +} - const Result = ({ label, value, highlight }) => ( +function ElektroResult({ label, value, highlight }) { + return (
{value}
); +} - const Section = ({ title, children }) => ( +function ElektroSection({ title, children }) { + return (
{title}
{children}
); +} + +// ── Elektro-Rechner ─────────────────────────────────────────────────────────── +function ElektroRechner({ mobile }) { + const [vals, setVals] = useState({}); + const [preis, setPreis] = useState('0.30'); + + const n = k => { const v = parseFloat(vals[k]); return isNaN(v) ? null : v; }; + const fmt = (v, unit, digits=3) => v == null ? '—' : `${parseFloat(v.toPrecision(digits))} ${unit}`; + + // Shorthand mit gebundenen props + const Inp = (props) => ; + const Res = (props) => ; + const Sec = (props) => ; const cols = mobile ? '1fr' : '1fr 1fr'; @@ -368,19 +379,19 @@ function ElektroRechner({ mobile }) {
{/* Ohmsches Gesetz */} -
+
- - - -
+ + + + {/* Leistung */} -
+
@@ -388,27 +399,27 @@ function ElektroRechner({ mobile }) {
{leistRes ? <> - - - - + + + + :
Mindestens 2 Werte eingeben
} -
+ {/* Wirkungsgrad */} -
+
- - -
+ + +
{/* Stromkosten */} -
+
@@ -422,41 +433,41 @@ function ElektroRechner({ mobile }) { step="0.01" min="0" style={{ ...S.inp, fontSize:13, padding:'7px 9px', width:'100%', boxSizing:'border-box' }}/>
- - - - - - -
+ + + + + + + {/* Widerstände */} -
+
SERIE (R = R1+R2+…)
{['rs1','rs2','rs3','rs4'].map(k=>)}
- =2 ? fmt(R_ser,'Ω') : '—'} highlight={r_ser.length>=2}/> + =2 ? fmt(R_ser,'Ω') : '—'} highlight={r_ser.length>=2}/>
PARALLEL (1/R = 1/R1+1/R2+…)
{['rp1','rp2','rp3','rp4'].map(k=>)}
- =2 ? fmt(R_par,'Ω') : '—'} highlight={r_par.length>=2}/> + =2 ? fmt(R_par,'Ω') : '—'} highlight={r_par.length>=2}/>
-
+ {/* Kondensator */} -
+
- -
+ +