Refactor code structure for improved readability and maintainability

This commit is contained in:
2025-07-21 11:58:40 +05:30
parent 0b9f23ba4f
commit 4868b78025
9 changed files with 179 additions and 109 deletions

View File

@@ -4,6 +4,8 @@ import InputWithDropDown from "../../../ui/inputs/InputWithDropDown";
import defaultTexture from '../../../../assets/textures/floor/white.png';
import flootTexture1 from '../../../../assets/textures/floor/factory wall texture.jpg';
import flootTexture2 from '../../../../assets/textures/floor/tex1/MI_FactoryConcreteFloor01_BaseColor.001.jpg';
import flootTexture3 from '../../../../assets/textures/floor/tex2/MI_FloorMats01_baseColor.png';
import { useBuilderStore } from "../../../../store/builder/useBuilderStore";
@@ -13,9 +15,11 @@ type Material = {
textureName: string;
};
const materials = [
export const materials = [
{ texture: defaultTexture, textureId: "Default Material", textureName: "Default Material" },
{ texture: flootTexture1, textureId: "Material 1", textureName: "Grunge Concrete Wall" }
{ texture: flootTexture1, textureId: "Material 1", textureName: "Grunge Concrete Wall" },
{ texture: flootTexture2, textureId: "Material 2", textureName: "Tiled Floor" },
{ texture: flootTexture3, textureId: "Material 3", textureName: "Metal Floor" },
];
const FloorProperties = () => {
@@ -30,7 +34,7 @@ const FloorProperties = () => {
top: materials.find((mat) => mat.textureId === topMaterial) || null,
side: materials.find((mat) => mat.textureId === sideMaterial) || null,
});
}, []);
}, [sideMaterial, topMaterial]);
const handleDepthChange = (val: string) => {
setFloorDepth(parseFloat(val));

View File

@@ -2,15 +2,13 @@ import { useEffect, useState } from "react";
import InputWithDropDown from "../../../ui/inputs/InputWithDropDown";
import InputToggle from "../../../ui/inputs/InputToggle";
import defaultTexture from '../../../../assets/textures/floor/white.png';
import floorTexture1 from '../../../../assets/textures/floor/factory wall texture.jpg';
import { useBuilderStore } from "../../../../store/builder/useBuilderStore";
import { useSceneContext } from "../../../../modules/scene/sceneContext";
import { useVersionContext } from "../../../../modules/builder/version/versionContext";
import { useParams } from "react-router-dom";
import { getUserData } from "../../../../functions/getUserData";
import { useSocketStore } from "../../../../store/builder/store";
import { materials } from "./FloorProperties";
// import { upsertFloorApi } from "../../../../services/factoryBuilder/floor/upsertFloorApi";
@@ -29,11 +27,6 @@ const SelectedFloorProperties = () => {
const [activeSurface, setActiveSurface] = useState<"top" | "side">("top");
const materials = [
{ texture: defaultTexture, textureId: "Default Material", textureName: "Default Material" },
{ texture: floorTexture1, textureId: "Material 1", textureName: "Grunge Concrete" }
];
const floor = selectedFloor ? getFloorById(selectedFloor.userData.floorUuid) : null;
useEffect(() => {