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:
2025-04-30 11:46:20 +05:30
parent 882c81a385
commit 014bc3a7ca
31 changed files with 203 additions and 161 deletions

View File

@@ -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) {

View File

@@ -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);