feat: Implement swap handling and enhance action management in conveyor system
This commit is contained in:
@@ -23,10 +23,10 @@ type MaterialsStore = {
|
||||
location?: {
|
||||
modelUuid: string;
|
||||
pointUuid: string;
|
||||
actionUuid: string;
|
||||
} | null
|
||||
) => MaterialSchema | undefined;
|
||||
|
||||
setMaterial: (materialId: string, materialType: string) => MaterialSchema | undefined;
|
||||
setStartTime: (materialId: string, startTime: string) => MaterialSchema | undefined;
|
||||
setEndTime: (materialId: string, endTime: string) => MaterialSchema | undefined;
|
||||
setCost: (materialId: string, cost: number) => MaterialSchema | undefined;
|
||||
@@ -37,6 +37,7 @@ type MaterialsStore = {
|
||||
|
||||
getMaterialById: (materialId: string) => MaterialSchema | undefined;
|
||||
getMaterialByCurrentModelUuid: (currentModelUuid: string) => MaterialSchema | undefined;
|
||||
getMaterialByCurrentPointUuid: (currentPointUuid: string) => MaterialSchema | undefined;
|
||||
getMaterialsByPoint: (pointUuid: string) => MaterialSchema[];
|
||||
getMaterialsByModel: (modelUuid: string) => MaterialSchema[];
|
||||
};
|
||||
@@ -107,6 +108,18 @@ export const useMaterialStore = create<MaterialsStore>()(
|
||||
return updatedMaterial;
|
||||
},
|
||||
|
||||
setMaterial: (materialId, materialType) => {
|
||||
let updatedMaterial: MaterialSchema | undefined;
|
||||
set((state) => {
|
||||
const material = state.materials.find(m => m.materialId === materialId);
|
||||
if (material) {
|
||||
material.materialType = materialType;
|
||||
updatedMaterial = JSON.parse(JSON.stringify(material));
|
||||
};
|
||||
});
|
||||
return updatedMaterial;
|
||||
},
|
||||
|
||||
setStartTime: (materialId, startTime) => {
|
||||
let updatedMaterial: MaterialSchema | undefined;
|
||||
set((state) => {
|
||||
@@ -198,6 +211,10 @@ export const useMaterialStore = create<MaterialsStore>()(
|
||||
getMaterialByCurrentModelUuid: (currentModelUuid) => {
|
||||
return get().materials.find(m => m.current?.modelUuid === currentModelUuid);
|
||||
},
|
||||
|
||||
getMaterialByCurrentPointUuid: (currentPointlUuid) => {
|
||||
return get().materials.find(m => m.current?.pointUuid === currentPointlUuid);
|
||||
},
|
||||
|
||||
getMaterialsByPoint: (pointUuid) => {
|
||||
return get().materials.filter(m =>
|
||||
|
||||
Reference in New Issue
Block a user