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(mes): board and list views for the assigned-to-me page
sidgaikwad85f48624609f
diff --git a/apps/mes/app/routes/x+/assigned.tsx b/apps/mes/app/routes/x+/assigned.tsxindex aa01a190df..739cb72256 100644--- a/apps/mes/app/routes/x+/assigned.tsx+++ b/apps/mes/app/routes/x+/assigned.tsx@@ -2,24 +2,28 @@ import { requirePermissions } from "@carbon/auth/auth.server";import { getCarbonServiceRole } from "@carbon/auth/client.server";import {Button,+ ClientOnly,Heading,Input,+ LoadingBars,SidebarTrigger,- useIsMobile+ ToggleGroup,+ ToggleGroupItem,+ useLocalStorage} from "@carbon/react";import { Trans, useLingui } from "@lingui/react/macro";-import { useEffect, useMemo, useRef, useState } from "react";-import { LuSearch, LuTriangleAlert } from "react-icons/lu";-import type { ImperativePanelHandle } from "react-resizable-panels";+import { useMemo, useState } from "react";+import { LuKanban, LuList, LuSearch, LuTriangleAlert } from "react-icons/lu";import type { LoaderFunctionArgs } from "react-router";-import { useLoaderData, useParams } from "react-router";+import { useLoaderData } from "react-router";import { OperationsList } from "~/components";+import type { Column, DisplaySettings, Item } from "~/components/Kanban";+import { Kanban } from "~/components/Kanban";import { userContext } from "~/context";import {getJobOperationsAssignedToEmployee,getWorkCentersByLocation} from "~/services/operations.service";-import type { Operation } from "~/services/types";import { makeDurations } from "~/utils/durations";export async function loader({ context, request }: LoaderFunctionArgs) {@@ -39,22 +43,31 @@ export async function loader({ context, request }: LoaderFunctionArgs) {};}+type AssignedView = "board" | "list";++const ASSIGNED_VIEW_KEY = "assigned-view";++const displaySettings: DisplaySettings = {+ emptyWorkCenters: false,+ showCustomer: false,+ showDescription: true,+ showDueDate: true,+ showDuration: true,+ showEmployee: false,+ showProgress: false,+ showStatus: true,+ showSalesOrder: true,+ showThumbnail: true+};+export default function AssignedRoute() {const { t } = useLingui();const { operations, workCenters } = useLoaderData<typeof loader>();const [searchTerm, setSearchTerm] = useState("");-- const panelRef = useRef<ImperativePanelHandle>(null);- const isMobile = useIsMobile();- const { operationId } = useParams();-- useEffect(() => {- if (isMobile && !!operationId) {- panelRef.current?.collapse();- } else {- panelRef.current?.expand();- }- }, [isMobile, operationId]);+ const [view, setView] = useLocalStorage<AssignedView>(+ ASSIGNED_VIEW_KEY,+ "board"+ );const filteredOperations = useMemo(() => {if (!searchTerm) return operations;@@ -68,20 +81,78 @@ export default function AssignedRoute() {);}, [operations, searchTerm]);- const filteredOperationsByWorkCenter = useMemo(() => {- return filteredOperations.reduce<Record<string, Operation[]>>(- (acc, operation) => {- const workCenter = operation.workCenterId;- if (!workCenter) return acc;- acc[workCenter] = [...(acc[workCenter] || []), operation];- return acc;- },- {}- );- }, [filteredOperations]);+ const { columns, items } = useMemo(() => {+ const activeWorkCenterIds = new Set<string>();+ const workCenterIdsWithOperations = new Set<string>();++ for (const operation of filteredOperations) {+ if (!operation.workCenterId) continue;+ workCenterIdsWithOperations.add(operation.workCenterId);+ if (operation.operationStatus === "In Progress") {+ activeWorkCenterIds.add(operation.workCenterId);+ }+ }++ // Only work centers with assigned operations become columns, so empty+ // work centers are always hidden on this board.+ const columns = Array.from(workCenterIdsWithOperations)+ .map((workCenterId) => {+ const workCenter = workCenters.find((wc) => wc.id === workCenterId);+ return {+ id: workCenterId,+ title: workCenter?.name ?? "",+ type: workCenter?.processes ?? [],+ active: activeWorkCenterIds.has(workCenterId),+ isBlocked: workCenter?.isBlocked ?? false,+ blockingDispatchId: workCenter?.blockingDispatchId ?? undefined,+ blockingDispatchReadableId:+ workCenter?.blockingDispatchReadableId ?? undefined+ };+ })+ .sort((a, b) => a.title.localeCompare(b.title)) satisfies Column[];++ const items = filteredOperations+ .filter((operation) => Boolean(operation.workCenterId))+ .map((operation, index) => ({+ id: operation.id,+ assignee: operation.assignee,+ tags: operation.tags,+ columnId: operation.workCenterId,+ columnType: operation.processId,+ // the RPC orders by priority but does not return it+ priority: index,+ title: operation.jobReadableId,+ subtitle: operation.itemReadableId,+ description: operation.description,+ dueDate: operation.operationDueDate,+ duration:+ operation.setupDuration ++ Math.max(operation.laborDuration, operation.machineDuration),+ deadlineType: operation.jobDeadlineType,+ customerId: operation.jobCustomerId,+ operationQuantity: operation.operationQuantity,+ targetQuantity: operation.targetQuantity ?? operation.operationQuantity,+ jobReadableId: operation.jobReadableId,+ itemReadableId: operation.itemReadableId,+ itemDescription: operation.itemDescription,+ salesOrderReadableId: operation.salesOrderReadableId,+ salesOrderId: operation.salesOrderId,+ salesOrderLineId: operation.salesOrderLineId,+ status: operation.operationStatus,+ thumbnailPath: operation.thumbnailPath,+ quantity: operation.operationQuantity,+ quantityCompleted: operation.quantityComplete,+ quantityScrapped: operation.quantityScrapped,+ setupDuration: operation.setupDuration,+ laborDuration: operation.laborDuration,+ machineDuration: operation.machineDuration+ })) satisfies Item[];++ return { columns, items };+ }, [filteredOperations, workCenters]);return (- <div className="flex flex-col flex-1">+ <div className="flex flex-col flex-1 min-w-0"><header className="sticky top-0 z-10 flex h-[var(--header-height)] overflow-y-scroll scrollbar-thin scrollbar-thumb-accent scrollbar-track-transparent shrink-0 items-center gap-2 transition-[width,height] ease-linear group-has-[[data-collapsible=icon]]/sidebar-wrapper:h-12 border-b bg-background"><div className="flex items-center gap-2 px-2"><SidebarTrigger />@@ -104,27 +175,50 @@ export default function AssignedRoute() {className="pl-8"/></div>+ <ToggleGroup+ type="single"+ value={view}+ onValueChange={(value) => {+ if (value) setView(value as AssignedView);+ }}+ >+ <ToggleGroupItem value="board" aria-label={t`Board view`}>+ <LuKanban />+ </ToggleGroupItem>+ <ToggleGroupItem value="list" aria-label={t`List view`}>+ <LuList />+ </ToggleGroupItem>+ </ToggleGroup></div></div></div>- {Object.keys(filteredOperationsByWorkCenter).length > 0 ? (- <div className="flex flex-col flex-1 mt-4">- {Object.entries(filteredOperationsByWorkCenter).map(- ([workCenterId, operations]) => (- <div key={workCenterId} className="flex flex-col">- <div className="bg-muted px-4 py-2 border-y">- <h3 className="font-medium">- {workCenters.find((wc) => wc.id === workCenterId)?.name}- </h3>- </div>- <div className="grid grid-cols-[repeat(auto-fill,minmax(min(100%,330px),1fr))] p-4 gap-4">- <OperationsList operations={operations} />+ {filteredOperations.length > 0 ? (+ view === "board" ? (+ <ClientOnly+ fallback={+ <div className="flex w-full h-[calc(100%-var(--header-height))] items-center justify-center">+ <LoadingBars />+ </div>+ }+ >+ {() => (+ <div className="flex flex-grow items-stretch overflow-hidden relative">+ <div className="flex flex-1 min-h-full w-full relative">+ <Kanban+ columns={columns}+ items={items}+ {...displaySettings}+ /></div></div>- )- )}- </div>+ )}+ </ClientOnly>+ ) : (+ <div className="grid grid-cols-[repeat(auto-fill,minmax(min(100%,330px),1fr))] p-4 gap-4">+ <OperationsList operations={filteredOperations} />+ </div>+ )) : searchTerm ? (<div className="flex flex-col flex-1 w-full h-[calc(100%-var(--header-height)*2)] items-center justify-center gap-4"><div className="flex justify-center items-center h-12 w-12 rounded-full bg-foreground text-background">diff --git a/packages/locale/locales/de/mes.po b/packages/locale/locales/de/mes.poindex 3c34de84c3..4a00618c7a 100644--- a/packages/locale/locales/de/mes.po+++ b/packages/locale/locales/de/mes.po@@ -176,6 +176,9 @@ msgstr "Blockiert durch {0}"msgid "Blocking"msgstr "Blockierend"+msgid "Board view"+msgstr "Boardansicht"+msgid "But don't worry. You can use the forgot password flow to request a new magic link."msgstr "Aber machen Sie sich keine Sorgen. Sie können den Passwort-Zurücksetzen-Ablauf verwenden, um einen neuen Magic Link anzufordern."@@ -630,6 +633,9 @@ msgstr "Lassen Sie uns etwas bauen"msgid "lines"msgstr "Zeilen"+msgid "List view"+msgstr "Listenansicht"+msgid "Loading item details..."msgstr "Artikeldetails werden geladen..."diff --git a/packages/locale/locales/en/mes.po b/packages/locale/locales/en/mes.poindex fda646b2fb..f593c86a67 100644--- a/packages/locale/locales/en/mes.po+++ b/packages/locale/locales/en/mes.po@@ -176,6 +176,9 @@ msgstr "Blocked by {0}"msgid "Blocking"msgstr "Blocking"+msgid "Board view"+msgstr "Board view"+msgid "But don't worry. You can use the forgot password flow to request a new magic link."msgstr "But don't worry. You can use the forgot password flow to request a new magic link."@@ -630,6 +633,9 @@ msgstr "Let's build something"msgid "lines"msgstr "lines"+msgid "List view"+msgstr "List view"+msgid "Loading item details..."msgstr "Loading item details..."diff --git a/packages/locale/locales/es/mes.po b/packages/locale/locales/es/mes.poindex 38f4217ec7..d04b19997f 100644--- a/packages/locale/locales/es/mes.po+++ b/packages/locale/locales/es/mes.po@@ -176,6 +176,9 @@ msgstr "Bloqueado por {0}"msgid "Blocking"msgstr "Bloqueando"+msgid "Board view"+msgstr "Vista de tablero"+msgid "But don't worry. You can use the forgot password flow to request a new magic link."msgstr "Pero no te preocupes. Puedes usar el flujo de contraseña olvidada para solicitar un nuevo enlace mágico."@@ -630,6 +633,9 @@ msgstr "Construyamos algo"msgid "lines"msgstr "líneas"+msgid "List view"+msgstr "Vista de lista"+msgid "Loading item details..."msgstr "Cargando detalles del artículo..."diff --git a/packages/locale/locales/fr/mes.po b/packages/locale/locales/fr/mes.poindex 0fe8edcce5..1352a32128 100644--- a/packages/locale/locales/fr/mes.po+++ b/packages/locale/locales/fr/mes.po@@ -176,6 +176,9 @@ msgstr "Bloqué par {0}"msgid "Blocking"msgstr "Bloquant"+msgid "Board view"+msgstr "Vue tableau"+msgid "But don't worry. You can use the forgot password flow to request a new magic link."msgstr "Mais ne vous inquiétez pas. Vous pouvez utiliser la procédure de réinitialisation de mot de passe pour demander un nouveau lien magique."@@ -630,6 +633,9 @@ msgstr "Construisons quelque chose"msgid "lines"msgstr "lignes"+msgid "List view"+msgstr "Vue liste"+msgid "Loading item details..."msgstr "Chargement des détails de l'article..."diff --git a/packages/locale/locales/hi/mes.po b/packages/locale/locales/hi/mes.poindex a2cd4e970a..e226cd7f20 100644--- a/packages/locale/locales/hi/mes.po+++ b/packages/locale/locales/hi/mes.po@@ -176,6 +176,9 @@ msgstr "{0} द्वारा अवरुद्ध"msgid "Blocking"msgstr "अवरुद्ध"+msgid "Board view"+msgstr "बोर्ड दृश्य"+msgid "But don't worry. You can use the forgot password flow to request a new magic link."msgstr "लेकिन चिंता न करें। आप नया जादुई लिंक अनुरोध करने के लिए भूल गए पासवर्ड प्रवाह का उपयोग कर सकते हैं।"@@ -630,6 +633,9 @@ msgstr "चलिए कुछ बनाते हैं"msgid "lines"msgstr "लाइनें"+msgid "List view"+msgstr "सूची दृश्य"+msgid "Loading item details..."msgstr "आइटम विवरण लोड हो रहे हैं..."diff --git a/packages/locale/locales/it/mes.po b/packages/locale/locales/it/mes.poindex 49a5e5ae83..1c9a96f414 100644--- a/packages/locale/locales/it/mes.po+++ b/packages/locale/locales/it/mes.po@@ -176,6 +176,9 @@ msgstr "Bloccato da {0}"msgid "Blocking"msgstr "Bloccante"+msgid "Board view"+msgstr "Vista bacheca"+msgid "But don't worry. You can use the forgot password flow to request a new magic link."msgstr "Ma non preoccuparti. Puoi utilizzare il flusso password dimenticata per richiedere un nuovo magic link."@@ -630,6 +633,9 @@ msgstr "Costruiamo qualcosa"msgid "lines"msgstr "righe"+msgid "List view"+msgstr "Vista elenco"+msgid "Loading item details..."msgstr "Caricamento dettagli articolo..."diff --git a/packages/locale/locales/ja/mes.po b/packages/locale/locales/ja/mes.poindex da0ff30050..caa69ebc73 100644--- a/packages/locale/locales/ja/mes.po+++ b/packages/locale/locales/ja/mes.po@@ -176,6 +176,9 @@ msgstr "{0} によりブロック中"msgid "Blocking"msgstr "ブロック中"+msgid "Board view"+msgstr "ボード表示"+msgid "But don't worry. You can use the forgot password flow to request a new magic link."msgstr "ご心配なく。パスワード忘却フローを使用して新しいマジックリンクをリクエストできます。"@@ -630,6 +633,9 @@ msgstr "さあ、何かを作りましょう"msgid "lines"msgstr "行"+msgid "List view"+msgstr "リスト表示"+msgid "Loading item details..."msgstr "品目詳細を読み込み中..."diff --git a/packages/locale/locales/ko/mes.po b/packages/locale/locales/ko/mes.poindex 82e07d3539..07126e9307 100644--- a/packages/locale/locales/ko/mes.po+++ b/packages/locale/locales/ko/mes.po@@ -176,6 +176,9 @@ msgstr "{0}에 의해 차단됨"msgid "Blocking"msgstr "차단"+msgid "Board view"+msgstr "보드 보기"+msgid "But don't worry. You can use the forgot password flow to request a new magic link."msgstr "걱정하지 마세요. 비밀번호 찾기를 통해 새 매직 링크를 요청할 수 있습니다."@@ -630,6 +633,9 @@ msgstr "무언가를 만들어봅시다"msgid "lines"msgstr "라인"+msgid "List view"+msgstr "목록 보기"+msgid "Loading item details..."msgstr "품목 세부정보를 불러오는 중..."diff --git a/packages/locale/locales/pl/mes.po b/packages/locale/locales/pl/mes.poindex 092c92a266..01c0c91218 100644--- a/packages/locale/locales/pl/mes.po+++ b/packages/locale/locales/pl/mes.po@@ -176,6 +176,9 @@ msgstr "Zablokowane przez {0}"msgid "Blocking"msgstr "Blokujące"+msgid "Board view"+msgstr "Widok tablicy"+msgid "But don't worry. You can use the forgot password flow to request a new magic link."msgstr "Ale nie martw się. Możesz użyć funkcji resetowania hasła, aby poprosić o nowy magiczny link."@@ -630,6 +633,9 @@ msgstr "Zbudujmy coś"msgid "lines"msgstr "linie"+msgid "List view"+msgstr "Widok listy"+msgid "Loading item details..."msgstr "Ładowanie szczegółów pozycji..."diff --git a/packages/locale/locales/pt/mes.po b/packages/locale/locales/pt/mes.poindex 7d1196760b..e68aaf470d 100644--- a/packages/locale/locales/pt/mes.po+++ b/packages/locale/locales/pt/mes.po@@ -176,6 +176,9 @@ msgstr "Bloqueado por {0}"msgid "Blocking"msgstr "Bloqueando"+msgid "Board view"+msgstr "Visualização em quadro"+msgid "But don't worry. You can use the forgot password flow to request a new magic link."msgstr "Mas não se preocupe. Você pode usar o fluxo de senha esquecida para solicitar um novo link mágico."@@ -630,6 +633,9 @@ msgstr "Vamos construir algo"msgid "lines"msgstr "linhas"+msgid "List view"+msgstr "Visualização em lista"+msgid "Loading item details..."msgstr "Carregando detalhes do item..."diff --git a/packages/locale/locales/ru/mes.po b/packages/locale/locales/ru/mes.poindex 13a4a35b7f..2b6429cbaa 100644--- a/packages/locale/locales/ru/mes.po+++ b/packages/locale/locales/ru/mes.po@@ -176,6 +176,9 @@ msgstr "Заблокировано {0}"msgid "Blocking"msgstr "Блокирующие"+msgid "Board view"+msgstr "Вид доски"+msgid "But don't worry. You can use the forgot password flow to request a new magic link."msgstr "Но не волнуйтесь. Вы можете использовать функцию восстановления пароля, чтобы запросить новую волшебную ссылку."@@ -630,6 +633,9 @@ msgstr "Давайте создадим что-то"msgid "lines"msgstr "строки"+msgid "List view"+msgstr "Вид списка"+msgid "Loading item details..."msgstr "Загрузка данных номенклатуры..."diff --git a/packages/locale/locales/tr/mes.po b/packages/locale/locales/tr/mes.poindex a861e6af14..43ab4384e9 100644--- a/packages/locale/locales/tr/mes.po+++ b/packages/locale/locales/tr/mes.po@@ -176,6 +176,9 @@ msgstr "Engelli edildi: {0}"msgid "Blocking"msgstr "Bloklayıcı"+msgid "Board view"+msgstr "Pano görünümü"+msgid "But don't worry. You can use the forgot password flow to request a new magic link."msgstr "Ama endişelenmeyin. Yeni bir sihirli bağlantı talep etmek için şifremi unuttum akışını kullanabilirsiniz."@@ -630,6 +633,9 @@ msgstr "Bir şeyler inşa edelim"msgid "lines"msgstr "satırlar"+msgid "List view"+msgstr "Liste görünümü"+msgid "Loading item details..."msgstr "Ürün detayları yükleniyor..."diff --git a/packages/locale/locales/zh/mes.po b/packages/locale/locales/zh/mes.poindex bf5ccf22b2..8a2ff067a4 100644--- a/packages/locale/locales/zh/mes.po+++ b/packages/locale/locales/zh/mes.po@@ -176,6 +176,9 @@ msgstr "被 {0} 阻塞"msgid "Blocking"msgstr "阻塞中"+msgid "Board view"+msgstr "看板视图"+msgid "But don't worry. You can use the forgot password flow to request a new magic link."msgstr "但别担心。您可以使用忘记密码流程来请求新的魔法链接。"@@ -630,6 +633,9 @@ msgstr "让我们开始构建"msgid "lines"msgstr "行"+msgid "List view"+msgstr "列表视图"+msgid "Loading item details..."msgstr "正在加载物料详情..."