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
feat: ui for completing maintenance in mes
Brad Barbincced8f6383e0
diff --git a/apps/erp/app/hooks/useAsyncFetcher.tsx b/apps/erp/app/hooks/useAsyncFetcher.tsxindex 6356db3a7b..79c27eddf5 100644--- a/apps/erp/app/hooks/useAsyncFetcher.tsx+++ b/apps/erp/app/hooks/useAsyncFetcher.tsx@@ -43,7 +43,7 @@ export function useAsyncFetcher<TData>(options?: FetcherOptions) {onStateChange(fetcher.state);if (fetcher.state === "idle") {if (fetcher.data) {- instance.current?.resolve(fetcher.data as TData); // I think we don't need to use SerializeFrom here+ instance.current?.resolve(fetcher.data as TData);instance.current = Promise.withResolvers<TData>();}}diff --git a/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchForm.tsx b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchForm.tsxindex d6ed8d4ff1..d242a19f2f 100644--- a/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchForm.tsx+++ b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchForm.tsx@@ -30,6 +30,7 @@ import {maintenanceSource,oeeImpact} from "../../production.models";+import MaintenanceOeeImpact from "./MaintenanceOeeImpact";import MaintenanceSeverity from "./MaintenanceSeverity";import MaintenanceSource from "./MaintenanceSource";@@ -170,7 +171,7 @@ const MaintenanceDispatchForm = ({label="OEE Impact"options={oeeImpact.map((impact) => ({value: impact,- label: impact+ label: <MaintenanceOeeImpact oeeImpact={impact} />}))}onChange={(option) => {if (option?.value) {diff --git a/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchProperties.tsx b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchProperties.tsxindex fe212ac9bf..42ec6f6b6d 100644--- a/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchProperties.tsx+++ b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchProperties.tsx@@ -28,6 +28,7 @@ import {oeeImpact} from "../../production.models";import type { MaintenanceDispatchDetail } from "../../types";+import MaintenanceOeeImpact from "./MaintenanceOeeImpact";import MaintenancePriority from "./MaintenancePriority";import MaintenanceSeverity from "./MaintenanceSeverity";import MaintenanceSource from "./MaintenanceSource";@@ -283,7 +284,7 @@ const MaintenanceDispatchProperties = () => {<Selectoptions={maintenanceSource.map((source) => ({value: source,- label: source+ label: <MaintenanceSource source={source} />}))}isReadOnly={!permissions.can("update", "production")}label="Source"@@ -315,13 +316,17 @@ const MaintenanceDispatchProperties = () => {<Selectoptions={oeeImpact.map((impact) => ({value: impact,- label: impact+ label: <MaintenanceOeeImpact oeeImpact={impact} />}))}isReadOnly={!permissions.can("update", "production")}label="OEE Impact"name="oeeImpact"inline={(value) => {- return <span>{value}</span>;+ return (+ <MaintenanceOeeImpact+ oeeImpact={value as (typeof oeeImpact)[number]}+ />+ );}}onChange={(value) => {if (value) {diff --git a/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchesTable.tsx b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchesTable.tsxindex 63a59dfa58..bb9ddb5a83 100644--- a/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchesTable.tsx+++ b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchesTable.tsx@@ -21,9 +21,11 @@ import { path } from "~/utils/path";import {maintenanceDispatchPriority,maintenanceDispatchStatus,- maintenanceSource+ maintenanceSource,+ oeeImpact} from "../../production.models";import type { MaintenanceDispatch } from "../../types";+import MaintenanceOeeImpact from "./MaintenanceOeeImpact";import MaintenancePriority from "./MaintenancePriority";import MaintenanceSource from "./MaintenanceSource";import MaintenanceStatus from "./MaintenanceStatus";@@ -112,6 +114,24 @@ const MaintenanceDispatchesTable = memo(pluralHeader: "Priorities"}},+ {+ accessorKey: "oeeImpact",+ header: "OEE Impact",+ cell: (item) => {+ const impact = item.getValue<(typeof oeeImpact)[number]>();+ return <MaintenanceOeeImpact oeeImpact={impact} />;+ },+ meta: {+ icon: <LuChartNoAxesColumnIncreasing />,+ filter: {+ type: "static",+ options: oeeImpact.map((impact) => ({+ value: impact,+ label: <MaintenanceOeeImpact oeeImpact={impact} />+ }))+ }+ }+ },{accessorKey: "assignee",header: "Assignee",diff --git a/apps/erp/app/modules/production/ui/Maintenance/MaintenanceOeeImpact.tsx b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceOeeImpact.tsxnew file mode 100644index 0000000000..216a3c69fd--- /dev/null+++ b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceOeeImpact.tsx@@ -0,0 +1,65 @@+import { Badge, cn } from "@carbon/react";+import {+ LuCalendar,+ LuCircleCheck,+ LuCircleX,+ LuTriangleAlert+} from "react-icons/lu";+import type { oeeImpact } from "../../production.models";++type MaintenanceOeeImpactProps = {+ oeeImpact?: (typeof oeeImpact)[number] | null;+ className?: string;+};++function MaintenanceOeeImpact({+ oeeImpact,+ className+}: MaintenanceOeeImpactProps) {+ switch (oeeImpact) {+ case "Down":+ return (+ <Badge+ variant="red"+ className={cn(className, "inline-flex items-center gap-1")}+ >+ <LuCircleX className="h-3 w-3" />+ Down+ </Badge>+ );+ case "Planned":+ return (+ <Badge+ variant="secondary"+ className={cn(className, "inline-flex items-center gap-1")}+ >+ <LuCalendar className="h-3 w-3" />+ Planned+ </Badge>+ );+ case "Impact":+ return (+ <Badge+ variant="yellow"+ className={cn(className, "inline-flex items-center gap-1")}+ >+ <LuTriangleAlert className="h-3 w-3" />+ Impact+ </Badge>+ );+ case "No Impact":+ return (+ <Badge+ variant="blue"+ className={cn(className, "inline-flex items-center gap-1")}+ >+ <LuCircleCheck className="h-3 w-3" />+ No Impact+ </Badge>+ );+ default:+ return null;+ }+}++export default MaintenanceOeeImpact;diff --git a/apps/erp/app/modules/production/ui/Maintenance/MaintenanceSource.tsx b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceSource.tsxindex d1e2606c6c..741fcc0f21 100644--- a/apps/erp/app/modules/production/ui/Maintenance/MaintenanceSource.tsx+++ b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceSource.tsx@@ -1,5 +1,10 @@import { Badge, cn } from "@carbon/react";-import { LuCalendarClock, LuShieldX, LuTriangleAlert } from "react-icons/lu";+import {+ LuCalendarClock,+ LuRefreshCcwDot,+ LuShieldX,+ LuTriangleAlert+} from "react-icons/lu";import type { maintenanceSource } from "../../production.models";type MaintenanceSourceProps = {@@ -22,10 +27,10 @@ function MaintenanceSource({ source, className }: MaintenanceSourceProps) {case "Reactive":return (<Badge- variant="red"+ variant="orange"className={cn(className, "inline-flex items-center gap-1")}>- <LuTriangleAlert />+ <LuRefreshCcwDot />{source}</Badge>);diff --git a/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ColumnCard.tsx b/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ColumnCard.tsxindex a748b156fc..fdb3c8a06f 100644--- a/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ColumnCard.tsx+++ b/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ColumnCard.tsx@@ -3,7 +3,10 @@ import {IconButton,PulsingDot,ScrollArea,- ScrollBar+ ScrollBar,+ Tooltip,+ TooltipContent,+ TooltipTrigger} from "@carbon/react";import { useUrlParams } from "@carbon/remix";import { formatDurationMilliseconds } from "@carbon/utils";@@ -14,6 +17,8 @@ import { cva } from "class-variance-authority";import type { ComponentType } from "react";import { useMemo } from "react";import { LuGripVertical } from "react-icons/lu";+import { Link } from "react-router";+import { path } from "~/utils/path";import type { Column, Item, Progress } from "../types";import { ItemCard } from "./ItemCard";@@ -99,14 +104,35 @@ export function ColumnCard({: `h-[calc(100dvh-var(--header-height)*2)]`)}>- <div className="p-4 w-full font-semibold text-left flex flex-row space-between items-center sticky top-0 bg-card z-1 border-b">+ <div+ className={cn(+ "p-4 w-full font-semibold text-left flex flex-row space-between items-center sticky top-0 z-1 border-b",+ column.isBlocked && column.blockingDispatchId+ ? "bg-red-100 text-red-800 dark:bg-red-900/50 dark:text-red-400"+ : "bg-card"+ )}+ ><div className="flex flex-grow items-start space-x-2">- {column.active || !isDateView ? (+ {!column.isBlocked && (column.active || !isDateView) ? (<PulsingDot inactive={!column.active} className="mt-2" />) : null}<div className="flex flex-col flex-grow"><span className="mr-auto truncate"> {column.title}</span>- {!isDateView && totalDuration > 0 ? (+ {column.isBlocked && column.blockingDispatchId ? (+ <Tooltip>+ <TooltipTrigger asChild>+ <Link+ to={path.to.maintenanceDispatch(column.blockingDispatchId)}+ className="inline-flex items-center gap-1 text-xs font-normal"+ >+ <span>Blocked by {column.blockingDispatchReadableId}</span>+ </Link>+ </TooltipTrigger>+ <TooltipContent>+ <p>View maintenance dispatch</p>+ </TooltipContent>+ </Tooltip>+ ) : !isDateView && totalDuration > 0 ? (<span className="text-muted-foreground text-xs">{formatDurationMilliseconds(totalDuration)}</span>diff --git a/apps/erp/app/modules/production/ui/Schedule/Kanban/types.ts b/apps/erp/app/modules/production/ui/Schedule/Kanban/types.tsindex 5b8ce9ace4..e8d635f087 100644--- a/apps/erp/app/modules/production/ui/Schedule/Kanban/types.ts+++ b/apps/erp/app/modules/production/ui/Schedule/Kanban/types.ts@@ -10,7 +10,10 @@ export const columnValidator = z.object({id: z.string(),title: z.string(),active: z.boolean().optional(),- type: z.array(z.string())+ type: z.array(z.string()),+ isBlocked: z.boolean().optional(),+ blockingDispatchId: z.string().optional(),+ blockingDispatchReadableId: z.string().optional()});export type Column = z.infer<typeof columnValidator>;diff --git a/apps/erp/app/modules/resources/resources.service.ts b/apps/erp/app/modules/resources/resources.service.tsindex 7f9ab0608e..71493777d7 100644--- a/apps/erp/app/modules/resources/resources.service.ts+++ b/apps/erp/app/modules/resources/resources.service.ts@@ -619,20 +619,63 @@ export async function getWorkCenters(export async function getWorkCentersByLocation(client: SupabaseClient<Database>,locationId: string+) {+ // Query both views and merge - workCenters has processes, workCentersWithBlockingStatus has blocking info+ const [workCentersResult, blockingStatusResult] = await Promise.all([+ client+ .from("workCenters")+ .select("*")+ .eq("locationId", locationId)+ .eq("active", true),+ client+ .from("workCentersWithBlockingStatus")+ .select("id, isBlocked, blockingDispatchId, blockingDispatchReadableId")+ .eq("locationId", locationId)+ .eq("active", true)+ ]);++ if (workCentersResult.error) {+ return workCentersResult;+ }++ // Create a map of blocking status by work center id+ const blockingStatusMap = new Map(+ blockingStatusResult.data?.map((wc) => [wc.id, wc]) ?? []+ );++ // Merge the data+ const mergedData = workCentersResult.data?.map((wc) => {+ const blockingStatus = blockingStatusMap.get(wc.id);+ return {+ ...wc,+ isBlocked: blockingStatus?.isBlocked ?? false,+ blockingDispatchId: blockingStatus?.blockingDispatchId ?? null,+ blockingDispatchReadableId:+ blockingStatus?.blockingDispatchReadableId ?? null+ };+ });++ return { data: mergedData, error: null };+}++export async function getWorkCentersList(+ client: SupabaseClient<Database>,+ companyId: string) {return client.from("workCenters").select("*")- .eq("locationId", locationId)- .eq("active", true);+ .eq("companyId", companyId)+ .eq("active", true)+ .order("name");}-export async function getWorkCentersList(+export async function getWorkCentersListWithBlockingStatus(client: SupabaseClient<Database>,companyId: string) {return client- .from("workCenters")+ .from("workCentersWithBlockingStatus").select("*").eq("companyId", companyId).eq("active", true)diff --git a/apps/erp/app/routes/api+/accounting.currencies.ts b/apps/erp/app/routes/api+/accounting.currencies.tsindex d69049b6a7..aa1019985c 100644--- a/apps/erp/app/routes/api+/accounting.currencies.ts+++ b/apps/erp/app/routes/api+/accounting.currencies.ts@@ -1,8 +1,7 @@import { requirePermissions } from "@carbon/auth/auth.server";import type {ClientLoaderFunctionArgs,- LoaderFunctionArgs,- SerializeFrom+ LoaderFunctionArgs} from "react-router";import { getCurrenciesList } from "~/modules/accounting";import { currenciesQuery } from "~/utils/react-query";@@ -15,9 +14,7 @@ export async function loader({ request }: LoaderFunctionArgs) {export async function clientLoader({ serverLoader }: ClientLoaderFunctionArgs) {const query = currenciesQuery();- const data = window?.clientCache?.getQueryData<SerializeFrom<typeof loader>>(- query.queryKey- );+ const data = window?.clientCache?.getQueryData<typeof loader>(query.queryKey);if (!data) {const serverData = await serverLoader<typeof loader>();diff --git a/apps/erp/app/routes/api+/accounting.payment-terms.ts b/apps/erp/app/routes/api+/accounting.payment-terms.tsindex 29a35c7733..671560701b 100644--- a/apps/erp/app/routes/api+/accounting.payment-terms.ts+++ b/apps/erp/app/routes/api+/accounting.payment-terms.ts@@ -1,8 +1,7 @@import { requirePermissions } from "@carbon/auth/auth.server";import type {ClientLoaderFunctionArgs,- LoaderFunctionArgs,- SerializeFrom+ LoaderFunctionArgs} from "react-router";import { getPaymentTermsList } from "~/modules/accounting";import { getCompanyId, paymentTermsQuery } from "~/utils/react-query";@@ -22,7 +21,9 @@ export async function clientLoader({ serverLoader }: ClientLoaderFunctionArgs) {const queryKey = paymentTermsQuery(companyId).queryKey;const data =- window?.clientCache?.getQueryData<SerializeFrom<typeof loader>>(queryKey);+ window?.clientCache?.getQueryData<Awaited<ReturnType<typeof loader>>>(+ queryKey+ );if (!data) {const serverData = await serverLoader<typeof loader>();diff --git a/apps/erp/app/routes/api+/countries.ts b/apps/erp/app/routes/api+/countries.tsindex 11f43f360b..afeaa262bf 100644--- a/apps/erp/app/routes/api+/countries.ts+++ b/apps/erp/app/routes/api+/countries.ts@@ -1,8 +1,7 @@import { requirePermissions } from "@carbon/auth/auth.server";import type {ClientLoaderFunctionArgs,- LoaderFunctionArgs,- SerializeFrom+ LoaderFunctionArgs} from "react-router";import { getCountries } from "~/modules/shared";import { countriesQuery } from "~/utils/react-query";@@ -14,9 +13,9 @@ export async function loader({ request }: LoaderFunctionArgs) {export async function clientLoader({ serverLoader }: ClientLoaderFunctionArgs) {const query = countriesQuery();- const data = window?.clientCache?.getQueryData<SerializeFrom<typeof loader>>(- query.queryKey- );+ const data = window?.clientCache?.getQueryData<+ Awaited<ReturnType<typeof loader>>+ >(query.queryKey);if (!data) {const serverData = await serverLoader<typeof loader>();diff --git a/apps/erp/app/routes/api+/docs.ts b/apps/erp/app/routes/api+/docs.tsindex 1e14395beb..868c9ed65a 100644--- a/apps/erp/app/routes/api+/docs.ts+++ b/apps/erp/app/routes/api+/docs.ts@@ -2,8 +2,7 @@ import { requirePermissions } from "@carbon/auth/auth.server";import swaggerDocsSchema from "@carbon/database/swagger-docs-schema";import type {ClientLoaderFunctionArgs,- LoaderFunctionArgs,- SerializeFrom+ LoaderFunctionArgs} from "react-router";import { docsQuery } from "~/utils/react-query";@@ -16,7 +15,9 @@ export async function loader({ request }: LoaderFunctionArgs) {export async function clientLoader({ serverLoader }: ClientLoaderFunctionArgs) {const queryKey = docsQuery().queryKey;const data =- window?.clientCache?.getQueryData<SerializeFrom<typeof loader>>(queryKey);+ window?.clientCache?.getQueryData<Awaited<ReturnType<typeof loader>>>(+ queryKey+ );if (!data) {const serverData = await serverLoader<typeof loader>();diff --git a/apps/erp/app/routes/api+/inventory.shelves-with-quantities.ts b/apps/erp/app/routes/api+/inventory.shelves-with-quantities.tsindex 72732131bf..cb575b0bdf 100644--- a/apps/erp/app/routes/api+/inventory.shelves-with-quantities.ts+++ b/apps/erp/app/routes/api+/inventory.shelves-with-quantities.ts@@ -1,8 +1,7 @@import { requirePermissions } from "@carbon/auth/auth.server";import type {ClientLoaderFunctionArgs,- LoaderFunctionArgs,- SerializeFrom+ LoaderFunctionArgs} from "react-router";import { getShelvesListForLocation } from "~/modules/inventory";import { getItemShelfQuantities } from "~/modules/items/items.service";@@ -84,7 +83,9 @@ export async function clientLoader({itemId ?? null).queryKey;const data =- window?.clientCache?.getQueryData<SerializeFrom<typeof loader>>(queryKey);+ window?.clientCache?.getQueryData<Awaited<ReturnType<typeof loader>>>(+ queryKey+ );if (!data) {const serverData = await serverLoader<typeof loader>();diff --git a/apps/erp/app/routes/api+/inventory.shelves.ts b/apps/erp/app/routes/api+/inventory.shelves.tsindex 03f421a708..133b44728e 100644--- a/apps/erp/app/routes/api+/inventory.shelves.ts+++ b/apps/erp/app/routes/api+/inventory.shelves.ts@@ -1,8 +1,7 @@import { requirePermissions } from "@carbon/auth/auth.server";import type {ClientLoaderFunctionArgs,- LoaderFunctionArgs,- SerializeFrom+ LoaderFunctionArgs} from "react-router";import { getShelvesListForLocation } from "~/modules/inventory";import { getCompanyId, shelvesQuery } from "~/utils/react-query";@@ -39,7 +38,9 @@ export async function clientLoader({const queryKey = shelvesQuery(companyId, locationId ?? null).queryKey;const data =- window?.clientCache?.getQueryData<SerializeFrom<typeof loader>>(queryKey);+ window?.clientCache?.getQueryData<Awaited<ReturnType<typeof loader>>>(+ queryKey+ );if (!data) {const serverData = await serverLoader<typeof loader>();diff --git a/apps/erp/app/routes/api+/inventory.shipping-methods.ts b/apps/erp/app/routes/api+/inventory.shipping-methods.tsindex 016c49ad58..2aa56e4e0c 100644--- a/apps/erp/app/routes/api+/inventory.shipping-methods.ts+++ b/apps/erp/app/routes/api+/inventory.shipping-methods.ts@@ -1,8 +1,7 @@import { requirePermissions } from "@carbon/auth/auth.server";import type {ClientLoaderFunctionArgs,- LoaderFunctionArgs,- SerializeFrom+ LoaderFunctionArgs} from "react-router";import { getShippingMethodsList } from "~/modules/inventory";import { getCompanyId, shippingMethodsQuery } from "~/utils/react-query";@@ -22,7 +21,9 @@ export async function clientLoader({ serverLoader }: ClientLoaderFunctionArgs) {const queryKey = shippingMethodsQuery(companyId).queryKey;const data =- window?.clientCache?.getQueryData<SerializeFrom<typeof loader>>(queryKey);+ window?.clientCache?.getQueryData<Awaited<ReturnType<typeof loader>>>(+ queryKey+ );if (!data) {const serverData = await serverLoader<typeof loader>();diff --git a/apps/erp/app/routes/api+/items.types.$substanceId.$formId.ts b/apps/erp/app/routes/api+/items.types.$substanceId.$formId.tsindex c310172c34..dabf67822f 100644--- a/apps/erp/app/routes/api+/items.types.$substanceId.$formId.ts+++ b/apps/erp/app/routes/api+/items.types.$substanceId.$formId.ts@@ -1,8 +1,7 @@import { requirePermissions } from "@carbon/auth/auth.server";import type {ClientLoaderFunctionArgs,- LoaderFunctionArgs,- SerializeFrom+ LoaderFunctionArgs} from "react-router";import { data } from "react-router";import { getMaterialTypeList } from "~/modules/items";@@ -44,9 +43,9 @@ export async function clientLoader({params.formId,companyId);- const data = window?.clientCache?.getQueryData<SerializeFrom<typeof loader>>(- query.queryKey- );+ const data = window?.clientCache?.getQueryData<+ Awaited<ReturnType<typeof loader>>+ >(query.queryKey);if (!data) {const serverData = await serverLoader<typeof loader>();diff --git a/apps/erp/app/routes/api+/items.uoms.ts b/apps/erp/app/routes/api+/items.uoms.tsindex cb6d4e5fd8..b38eae19c9 100644--- a/apps/erp/app/routes/api+/items.uoms.ts+++ b/apps/erp/app/routes/api+/items.uoms.ts@@ -1,8 +1,7 @@import { requirePermissions } from "@carbon/auth/auth.server";import type {ClientLoaderFunctionArgs,- LoaderFunctionArgs,- SerializeFrom+ LoaderFunctionArgs} from "react-router";import { getUnitOfMeasuresList } from "~/modules/items";import { getCompanyId, uomsQuery } from "~/utils/react-query";@@ -22,7 +21,9 @@ export async function clientLoader({ serverLoader }: ClientLoaderFunctionArgs) {const queryKey = uomsQuery(companyId).queryKey;const data =- window?.clientCache?.getQueryData<SerializeFrom<typeof loader>>(queryKey);+ window?.clientCache?.getQueryData<Awaited<ReturnType<typeof loader>>>(+ queryKey+ );if (!data) {const serverData = await serverLoader<typeof loader>();diff --git a/apps/erp/app/routes/api+/production.procedures.ts b/apps/erp/app/routes/api+/production.procedures.tsindex fec89bd657..0b65276b33 100644--- a/apps/erp/app/routes/api+/production.procedures.ts+++ b/apps/erp/app/routes/api+/production.procedures.ts@@ -1,8 +1,7 @@import { requirePermissions } from "@carbon/auth/auth.server";import type {ClientLoaderFunctionArgs,- LoaderFunctionArgs,- SerializeFrom+ LoaderFunctionArgs} from "react-router";import { getProceduresList } from "~/modules/production";import { getCompanyId, proceduresQuery } from "~/utils/react-query";@@ -24,7 +23,9 @@ export async function clientLoader({ serverLoader }: ClientLoaderFunctionArgs) {const queryKey = proceduresQuery(companyId).queryKey;const data =- window?.clientCache?.getQueryData<SerializeFrom<typeof loader>>(queryKey);+ window?.clientCache?.getQueryData<Awaited<ReturnType<typeof loader>>>(+ queryKey+ );if (!data) {const serverData = await serverLoader<typeof loader>();diff --git a/apps/erp/app/routes/api+/purchasing.supplier-contacts.$supplierId.ts b/apps/erp/app/routes/api+/purchasing.supplier-contacts.$supplierId.tsindex 622b6b9a7e..65c0a2eb09 100644--- a/apps/erp/app/routes/api+/purchasing.supplier-contacts.$supplierId.ts+++ b/apps/erp/app/routes/api+/purchasing.supplier-contacts.$supplierId.ts@@ -3,8 +3,7 @@ import { requirePermissions } from "@carbon/auth/auth.server";import { flash } from "@carbon/auth/session.server";import type {ClientLoaderFunctionArgs,- LoaderFunctionArgs,- SerializeFrom+ LoaderFunctionArgs} from "react-router";import { data } from "react-router";import { getSupplierContacts } from "~/modules/purchasing";@@ -48,7 +47,9 @@ export async function clientLoader({const queryKey = supplierContactsQuery(supplierId).queryKey;const data =- window?.clientCache?.getQueryData<SerializeFrom<typeof loader>>(queryKey);+ window?.clientCache?.getQueryData<Awaited<ReturnType<typeof loader>>>(+ queryKey+ );if (!data) {const serverData = await serverLoader<typeof loader>();diff --git a/apps/erp/app/routes/api+/purchasing.supplier-locations.$supplierId.ts b/apps/erp/app/routes/api+/purchasing.supplier-locations.$supplierId.tsindex c8941c46a2..12807c4553 100644--- a/apps/erp/app/routes/api+/purchasing.supplier-locations.$supplierId.ts+++ b/apps/erp/app/routes/api+/purchasing.supplier-locations.$supplierId.ts@@ -3,8 +3,7 @@ import { requirePermissions } from "@carbon/auth/auth.server";import { flash } from "@carbon/auth/session.server";import type {ClientLoaderFunctionArgs,- LoaderFunctionArgs,- SerializeFrom+ LoaderFunctionArgs} from "react-router";import { data } from "react-router";import { getSupplierLocations } from "~/modules/purchasing";@@ -48,7 +47,9 @@ export async function clientLoader({const queryKey = supplierLocationsQuery(supplierId).queryKey;const data =- window?.clientCache?.getQueryData<SerializeFrom<typeof loader>>(queryKey);+ window?.clientCache?.getQueryData<Awaited<ReturnType<typeof loader>>>(+ queryKey+ );if (!data) {const serverData = await serverLoader<typeof loader>();diff --git a/apps/erp/app/routes/api+/purchasing.supplier-processes.$processId.ts b/apps/erp/app/routes/api+/purchasing.supplier-processes.$processId.tsindex 5bce647edb..59b39ba611 100644--- a/apps/erp/app/routes/api+/purchasing.supplier-processes.$processId.ts+++ b/apps/erp/app/routes/api+/purchasing.supplier-processes.$processId.ts@@ -3,8 +3,7 @@ import { requirePermissions } from "@carbon/auth/auth.server";import { flash } from "@carbon/auth/session.server";import type {ClientLoaderFunctionArgs,- LoaderFunctionArgs,- SerializeFrom+ LoaderFunctionArgs} from "react-router";import { data } from "react-router";import { getSupplierProcessesByProcess } from "~/modules/purchasing";@@ -49,7 +48,9 @@ export async function clientLoader({const queryKey = supplierProcessesQuery(processId).queryKey;const data =- window?.clientCache?.getQueryData<SerializeFrom<typeof loader>>(queryKey);+ window?.clientCache?.getQueryData<Awaited<ReturnType<typeof loader>>>(+ queryKey+ );if (!data) {const serverData = await serverLoader<typeof loader>();diff --git a/apps/erp/app/routes/api+/purchasing.supplier-types.ts b/apps/erp/app/routes/api+/purchasing.supplier-types.tsindex 71e20ae00e..a285fb48c0 100644--- a/apps/erp/app/routes/api+/purchasing.supplier-types.ts+++ b/apps/erp/app/routes/api+/purchasing.supplier-types.ts@@ -1,8 +1,7 @@import { requirePermissions } from "@carbon/auth/auth.server";import type {ClientLoaderFunctionArgs,- LoaderFunctionArgs,- SerializeFrom+ LoaderFunctionArgs} from "react-router";import { getSupplierTypesList } from "~/modules/purchasing";import { getCompanyId, supplierTypesQuery } from "~/utils/react-query";@@ -24,7 +23,9 @@ export async function clientLoader({ serverLoader }: ClientLoaderFunctionArgs) {const queryKey = supplierTypesQuery(companyId).queryKey;const data =- window?.clientCache?.getQueryData<SerializeFrom<typeof loader>>(queryKey);+ window?.clientCache?.getQueryData<Awaited<ReturnType<typeof loader>>>(+ queryKey+ );if (!data) {const serverData = await serverLoader<typeof loader>();diff --git a/apps/erp/app/routes/api+/resources.abilities.ts b/apps/erp/app/routes/api+/resources.abilities.tsindex fd7587f44c..3dbc920a5b 100644--- a/apps/erp/app/routes/api+/resources.abilities.ts+++ b/apps/erp/app/routes/api+/resources.abilities.ts@@ -1,8 +1,7 @@import { requirePermissions } from "@carbon/auth/auth.server";import type {ClientLoaderFunctionArgs,- LoaderFunctionArgs,- SerializeFrom+ LoaderFunctionArgs} from "react-router";import { getAbilitiesList } from "~/modules/resources";import { abilitiesQuery, getCompanyId } from "~/utils/react-query";@@ -24,7 +23,9 @@ export async function clientLoader({ serverLoader }: ClientLoaderFunctionArgs) {const queryKey = abilitiesQuery(companyId).queryKey;const data =- window?.clientCache?.getQueryData<SerializeFrom<typeof loader>>(queryKey);+ window?.clientCache?.getQueryData<Awaited<ReturnType<typeof loader>>>(+ queryKey+ );if (!data) {const serverData = await serverLoader<typeof loader>();diff --git a/apps/erp/app/routes/api+/resources.locations.ts b/apps/erp/app/routes/api+/resources.locations.tsindex 9c256093b3..5332a9607e 100644--- a/apps/erp/app/routes/api+/resources.locations.ts+++ b/apps/erp/app/routes/api+/resources.locations.ts@@ -1,8 +1,7 @@import { requirePermissions } from "@carbon/auth/auth.server";import type {ClientLoaderFunctionArgs,- LoaderFunctionArgs,- SerializeFrom+ LoaderFunctionArgs} from "react-router";import { getLocationsList } from "~/modules/resources";import { getCompanyId, locationsQuery } from "~/utils/react-query";@@ -22,7 +21,9 @@ export async function clientLoader({ serverLoader }: ClientLoaderFunctionArgs) {const queryKey = locationsQuery(companyId).queryKey;const data =- window?.clientCache?.getQueryData<SerializeFrom<typeof loader>>(queryKey);+ window?.clientCache?.getQueryData<Awaited<ReturnType<typeof loader>>>(+ queryKey+ );if (!data) {const serverData = await serverLoader<typeof loader>();diff --git a/apps/erp/app/routes/api+/resources.processes.tsx b/apps/erp/app/routes/api+/resources.processes.tsxindex c3a98b4a73..dfe39d5fd7 100644--- a/apps/erp/app/routes/api+/resources.processes.tsx+++ b/apps/erp/app/routes/api+/resources.processes.tsx@@ -1,8 +1,7 @@import { requirePermissions } from "@carbon/auth/auth.server";import type {ClientLoaderFunctionArgs,- LoaderFunctionArgs,- SerializeFrom+ LoaderFunctionArgs} from "react-router";import { getProcessesList } from "~/modules/resources";import { getCompanyId, processesQuery } from "~/utils/react-query";@@ -22,7 +21,9 @@ export async function clientLoader({ serverLoader }: ClientLoaderFunctionArgs) {const queryKey = processesQuery(companyId).queryKey;const data =- window?.clientCache?.getQueryData<SerializeFrom<typeof loader>>(queryKey);+ window?.clientCache?.getQueryData<Awaited<ReturnType<typeof loader>>>(+ queryKey+ );if (!data) {const serverData = await serverLoader<typeof loader>();diff --git a/apps/erp/app/routes/api+/resources.work-centers.tsx b/apps/erp/app/routes/api+/resources.work-centers.tsxindex d80335f42d..9a580a505b 100644--- a/apps/erp/app/routes/api+/resources.work-centers.tsx+++ b/apps/erp/app/routes/api+/resources.work-centers.tsx@@ -1,8 +1,7 @@import { requirePermissions } from "@carbon/auth/auth.server";import type {ClientLoaderFunctionArgs,- LoaderFunctionArgs,- SerializeFrom+ LoaderFunctionArgs} from "react-router";import { getWorkCentersList } from "~/modules/resources";import { getCompanyId, workCentersQuery } from "~/utils/react-query";@@ -21,8 +20,7 @@ export async function clientLoader({ serverLoader }: ClientLoaderFunctionArgs) {}const queryKey = workCentersQuery(companyId).queryKey;- const data =- window?.clientCache?.getQueryData<SerializeFrom<typeof loader>>(queryKey);+ const data = window?.clientCache?.getQueryData<typeof loader>(queryKey);if (!data) {const serverData = await serverLoader<typeof loader>();diff --git a/apps/erp/app/routes/api+/sales.customer-locations.$customerId.ts b/apps/erp/app/routes/api+/sales.customer-locations.$customerId.tsindex eb37d43bd3..c96097449f 100644--- a/apps/erp/app/routes/api+/sales.customer-locations.$customerId.ts+++ b/apps/erp/app/routes/api+/sales.customer-locations.$customerId.ts@@ -3,8 +3,7 @@ import { requirePermissions } from "@carbon/auth/auth.server";import { flash } from "@carbon/auth/session.server";import type {ClientLoaderFunctionArgs,- LoaderFunctionArgs,- SerializeFrom+ LoaderFunctionArgs} from "react-router";import { data } from "react-router";import { getCustomerLocations } from "~/modules/sales";@@ -48,7 +47,9 @@ export async function clientLoader({const queryKey = customerLocationsQuery(customerId).queryKey;const data =- window?.clientCache?.getQueryData<SerializeFrom<typeof loader>>(queryKey);+ window?.clientCache?.getQueryData<Awaited<ReturnType<typeof loader>>>(+ queryKey+ );if (!data) {const serverData = await serverLoader<typeof loader>();diff --git a/apps/erp/app/routes/api+/sales.customer-types.ts b/apps/erp/app/routes/api+/sales.customer-types.tsindex 6679084bd0..31ffd7db6c 100644--- a/apps/erp/app/routes/api+/sales.customer-types.ts+++ b/apps/erp/app/routes/api+/sales.customer-types.ts@@ -1,8 +1,7 @@import { requirePermissions } from "@carbon/auth/auth.server";import type {ClientLoaderFunctionArgs,- LoaderFunctionArgs,- SerializeFrom+ LoaderFunctionArgs} from "react-router";import { getCustomerTypesList } from "~/modules/sales";import { customerTypesQuery, getCompanyId } from "~/utils/react-query";@@ -24,7 +23,9 @@ export async function clientLoader({ serverLoader }: ClientLoaderFunctionArgs) {const queryKey = customerTypesQuery(companyId).queryKey;const data =- window?.clientCache?.getQueryData<SerializeFrom<typeof loader>>(queryKey);+ window?.clientCache?.getQueryData<Awaited<ReturnType<typeof loader>>>(+ queryKey+ );if (!data) {const serverData = await serverLoader<typeof loader>();diff --git a/apps/erp/app/routes/api+/webhook.tables.ts b/apps/erp/app/routes/api+/webhook.tables.tsindex d468289194..91d789239d 100644--- a/apps/erp/app/routes/api+/webhook.tables.ts+++ b/apps/erp/app/routes/api+/webhook.tables.ts@@ -1,8 +1,7 @@import { requirePermissions } from "@carbon/auth/auth.server";import type {ClientLoaderFunctionArgs,- LoaderFunctionArgs,- SerializeFrom+ LoaderFunctionArgs} from "react-router";import { getWebhookTables } from "~/modules/settings/settings.service";import { getCompanyId, webhookTablesQuery } from "~/utils/react-query";@@ -22,7 +21,9 @@ export async function clientLoader({ serverLoader }: ClientLoaderFunctionArgs) {const queryKey = webhookTablesQuery().queryKey;const data =- window?.clientCache?.getQueryData<SerializeFrom<typeof loader>>(queryKey);+ window?.clientCache?.getQueryData<Awaited<ReturnType<typeof loader>>>(+ queryKey+ );if (!data) {const serverData = await serverLoader<typeof loader>();diff --git a/apps/erp/app/routes/x+/production+/_index.tsx b/apps/erp/app/routes/x+/production+/_index.tsxindex f0e4737825..7f39e26ae8 100644--- a/apps/erp/app/routes/x+/production+/_index.tsx+++ b/apps/erp/app/routes/x+/production+/_index.tsx@@ -72,7 +72,7 @@ import type { ActiveProductionEvent } from "~/modules/production";import { getActiveProductionEvents, KPIs } from "~/modules/production";import { getDeadlineIcon } from "~/modules/production/ui/Jobs";import type { WorkCenter } from "~/modules/resources";-import { getWorkCentersList } from "~/modules/resources";+import { getWorkCentersListWithBlockingStatus } from "~/modules/resources";import { chartIntervals } from "~/modules/shared";import type { loader as kpiLoader } from "~/routes/api+/production.kpi.$key";import { path } from "~/utils/path";@@ -110,7 +110,7 @@ export async function loader({ request }: LoaderFunctionArgs) {.select("id,status,assignee").eq("companyId", companyId).eq("assignee", userId),- getWorkCentersList(client, companyId)+ getWorkCentersListWithBlockingStatus(client, companyId)]);return {@@ -629,12 +629,18 @@ type JobOperationMetaData = {salesOrderReadableId?: string | null;};+type WorkCenterWithBlocking = WorkCenter & {+ isBlocked?: boolean | null;+ blockingDispatchId?: string | null;+ blockingDispatchReadableId?: string | null;+};+function WorkCenterCards({events: initialEvents,workCenters}: {events: ActiveProductionEvent[];- workCenters: WorkCenter[];+ workCenters: WorkCenterWithBlocking[];}) {const [events, setEvents] = useState<ActiveProductionEvent[]>(initialEvents);const [jobOperationMetaData, setJobOperationMetaData] = useState<@@ -819,19 +825,49 @@ function WorkCenterCards({? new Date(dueDate) < new Date(): false;+ const isBlocked = workCenter.isBlocked && workCenter.blockingDispatchId;+return (<Cardkey={workCenter.id}className="p-0 h-[300px] col-span-6 lg:col-span-3 xl:col-span-2">- <HStack className="justify-between w-full relative">+ <HStack+ className={cn(+ "justify-between w-full relative rounded-t-lg",+ isBlocked+ ? "bg-red-100 text-red-800 dark:bg-red-900/50 dark:text-red-400"+ : ""+ )}+ ><CardHeader><CardTitle className="line-clamp-2 text-base">{workCenter.name}</CardTitle>+ {isBlocked && (+ <Tooltip>+ <TooltipTrigger asChild>+ <Link+ to={path.to.maintenanceDispatch(+ workCenter.blockingDispatchId!+ )}+ className="inline-flex items-center gap-1 text-xs font-normal"+ >+ <span>+ Blocked by {workCenter.blockingDispatchReadableId}+ </span>+ </Link>+ </TooltipTrigger>+ <TooltipContent>+ <p>View maintenance dispatch</p>+ </TooltipContent>+ </Tooltip>+ )}</CardHeader><CardAction className="pt-2">- <PulsingDot inactive={!hasEvents} className="mt-2" />+ {!isBlocked && (+ <PulsingDot inactive={!hasEvents} className="mt-2" />+ )}</CardAction></HStack><CardContent className="flex items-start justify-start p-6 pt-3 border-t">diff --git a/apps/erp/app/routes/x+/schedule+/operations.tsx b/apps/erp/app/routes/x+/schedule+/operations.tsxindex bc2bbb4aac..9ba8457118 100644--- a/apps/erp/app/routes/x+/schedule+/operations.tsx+++ b/apps/erp/app/routes/x+/schedule+/operations.tsx@@ -180,6 +180,12 @@ export async function loader({ request }: LoaderFunctionArgs) {);}+ if (selectedProcessIds.length) {+ filteredOperations = filteredOperations.filter((op) =>+ selectedProcessIds.includes(op.processId)+ );+ }+if (selectedTags.length) {filteredOperations = filteredOperations.filter((op) => {if (op.tags) {@@ -210,15 +216,13 @@ export async function loader({ request }: LoaderFunctionArgs) {if (selectedWorkCenterIds.length && selectedProcessIds.length) {return (selectedWorkCenterIds.includes(wc.id!) &&- wc.processes?.some((p: { id: string }) =>- selectedProcessIds.includes(p.id)- )+ wc.processes?.some((p: string) => selectedProcessIds.includes(p)));} else if (selectedWorkCenterIds.length) {return selectedWorkCenterIds.includes(wc.id!);} else if (selectedProcessIds.length) {- return wc.processes?.some((p: { id: string }) =>- selectedProcessIds.includes(p.id)+ return wc.processes?.some((p: string) =>+ selectedProcessIds.includes(p));}return true;@@ -230,7 +234,10 @@ export async function loader({ request }: LoaderFunctionArgs) {id: wc.id!,title: wc.name!,type: wc.processes ?? [],- active: activeWorkCenters.has(wc.id)+ active: activeWorkCenters.has(wc.id),+ isBlocked: wc.isBlocked ?? false,+ blockingDispatchId: wc.blockingDispatchId ?? undefined,+ blockingDispatchReadableId: wc.blockingDispatchReadableId ?? undefined})).sort((a, b) => a.title.localeCompare(b.title)) satisfies Column[],items: (filteredOperations.map((op) => {diff --git a/apps/mes/app/components/JobOperation/JobOperation.tsx b/apps/mes/app/components/JobOperation/JobOperation.tsxindex 5c46810564..7bc2f487a5 100644--- a/apps/mes/app/components/JobOperation/JobOperation.tsx+++ b/apps/mes/app/components/JobOperation/JobOperation.tsx@@ -74,9 +74,10 @@ import {LuQrCode,LuSquareUser,LuTimer,- LuTriangleAlert+ LuTriangleAlert,+ LuWrench} from "react-icons/lu";-import { Await, useFetcher, useNavigate, useParams } from "react-router";+import { Await, Link, useFetcher, useNavigate, useParams } from "react-router";import {DeadlineIcon,FileIcon,@@ -153,7 +154,15 @@ type JobOperationProps = {job: Job;thumbnailPath: string | null;trackedEntities: TrackedEntity[];- workCenter: Promise<PostgrestSingleResponse<{ name: string; id: string }>>;+ workCenter: Promise<+ PostgrestSingleResponse<{+ name: string;+ id: string;+ isBlocked: boolean | null;+ blockingDispatchId: string | null;+ blockingDispatchReadableId: string | null;+ }>+ >;};export const JobOperation = ({@@ -1852,14 +1861,46 @@ export const JobOperation = ({<Await resolve={workCenter}>{(resolvedWorkCenter) =>resolvedWorkCenter.data && (- <HStack className="justify-between items-start w-full">- <Heading size="h4" className="line-clamp-1">- {resolvedWorkCenter.data?.name}- </Heading>- <MaintenanceDispatch- workCenter={resolvedWorkCenter.data}- />- </HStack>+ <VStack spacing={1}>+ <HStack className="justify-between items-start w-full">+ <Heading size="h4" className="line-clamp-1">+ {resolvedWorkCenter.data?.name}+ </Heading>+ <MaintenanceDispatch+ workCenter={resolvedWorkCenter.data}+ />+ </HStack>+ {resolvedWorkCenter.data?.isBlocked &&+ resolvedWorkCenter.data?.blockingDispatchId && (+ <Tooltip>+ <TooltipTrigger asChild>+ <Link+ to={path.to.maintenanceDetail(+ resolvedWorkCenter.data+ .blockingDispatchId+ )}+ >+ <Badge+ variant="red"+ className="inline-flex items-center gap-1"+ >+ <LuWrench className="h-3 w-3" />+ <span>Blocked by maintenance</span>+ </Badge>+ </Link>+ </TooltipTrigger>+ <TooltipContent>+ <p>+ Blocked by{" "}+ {+ resolvedWorkCenter.data+ ?.blockingDispatchReadableId+ }+ </p>+ </TooltipContent>+ </Tooltip>+ )}+ </VStack>)}</Await>diff --git a/apps/mes/app/components/Kanban/components/ColumnCard.tsx b/apps/mes/app/components/Kanban/components/ColumnCard.tsxindex 86185cac66..e94ea7b065 100644--- a/apps/mes/app/components/Kanban/components/ColumnCard.tsx+++ b/apps/mes/app/components/Kanban/components/ColumnCard.tsx@@ -3,7 +3,10 @@ import {IconButton,PulsingDot,ScrollArea,- ScrollBar+ ScrollBar,+ Tooltip,+ TooltipContent,+ TooltipTrigger} from "@carbon/react";import { formatDurationMilliseconds } from "@carbon/utils";import { useDndContext } from "@dnd-kit/core";@@ -12,7 +15,9 @@ import { CSS } from "@dnd-kit/utilities";import { cva } from "class-variance-authority";import { useMemo } from "react";import { LuGripVertical } from "react-icons/lu";+import { Link } from "react-router";import { useUrlParams } from "~/hooks";+import { path } from "~/utils/path";import type { Column, ColumnDragData, DisplaySettings, Item } from "../types";import { ItemCard } from "./ItemCard";@@ -96,13 +101,36 @@ export function ColumnCard({: `h-[calc(100dvh-var(--header-height)*2)]`)}>- <div className="p-4 w-full font-semibold text-left flex flex-row space-between items-center sticky top-0 bg-card z-1 border-b">+ <div+ className={cn(+ "p-4 w-full font-semibold text-left flex flex-row space-between items-center sticky top-0 z-1 border-b",+ column.isBlocked && column.blockingDispatchId+ ? "bg-red-100 text-red-800 dark:bg-red-900/50 dark:text-red-400"+ : "bg-card"+ )}+ ><div className="flex flex-grow items-start space-x-2">- <PulsingDot inactive={!column.active} className="mt-2" />+ {!column.isBlocked && (+ <PulsingDot inactive={!column.active} className="mt-2" />+ )}<div className="flex flex-col flex-grow"><span className="mr-auto truncate"> {column.title}</span>- {totalDuration > 0 ? (+ {column.isBlocked && column.blockingDispatchId ? (+ <Tooltip>+ <TooltipTrigger asChild>+ <Link+ to={path.to.maintenanceDetail(column.blockingDispatchId)}+ className="inline-flex items-center gap-1 text-xs font-normal"+ >+ <span>Blocked by {column.blockingDispatchReadableId}</span>+ </Link>+ </TooltipTrigger>+ <TooltipContent>+ <p>View maintenance dispatch</p>+ </TooltipContent>+ </Tooltip>+ ) : totalDuration > 0 ? (<span className="text-muted-foreground text-xs">{formatDurationMilliseconds(totalDuration)}</span>diff --git a/apps/mes/app/components/Kanban/types.ts b/apps/mes/app/components/Kanban/types.tsindex eb5b8d4c3d..af708a4743 100644--- a/apps/mes/app/components/Kanban/types.ts+++ b/apps/mes/app/components/Kanban/types.ts@@ -5,7 +5,10 @@ export const columnValidator = z.object({id: z.string(),title: z.string(),active: z.boolean().optional(),- type: z.array(z.string())+ type: z.array(z.string()),+ isBlocked: z.boolean().optional(),+ blockingDispatchId: z.string().optional(),+ blockingDispatchReadableId: z.string().optional()});export type Column = z.infer<typeof columnValidator>;diff --git a/apps/mes/app/components/MaintenanceOeeImpact.tsx b/apps/mes/app/components/MaintenanceOeeImpact.tsxnew file mode 100644index 0000000000..75e62e55f2--- /dev/null+++ b/apps/mes/app/components/MaintenanceOeeImpact.tsx@@ -0,0 +1,65 @@+import type { Database } from "@carbon/database";+import { Badge, cn } from "@carbon/react";+import {+ LuCalendar,+ LuCircleCheck,+ LuCircleX,+ LuTriangleAlert+} from "react-icons/lu";++type MaintenanceOeeImpactProps = {+ oeeImpact?: Database["public"]["Enums"]["oeeImpact"] | null;+ className?: string;+};++function MaintenanceOeeImpact({+ oeeImpact,+ className+}: MaintenanceOeeImpactProps) {+ switch (oeeImpact) {+ case "Down":+ return (+ <Badge+ variant="red"+ className={cn(className, "inline-flex items-center gap-1")}+ >+ <LuCircleX className="h-3 w-3" />+ Down+ </Badge>+ );+ case "Planned":+ return (+ <Badge+ variant="secondary"+ className={cn(className, "inline-flex items-center gap-1")}+ >+ <LuCalendar className="h-3 w-3" />+ Planned+ </Badge>+ );+ case "Impact":+ return (+ <Badge+ variant="yellow"+ className={cn(className, "inline-flex items-center gap-1")}+ >+ <LuTriangleAlert className="h-3 w-3" />+ Impact+ </Badge>+ );+ case "No Impact":+ return (+ <Badge+ variant="blue"+ className={cn(className, "inline-flex items-center gap-1")}+ >+ <LuCircleCheck className="h-3 w-3" />+ No Impact+ </Badge>+ );+ default:+ return null;+ }+}++export default MaintenanceOeeImpact;diff --git a/apps/mes/app/routes/x+/dispatch.$dispatchId.tsx b/apps/mes/app/routes/x+/dispatch.$dispatchId.tsxindex 1a2aff3ad9..2643603e9b 100644--- a/apps/mes/app/routes/x+/dispatch.$dispatchId.tsx+++ b/apps/mes/app/routes/x+/dispatch.$dispatchId.tsx@@ -26,6 +26,7 @@ import { HighPriorityIcon } from "~/assets/icons/HighPriorityIcon";import { LowPriorityIcon } from "~/assets/icons/LowPriorityIcon";import { MediumPriorityIcon } from "~/assets/icons/MediumPriorityIcon";import EmployeeAvatar from "~/components/EmployeeAvatar";+import MaintenanceOeeImpact from "~/components/MaintenanceOeeImpact";import {getActiveMaintenanceEventByEmployee,getMaintenanceDispatch,@@ -116,21 +117,6 @@ function MaintenanceStatus({ status, className }: MaintenanceStatusProps) {}}-function getOeeImpactBadge(- oeeImpact: Database["public"]["Enums"]["oeeImpact"]-) {- switch (oeeImpact) {- case "Down":- return <Badge variant="destructive">Down</Badge>;- case "Planned":- return <Badge variant="secondary">Planned</Badge>;- case "Impact":- return <Badge variant="yellow">Impact</Badge>;- default:- return <Badge variant="outline">No Impact</Badge>;- }-}-function formatDuration(seconds: number): string {const hours = Math.floor(seconds / 3600);const minutes = Math.floor((seconds % 3600) / 60);@@ -212,7 +198,7 @@ export default function MaintenanceDetailRoute() {{dispatch.workCenter?.name ?? "Unknown"}</span><HStack className="mt-2">- {getOeeImpactBadge(dispatch.oeeImpact)}+ <MaintenanceOeeImpact oeeImpact={dispatch.oeeImpact} /><Badge variant="outline">{dispatch.severity}</Badge></HStack></VStack>diff --git a/apps/mes/app/routes/x+/operations.tsx b/apps/mes/app/routes/x+/operations.tsxindex 47a8185ed2..85814efafb 100644--- a/apps/mes/app/routes/x+/operations.tsx+++ b/apps/mes/app/routes/x+/operations.tsx@@ -177,6 +177,12 @@ export async function loader({ request }: LoaderFunctionArgs) {);}+ if (selectedProcessIds.length) {+ filteredOperations = filteredOperations.filter((op) =>+ selectedProcessIds.includes(op.processId)+ );+ }+if (search) {filteredOperations = filteredOperations.filter((op) =>@@ -191,15 +197,13 @@ export async function loader({ request }: LoaderFunctionArgs) {if (selectedWorkCenterIds.length && selectedProcessIds.length) {return (selectedWorkCenterIds.includes(wc.id!) &&- wc.processes?.some((p: { id: string }) =>- selectedProcessIds.includes(p.id)- )+ wc.processes?.some((p: string) => selectedProcessIds.includes(p)));} else if (selectedWorkCenterIds.length) {return selectedWorkCenterIds.includes(wc.id!);} else if (selectedProcessIds.length) {- return wc.processes?.some((p: { id: string }) =>- selectedProcessIds.includes(p.id)+ return wc.processes?.some((p: string) =>+ selectedProcessIds.includes(p));}return true;@@ -216,11 +220,14 @@ export async function loader({ request }: LoaderFunctionArgs) {return data({columns: filteredWorkCenters- .map((wc) => ({+ .map((wc: any) => ({id: wc.id!,title: wc.name!,type: wc.processes ?? [],- active: activeWorkCenters.has(wc.id)+ active: activeWorkCenters.has(wc.id),+ isBlocked: wc.isBlocked ?? false,+ blockingDispatchId: wc.blockingDispatchId ?? undefined,+ blockingDispatchReadableId: wc.blockingDispatchReadableId ?? undefined})).sort((a, b) => a.title.localeCompare(b.title)) satisfies Column[],items: (filteredOperations.map((op) => {diff --git a/apps/mes/app/services/operations.service.ts b/apps/mes/app/services/operations.service.tsindex cbab35e3e3..bebe8f2634 100644--- a/apps/mes/app/services/operations.service.ts+++ b/apps/mes/app/services/operations.service.ts@@ -593,8 +593,10 @@ export async function getWorkCenter(workCenterId: string) {return client- .from("workCenter")- .select("id, name")+ .from("workCentersWithBlockingStatus")+ .select(+ "id, name, isBlocked, blockingDispatchId, blockingDispatchReadableId"+ ).eq("id", workCenterId).single();}@@ -603,12 +605,43 @@ export async function getWorkCentersByLocation(client: SupabaseClient<Database>,locationId: string) {- return client- .from("workCenters")- .select("*")- .eq("locationId", locationId)- .eq("active", true)- .order("name", { ascending: true });+ // Query both views and merge - workCenters has processes, workCentersWithBlockingStatus has blocking info+ const [workCentersResult, blockingStatusResult] = await Promise.all([+ client+ .from("workCenters")+ .select("*")+ .eq("locationId", locationId)+ .eq("active", true)+ .order("name", { ascending: true }),+ client+ .from("workCentersWithBlockingStatus")+ .select("id, isBlocked, blockingDispatchId, blockingDispatchReadableId")+ .eq("locationId", locationId)+ .eq("active", true)+ ]);++ if (workCentersResult.error) {+ return workCentersResult;+ }++ // Create a map of blocking status by work center id+ const blockingStatusMap = new Map(+ blockingStatusResult.data?.map((wc) => [wc.id, wc]) ?? []+ );++ // Merge the data+ const mergedData = workCentersResult.data?.map((wc) => {+ const blockingStatus = blockingStatusMap.get(wc.id);+ return {+ ...wc,+ isBlocked: blockingStatus?.isBlocked ?? false,+ blockingDispatchId: blockingStatus?.blockingDispatchId ?? null,+ blockingDispatchReadableId:+ blockingStatus?.blockingDispatchReadableId ?? null+ };+ });++ return { data: mergedData, error: null };}export async function getWorkCentersByCompany(