Refactor user data retrieval across visualization components
- Replaced direct localStorage access for email and organization with a centralized getUserData function in LineGraphComponent, PieGraphComponent, PolarAreaGraphComponent, ProgressCard1, ProgressCard2, Dropped3dWidgets, ProductionCapacity, ReturnOfInvestment, StateWorking, Throughput, and various floating widgets.
- Improved code readability and maintainability by consolidating user data extraction logic.
- Ensured consistent user data handling across multiple components to reduce redundancy.
2025-06-13 11:41:28 +00:00
import { toast } from "react-toastify" ;
import RemoveConnectedLines from "../lines/removeConnectedLines" ;
2025-03-25 12:04:20 +00:00
Refactor user data retrieval across visualization components
- Replaced direct localStorage access for email and organization with a centralized getUserData function in LineGraphComponent, PieGraphComponent, PolarAreaGraphComponent, ProgressCard1, ProgressCard2, Dropped3dWidgets, ProductionCapacity, ReturnOfInvestment, StateWorking, Throughput, and various floating widgets.
- Improved code readability and maintainability by consolidating user data extraction logic.
- Ensured consistent user data handling across multiple components to reduce redundancy.
2025-06-13 11:41:28 +00:00
import * as Types from "../../../../types/world/worldTypes" ;
import { Socket } from "socket.io-client" ;
import { getUserData } from "../../../../functions/getUserData" ;
2025-03-25 12:04:20 +00:00
// import { deleteLayer } from '../../../../services/factoryBuilder/lines/deleteLayerApi';
async function DeleteLayer (
Refactor user data retrieval across visualization components
- Replaced direct localStorage access for email and organization with a centralized getUserData function in LineGraphComponent, PieGraphComponent, PolarAreaGraphComponent, ProgressCard1, ProgressCard2, Dropped3dWidgets, ProductionCapacity, ReturnOfInvestment, StateWorking, Throughput, and various floating widgets.
- Improved code readability and maintainability by consolidating user data extraction logic.
- Ensured consistent user data handling across multiple components to reduce redundancy.
2025-06-13 11:41:28 +00:00
removedLayer : Types.Number ,
lines : Types.RefLines ,
floorPlanGroupLine : Types.RefGroup ,
floorPlanGroupPoint : Types.RefGroup ,
onlyFloorlines : Types.RefOnlyFloorLines ,
floorGroup : Types.RefGroup ,
setDeletedLines : any ,
setRemovedLayer : Types.setRemoveLayerSetState ,
socket : Socket < any > ,
2025-06-21 07:04:29 +00:00
projectId? : string ,
versionId? : string ,
2025-03-25 12:04:20 +00:00
) : Promise < void > {
Refactor user data retrieval across visualization components
- Replaced direct localStorage access for email and organization with a centralized getUserData function in LineGraphComponent, PieGraphComponent, PolarAreaGraphComponent, ProgressCard1, ProgressCard2, Dropped3dWidgets, ProductionCapacity, ReturnOfInvestment, StateWorking, Throughput, and various floating widgets.
- Improved code readability and maintainability by consolidating user data extraction logic.
- Ensured consistent user data handling across multiple components to reduce redundancy.
2025-06-13 11:41:28 +00:00
////////// Remove the Lines from the lines.current based on the removed layer and rearrange the layer number that are higher than the removed layer //////////
2025-03-25 12:04:20 +00:00
Refactor user data retrieval across visualization components
- Replaced direct localStorage access for email and organization with a centralized getUserData function in LineGraphComponent, PieGraphComponent, PolarAreaGraphComponent, ProgressCard1, ProgressCard2, Dropped3dWidgets, ProductionCapacity, ReturnOfInvestment, StateWorking, Throughput, and various floating widgets.
- Improved code readability and maintainability by consolidating user data extraction logic.
- Ensured consistent user data handling across multiple components to reduce redundancy.
2025-06-13 11:41:28 +00:00
const removedLines : Types.Lines = lines . current . filter (
( line ) = > line [ 0 ] [ 2 ] === removedLayer
) ;
2025-06-21 07:04:29 +00:00
const { userId , organization } = getUserData ( ) ;
2025-03-25 12:04:20 +00:00
Refactor user data retrieval across visualization components
- Replaced direct localStorage access for email and organization with a centralized getUserData function in LineGraphComponent, PieGraphComponent, PolarAreaGraphComponent, ProgressCard1, ProgressCard2, Dropped3dWidgets, ProductionCapacity, ReturnOfInvestment, StateWorking, Throughput, and various floating widgets.
- Improved code readability and maintainability by consolidating user data extraction logic.
- Ensured consistent user data handling across multiple components to reduce redundancy.
2025-06-13 11:41:28 +00:00
//REST
2025-03-25 12:04:20 +00:00
Refactor user data retrieval across visualization components
- Replaced direct localStorage access for email and organization with a centralized getUserData function in LineGraphComponent, PieGraphComponent, PolarAreaGraphComponent, ProgressCard1, ProgressCard2, Dropped3dWidgets, ProductionCapacity, ReturnOfInvestment, StateWorking, Throughput, and various floating widgets.
- Improved code readability and maintainability by consolidating user data extraction logic.
- Ensured consistent user data handling across multiple components to reduce redundancy.
2025-06-13 11:41:28 +00:00
// await deleteLayer(organization, removedLayer);
2025-03-25 12:04:20 +00:00
Refactor user data retrieval across visualization components
- Replaced direct localStorage access for email and organization with a centralized getUserData function in LineGraphComponent, PieGraphComponent, PolarAreaGraphComponent, ProgressCard1, ProgressCard2, Dropped3dWidgets, ProductionCapacity, ReturnOfInvestment, StateWorking, Throughput, and various floating widgets.
- Improved code readability and maintainability by consolidating user data extraction logic.
- Ensured consistent user data handling across multiple components to reduce redundancy.
2025-06-13 11:41:28 +00:00
//SOCKET
2025-03-25 12:04:20 +00:00
Refactor user data retrieval across visualization components
- Replaced direct localStorage access for email and organization with a centralized getUserData function in LineGraphComponent, PieGraphComponent, PolarAreaGraphComponent, ProgressCard1, ProgressCard2, Dropped3dWidgets, ProductionCapacity, ReturnOfInvestment, StateWorking, Throughput, and various floating widgets.
- Improved code readability and maintainability by consolidating user data extraction logic.
- Ensured consistent user data handling across multiple components to reduce redundancy.
2025-06-13 11:41:28 +00:00
const data = {
organization ,
layer : removedLayer ,
socketId : socket.id ,
2025-06-21 07:04:29 +00:00
versionId ,
Refactor user data retrieval across visualization components
- Replaced direct localStorage access for email and organization with a centralized getUserData function in LineGraphComponent, PieGraphComponent, PolarAreaGraphComponent, ProgressCard1, ProgressCard2, Dropped3dWidgets, ProductionCapacity, ReturnOfInvestment, StateWorking, Throughput, and various floating widgets.
- Improved code readability and maintainability by consolidating user data extraction logic.
- Ensured consistent user data handling across multiple components to reduce redundancy.
2025-06-13 11:41:28 +00:00
projectId ,
userId ,
} ;
2025-03-25 12:04:20 +00:00
Refactor user data retrieval across visualization components
- Replaced direct localStorage access for email and organization with a centralized getUserData function in LineGraphComponent, PieGraphComponent, PolarAreaGraphComponent, ProgressCard1, ProgressCard2, Dropped3dWidgets, ProductionCapacity, ReturnOfInvestment, StateWorking, Throughput, and various floating widgets.
- Improved code readability and maintainability by consolidating user data extraction logic.
- Ensured consistent user data handling across multiple components to reduce redundancy.
2025-06-13 11:41:28 +00:00
socket . emit ( "v1:Line:delete:layer" , data ) ;
2025-03-25 12:04:20 +00:00
Refactor user data retrieval across visualization components
- Replaced direct localStorage access for email and organization with a centralized getUserData function in LineGraphComponent, PieGraphComponent, PolarAreaGraphComponent, ProgressCard1, ProgressCard2, Dropped3dWidgets, ProductionCapacity, ReturnOfInvestment, StateWorking, Throughput, and various floating widgets.
- Improved code readability and maintainability by consolidating user data extraction logic.
- Ensured consistent user data handling across multiple components to reduce redundancy.
2025-06-13 11:41:28 +00:00
////////// Remove Points and lines from the removed layer //////////
2025-03-25 12:04:20 +00:00
Refactor user data retrieval across visualization components
- Replaced direct localStorage access for email and organization with a centralized getUserData function in LineGraphComponent, PieGraphComponent, PolarAreaGraphComponent, ProgressCard1, ProgressCard2, Dropped3dWidgets, ProductionCapacity, ReturnOfInvestment, StateWorking, Throughput, and various floating widgets.
- Improved code readability and maintainability by consolidating user data extraction logic.
- Ensured consistent user data handling across multiple components to reduce redundancy.
2025-06-13 11:41:28 +00:00
removedLines . forEach ( ( line ) = > {
line . forEach ( ( removedPoint ) = > {
RemoveConnectedLines (
removedPoint [ 1 ] ,
floorPlanGroupLine ,
floorPlanGroupPoint ,
setDeletedLines ,
lines
) ;
2025-03-25 12:04:20 +00:00
} ) ;
Refactor user data retrieval across visualization components
- Replaced direct localStorage access for email and organization with a centralized getUserData function in LineGraphComponent, PieGraphComponent, PolarAreaGraphComponent, ProgressCard1, ProgressCard2, Dropped3dWidgets, ProductionCapacity, ReturnOfInvestment, StateWorking, Throughput, and various floating widgets.
- Improved code readability and maintainability by consolidating user data extraction logic.
- Ensured consistent user data handling across multiple components to reduce redundancy.
2025-06-13 11:41:28 +00:00
} ) ;
2025-03-25 12:04:20 +00:00
Refactor user data retrieval across visualization components
- Replaced direct localStorage access for email and organization with a centralized getUserData function in LineGraphComponent, PieGraphComponent, PolarAreaGraphComponent, ProgressCard1, ProgressCard2, Dropped3dWidgets, ProductionCapacity, ReturnOfInvestment, StateWorking, Throughput, and various floating widgets.
- Improved code readability and maintainability by consolidating user data extraction logic.
- Ensured consistent user data handling across multiple components to reduce redundancy.
2025-06-13 11:41:28 +00:00
////////// Update the remaining lines layer values in the userData and in lines.current //////////
2025-03-25 12:04:20 +00:00
Refactor user data retrieval across visualization components
- Replaced direct localStorage access for email and organization with a centralized getUserData function in LineGraphComponent, PieGraphComponent, PolarAreaGraphComponent, ProgressCard1, ProgressCard2, Dropped3dWidgets, ProductionCapacity, ReturnOfInvestment, StateWorking, Throughput, and various floating widgets.
- Improved code readability and maintainability by consolidating user data extraction logic.
- Ensured consistent user data handling across multiple components to reduce redundancy.
2025-06-13 11:41:28 +00:00
let remaining = lines . current . filter ( ( line ) = > line [ 0 ] [ 2 ] !== removedLayer ) ;
let updatedLines : Types.Lines = [ ] ;
remaining . forEach ( ( line ) = > {
let newLines : Types.Line = [ . . . line ] ;
if ( newLines [ 0 ] [ 2 ] > removedLayer ) {
newLines [ 0 ] [ 2 ] -= 1 ;
newLines [ 1 ] [ 2 ] -= 1 ;
}
2025-03-25 12:04:20 +00:00
Refactor user data retrieval across visualization components
- Replaced direct localStorage access for email and organization with a centralized getUserData function in LineGraphComponent, PieGraphComponent, PolarAreaGraphComponent, ProgressCard1, ProgressCard2, Dropped3dWidgets, ProductionCapacity, ReturnOfInvestment, StateWorking, Throughput, and various floating widgets.
- Improved code readability and maintainability by consolidating user data extraction logic.
- Ensured consistent user data handling across multiple components to reduce redundancy.
2025-06-13 11:41:28 +00:00
const matchingLine = floorPlanGroupLine . current . children . find (
( l ) = >
l . userData . linePoints [ 0 ] [ 1 ] === line [ 0 ] [ 1 ] &&
l . userData . linePoints [ 1 ] [ 1 ] === line [ 1 ] [ 1 ]
2025-03-25 12:04:20 +00:00
) ;
Refactor user data retrieval across visualization components
- Replaced direct localStorage access for email and organization with a centralized getUserData function in LineGraphComponent, PieGraphComponent, PolarAreaGraphComponent, ProgressCard1, ProgressCard2, Dropped3dWidgets, ProductionCapacity, ReturnOfInvestment, StateWorking, Throughput, and various floating widgets.
- Improved code readability and maintainability by consolidating user data extraction logic.
- Ensured consistent user data handling across multiple components to reduce redundancy.
2025-06-13 11:41:28 +00:00
if ( matchingLine ) {
const updatedUserData = matchingLine . userData ;
updatedUserData . linePoints [ 0 ] [ 2 ] = newLines [ 0 ] [ 2 ] ;
updatedUserData . linePoints [ 1 ] [ 2 ] = newLines [ 1 ] [ 2 ] ;
2025-03-25 12:04:20 +00:00
}
Refactor user data retrieval across visualization components
- Replaced direct localStorage access for email and organization with a centralized getUserData function in LineGraphComponent, PieGraphComponent, PolarAreaGraphComponent, ProgressCard1, ProgressCard2, Dropped3dWidgets, ProductionCapacity, ReturnOfInvestment, StateWorking, Throughput, and various floating widgets.
- Improved code readability and maintainability by consolidating user data extraction logic.
- Ensured consistent user data handling across multiple components to reduce redundancy.
2025-06-13 11:41:28 +00:00
updatedLines . push ( newLines ) ;
} ) ;
lines . current = updatedLines ;
localStorage . setItem ( "Lines" , JSON . stringify ( lines . current ) ) ;
////////// Also remove OnlyFloorLines and update it in localstorage //////////
onlyFloorlines . current = onlyFloorlines . current . filter ( ( floor ) = > {
return floor [ 0 ] [ 0 ] [ 2 ] !== removedLayer ;
} ) ;
const meshToRemove : any = floorGroup . current ? . children . find (
( mesh ) = > mesh . name === ` Only_Floor_Line_ ${ removedLayer } `
) ;
if ( meshToRemove ) {
( < any > meshToRemove . material ) . dispose ( ) ;
( < any > meshToRemove . geometry ) . dispose ( ) ;
floorGroup . current ? . remove ( meshToRemove ) ;
}
echo . success ( "Layer Removed!" ) ;
setRemovedLayer ( null ) ;
2025-03-25 12:04:20 +00:00
}
export default DeleteLayer ;