From 6aeef163d2359c060592d0096a6f2ed6c063bf3f Mon Sep 17 00:00:00 2001 From: Gomathi9520 Date: Mon, 25 Aug 2025 17:05:24 +0530 Subject: [PATCH] feat: implement resource management ID handling in Hrm and AssetManagement components --- .../resourceManagement/hrm/Hrm.tsx | 17 +++++++++--- .../hrm/assetManagement/AssetManagement.tsx | 26 ++++++++++++------- app/src/components/ui/list/List.tsx | 15 ++++++----- .../model/eventHandlers/useEventHandlers.ts | 19 +++++++++++--- app/src/store/builder/store.ts | 10 +++++++ 5 files changed, 62 insertions(+), 25 deletions(-) diff --git a/app/src/components/layout/sidebarRight/resourceManagement/hrm/Hrm.tsx b/app/src/components/layout/sidebarRight/resourceManagement/hrm/Hrm.tsx index 369c04f..99828ae 100644 --- a/app/src/components/layout/sidebarRight/resourceManagement/hrm/Hrm.tsx +++ b/app/src/components/layout/sidebarRight/resourceManagement/hrm/Hrm.tsx @@ -3,6 +3,8 @@ import { ClockThreeIcon, LocationPinIcon, TargetIcon } from '../../../../icons/E import { useSceneContext } from '../../../../../modules/scene/sceneContext'; import { useProductContext } from '../../../../../modules/simulation/products/productContext'; import RenameInput from '../../../../ui/inputs/RenameInput'; +import { useResourceManagementId } from '../../../../../store/builder/store'; +import { set } from 'immer/dist/internal'; // import NavigateCatagory from '../NavigateCatagory' const Hrm = () => { @@ -13,6 +15,7 @@ const Hrm = () => { const { products, getProductById } = productStore(); const { selectedProductStore } = useProductContext(); const { selectedProduct } = selectedProductStore(); + const { setResourceManagementId } = useResourceManagementId(); useEffect(() => { if (selectedProduct) { @@ -25,6 +28,7 @@ const Hrm = () => { employee: { image: "", name: worker.modelName, + modelId: worker.modelUuid, employee_id: `HR-${204 + index}`, status: "Active", }, @@ -54,7 +58,7 @@ const Hrm = () => { }, [selectedProduct, getProductById]); useEffect(() => { - // console.log("Workers data updated:", workers); + // }, [workers]); @@ -147,9 +151,14 @@ const Hrm = () => { // }, // ] function handleRenameWorker(newName: string) { - // console.log('newName: ', newName); + // } + function handleHumanClick(employee: any) { + if (employee.modelId) { + setResourceManagementId(employee.modelId); + } + } return ( @@ -173,14 +182,14 @@ const Hrm = () => {
-
+
{/*
{employee.employee.name}
*/}
{employee.employee.employee_id}
-
View more
+
{ handleHumanClick(employee.employee) }}>View in Scene
diff --git a/app/src/components/layout/sidebarRight/resourceManagement/hrm/assetManagement/AssetManagement.tsx b/app/src/components/layout/sidebarRight/resourceManagement/hrm/assetManagement/AssetManagement.tsx index 2cfe731..463afe1 100644 --- a/app/src/components/layout/sidebarRight/resourceManagement/hrm/assetManagement/AssetManagement.tsx +++ b/app/src/components/layout/sidebarRight/resourceManagement/hrm/assetManagement/AssetManagement.tsx @@ -5,6 +5,7 @@ import assetImage from "../../../../../../assets/image/asset-image.png" import { useSceneContext } from '../../../../../../modules/scene/sceneContext'; import { useProductContext } from '../../../../../../modules/simulation/products/productContext'; import RenameInput from '../../../../../ui/inputs/RenameInput'; +import { useResourceManagementId } from '../../../../../../store/builder/store'; const AssetManagement = () => { // const [selectedCategory, setSelectedCategory] = useState("All Assets"); const [expandedAssetId, setExpandedAssetId] = useState(null); @@ -14,6 +15,7 @@ const AssetManagement = () => { const { products, getProductById } = productStore(); const { selectedProductStore } = useProductContext(); const { selectedProduct } = selectedProductStore(); + const { setResourceManagementId } = useResourceManagementId(); @@ -26,7 +28,7 @@ const AssetManagement = () => { if (asset.type === "storageUnit" || asset.type === "human") return; if (!grouped[asset.modelName]) { grouped[asset.modelName] = { - id: asset.assetId, + id: asset.modelUuid, name: asset.modelName, model: asset.modelCode || "N/A", status: asset.status || "Online", @@ -47,7 +49,7 @@ const AssetManagement = () => { }, [selectedProduct]); function handleRenameAsset(newName: string) { - // console.log('newName: ', newName); + // // if (expandedAssetId) { // setAssets(prevAssets => // prevAssets.map(asset => @@ -62,6 +64,12 @@ const AssetManagement = () => { }, [assets]); + function handleAssetClick(id: string) { + + + setResourceManagementId(id); + } + // const dummyAssets = [ // { // id: '1', @@ -105,10 +113,10 @@ const AssetManagement = () => { return ( <> {/* */} + category={["All Assets", "Machines", "Workstation", "Vehicles"]} + selectedCategory={selectedCategory} + setSelectedCategory={setSelectedCategory} + /> */}
{assets.map((asset, index) => ( @@ -122,15 +130,13 @@ const AssetManagement = () => {
}
-
+
{/*
{asset.name}
*/} {asset.count !== 1 &&
x {asset.count}
} - -
{asset.model}
@@ -163,7 +169,7 @@ const AssetManagement = () => {
setExpandedAssetId(null)}> -
View in Scene
+
handleAssetClick(asset.id)}>View in Scene
diff --git a/app/src/components/ui/list/List.tsx b/app/src/components/ui/list/List.tsx index 6792fa4..8f38189 100644 --- a/app/src/components/ui/list/List.tsx +++ b/app/src/components/ui/list/List.tsx @@ -57,6 +57,7 @@ const List: React.FC = ({ items = [], remove }) => { const { zoneStore } = useSceneContext(); const { zones, setZoneName } = zoneStore(); + useEffect(() => { useSelectedZoneStore.getState().setSelectedZone({ zoneName: "", @@ -121,6 +122,7 @@ const List: React.FC = ({ items = [], remove }) => { } function handleAssetClick(asset: Asset) { + setZoneAssetId(asset); } @@ -157,8 +159,9 @@ const List: React.FC = ({ items = [], remove }) => { modelUuid: zoneAssetId.id, modelName: newName, projectId, + versionId: selectedVersion?.versionId || '' + }); - // console.log("response: ", response); setName(zoneAssetId.id, response.modelName); } @@ -255,9 +258,8 @@ const List: React.FC = ({ items = [], remove }) => { }} >