diff --git a/app/src/components/layout/scenes/MainScene.tsx b/app/src/components/layout/scenes/MainScene.tsx
index 67dc35a..4139b5a 100644
--- a/app/src/components/layout/scenes/MainScene.tsx
+++ b/app/src/components/layout/scenes/MainScene.tsx
@@ -52,7 +52,7 @@ function MainScene() {
const { visualizationSocket } = useSocketStore();
const { selectedZone } = useSelectedZoneStore();
const { setFloatingWidget } = useFloatingWidget();
- const { clearComparisonProduct } = useComparisonProduct();
+ const { comparisonProduct, clearComparisonProduct } = useComparisonProduct();
const { selectedFloorItem, setSelectedFloorItem } = useSelectedFloorItem();
const { setName } = useAssetsStore();
const { projectId } = useParams()
@@ -120,7 +120,9 @@ function MainScene() {
>
)}
{
const { wallHeight, wallThickness, setWallHeight, setWallThickness } = useBuilderStore();
const [activeSide, setActiveSide] = useState<"side1" | "side2">("side1");
- const [materials, setMaterials] = useState
([initialMaterial]);
+ const [materials, setMaterials] = useState([
+ defaultMaterial,
+ initialMaterial,
+ ]);
const [selectedMaterials, setSelectedMaterials] = useState<{
side1: Material | null;
@@ -39,11 +42,11 @@ const WallProperties = () => {
side2: null,
});
- // Select initial material for both sides on mount
+ // Set default material initially for both sides
useEffect(() => {
setSelectedMaterials({
- side1: initialMaterial,
- side2: initialMaterial,
+ side1: defaultMaterial,
+ side2: defaultMaterial,
});
}, []);
@@ -71,21 +74,16 @@ const WallProperties = () => {
};
const handleRemoveMaterial = (index: number) => {
- const updatedMaterials = materials.filter((_, i) => i !== index);
+ const removedTexture = materials[index].texture;
- // Ensure there's always at least one material
- const newMaterials =
- updatedMaterials.length === 0 ? [defaultMaterial] : updatedMaterials;
+ const updatedMaterials = materials.filter((_, i) => i !== index);
+ const newMaterials = updatedMaterials.length === 0 ? [defaultMaterial] : updatedMaterials;
setMaterials(newMaterials);
- // Deselect the material if it's the one removed
setSelectedMaterials((prev) => {
const updated = { ...prev };
["side1", "side2"].forEach((side) => {
- if (
- updated[side as "side1" | "side2"]?.texture ===
- materials[index].texture
- ) {
+ if (updated[side as "side1" | "side2"]?.texture === removedTexture) {
updated[side as "side1" | "side2"] = defaultMaterial;
}
});
@@ -119,42 +117,43 @@ const WallProperties = () => {
-
setActiveSide("side1")}
>
Side 1
{selectedMaterials.side1 && (

)}
-
+
-
setActiveSide("side2")}
>
Side 2
{selectedMaterials.side2 && (

)}
-
+
{selectedMaterials[activeSide] && (
![{selectedMaterials[activeSide]!.textureName}]({selectedMaterials[activeSide]!.texture})
@@ -167,29 +166,37 @@ const WallProperties = () => {
No materials added yet.
) : (
- {materials.map((material, index) => (
-
handleSelectMaterial(material)}
- >
-
-
-

-
-
{material.textureName}
-
-
{
- e.stopPropagation();
- handleRemoveMaterial(index);
- }}
+ {materials.map((material, index) => {
+ const isSelected = selectedMaterials[activeSide]?.texture === material.texture;
+
+ return (
+
-
- ))}
+
+
+

+
+
{material.textureName}
+
+
+
+ );
+ })}
)}
diff --git a/app/src/components/ui/compareVersion/CompareLayOut.tsx b/app/src/components/ui/compareVersion/CompareLayOut.tsx
index e111252..1a5f14c 100644
--- a/app/src/components/ui/compareVersion/CompareLayOut.tsx
+++ b/app/src/components/ui/compareVersion/CompareLayOut.tsx
@@ -127,7 +127,7 @@ const CompareLayOut = () => {
ref={wrapperRef}
style={{ width }}
>
- {loadingProgress == 0 && comparisonProduct && (
+ {loadingProgress == 0 && comparisonProduct?.productUuid && (