Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

refactor: update dependencies for useEffect

Brad Barbinb36eea32a25a
diff --git a/apps/erp/app/modules/production/ui/Planning/ProductionPlanningTable.tsx b/apps/erp/app/modules/production/ui/Planning/ProductionPlanningTable.tsx
index b95c7658b6..38610bde78 100644
--- a/apps/erp/app/modules/production/ui/Planning/ProductionPlanningTable.tsx
+++ b/apps/erp/app/modules/production/ui/Planning/ProductionPlanningTable.tsx
@@ -593,17 +593,24 @@ const ProductionPlanningTable = memo(
}
});
return initialMap;
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [data]);
+ }, [data, periods]);
// Store orders in a map keyed by item id
- const [ordersMap, setOrdersMap] =
- useState<Record<string, ProductionOrder[]>>(getOrders);
+ const [ordersMap, setOrdersMap] = useState<
+ Record<string, ProductionOrder[]>
+ >(() => {
+ const initialMap: Record<string, ProductionOrder[]> = {};
+ data.forEach((item) => {
+ if (item.id) {
+ initialMap[item.id] = getProductionOrdersFromPlanning(item, periods);
+ }
+ });
+ return initialMap;
+ });
useEffect(() => {
setOrdersMap(getOrders());
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [data]);
+ }, [getOrders]);
const onBulkUpdate = useCallback(
(selectedRows: typeof data, action: "order") => {