Refactor model identifier naming conventions from 'modeluuid' and 'modelname' to 'modelUuid' and 'modelName' across multiple modules for consistency and clarity. Update related API calls and local storage handling to reflect these changes. Remove unused deleteProductDataApi service and implement deleteProductApi service for product data deletion. Introduce steeringAngle property in vehicle configurations.
This commit is contained in:
@@ -13,6 +13,7 @@ type ProductsStore = {
|
||||
// Event-level actions
|
||||
addEvent: (productId: string, event: EventsSchema) => void;
|
||||
removeEvent: (productId: string, modelUuid: string) => void;
|
||||
deleteEvent: (modelUuid: string) => void;
|
||||
updateEvent: (productId: string, modelUuid: string, updates: Partial<EventsSchema>) => void;
|
||||
|
||||
// Point-level actions
|
||||
@@ -119,6 +120,14 @@ export const useProductStore = create<ProductsStore>()(
|
||||
});
|
||||
},
|
||||
|
||||
deleteEvent: (modelUuid: string) => {
|
||||
set((state) => {
|
||||
for (const product of state.products) {
|
||||
product.eventDatas = product.eventDatas.filter(e => 'modelUuid' in e && e.modelUuid !== modelUuid);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
updateEvent: (productId, modelUuid, updates) => {
|
||||
set((state) => {
|
||||
const product = state.products.find(p => p.productId === productId);
|
||||
@@ -440,7 +449,7 @@ export const useProductStore = create<ProductsStore>()(
|
||||
getPointByUuid: (productId, modelUuid, pointUuid) => {
|
||||
const event = get().getEventByModelUuid(productId, modelUuid);
|
||||
if (!event) return undefined;
|
||||
|
||||
|
||||
if ('points' in event) {
|
||||
return (event as ConveyorEventSchema).points.find(p => p.uuid === pointUuid);
|
||||
} else if ('point' in event && (event as any).point.uuid === pointUuid) {
|
||||
|
||||
@@ -22,6 +22,7 @@ interface VehiclesStore {
|
||||
) => void;
|
||||
|
||||
setVehicleActive: (modelUuid: string, isActive: boolean) => void;
|
||||
updateSteeringAngle: (modelUuid: string, steeringAngle: number) => void;
|
||||
incrementVehicleLoad: (modelUuid: string, incrementBy: number) => void;
|
||||
decrementVehicleLoad: (modelUuid: string, decrementBy: number) => void;
|
||||
setVehicleState: (modelUuid: string, newState: VehicleStatus['state']) => void;
|
||||
@@ -76,6 +77,15 @@ export const useVehicleStore = create<VehiclesStore>()(
|
||||
});
|
||||
},
|
||||
|
||||
updateSteeringAngle: (modelUuid, steeringAngle) => {
|
||||
set((state) => {
|
||||
const vehicle = state.vehicles.find(v => v.modelUuid === modelUuid);
|
||||
if (vehicle) {
|
||||
vehicle.point.action.steeringAngle = steeringAngle;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
incrementVehicleLoad: (modelUuid, incrementBy) => {
|
||||
set((state) => {
|
||||
const vehicle = state.vehicles.find(v => v.modelUuid === modelUuid);
|
||||
|
||||
Reference in New Issue
Block a user