feat: Refactor vehicle management and update storage unit load handling; remove unused vehicle component and enhance vehicle status types

This commit is contained in:
2025-04-22 17:24:30 +05:30
parent 83ee14e9c7
commit d161b70537
10 changed files with 380 additions and 282 deletions

View File

@@ -25,7 +25,7 @@ interface StorageUnitStore {
setStorageUnitState: (modelUuid: string, newState: StorageUnitStatus['state']) => void;
// Load updates
updateStorageUnitLoad: (modelUuid: string, load: number) => void;
updateStorageUnitLoad: (modelUuid: string, incrementBy: number) => void;
// Time tracking
incrementActiveTime: (modelUuid: string, incrementBy: number) => void;
@@ -95,11 +95,11 @@ export const useStorageUnitStore = create<StorageUnitStore>()(
},
// Load updates
updateStorageUnitLoad: (modelUuid, load) => {
updateStorageUnitLoad: (modelUuid, incrementBy) => {
set((state) => {
const unit = state.storageUnits.find(s => s.modelUuid === modelUuid);
if (unit) {
unit.currentLoad = load;
unit.currentLoad += incrementBy;
}
});
},

View File

@@ -30,7 +30,6 @@ interface VehiclesStore {
getVehiclesByProduct: (productId: string) => VehicleStatus[];
getVehiclesByState: (state: string) => VehicleStatus[];
getActiveVehicles: () => VehicleStatus[];
getIdleVehicles: () => VehicleStatus[];
}
export const useVehicleStore = create<VehiclesStore>()(
@@ -125,10 +124,6 @@ export const useVehicleStore = create<VehiclesStore>()(
getActiveVehicles: () => {
return get().vehicles.filter(v => v.isActive);
},
getIdleVehicles: () => {
return get().vehicles.filter(v => !v.isActive && v.currentLoad > 0);
}
}))
);