diff --git a/app/src/components/icons/SimulationIcons.tsx b/app/src/components/icons/SimulationIcons.tsx index 29b8de4..4d9657a 100644 --- a/app/src/components/icons/SimulationIcons.tsx +++ b/app/src/components/icons/SimulationIcons.tsx @@ -330,3 +330,59 @@ export function CartBagIcon() { ); } + +export function StorageCapacityIcon() { + return ( + + + + + + + + + + + + + + + + + + + ); +} diff --git a/app/src/components/layout/sidebarRight/properties/GlobalProperties.tsx b/app/src/components/layout/sidebarRight/properties/GlobalProperties.tsx index 514808a..8881953 100644 --- a/app/src/components/layout/sidebarRight/properties/GlobalProperties.tsx +++ b/app/src/components/layout/sidebarRight/properties/GlobalProperties.tsx @@ -243,12 +243,12 @@ const GlobalProperties: React.FC = () => { label="Wall Visibility" onClick={changeWallVisibility} /> - + /> */} void; - placePointValue: string; - placePointOnChange: (value: string) => void; + clearPoints: () => void; } const PickAndPlaceAction: React.FC = ({ - pickPointValue, - pickPointOnChange, - placePointValue, - placePointOnChange, + clearPoints, }) => { - return ( - <> - - - - ); + return ( +
+
+
Reset
+ +
+
+ ); }; export default PickAndPlaceAction; diff --git a/app/src/components/layout/sidebarRight/properties/eventProperties/actions/StorageAction.tsx b/app/src/components/layout/sidebarRight/properties/eventProperties/actions/StorageAction.tsx index 5c9bf86..5fd62df 100644 --- a/app/src/components/layout/sidebarRight/properties/eventProperties/actions/StorageAction.tsx +++ b/app/src/components/layout/sidebarRight/properties/eventProperties/actions/StorageAction.tsx @@ -1,27 +1,56 @@ import React from "react"; import InputWithDropDown from "../../../../../ui/inputs/InputWithDropDown"; +import LabledDropdown from "../../../../../ui/inputs/LabledDropdown"; interface StorageActionProps { + type: "store" | "spawn" | "default"; value: string; min: number; - max: number; + max?: number; defaultValue: string; - onChange: (value: string) => void; + currentMaterialType: string; + handleCapacityChange: (value: string) => void; + handleMaterialTypeChange: (value: string) => void; } -const StorageAction: React.FC = ({ value, min, max, defaultValue, onChange }) => { +const StorageAction: React.FC = ({ type, value, min, max, defaultValue, currentMaterialType, handleCapacityChange, handleMaterialTypeChange }) => { return ( - { }} - onChange={onChange} - /> + <> + {type === 'store' && + { }} + onChange={handleCapacityChange} + /> + } + {type === 'spawn' && + <> + { }} + onChange={handleCapacityChange} + /> + + + } + ); }; diff --git a/app/src/components/layout/sidebarRight/properties/eventProperties/actions/TravelAction.tsx b/app/src/components/layout/sidebarRight/properties/eventProperties/actions/TravelAction.tsx index 49eb683..e53cdc7 100644 --- a/app/src/components/layout/sidebarRight/properties/eventProperties/actions/TravelAction.tsx +++ b/app/src/components/layout/sidebarRight/properties/eventProperties/actions/TravelAction.tsx @@ -3,76 +3,92 @@ import InputWithDropDown from "../../../../../ui/inputs/InputWithDropDown"; import EyeDropInput from "../../../../../ui/inputs/EyeDropInput"; interface TravelActionProps { - loadCapacity: { - value: string; - min: number; - max: number; - defaultValue: string; - onChange: (value: string) => void; - }; - unloadDuration: { - value: string; - min: number; - max: number; - defaultValue: string; - onChange: (value: string) => void; - }; - pickPoint?: { - value: string; - onChange: (value: string) => void; - }; - unloadPoint?: { - value: string; - onChange: (value: string) => void; - }; + loadCapacity: { + value: string; + min: number; + max: number; + defaultValue: string; + onChange: (value: string) => void; + }; + unloadDuration: { + value: string; + min: number; + max: number; + defaultValue: string; + onChange: (value: string) => void; + }; + pickPoint?: { + value: string; + onChange: (value: string) => void; + }; + unloadPoint?: { + value: string; + onChange: (value: string) => void; + }; + clearPoints: () => void; } const TravelAction: React.FC = ({ - loadCapacity, - unloadDuration, - pickPoint, - unloadPoint, + loadCapacity, + unloadDuration, + pickPoint, + unloadPoint, + clearPoints, }) => { - return ( - <> - { }} - onChange={loadCapacity.onChange} - /> - { }} - onChange={unloadDuration.onChange} - /> - {pickPoint && ( - - )} - {unloadPoint && ( - - )} - - ); + return ( + <> + {}} + onChange={loadCapacity.onChange} + /> + {}} + onChange={unloadDuration.onChange} + /> +
+
+
Reset
+ +
+
+ {pickPoint && ( + + )} + {unloadPoint && ( + + )} + + ); }; export default TravelAction; diff --git a/app/src/components/layout/sidebarRight/properties/eventProperties/mechanics/conveyorMechanics.tsx b/app/src/components/layout/sidebarRight/properties/eventProperties/mechanics/conveyorMechanics.tsx index 046eefa..027dc0b 100644 --- a/app/src/components/layout/sidebarRight/properties/eventProperties/mechanics/conveyorMechanics.tsx +++ b/app/src/components/layout/sidebarRight/properties/eventProperties/mechanics/conveyorMechanics.tsx @@ -8,7 +8,7 @@ import SwapAction from "../actions/SwapAction"; import SpawnAction from "../actions/SpawnAction"; import DefaultAction from "../actions/DefaultAction"; import Trigger from "../trigger/Trigger"; -import { useSelectedEventData, useSelectedProduct } from "../../../../../../store/simulation/useSimulationStore"; +import { useSelectedAction, useSelectedEventData, useSelectedProduct } from "../../../../../../store/simulation/useSimulationStore"; import { useProductStore } from "../../../../../../store/simulation/useProductStore"; import ActionsList from "../components/ActionsList"; import { upsertProductOrEventApi } from "../../../../../../services/simulation/UpsertProductOrEventApi"; @@ -19,6 +19,7 @@ function ConveyorMechanics() { const { selectedEventData } = useSelectedEventData(); const { getPointByUuid, getEventByModelUuid, updateEvent, updateAction } = useProductStore(); const { selectedProduct } = useSelectedProduct(); + const { setSelectedAction, clearSelectedAction } = useSelectedAction(); const email = localStorage.getItem('email') const organization = (email!.split("@")[1]).split(".")[0]; @@ -33,9 +34,12 @@ function ConveyorMechanics() { if (point && "action" in point) { setSelectedPointData(point); setActiveOption(point.action.actionType as | "default" | "spawn" | "swap" | "delay" | "despawn"); + setSelectedAction(point.action.actionUuid, point.action.actionName); } + } else { + clearSelectedAction(); } - }, [selectedProduct, selectedEventData, getPointByUuid]); + }, [selectedProduct, selectedEventData]); const updateBackend = ( productName: string, diff --git a/app/src/components/layout/sidebarRight/properties/eventProperties/mechanics/machineMechanics.tsx b/app/src/components/layout/sidebarRight/properties/eventProperties/mechanics/machineMechanics.tsx index 0b5b63b..8437612 100644 --- a/app/src/components/layout/sidebarRight/properties/eventProperties/mechanics/machineMechanics.tsx +++ b/app/src/components/layout/sidebarRight/properties/eventProperties/mechanics/machineMechanics.tsx @@ -2,7 +2,7 @@ import { useEffect, useState } from "react"; import RenameInput from "../../../../../ui/inputs/RenameInput"; import LabledDropdown from "../../../../../ui/inputs/LabledDropdown"; import Trigger from "../trigger/Trigger"; -import { useSelectedEventData, useSelectedProduct } from "../../../../../../store/simulation/useSimulationStore"; +import { useSelectedAction, useSelectedEventData, useSelectedProduct } from "../../../../../../store/simulation/useSimulationStore"; import { useProductStore } from "../../../../../../store/simulation/useProductStore"; import ProcessAction from "../actions/ProcessAction"; import ActionsList from "../components/ActionsList"; @@ -14,6 +14,7 @@ function MachineMechanics() { const { selectedEventData } = useSelectedEventData(); const { getPointByUuid, updateAction } = useProductStore(); const { selectedProduct } = useSelectedProduct(); + const { setSelectedAction, clearSelectedAction } = useSelectedAction(); const email = localStorage.getItem('email') const organization = (email!.split("@")[1]).split(".")[0]; @@ -28,9 +29,12 @@ function MachineMechanics() { if (point && "action" in point) { setSelectedPointData(point); setActiveOption(point.action.actionType as "process"); + setSelectedAction(point.action.actionUuid, point.action.actionName); } + } else { + clearSelectedAction(); } - }, [selectedProduct, selectedEventData, getPointByUuid]); + }, [selectedProduct, selectedEventData]); const updateBackend = ( productName: string, @@ -68,6 +72,15 @@ function MachineMechanics() { const handleRenameAction = (newName: string) => { if (!selectedPointData) return; const event = updateAction(selectedProduct.productId, selectedPointData.action.actionUuid, { actionName: newName }); + + if (event) { + updateBackend( + selectedProduct.productName, + selectedProduct.productId, + organization, + event + ); + } }; const handleProcessTimeChange = (value: string) => { @@ -75,6 +88,15 @@ function MachineMechanics() { const event = updateAction(selectedProduct.productId, selectedPointData.action.actionUuid, { processTime: parseFloat(value), }); + + if (event) { + updateBackend( + selectedProduct.productName, + selectedProduct.productId, + organization, + event + ); + } }; const handleMaterialSelect = (material: string) => { @@ -82,6 +104,15 @@ function MachineMechanics() { const event = updateAction(selectedProduct.productId, selectedPointData.action.actionUuid, { swapMaterial: material, }); + + if (event) { + updateBackend( + selectedProduct.productName, + selectedProduct.productId, + organization, + event + ); + } }; // Get current values from store @@ -137,7 +168,7 @@ function MachineMechanics() {
- +
)} diff --git a/app/src/components/layout/sidebarRight/properties/eventProperties/mechanics/roboticArmMechanics.tsx b/app/src/components/layout/sidebarRight/properties/eventProperties/mechanics/roboticArmMechanics.tsx index 3ecbc9d..2295161 100644 --- a/app/src/components/layout/sidebarRight/properties/eventProperties/mechanics/roboticArmMechanics.tsx +++ b/app/src/components/layout/sidebarRight/properties/eventProperties/mechanics/roboticArmMechanics.tsx @@ -4,286 +4,304 @@ import InputWithDropDown from "../../../../../ui/inputs/InputWithDropDown"; import RenameInput from "../../../../../ui/inputs/RenameInput"; import LabledDropdown from "../../../../../ui/inputs/LabledDropdown"; import Trigger from "../trigger/Trigger"; -import { useSelectedEventData, useSelectedProduct, useSelectedAction } from "../../../../../../store/simulation/useSimulationStore"; +import { + useSelectedEventData, + useSelectedProduct, + useSelectedAction, +} from "../../../../../../store/simulation/useSimulationStore"; import { useProductStore } from "../../../../../../store/simulation/useProductStore"; import PickAndPlaceAction from "../actions/PickAndPlaceAction"; import ActionsList from "../components/ActionsList"; import { upsertProductOrEventApi } from "../../../../../../services/simulation/UpsertProductOrEventApi"; function RoboticArmMechanics() { - const [activeOption, setActiveOption] = useState<"default" | "pickAndPlace">("default"); - const [selectedPointData, setSelectedPointData] = useState(); - const { selectedEventData } = useSelectedEventData(); - const { getPointByUuid, getEventByModelUuid, getActionByUuid, updateEvent, updateAction, addAction, removeAction } = useProductStore(); - const { selectedProduct } = useSelectedProduct(); - const { selectedAction, setSelectedAction, clearSelectedAction } = useSelectedAction(); + const [activeOption, setActiveOption] = useState<"default" | "pickAndPlace">( + "default" + ); + const [selectedPointData, setSelectedPointData] = useState< + RoboticArmPointSchema | undefined + >(); + const { selectedEventData } = useSelectedEventData(); + const { + getPointByUuid, + getEventByModelUuid, + updateEvent, + updateAction, + addAction, + removeAction, + } = useProductStore(); + const { selectedProduct } = useSelectedProduct(); + const { selectedAction, setSelectedAction, clearSelectedAction } = + useSelectedAction(); - const email = localStorage.getItem('email') - const organization = (email!.split("@")[1]).split(".")[0]; + const email = localStorage.getItem("email"); + const organization = email!.split("@")[1].split(".")[0]; - useEffect(() => { - if (selectedEventData) { - const point = getPointByUuid( - selectedProduct.productId, - selectedEventData.data.modelUuid, - selectedEventData.selectedPoint - ) as RoboticArmPointSchema | undefined; - if (point?.actions) { - setSelectedPointData(point); - if (point.actions.length > 0) { - setActiveOption(point.actions[0].actionType as "default" | "pickAndPlace"); - setSelectedAction(point.actions[0].actionUuid, point.actions[0].actionName); - } - } - } else { - clearSelectedAction(); + useEffect(() => { + if (selectedEventData) { + const point = getPointByUuid( + selectedProduct.productId, + selectedEventData.data.modelUuid, + selectedEventData.selectedPoint + ) as RoboticArmPointSchema | undefined; + if (point?.actions) { + setSelectedPointData(point); + if (point.actions.length > 0) { + setActiveOption( + point.actions[0].actionType as "default" | "pickAndPlace" + ); + setSelectedAction( + point.actions[0].actionUuid, + point.actions[0].actionName + ); } - }, [selectedEventData, selectedProduct]); + } + } else { + clearSelectedAction(); + } + }, [selectedEventData, selectedProduct]); - const updateBackend = ( - productName: string, - productId: string, - organization: string, - eventData: EventsSchema - ) => { - upsertProductOrEventApi({ - productName: productName, - productId: productId, - organization: organization, - eventDatas: eventData - }) + const updateBackend = ( + productName: string, + productId: string, + organization: string, + eventData: EventsSchema + ) => { + upsertProductOrEventApi({ + productName: productName, + productId: productId, + organization: organization, + eventDatas: eventData, + }); + }; + + const handleRenameAction = (newName: string) => { + if (!selectedAction.actionId) return; + const event = updateAction( + selectedProduct.productId, + selectedAction.actionId, + { actionName: newName } + ); + + if (selectedPointData) { + const updatedActions = selectedPointData.actions.map((action) => + action.actionUuid === selectedAction.actionId + ? { ...action, actionName: newName } + : action + ); + setSelectedPointData({ + ...selectedPointData, + actions: updatedActions, + }); } - const handleRenameAction = (newName: string) => { - if (!selectedAction.actionId) return; - const event = updateAction(selectedProduct.productId, selectedAction.actionId, { actionName: newName }); + if (event) { + updateBackend( + selectedProduct.productName, + selectedProduct.productId, + organization, + event + ); + } + }; - if (selectedPointData) { - const updatedActions = selectedPointData.actions.map((action) => - action.actionUuid === selectedAction.actionId ? { ...action, actionName: newName } : action - ); - setSelectedPointData({ - ...selectedPointData, - actions: updatedActions, - }); - } - - if (event) { - updateBackend( - selectedProduct.productName, - selectedProduct.productId, - organization, - event - ); - } - }; - - const handleSpeedChange = (value: string) => { - if (!selectedEventData) return; - const event = updateEvent(selectedProduct.productId, selectedEventData.data.modelUuid, { - speed: parseFloat(value), - }); - - if (event) { - updateBackend( - selectedProduct.productName, - selectedProduct.productId, - organization, - event - ); - } - }; - - const handlePickPointChange = (value: string) => { - if (!selectedAction.actionId || !selectedPointData) return; - const [x, y, z] = value.split(",").map(Number); - - const event = updateAction(selectedProduct.productId, selectedAction.actionId, { - process: { - startPoint: [x, y, z] as [number, number, number], - endPoint: selectedPointData.actions.find((a) => a.actionUuid === selectedAction.actionId)?.process.endPoint || null, - }, - }); - - if (event) { - updateBackend( - selectedProduct.productName, - selectedProduct.productId, - organization, - event - ); - } - }; - - const handlePlacePointChange = (value: string) => { - if (!selectedAction.actionId || !selectedPointData) return; - const [x, y, z] = value.split(",").map(Number); - - const event = updateAction(selectedProduct.productId, selectedAction.actionId, { - process: { - startPoint: selectedPointData.actions.find((a) => a.actionUuid === selectedAction.actionId)?.process.startPoint || null, - endPoint: [x, y, z] as [number, number, number], - }, - }); - - if (event) { - updateBackend( - selectedProduct.productName, - selectedProduct.productId, - organization, - event - ); - } - }; - - - const handleAddAction = () => { - if (!selectedEventData || !selectedPointData) return; - - const newAction = { - actionUuid: MathUtils.generateUUID(), - actionName: `Action ${selectedPointData.actions.length + 1}`, - actionType: "pickAndPlace" as const, - process: { - startPoint: null, - endPoint: null, - }, - triggers: [] as TriggerSchema[], - }; - - const event = addAction( - selectedProduct.productId, - selectedEventData.data.modelUuid, - selectedEventData.selectedPoint, - newAction - ); - - if (event) { - updateBackend( - selectedProduct.productName, - selectedProduct.productId, - organization, - event - ); - } - - const updatedPoint = { - ...selectedPointData, - actions: [...selectedPointData.actions, newAction], - }; - setSelectedPointData(updatedPoint); - setSelectedAction(newAction.actionUuid, newAction.actionName); - }; - - const handleDeleteAction = (actionUuid: string) => { - if (!selectedPointData) return; - - const event = removeAction(selectedProduct.productId, actionUuid); - - if (event) { - updateBackend( - selectedProduct.productName, - selectedProduct.productId, - organization, - event - ); - } - - const index = selectedPointData.actions.findIndex(a => a.actionUuid === actionUuid); - const newActions = selectedPointData.actions.filter(a => a.actionUuid !== actionUuid); - - const updatedPoint = { - ...selectedPointData, - actions: newActions, - }; - setSelectedPointData(updatedPoint); - - if (selectedAction.actionId === actionUuid) { - const nextAction = newActions[index] || newActions[index - 1]; - if (nextAction) { - setSelectedAction(nextAction.actionUuid, nextAction.actionName); - } else { - clearSelectedAction(); - } - } - }; - - const availableActions = { - defaultOption: "pickAndPlace", - options: ["pickAndPlace"], - }; - - const currentSpeed = (getEventByModelUuid( - selectedProduct.productId, selectedEventData?.data.modelUuid || "" - ) as RoboticArmEventSchema | undefined)?.speed?.toString() || "0.5"; - - const currentAction = selectedPointData?.actions.find((a) => a.actionUuid === selectedAction.actionId); - - const currentPickPoint = currentAction?.process.startPoint - ? `${currentAction.process.startPoint[0]},${currentAction.process.startPoint[1]},${currentAction.process.startPoint[2]}` - : ""; - const currentPlacePoint = currentAction?.process.endPoint - ? `${currentAction.process.endPoint[0]},${currentAction.process.endPoint[1]},${currentAction.process.endPoint[2]}` - : ""; - - return ( - <> -
-
-
- { }} - onChange={handleSpeedChange} - /> -
-
-
-
- - - - {selectedAction.actionId && currentAction && ( -
-
- -
-
- { }} - disabled={true} - /> - -
-
- -
-
- )} -
- + const handleSpeedChange = (value: string) => { + if (!selectedEventData) return; + const event = updateEvent( + selectedProduct.productId, + selectedEventData.data.modelUuid, + { + speed: parseFloat(value), + } ); + + if (event) { + updateBackend( + selectedProduct.productName, + selectedProduct.productId, + organization, + event + ); + } + }; + const handleClearPoints = () => { + if (!selectedAction.actionId || !selectedPointData) return; + + const event = updateAction( + selectedProduct.productId, + selectedAction.actionId, + { + process: { + startPoint: null, + endPoint: null, + }, + } + ); + + if (event) { + updateBackend( + selectedProduct.productName, + selectedProduct.productId, + organization, + event + ); + } + }; + + const handleAddAction = () => { + if (!selectedEventData || !selectedPointData) return; + + const newAction = { + actionUuid: MathUtils.generateUUID(), + actionName: `Action ${selectedPointData.actions.length + 1}`, + actionType: "pickAndPlace" as const, + process: { + startPoint: null, + endPoint: null, + }, + triggers: [] as TriggerSchema[], + }; + + const event = addAction( + selectedProduct.productId, + selectedEventData.data.modelUuid, + selectedEventData.selectedPoint, + newAction + ); + + if (event) { + updateBackend( + selectedProduct.productName, + selectedProduct.productId, + organization, + event + ); + } + + const updatedPoint = { + ...selectedPointData, + actions: [...selectedPointData.actions, newAction], + }; + setSelectedPointData(updatedPoint); + setSelectedAction(newAction.actionUuid, newAction.actionName); + }; + + const handleDeleteAction = (actionUuid: string) => { + if (!selectedPointData) return; + + const event = removeAction(selectedProduct.productId, actionUuid); + + if (event) { + updateBackend( + selectedProduct.productName, + selectedProduct.productId, + organization, + event + ); + } + + const index = selectedPointData.actions.findIndex( + (a) => a.actionUuid === actionUuid + ); + const newActions = selectedPointData.actions.filter( + (a) => a.actionUuid !== actionUuid + ); + + const updatedPoint = { + ...selectedPointData, + actions: newActions, + }; + setSelectedPointData(updatedPoint); + + if (selectedAction.actionId === actionUuid) { + const nextAction = newActions[index] || newActions[index - 1]; + if (nextAction) { + setSelectedAction(nextAction.actionUuid, nextAction.actionName); + } else { + clearSelectedAction(); + } + } + }; + + const availableActions = { + defaultOption: "pickAndPlace", + options: ["pickAndPlace"], + }; + + const currentSpeed = + ( + getEventByModelUuid( + selectedProduct.productId, + selectedEventData?.data.modelUuid || "" + ) as RoboticArmEventSchema | undefined + )?.speed?.toString() || "0.5"; + + const currentAction = selectedPointData?.actions.find( + (a) => a.actionUuid === selectedAction.actionId + ); + + const currentPickPoint = currentAction?.process.startPoint + ? `${currentAction.process.startPoint[0]},${currentAction.process.startPoint[1]},${currentAction.process.startPoint[2]}` + : ""; + const currentPlacePoint = currentAction?.process.endPoint + ? `${currentAction.process.endPoint[0]},${currentAction.process.endPoint[1]},${currentAction.process.endPoint[2]}` + : ""; + + return ( + <> +
+
+
+ {}} + onChange={handleSpeedChange} + /> +
+
+
+
+ + + {selectedAction.actionId && currentAction && ( +
+
+ +
+
+ {}} + disabled={true} + /> + +
+
+ +
+
+ )} +
+ + ); } export default RoboticArmMechanics; diff --git a/app/src/components/layout/sidebarRight/properties/eventProperties/mechanics/storageMechanics.tsx b/app/src/components/layout/sidebarRight/properties/eventProperties/mechanics/storageMechanics.tsx index 34e35ae..564a53f 100644 --- a/app/src/components/layout/sidebarRight/properties/eventProperties/mechanics/storageMechanics.tsx +++ b/app/src/components/layout/sidebarRight/properties/eventProperties/mechanics/storageMechanics.tsx @@ -1,12 +1,14 @@ -import { useEffect, useState } from "react"; +import { useEffect, useMemo, useState } from "react"; import RenameInput from "../../../../../ui/inputs/RenameInput"; import LabledDropdown from "../../../../../ui/inputs/LabledDropdown"; import Trigger from "../trigger/Trigger"; -import { useSelectedEventData, useSelectedProduct } from "../../../../../../store/simulation/useSimulationStore"; -import { useProductStore } from "../../../../../../store/simulation/useProductStore"; import StorageAction from "../actions/StorageAction"; import ActionsList from "../components/ActionsList"; import { upsertProductOrEventApi } from "../../../../../../services/simulation/UpsertProductOrEventApi"; +import { useProductStore } from "../../../../../../store/simulation/useProductStore"; +import { useStorageUnitStore } from "../../../../../../store/simulation/useStorageUnitStore"; +import { useSelectedAction, useSelectedEventData, useSelectedProduct } from "../../../../../../store/simulation/useSimulationStore"; +import * as THREE from 'three'; function StorageMechanics() { const [activeOption, setActiveOption] = useState<"default" | "store" | "spawn">("default"); @@ -14,10 +16,28 @@ function StorageMechanics() { const { selectedEventData } = useSelectedEventData(); const { getPointByUuid, updateAction } = useProductStore(); const { selectedProduct } = useSelectedProduct(); + const { setSelectedAction, clearSelectedAction } = useSelectedAction(); + const { setCurrentMaterials, clearCurrentMaterials, updateCurrentLoad, getStorageUnitById } = useStorageUnitStore(); const email = localStorage.getItem('email') const organization = (email!.split("@")[1]).split(".")[0]; + const updateSelectedPointData = () => { + if (selectedEventData && selectedProduct) { + const point = getPointByUuid( + selectedProduct.productId, + selectedEventData?.data.modelUuid, + selectedEventData?.selectedPoint + ) as StoragePointSchema | undefined; + if (point && "action" in point) { + setSelectedPointData(point); + const uiOption = point.action.actionType === "retrieve" ? "spawn" : point.action.actionType; + setActiveOption(uiOption as "store" | "spawn"); + setSelectedAction(point.action.actionUuid, point.action.actionName); + } + } + }; + useEffect(() => { if (selectedEventData) { const point = getPointByUuid( @@ -27,10 +47,14 @@ function StorageMechanics() { ) as StoragePointSchema | undefined; if (point && "action" in point) { setSelectedPointData(point); - setActiveOption(point.action.actionType as "store" | "spawn"); + const uiOption = point.action.actionType === "retrieve" ? "spawn" : point.action.actionType; + setActiveOption(uiOption as "store" | "spawn"); + setSelectedAction(point.action.actionUuid, point.action.actionName); } + } else { + clearSelectedAction(); } - }, [selectedProduct, selectedEventData, getPointByUuid]); + }, [selectedProduct, selectedEventData]); const updateBackend = ( productName: string, @@ -48,11 +72,12 @@ function StorageMechanics() { const handleActionTypeChange = (option: string) => { if (!selectedEventData || !selectedPointData) return; - const validOption = option as "store" | "spawn"; - setActiveOption(validOption); + const internalOption = actionTypeMap[option as keyof typeof actionTypeMap] as "store" | "retrieve"; + + setActiveOption(option as "store" | "spawn"); const event = updateAction(selectedProduct.productId, selectedPointData.action.actionUuid, { - actionType: validOption, + actionType: internalOption, }); if (event) { @@ -62,6 +87,23 @@ function StorageMechanics() { organization, event ); + updateSelectedPointData(); + } + + if (option === "spawn") { + const storageUnit = getStorageUnitById(selectedEventData.data.modelUuid); + if (storageUnit) { + const materialType = selectedPointData.action.materialType || "Default material"; + const materials = Array.from({ length: selectedPointData.action.storageCapacity }, () => + createNewMaterial(materialType) + ).filter(Boolean) as { materialType: string; materialId: string }[]; + + setCurrentMaterials(selectedEventData.data.modelUuid, materials); + updateCurrentLoad(selectedEventData.data.modelUuid, selectedPointData.action.storageCapacity); + } + } else { + clearCurrentMaterials(selectedEventData.data.modelUuid); + updateCurrentLoad(selectedEventData.data.modelUuid, 0); } }; @@ -76,13 +118,16 @@ function StorageMechanics() { organization, event ); + updateSelectedPointData(); } }; const handleCapacityChange = (value: string) => { - if (!selectedPointData) return; + if (!selectedEventData || !selectedPointData) return; + const newCapacity = parseInt(value); + const event = updateAction(selectedProduct.productId, selectedPointData.action.actionUuid, { - storageCapacity: parseInt(value), + storageCapacity: newCapacity, }); if (event) { @@ -92,23 +137,88 @@ function StorageMechanics() { organization, event ); + updateSelectedPointData(); + + if (activeOption === "spawn") { + const storageUnit = getStorageUnitById(selectedEventData.data.modelUuid); + if (storageUnit) { + const materialType = selectedPointData.action.materialType || "Default material"; + const materials = Array.from({ length: selectedPointData.action.storageCapacity }, () => + createNewMaterial(materialType) + ).filter(Boolean) as { materialType: string; materialId: string }[]; + + setCurrentMaterials(selectedEventData.data.modelUuid, materials); + updateCurrentLoad(selectedEventData.data.modelUuid, selectedPointData.action.storageCapacity); + } + } else { + updateCurrentLoad(selectedEventData.data.modelUuid, 0); + } } }; - // Get current values from store - const currentActionName = selectedPointData - ? selectedPointData.action.actionName - : "Action Name"; + const createNewMaterial = (materialType: string): { materialType: string; materialId: string } | null => { + if (!selectedEventData || !selectedPointData) return null; + const materialId = THREE.MathUtils.generateUUID(); + return { + materialType, + materialId + }; + }; - const currentCapacity = selectedPointData - ? selectedPointData.action.storageCapacity.toString() - : "0"; + const handleMaterialTypeChange = (value: string) => { + if (!selectedEventData || !selectedPointData) return; + + const event = updateAction(selectedProduct.productId, selectedPointData.action.actionUuid, { + materialType: value, + }); + + if (event) { + updateBackend( + selectedProduct.productName, + selectedProduct.productId, + organization, + event + ); + updateSelectedPointData(); + + if (activeOption === "spawn") { + const storageUnit = getStorageUnitById(selectedEventData.data.modelUuid); + if (storageUnit) { + const materials = Array.from({ length: storageUnit.currentMaterials.length }, () => + createNewMaterial(value) + ).filter(Boolean) as { materialType: string; materialId: string }[]; + + setCurrentMaterials(selectedEventData.data.modelUuid, materials); + } + } + } + }; + + const currentActionName = useMemo(() => + selectedPointData ? selectedPointData.action.actionName : "Action Name", + [selectedPointData] + ); + + const currentCapacity = useMemo(() => + selectedPointData ? selectedPointData.action.storageCapacity.toString() : "0", + [selectedPointData] + ); + + const currentMaterialType = useMemo(() => + selectedPointData?.action.materialType || "Default material", + [selectedPointData] + ); const availableActions = { defaultOption: "store", options: ["store", "spawn"], }; + const actionTypeMap = { + spawn: "retrieve", + store: "store" + }; + return ( <> {selectedEventData && ( @@ -129,24 +239,19 @@ function StorageMechanics() { options={availableActions.options} onSelect={handleActionTypeChange} /> - {activeOption === "store" && ( - - )} - {activeOption === "spawn" && ( -
-

Spawn configuration options would go here

-
- )} +
- +
)} @@ -154,4 +259,4 @@ function StorageMechanics() { ); } -export default StorageMechanics; +export default StorageMechanics; \ No newline at end of file diff --git a/app/src/components/layout/sidebarRight/properties/eventProperties/mechanics/vehicleMechanics.tsx b/app/src/components/layout/sidebarRight/properties/eventProperties/mechanics/vehicleMechanics.tsx index 0f52437..baa7541 100644 --- a/app/src/components/layout/sidebarRight/properties/eventProperties/mechanics/vehicleMechanics.tsx +++ b/app/src/components/layout/sidebarRight/properties/eventProperties/mechanics/vehicleMechanics.tsx @@ -4,244 +4,319 @@ import RenameInput from "../../../../../ui/inputs/RenameInput"; import LabledDropdown from "../../../../../ui/inputs/LabledDropdown"; import Trigger from "../trigger/Trigger"; import { - useSelectedEventData, - useSelectedProduct, + useSelectedAction, + useSelectedEventData, + useSelectedEventSphere, + useSelectedProduct, } from "../../../../../../store/simulation/useSimulationStore"; import { useProductStore } from "../../../../../../store/simulation/useProductStore"; import TravelAction from "../actions/TravelAction"; import ActionsList from "../components/ActionsList"; import { upsertProductOrEventApi } from "../../../../../../services/simulation/UpsertProductOrEventApi"; +import { useVehicleStore } from "../../../../../../store/simulation/useVehicleStore"; function VehicleMechanics() { - const [activeOption, setActiveOption] = useState<"default" | "travel">("default"); - const [selectedPointData, setSelectedPointData] = useState(); - const { selectedEventData } = useSelectedEventData(); - const { getPointByUuid, getEventByModelUuid, updateEvent, updateAction } = useProductStore(); - const { selectedProduct } = useSelectedProduct(); + const [activeOption, setActiveOption] = useState<"default" | "travel">( + "default" + ); + const [selectedPointData, setSelectedPointData] = useState< + VehiclePointSchema | undefined + >(); + const { selectedEventData } = useSelectedEventData(); + const { getPointByUuid, getEventByModelUuid, updateEvent, updateAction } = + useProductStore(); + const { selectedProduct } = useSelectedProduct(); + const { setSelectedAction, clearSelectedAction } = useSelectedAction(); + const { getVehicleById } = useVehicleStore(); - const email = localStorage.getItem('email') - const organization = (email!.split("@")[1]).split(".")[0]; + const email = localStorage.getItem("email"); + const organization = email!.split("@")[1].split(".")[0]; - useEffect(() => { - if (selectedEventData && selectedEventData.data.type === 'vehicle') { - const point = getPointByUuid( - selectedProduct.productId, - selectedEventData.data.modelUuid, - selectedEventData.selectedPoint - ) as VehiclePointSchema | undefined; + useEffect(() => { + if (selectedEventData && selectedEventData.data.type === "vehicle") { + const point = getPointByUuid( + selectedProduct.productId, + selectedEventData.data.modelUuid, + selectedEventData.selectedPoint + ) as VehiclePointSchema | undefined; - if (point) { - setSelectedPointData(point); - setActiveOption(point.action.actionType as "travel"); - } - } - }, [selectedProduct, selectedEventData, getPointByUuid]); - - const updateBackend = ( - productName: string, - productId: string, - organization: string, - eventData: EventsSchema - ) => { - upsertProductOrEventApi({ - productName: productName, - productId: productId, - organization: organization, - eventDatas: eventData - }) + if (point) { + setSelectedPointData(point); + setActiveOption(point.action.actionType as "travel"); + setSelectedAction(point.action.actionUuid, point.action.actionName); + } + } else { + clearSelectedAction(); } + }, [selectedProduct, selectedEventData]); - const handleSpeedChange = (value: string) => { - if (!selectedEventData) return; - const event = updateEvent(selectedProduct.productId, selectedEventData.data.modelUuid, { - speed: parseFloat(value), - }); + const updateBackend = ( + productName: string, + productId: string, + organization: string, + eventData: EventsSchema + ) => { + upsertProductOrEventApi({ + productName: productName, + productId: productId, + organization: organization, + eventDatas: eventData, + }); + }; - if (event) { - updateBackend( - selectedProduct.productName, - selectedProduct.productId, - organization, - event - ); - } - }; - - const handleActionTypeChange = (option: string) => { - if (!selectedEventData || !selectedPointData) return; - const validOption = option as "travel"; - setActiveOption(validOption); - - const event = updateAction(selectedProduct.productId, selectedPointData.action.actionUuid, { - actionType: validOption, - }); - - if (event) { - updateBackend( - selectedProduct.productName, - selectedProduct.productId, - organization, - event - ); - } - }; - - const handleRenameAction = (newName: string) => { - if (!selectedPointData) return; - const event = updateAction(selectedProduct.productId, selectedPointData.action.actionUuid, { actionName: newName }); - - if (event) { - updateBackend( - selectedProduct.productName, - selectedProduct.productId, - organization, - event - ); - } - }; - - const handleLoadCapacityChange = (value: string) => { - if (!selectedPointData) return; - const event = updateAction(selectedProduct.productId, selectedPointData.action.actionUuid, { - loadCapacity: parseFloat(value), - }); - - if (event) { - updateBackend( - selectedProduct.productName, - selectedProduct.productId, - organization, - event - ); - } - }; - - const handleUnloadDurationChange = (value: string) => { - if (!selectedPointData) return; - const event = updateAction(selectedProduct.productId, selectedPointData.action.actionUuid, { - unLoadDuration: parseFloat(value), - }); - - if (event) { - updateBackend( - selectedProduct.productName, - selectedProduct.productId, - organization, - event - ); - } - }; - - const handlePickPointChange = (value: string) => { - if (!selectedPointData) return; - }; - - const handleUnloadPointChange = (value: string) => { - if (!selectedPointData) return; - }; - - // Get current values from store - - const currentSpeed = (getEventByModelUuid( - selectedProduct.productId, selectedEventData?.data.modelUuid || "" - ) as VehicleEventSchema | undefined)?.speed?.toString() || "0.5"; - - const currentActionName = selectedPointData - ? selectedPointData.action.actionName - : "Action Name"; - - const currentLoadCapacity = selectedPointData - ? selectedPointData.action.loadCapacity.toString() - : "1"; - - const currentUnloadDuration = selectedPointData - ? selectedPointData.action.unLoadDuration.toString() - : "1"; - - const currentPickPoint = selectedPointData?.action.pickUpPoint; - - const currentUnloadPoint = selectedPointData?.action.unLoadPoint; - - const availableActions = { - defaultOption: "travel", - options: ["travel"], - }; - - return ( - <> - {selectedEventData && ( - <> -
-
-
- { }} - onChange={handleSpeedChange} - /> -
-
-
-
- -
-
- -
-
- - - {activeOption === "travel" && ( - - )} -
-
-
- -
-
- - )} - + const handleSpeedChange = (value: string) => { + if (!selectedEventData) return; + const event = updateEvent( + selectedProduct.productId, + selectedEventData.data.modelUuid, + { + speed: parseFloat(value), + } ); + + if (event) { + updateBackend( + selectedProduct.productName, + selectedProduct.productId, + organization, + event + ); + } + }; + + const handleActionTypeChange = (option: string) => { + if (!selectedEventData || !selectedPointData) return; + const validOption = option as "travel"; + setActiveOption(validOption); + + const event = updateAction( + selectedProduct.productId, + selectedPointData.action.actionUuid, + { + actionType: validOption, + } + ); + + if (event) { + updateBackend( + selectedProduct.productName, + selectedProduct.productId, + organization, + event + ); + } + }; + + const handleRenameAction = (newName: string) => { + if (!selectedPointData) return; + const event = updateAction( + selectedProduct.productId, + selectedPointData.action.actionUuid, + { actionName: newName } + ); + + if (event) { + updateBackend( + selectedProduct.productName, + selectedProduct.productId, + organization, + event + ); + } + }; + + const handleLoadCapacityChange = (value: string) => { + if (!selectedPointData) return; + const event = updateAction( + selectedProduct.productId, + selectedPointData.action.actionUuid, + { + loadCapacity: parseFloat(value), + } + ); + + if (event) { + updateBackend( + selectedProduct.productName, + selectedProduct.productId, + organization, + event + ); + } + }; + + const handleUnloadDurationChange = (value: string) => { + if (!selectedPointData) return; + const event = updateAction( + selectedProduct.productId, + selectedPointData.action.actionUuid, + { + unLoadDuration: parseFloat(value), + } + ); + + if (event) { + updateBackend( + selectedProduct.productName, + selectedProduct.productId, + organization, + event + ); + } + }; + + const handlePickPointChange = (value: string) => { + if (!selectedPointData) return; + }; + + const handleUnloadPointChange = (value: string) => { + if (!selectedPointData) return; + }; + + // Get current values from store + + const currentSpeed = + ( + getEventByModelUuid( + selectedProduct.productId, + selectedEventData?.data.modelUuid || "" + ) as VehicleEventSchema | undefined + )?.speed?.toString() || "0.5"; + + const currentActionName = selectedPointData + ? selectedPointData.action.actionName + : "Action Name"; + + const currentLoadCapacity = selectedPointData + ? selectedPointData.action.loadCapacity.toString() + : "1"; + + const currentUnloadDuration = selectedPointData + ? selectedPointData.action.unLoadDuration.toString() + : "1"; + + const { selectedEventSphere } = useSelectedEventSphere(); + + function handleClearPoints() { + const updatedVehicle = getVehicleById( + selectedEventSphere?.userData.modelUuid + ); + + if ( + !selectedProduct?.productId || + !selectedEventSphere?.userData?.modelUuid || + !updatedVehicle?.point + ) + return; + + const event = updateEvent( + selectedProduct.productId, + selectedEventSphere.userData.modelUuid, + { + point: { + ...updatedVehicle.point, + action: { + ...updatedVehicle.point?.action, + pickUpPoint: null, + unLoadPoint: null, + steeringAngle: 0, + }, + }, + } + ); + + if (event) { + updateBackend( + selectedProduct.productName, + selectedProduct.productId, + organization, + event + ); + } + } + + const availableActions = { + defaultOption: "travel", + options: ["travel"], + }; + + return ( + <> + {selectedEventData && ( + <> +
+
+
+ {}} + onChange={handleSpeedChange} + /> +
+
+
+
+ +
+
+ +
+
+ + + {activeOption === "travel" && ( + + )} +
+
+
+ +
+
+ + )} + + ); } export default VehicleMechanics; diff --git a/app/src/components/layout/sidebarRight/properties/eventProperties/trigger/Trigger.tsx b/app/src/components/layout/sidebarRight/properties/eventProperties/trigger/Trigger.tsx index 67fd358..da36384 100644 --- a/app/src/components/layout/sidebarRight/properties/eventProperties/trigger/Trigger.tsx +++ b/app/src/components/layout/sidebarRight/properties/eventProperties/trigger/Trigger.tsx @@ -37,7 +37,7 @@ const Trigger = ({ selectedPointData, type }: TriggerProps) => { if (type === 'Conveyor' || type === 'Vehicle' || type === 'Machine' || type === 'StorageUnit') { actionUuid = (selectedPointData as ConveyorPointSchema | VehiclePointSchema | MachinePointSchema | StoragePointSchema).action?.actionUuid; - } else if (type === 'RoboticArm' && selectedAction) { + } else if (type === 'RoboticArm' && selectedAction && selectedAction.actionId) { actionUuid = selectedAction.actionId; } diff --git a/app/src/components/layout/sidebarRight/simulation/Simulations.tsx b/app/src/components/layout/sidebarRight/simulation/Simulations.tsx index 7799858..6609e92 100644 --- a/app/src/components/layout/sidebarRight/simulation/Simulations.tsx +++ b/app/src/components/layout/sidebarRight/simulation/Simulations.tsx @@ -1,4 +1,4 @@ -import React, { useRef, useState } from "react"; +import React, { useEffect, useRef, useState } from "react"; import { AddIcon, ArrowIcon, @@ -20,9 +20,12 @@ import { useEventsStore } from "../../../../store/simulation/useEventsStore"; import { deleteEventDataApi } from "../../../../services/simulation/deleteEventDataApi"; import { upsertProductOrEventApi } from "../../../../services/simulation/UpsertProductOrEventApi"; import { deleteProductApi } from "../../../../services/simulation/deleteProductApi"; +import { renameProductApi } from "../../../../services/simulation/renameProductApi"; +import { determineExecutionMachineSequences } from "../../../../modules/simulation/simulator/functions/determineExecutionMachineSequences"; interface Event { - pathName: string; + modelName: string; + modelId: string; } interface ListProps { @@ -32,7 +35,7 @@ interface ListProps { const List: React.FC = ({ val }) => { return (
-
{val.pathName}
+
{val.modelName}
); }; @@ -46,6 +49,7 @@ const Simulations: React.FC = () => { renameProduct, addEvent, removeEvent, + getProductById } = useProductStore(); const { selectedProduct, setSelectedProduct } = useSelectedProduct(); const { getEventByModelUuid } = useEventsStore(); @@ -53,6 +57,7 @@ const Simulations: React.FC = () => { const email = localStorage.getItem("email"); const organization = email!.split("@")[1].split(".")[0]; const [openObjects, setOpenObjects] = useState(true); + const [processes, setProcesses] = useState(); const handleAddProduct = () => { const id = generateUUID(); @@ -92,6 +97,7 @@ const Simulations: React.FC = () => { const handleRenameProduct = (productId: string, newName: string) => { renameProduct(productId, newName); + renameProductApi({ productName: newName, productId, organization }); if (selectedProduct.productId === productId) { setSelectedProduct(productId, newName); } @@ -111,14 +117,26 @@ const Simulations: React.FC = () => { } }; - const selectedProductData = products.find( - (product) => product.productId === selectedProduct.productId - ); + useEffect(() => { + const processes: Event[][] = []; + const selectedProductData = getProductById(selectedProduct.productId); - const events: Event[] = - selectedProductData?.eventDatas.map((event) => ({ - pathName: event.modelName, - })) || []; + if (selectedProductData) { + determineExecutionMachineSequences([selectedProductData]) + .then((sequences) => { + sequences.forEach((sequence) => { + const events: Event[] = + sequence.map((event) => ({ + modelName: event.modelName, + modelId: event.modelUuid + })) || []; + processes.push(events); + }) + setProcesses(processes) + }) + + } + }, [selectedProduct.productId, products]) return (
@@ -140,11 +158,10 @@ const Simulations: React.FC = () => { {products.map((product, index) => (
{/* eslint-disable-next-line */}
{ className="collapse-header-container" onClick={() => setOpenObjects(!openObjects)} > -
Events
+
Process Flow
{openObjects && - events.map((event, index) => ( - - ))} + processes?.map((process, index) => +
+ {process.map((event, index) => ( + + ))} +
+ ) + }
diff --git a/app/src/components/ui/FileMenu.tsx b/app/src/components/ui/FileMenu.tsx index da85e54..9997ee4 100644 --- a/app/src/components/ui/FileMenu.tsx +++ b/app/src/components/ui/FileMenu.tsx @@ -31,6 +31,22 @@ const FileMenu: React.FC = () => { return () => document.removeEventListener("mousedown", handleClickOutside); }, []); + // project + const [projectName, setProjectName] = useState("project 1"); + + // Load project name from localStorage on mount + useEffect(() => { + const savedName = localStorage.getItem("projectName"); + if (savedName) { + setProjectName(savedName); + } + }, []); + + const handleProjectRename = (newName: string) => { + setProjectName(newName); + localStorage.setItem("projectName", newName); + }; + return (
diff --git a/app/src/components/ui/Tools.tsx b/app/src/components/ui/Tools.tsx index 4729d25..2187fdc 100644 --- a/app/src/components/ui/Tools.tsx +++ b/app/src/components/ui/Tools.tsx @@ -24,7 +24,6 @@ import { useAddAction, useDeleteTool, useDeletePointOrLine, - useMovePoint, useRefTextUpdate, useSelectedWallItem, useSocketStore, @@ -64,7 +63,6 @@ const Tools: React.FC = () => { const { setTransformMode } = useTransformMode(); const { setDeletePointOrLine } = useDeletePointOrLine(); - const { setMovePoint } = useMovePoint(); const { setToolMode } = useToolMode(); const { activeTool, setActiveTool } = useActiveTool(); const { setRefTextUpdate } = useRefTextUpdate(); @@ -77,7 +75,7 @@ const Tools: React.FC = () => { : true ); }, []); - useEffect(() => {}, [activeModule]); + useEffect(() => { setActiveTool(activeSubTool); setActiveSubTool(activeSubTool); @@ -129,14 +127,13 @@ const Tools: React.FC = () => { setDeleteTool(false); setAddAction(null); setTransformMode(null); - setMovePoint(false); setDeletePointOrLine(false); setRefTextUpdate((prevUpdate) => prevUpdate - 1); switch (activeTool) { - case "Move": + case "cursor": if (toggleView) { - setMovePoint(true); + setToolMode('move'); } else { setTransformMode("translate"); } @@ -201,7 +198,7 @@ const Tools: React.FC = () => { } setActiveTool(activeTool); - }, [activeTool]); + }, [activeTool, toggleView]); return ( <> @@ -211,9 +208,8 @@ const Tools: React.FC = () => {
{activeSubTool == "cursor" && (
{ setActiveTool("cursor"); }} @@ -224,9 +220,8 @@ const Tools: React.FC = () => { )} {activeSubTool == "free-hand" && (
{ setActiveTool("free-hand"); }} @@ -237,9 +232,8 @@ const Tools: React.FC = () => { )} {activeSubTool == "delete" && (
{ setActiveTool("delete"); }} @@ -312,9 +306,8 @@ const Tools: React.FC = () => {
{ setActiveTool("draw-wall"); }} @@ -323,9 +316,8 @@ const Tools: React.FC = () => {
{ setActiveTool("draw-zone"); }} @@ -334,9 +326,8 @@ const Tools: React.FC = () => {
{ setActiveTool("draw-aisle"); }} @@ -345,9 +336,8 @@ const Tools: React.FC = () => {
{ setActiveTool("draw-floor"); }} @@ -363,9 +353,8 @@ const Tools: React.FC = () => {
{ setActiveTool("measure"); }} @@ -381,9 +370,8 @@ const Tools: React.FC = () => {
{ setActiveTool("pen"); }} @@ -420,9 +408,8 @@ const Tools: React.FC = () => {
{ setActiveTool("comment"); }} @@ -432,9 +419,8 @@ const Tools: React.FC = () => {
{toggleThreeD && (
{ setIsPlaying(!isPlaying); }} @@ -448,9 +434,8 @@ const Tools: React.FC = () => { <>
toggle view (tab)
diff --git a/app/src/components/ui/analysis/ProductionCapacity.tsx b/app/src/components/ui/analysis/ProductionCapacity.tsx index d6ebc58..b8b17c8 100644 --- a/app/src/components/ui/analysis/ProductionCapacity.tsx +++ b/app/src/components/ui/analysis/ProductionCapacity.tsx @@ -12,11 +12,11 @@ import SkeletonUI from "../../templates/SkeletonUI"; ChartJS.register(LineElement, CategoryScale, LinearScale, PointElement); -const ThroughputSummary = () => { +const ThroughputSummary:React.FC = () => { // Define all data internally within the component const timeRange = { startTime: "08:00 AM", - endTime: "09:00 AM", + endTime: "06:00 PM", }; const throughputData = { diff --git a/app/src/components/ui/analysis/ROISummary.tsx b/app/src/components/ui/analysis/ROISummary.tsx index bf9b410..0c4d80e 100644 --- a/app/src/components/ui/analysis/ROISummary.tsx +++ b/app/src/components/ui/analysis/ROISummary.tsx @@ -12,9 +12,9 @@ import SkeletonUI from "../../templates/SkeletonUI"; const ROISummary = ({ roiSummaryData = { - productName: "Product name", + productName: "Product 1", roiPercentage: 133, - paybackPeriod: 50.3, + paybackPeriod: 53, totalCost: "1,20,000", revenueGenerated: "2,80,000", netProfit: "1,60,000", @@ -72,6 +72,14 @@ const ROISummary = ({ setIsTableOpen(!isTableOpen); }; + function getCurrentDate() { + const now = new Date(); + const day = now.getDate().toString().padStart(2, "0"); + const month = now.toLocaleString("en-GB", { month: "long" }); + const year = now.getFullYear(); + return `${day} ${month}, ${year}`; + } + const isLoading = false; return (
@@ -79,7 +87,7 @@ const ROISummary = ({
ROI Summary
-
From 24 November, 2025
+
From {getCurrentDate()}
@@ -130,14 +138,16 @@ const ROISummary = ({ className={`metric-item net-profit ${ roiSummaryData.netProfit ?? "loss" }`} - > + >
Net Profit
- {roiSummaryData.netProfit ? roiSummaryData.netProfit : roiSummaryData.netLoss} + {roiSummaryData.netProfit + ? roiSummaryData.netProfit + : roiSummaryData.netLoss}
diff --git a/app/src/components/ui/analysis/ThroughputSummary.tsx b/app/src/components/ui/analysis/ThroughputSummary.tsx index 57eabd1..82116cf 100644 --- a/app/src/components/ui/analysis/ThroughputSummary.tsx +++ b/app/src/components/ui/analysis/ThroughputSummary.tsx @@ -1,5 +1,4 @@ import { - ProductionCapacityIcon, ThroughputSummaryIcon, } from "../../icons/analysis"; import SkeletonUI from "../../templates/SkeletonUI"; diff --git a/app/src/components/ui/inputs/EyeDropInput.tsx b/app/src/components/ui/inputs/EyeDropInput.tsx index 72c5ded..c6fe3ca 100644 --- a/app/src/components/ui/inputs/EyeDropInput.tsx +++ b/app/src/components/ui/inputs/EyeDropInput.tsx @@ -1,21 +1,18 @@ import React from "react"; import { EyeDroperIcon } from "../../icons/ExportCommonIcons"; -import RegularDropDown from "./RegularDropDown"; interface EyeDropInputProps { label: string; value: string; onChange: (value: string) => void; - options?: string[]; } const EyeDropInput: React.FC = ({ label = "Object", + value, onChange, }) => { const handleEyeDropClick = () => { - // Here you would typically implement the eye dropper functionality - // For now, we'll just simulate selecting a value const simulatedValue = "picked_value"; // Replace with actual eye dropper logic onChange(simulatedValue); }; @@ -24,18 +21,15 @@ const EyeDropInput: React.FC = ({
{label}
- {/* */} - { }} - /> -
+ + {/* */} + {/* */} +
+
); }; -export default EyeDropInput; \ No newline at end of file +export default EyeDropInput; diff --git a/app/src/components/ui/list/DropDownList.tsx b/app/src/components/ui/list/DropDownList.tsx index 2a77303..10ca425 100644 --- a/app/src/components/ui/list/DropDownList.tsx +++ b/app/src/components/ui/list/DropDownList.tsx @@ -123,6 +123,7 @@ const DropDownList: React.FC = ({
)}