Refactor: Add setDfxUploaded to useDfxUpload hook and update useEffect to reset uploaded data on toggle view change

This commit is contained in:
2025-06-30 14:02:44 +05:30
parent e589cb22b5
commit 3a70a13c94

View File

@@ -17,7 +17,7 @@ import { useSceneContext } from '../../scene/sceneContext';
*/ */
const DxfFile = () => { const DxfFile = () => {
// State management hooks // State management hooks
const { dfxuploaded, dfxWallGenerate, setObjValue, objValue } = useDfxUpload(); const { dfxuploaded, dfxWallGenerate, setObjValue, objValue, setDfxUploaded } = useDfxUpload();
const { toggleView } = useToggleView(); const { toggleView } = useToggleView();
const { socket } = useSocketStore(); const { socket } = useSocketStore();
const { selectedVersionStore } = useVersionContext(); const { selectedVersionStore } = useVersionContext();
@@ -31,13 +31,13 @@ const DxfFile = () => {
const { wallStore } = useSceneContext(); const { wallStore } = useSceneContext();
const { addWall, } = wallStore(); const { addWall, } = wallStore();
const { walls } = wallStore(); const { walls } = wallStore();
/** /**
* Effect hook that runs when DXF wall generation is triggered. * Effect hook that runs when DXF wall generation is triggered.
* Loads initial points and lines from the DXF data and updates the scene. * Loads initial points and lines from the DXF data and updates the scene.
*/ */
useEffect(() => { useEffect(() => {
if (dfxWallGenerate) { if (dfxWallGenerate) {
dfxWallGenerate.map((wall: Wall) => { dfxWallGenerate.map((wall: Wall) => {
const data = { const data = {
@@ -80,7 +80,11 @@ const DxfFile = () => {
wallThickness, wallHeight, outsideMaterial, insideMaterial, activeLayer, addWall, walls wallThickness, wallHeight, outsideMaterial, insideMaterial, activeLayer, addWall, walls
}); });
}; };
useEffect(() => {
if (!toggleView) {
setDfxUploaded([])
}
}, [toggleView])
return ( return (
<> <>
{/* Render DXF lines with transform controls when DXF data is available and view is toggled */} {/* Render DXF lines with transform controls when DXF data is available and view is toggled */}