feat: Implement wall asset management APIs and socket integration for create, update, and delete operations

This commit is contained in:
2025-07-02 10:49:07 +05:30
parent d6f6c4c901
commit 64d086f808
9 changed files with 257 additions and 21 deletions

View File

@@ -1,11 +1,16 @@
import { useThree } from '@react-three/fiber';
import { useEffect } from 'react'
import { useSelectedItem, useSocketStore, useToggleView } from '../../../store/builder/store';
import useModuleStore from '../../../store/useModuleStore';
import { useSelectedItem, useSocketStore, useToggleView } from '../../../store/builder/store';
import { MathUtils, Vector3 } from 'three';
import { useSceneContext } from '../../scene/sceneContext';
import { useParams } from 'react-router-dom';
import { useVersionContext } from '../version/versionContext';
import { getUserData } from '../../../functions/getUserData';
import closestPointOnLineSegment from '../line/helpers/getClosestPointOnLineSegment';
import { upsertWallAssetApi } from '../../../services/factoryBuilder/asset/wallAsset/upsertWallAssetApi';
function WallAssetCreator() {
const { socket } = useSocketStore();
const { pointer, camera, raycaster, scene, gl } = useThree();
@@ -14,6 +19,10 @@ function WallAssetCreator() {
const { wallAssetStore } = useSceneContext();
const { addWallAsset } = wallAssetStore();
const { selectedItem, setSelectedItem } = useSelectedItem();
const { selectedVersionStore } = useVersionContext();
const { selectedVersion } = selectedVersionStore();
const { userId, organization } = getUserData();
const { projectId } = useParams();
useEffect(() => {
const canvasElement = gl.domElement;
@@ -52,6 +61,25 @@ function WallAssetCreator() {
};
addWallAsset(newWallAsset);
if (projectId) {
// API
// upsertWallAssetApi(projectId, selectedVersion?.versionId || '', newWallAsset);
// SOCKET
const data = {
wallAssetData: newWallAsset,
projectId: projectId,
versionId: selectedVersion?.versionId || '',
userId: userId,
organization: organization
}
socket.emit('v1:wall-asset:add', data);
}
}
}
};