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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
fix: useRealtime
Sidwebworks97e057a45249
diff --git a/apps/erp/app/hooks/useRealtime.tsx b/apps/erp/app/hooks/useRealtime.tsxindex 0142c75218..a64e782a65 100644--- a/apps/erp/app/hooks/useRealtime.tsx+++ b/apps/erp/app/hooks/useRealtime.tsx@@ -7,7 +7,7 @@ export function useRealtime(table: string, filter?: string) {const revalidator = useRevalidator();const channel = useRealtimeChannel({- topic: `postgres_changes:${table}}`,+ topic: `postgres_changes:${table}`,dependencies: [company.id, filter],setup(channel) {return channel.on(@@ -17,6 +17,7 @@ export function useRealtime(table: string, filter?: string) {if ("companyId" in payload && payload.companyId !== company.id) {return;}+ console.log("🌀 Revalidaiton payload received:", payload);revalidator.revalidate();});diff --git a/apps/erp/app/routes/x+/items+/parts.tsx b/apps/erp/app/routes/x+/items+/parts.tsxindex 35712af9d8..0adb499406 100644--- a/apps/erp/app/routes/x+/items+/parts.tsx+++ b/apps/erp/app/routes/x+/items+/parts.tsx@@ -11,6 +11,7 @@ import { getTagsList } from "~/modules/shared";import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";import { getGenericQueryFilters } from "~/utils/query";+import { useRealtime } from "../../../hooks";export const handle: Handle = {breadcrumb: "Parts",@@ -60,6 +61,8 @@ export async function loader({ request }: LoaderFunctionArgs) {export default function PartsSearchRoute() {const { count, parts, tags } = useLoaderData<typeof loader>();+ useRealtime("part");+return (<VStack spacing={0} className="h-full"><PartsTable data={parts} count={count} tags={tags} />diff --git a/apps/mes/app/hooks/useRealtime.tsx b/apps/mes/app/hooks/useRealtime.tsxindex 72fbec3f0e..1479f4081f 100644--- a/apps/mes/app/hooks/useRealtime.tsx+++ b/apps/mes/app/hooks/useRealtime.tsx@@ -7,7 +7,7 @@ export function useRealtime(table: string, filter?: string) {const revalidator = useRevalidator();const channel = useRealtimeChannel({- topic: `postgres_changes:${table}}`,+ topic: `postgres_changes:${table}`,dependencies: [company.id, filter],setup(channel) {return channel.on(diff --git a/packages/react/src/hooks/useRealtimeChannel.ts b/packages/react/src/hooks/useRealtimeChannel.tsindex 063717ea1d..555f0618e9 100644--- a/packages/react/src/hooks/useRealtimeChannel.ts+++ b/packages/react/src/hooks/useRealtimeChannel.ts@@ -26,6 +26,7 @@ export const useRealtimeChannel = <TDeps extends any[]>(const memoSetup = useCallback(setup, [topic, ...dependencies]);const teardown = useCallback(async () => {+ console.log(`🌀 Tearing down realtime channel ${topic}...`);const channel = channelRef.current;if (!channel || !carbon) return;@@ -67,6 +68,7 @@ export const useRealtimeChannel = <TDeps extends any[]>(channelRef.current = configuredChannel;configuredChannel.subscribe(async (status, err) => {+ console.log(`🌀 Realtime channel ${topic} status:`, status);if (status === REALTIME_SUBSCRIBE_STATES.SUBSCRIBED) {return;}