feat: Enhance conveyor and material handling with pause functionality and state management

This commit is contained in:
2025-05-06 19:12:58 +05:30
parent 815a9a94ca
commit 53912b2597
17 changed files with 202 additions and 69 deletions

View File

@@ -33,6 +33,7 @@ type MaterialsStore = {
setWeight: (materialId: string, weight: number) => MaterialSchema | undefined;
setIsActive: (materialId: string, isActive: boolean) => MaterialSchema | undefined;
setIsVisible: (materialId: string, isVisible: boolean) => MaterialSchema | undefined;
setIsPaused: (materialId: string, isPlaying: boolean) => MaterialSchema | undefined;
setIsRendered: (materialId: string, isRendered: boolean) => MaterialSchema | undefined;
getMaterialById: (materialId: string) => MaterialSchema | undefined;
@@ -192,6 +193,18 @@ export const useMaterialStore = create<MaterialsStore>()(
return updatedMaterial;
},
setIsPaused: (materialId, isPaused) => {
let updatedMaterial: MaterialSchema | undefined;
set((state) => {
const material = state.materials.find(m => m.materialId === materialId);
if (material) {
material.isPaused = isPaused;
updatedMaterial = JSON.parse(JSON.stringify(material));
};
});
return updatedMaterial;
},
setIsRendered: (materialId, isRendered) => {
let updatedMaterial: MaterialSchema | undefined;
set((state) => {