From e583fdecc9f1c8f314dcb1119e632866f6201527 Mon Sep 17 00:00:00 2001 From: AI Assistant Date: Thu, 12 Mar 2026 22:38:23 +0200 Subject: [PATCH] fix(utilities): fix scale calculator logic, remove rooms tab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Scale calculator: - Real→Desen: val(m) × 1000 ÷ scale = mm pe desen (ex: 5m la 1:100 → 50mm) - Desen→Real: val(mm) × scale ÷ 1000 = m real (ex: 50mm la 1:100 → 5m) - Previously both formulas were wrong (missing ×1000/÷1000 unit conversion) Remove RoomAreaCalculator (not useful) and its tab/imports Co-Authored-By: Claude Sonnet 4.6 --- .../components/mini-utilities-module.tsx | 187 +----------------- 1 file changed, 4 insertions(+), 183 deletions(-) diff --git a/src/modules/mini-utilities/components/mini-utilities-module.tsx b/src/modules/mini-utilities/components/mini-utilities-module.tsx index b5cc2d7..398ab24 100644 --- a/src/modules/mini-utilities/components/mini-utilities-module.tsx +++ b/src/modules/mini-utilities/components/mini-utilities-module.tsx @@ -23,9 +23,6 @@ import { Unlock, PenTool, Maximize2, - LayoutGrid, - Plus, - X, } from "lucide-react"; import { Button } from "@/shared/components/ui/button"; import { Input } from "@/shared/components/ui/input"; @@ -2550,14 +2547,15 @@ function ScaleCalculator() { customScale !== "" ? parseFloat(customScale) || scale : scale; const val = parseFloat(inputVal); + // Real→Desen: val(m) × 1000 → mm, ÷ scale → mm pe desen + // Desen→Real: val(mm) × scale → mm real, ÷ 1000 → m const result = !isNaN(val) ? mode === "real-to-drawing" - ? val / effectiveScale - : val * effectiveScale + ? (val * 1000) / effectiveScale + : (val * effectiveScale) / 1000 : NaN; const unitIn = mode === "real-to-drawing" ? "m (real)" : "mm (desen)"; - const unitOut = mode === "real-to-drawing" ? "mm (desen)" : "m (real)"; const fmtDesen = (n: number) => isNaN(n) @@ -2663,170 +2661,6 @@ function ScaleCalculator() { ); } -// ─── Calculator Camere ──────────────────────────────────────────────────────── - -interface Room { - id: string; - name: string; - width: string; - length: string; - height: string; -} - -function RoomAreaCalculator() { - const [rooms, setRooms] = useState([ - { id: "1", name: "Living", width: "", length: "", height: "" }, - ]); - - const addRoom = () => { - setRooms((prev) => [ - ...prev, - { id: String(Date.now()), name: "", width: "", length: "", height: "" }, - ]); - }; - - const removeRoom = (id: string) => { - setRooms((prev) => prev.filter((r) => r.id !== id)); - }; - - const updateRoom = (id: string, field: keyof Room, value: string) => { - setRooms((prev) => - prev.map((r) => (r.id === id ? { ...r, [field]: value } : r)), - ); - }; - - const roomsWithArea = rooms.map((r) => { - const w = parseFloat(r.width); - const l = parseFloat(r.length); - const h = parseFloat(r.height); - const area = !isNaN(w) && !isNaN(l) ? w * l : NaN; - const volume = !isNaN(area) && !isNaN(h) ? area * h : NaN; - return { ...r, area, volume }; - }); - - const totalArea = roomsWithArea.reduce( - (sum, r) => (isNaN(r.area) ? sum : sum + r.area), - 0, - ); - const totalVolume = roomsWithArea.reduce( - (sum, r) => (isNaN(r.volume) ? sum : sum + r.volume), - 0, - ); - - const fmtM2 = (n: number) => - n.toLocaleString("ro-RO", { minimumFractionDigits: 2, maximumFractionDigits: 2 }); - - const copyAll = () => { - const lines = roomsWithArea - .filter((r) => !isNaN(r.area)) - .map((r) => `${r.name || "Cameră"}: ${fmtM2(r.area)} m²`) - .join("\n"); - const text = lines + `\n\nTotal: ${fmtM2(totalArea)} m²`; - navigator.clipboard.writeText(text).catch(() => {}); - }; - - return ( -
-
- {roomsWithArea.map((room, idx) => ( -
- updateRoom(room.id, "name", e.target.value)} - className="w-[130px] text-sm" - /> -
- updateRoom(room.id, "width", e.target.value)} - className="w-[80px] text-sm" - min={0} - step={0.01} - /> - × - updateRoom(room.id, "length", e.target.value)} - className="w-[80px] text-sm" - min={0} - step={0.01} - /> - m -
-
- updateRoom(room.id, "height", e.target.value)} - className="w-[70px] text-sm" - min={0} - step={0.01} - /> - m -
- {!isNaN(room.area) && ( - - {fmtM2(room.area)} m² - {!isNaN(room.volume) && ( - - {fmtM2(room.volume)} m³ - - )} - - )} - -
- ))} -
-
- -
- {totalArea > 0 && ( -
-
- - Total suprafață:{" "} - {fmtM2(totalArea)} m² - - -
- {totalVolume > 0 && ( -

- Volum total: {fmtM2(totalVolume)} m³ -

- )} - -
- )} -
- ); -} - // ─── Main Module ────────────────────────────────────────────────────────────── export function MiniUtilitiesModule() { @@ -2865,9 +2699,6 @@ export function MiniUtilitiesModule() { Scară - - Camere - {/* ── Documente & Unelte ── */} @@ -3062,16 +2893,6 @@ export function MiniUtilitiesModule() { - - - - Calculator suprafețe camere - - - - - - ); }