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: add header to procedure
Brad Barbinece94306f729
diff --git a/apps/erp/app/components/Layout/Topbar/Notifications.tsx b/apps/erp/app/components/Layout/Topbar/Notifications.tsxindex 783ff1d7ad..d4a538a50a 100644--- a/apps/erp/app/components/Layout/Topbar/Notifications.tsx+++ b/apps/erp/app/components/Layout/Topbar/Notifications.tsx@@ -26,6 +26,7 @@ import {LuMailCheck,LuMessageSquare,LuShoppingCart,+ LuWaypoints,} from "react-icons/lu";import {RiProgress2Line,@@ -160,6 +161,14 @@ function GenericNotification({{...props}/>);+ case NotificationEvent.ProcedureAssignment:+ return (+ <Notification+ icon={<LuWaypoints />}+ to={path.to.procedure(id)}+ {...props}+ />+ );case NotificationEvent.QuoteExpired:return (<Notificationdiff --git a/apps/erp/app/components/Table/components/TableHeader.tsx b/apps/erp/app/components/Table/components/TableHeader.tsxindex 3425d176a4..3de8a90011 100644--- a/apps/erp/app/components/Table/components/TableHeader.tsx+++ b/apps/erp/app/components/Table/components/TableHeader.tsx@@ -158,13 +158,15 @@ const TableHeader = <T extends object>({name="name"placeholder="My Saved View"label=""- className="border-none p-0 ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 font-medium text-base shadow-none"+ className="font-medium text-base"+ borderless/><Inputname="description"label=""placeholder="Description (optional)"- className="border-none p-0 ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 text-sm shadow-none"+ className="text-sm"+ borderless/></CardContent><CardFooter className="border-t bg-muted/30 p-4">diff --git a/apps/erp/app/modules/production/production.service.ts b/apps/erp/app/modules/production/production.service.tsindex f952729e3f..e870eaaace 100644--- a/apps/erp/app/modules/production/production.service.ts+++ b/apps/erp/app/modules/production/production.service.ts@@ -412,14 +412,15 @@ export async function getProcedure(export async function getProcedureVersions(client: SupabaseClient<Database>,- name: string,+ procedure: { name: string; version: number },companyId: string) {return client.from("procedure").select("*")- .eq("name", name)+ .eq("name", procedure.name).eq("companyId", companyId)+ .neq("version", procedure.version).order("version", { ascending: false });}diff --git a/apps/erp/app/modules/production/ui/Procedures/ProcedureProperties.tsx b/apps/erp/app/modules/production/ui/Procedures/ProcedureProperties.tsxindex 6a519d5a46..a89f07b3fc 100644--- a/apps/erp/app/modules/production/ui/Procedures/ProcedureProperties.tsx+++ b/apps/erp/app/modules/production/ui/Procedures/ProcedureProperties.tsx@@ -13,13 +13,14 @@ import { useCallback, useEffect } from "react";import { LuCopy, LuKeySquare, LuLink } from "react-icons/lu";import { z } from "zod";import { Process } from "~/components/Form";-import { useRouteData } from "~/hooks";+import { usePermissions, useRouteData } from "~/hooks";import type { action } from "~/routes/x+/items+/update";import { path } from "~/utils/path";import { copyToClipboard } from "~/utils/string";-import { Procedure } from "../../types";+import type { Procedure } from "../../types";import ProcedureStatus from "./ProcedureStatus";import { procedureStatus } from "../../production.models";+import Assignee, { useOptimisticAssignment } from "~/components/Assignee";const ProcedureProperties = () => {const { id } = useParams();@@ -53,6 +54,17 @@ const ProcedureProperties = () => {[id]);+ const optimisticAssignment = useOptimisticAssignment({+ id: id,+ table: "procedure",+ });+ const assignee =+ optimisticAssignment !== undefined+ ? optimisticAssignment+ : routeData?.procedure?.assignee;++ const permissions = usePermissions();+return (<VStackspacing={4}@@ -124,6 +136,15 @@ const ProcedureProperties = () => {{routeData?.procedure?.name}</span></VStack>++ <Assignee+ id={id}+ table="procedure"+ value={assignee ?? ""}+ variant="inline"+ isReadOnly={!permissions.can("update", "production")}+ />+<ValidatedFormdefaultValues={{status: routeData?.procedure?.status ?? undefined,diff --git a/apps/erp/app/novu/workflows.ts b/apps/erp/app/novu/workflows.tsindex b7e76655c0..803cebcfc8 100644--- a/apps/erp/app/novu/workflows.ts+++ b/apps/erp/app/novu/workflows.ts@@ -14,6 +14,7 @@ const payloadSchema = z.object({NotificationEvent.JobAssignment,NotificationEvent.JobOperationAssignment,NotificationEvent.JobOperationMessage,+ NotificationEvent.ProcedureAssignment,NotificationEvent.PurchaseInvoiceAssignment,NotificationEvent.PurchaseOrderAssignment,NotificationEvent.QuoteAssignment,diff --git a/apps/erp/app/routes/api+/assign.ts b/apps/erp/app/routes/api+/assign.tsindex 0ab45c8c49..0f72179979 100644--- a/apps/erp/app/routes/api+/assign.ts+++ b/apps/erp/app/routes/api+/assign.ts@@ -87,6 +87,8 @@ function getNotificationEvent(table: string): NotificationEvent | null {return NotificationEvent.JobAssignment;case "jobOperation":return NotificationEvent.JobOperationAssignment;+ case "procedure":+ return NotificationEvent.ProcedureAssignment;case "purchaseOrder":return NotificationEvent.PurchaseOrderAssignment;case "purchaseInvoice":diff --git a/apps/erp/app/routes/x+/procedure+/$id.tsx b/apps/erp/app/routes/x+/procedure+/$id.tsxindex 695893167c..d2b6c73df9 100644--- a/apps/erp/app/routes/x+/procedure+/$id.tsx+++ b/apps/erp/app/routes/x+/procedure+/$id.tsx@@ -1,25 +1,26 @@import { error, useCarbon } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";import { flash } from "@carbon/auth/session.server";-import { Input, JSONContent, toast, useDebounce } from "@carbon/react";-import { generateHTML } from "@carbon/react/Editor";-import { Editor } from "@carbon/react/Editor";-import { today } from "@internationalized/date";-import { getLocalTimeZone } from "@internationalized/date";+import type { JSONContent} from "@carbon/react";+import { Input, toast, useDebounce } from "@carbon/react";+import { generateHTML , Editor } from "@carbon/react/Editor";+import { today , getLocalTimeZone } from "@internationalized/date";import { Outlet, useFetcher, useParams } from "@remix-run/react";import type { LoaderFunctionArgs } from "@vercel/remix";import { defer, redirect } from "@vercel/remix";import { nanoid } from "nanoid";import { useState } from "react";import { usePermissions, useRouteData, useUser } from "~/hooks";+import type {+ Procedure} from "~/modules/production";import {getProcedure,- getProcedureVersions,- Procedure,+ getProcedureVersions} from "~/modules/production";+import ProcedureHeader from "~/modules/production/ui/Procedures/ProcedureHeader";import ProcedureProperties from "~/modules/production/ui/Procedures/ProcedureProperties";import type { action } from "~/routes/x+/procedure+/update";-import { Handle } from "~/utils/handle";+import type { Handle } from "~/utils/handle";import { getPrivateUrl, path } from "~/utils/path";export const handle: Handle = {@@ -49,13 +50,14 @@ export async function loader({ request, params }: LoaderFunctionArgs) {return defer({procedure: procedure.data,- versions: getProcedureVersions(client, procedure.data.name, companyId),+ versions: getProcedureVersions(client, procedure.data, companyId),});}export default function ProcedureRoute() {return (<div className="flex flex-col h-[calc(100dvh-49px)] overflow-hidden w-full">+ <ProcedureHeader /><div className="flex h-[calc(100dvh-49px)] w-full"><div className="flex h-full w-full overflow-y-auto scrollbar-hide"><ProcedureEditor />@@ -102,7 +104,7 @@ function ProcedureEditor() {}).eq("id", id!);},- 300,+ 500,true);@@ -121,7 +123,7 @@ function ProcedureEditor() {action: path.to.bulkUpdateProcedure,});},- 2500,+ 1000,true);@@ -146,8 +148,9 @@ function ProcedureEditor() {return (<div className="flex flex-col gap-6 w-full h-full p-6"><Input- className="border-none px-0 outline-none md:text-3xl text-2xl font-semibold leading-none tracking-tight text-foreground ring-transparent focus:ring-transparent focus:ring-offset-0 focus-visible:ring-transparent focus:outline-none focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0"+ className="md:text-3xl text-2xl font-semibold leading-none tracking-tight text-foreground"value={procedureName}+ borderlessonChange={(e) => {setProcedureName(e.target.value);updateProcedureName(e.target.value);diff --git a/apps/erp/app/trigger/notify.ts b/apps/erp/app/trigger/notify.tsindex 749cc44a3c..18ea87dc79 100644--- a/apps/erp/app/trigger/notify.ts+++ b/apps/erp/app/trigger/notify.ts@@ -49,6 +49,7 @@ export const notifyTask = task({switch (type) {case NotificationEvent.JobAssignment:case NotificationEvent.JobOperationAssignment:+ case NotificationEvent.ProcedureAssignment:case NotificationEvent.PurchaseInvoiceAssignment:case NotificationEvent.PurchaseOrderAssignment:case NotificationEvent.QuoteAssignment:@@ -147,6 +148,20 @@ export const notifyTask = task({return `New message on ${jobOperation?.data?.job?.jobId} operation: ${jobOperation?.data?.description}`;}+ case NotificationEvent.ProcedureAssignment:+ const procedure = await client+ .from("procedure")+ .select("*")+ .eq("id", documentId)+ .single();++ if (procedure.error) {+ console.error("Failed to get procedure", procedure.error);+ throw procedure.error;+ }++ return `Procedure ${procedure?.data?.name} version ${procedure?.data?.version} assigned to you`;+case NotificationEvent.DigitalQuoteResponse:const digitalQuote = await client.from("quote")diff --git a/packages/notifications/src/index.ts b/packages/notifications/src/index.tsindex 2cef23e9cd..b868838f47 100644--- a/packages/notifications/src/index.ts+++ b/packages/notifications/src/index.ts@@ -14,6 +14,7 @@ export enum NotificationEvent {JobAssignment = "job-assignment",JobOperationAssignment = "job-operation-assignment",JobOperationMessage = "job-operation-message",+ ProcedureAssignment = "procedure-assignment",PurchaseInvoiceAssignment = "purchase-invoice-assignment",PurchaseOrderAssignment = "purchase-order-assignment",QuoteAssignment = "quote-assignment",diff --git a/packages/react/src/Input.tsx b/packages/react/src/Input.tsxindex 37a68bbc60..4775cf7ccc 100644--- a/packages/react/src/Input.tsx+++ b/packages/react/src/Input.tsx@@ -135,6 +135,10 @@ export const inputVariants = cva(true: "bg-muted text-muted-foreground",false: "",},+ borderless: {+ true: "border-none px-0 outline-none ring-transparent focus:ring-transparent focus:ring-offset-0 focus-visible:ring-transparent focus:outline-none focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0 shadow-none",+ false: "",+ },},compoundVariants: [{@@ -159,6 +163,7 @@ export const inputVariants = cva(isFirstChild: false,isLastChild: false,isInvalid: false,+ borderless: false,},});@@ -171,6 +176,7 @@ export interface InputPropsisInvalid?: boolean;isDisabled?: boolean;isReadOnly?: boolean;+ borderless?: boolean;}const Input = forwardRef<HTMLInputElement, InputProps>(@@ -183,6 +189,7 @@ const Input = forwardRef<HTMLInputElement, InputProps>(isInvalid = false,isDisabled = false,isReadOnly = false,+ borderless = false,type = "text",...props},@@ -201,6 +208,7 @@ const Input = forwardRef<HTMLInputElement, InputProps>(isInvalid,isReadOnly,isDisabled,+ borderless,}),className)}