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(sales): show external notes on the digital quote (#2042)
BettrCallRaul0647149bbcc9
diff --git a/apps/erp/app/routes/share+/quote.$id.tsx b/apps/erp/app/routes/share+/quote.$id.tsxindex 01c9a62505..55e0c6ecdc 100644--- a/apps/erp/app/routes/share+/quote.$id.tsx+++ b/apps/erp/app/routes/share+/quote.$id.tsx@@ -19,6 +19,7 @@ import {generateHTML,Heading,HStack,+ isRichTextEmpty,Modal,ModalBody,ModalContent,@@ -29,6 +30,7 @@ import {ModalTitle,RadioGroup,RadioGroupItem,+ RichTextView,Separator,Table,Tbody,@@ -540,12 +542,11 @@ const LineItems = ({>{line.description}</TruncatedTooltipText>- {Object.keys(line.externalNotes ?? {}).length > 0 && (- <div- className="prose dark:prose-invert mt-2 text-muted-foreground"- dangerouslySetInnerHTML={{- __html: generateHTML(line.externalNotes as JSONContent)- }}+ {!isRichTextEmpty(line.externalNotes as JSONContent) && (+ <RichTextView+ content={line.externalNotes as JSONContent}+ empty={null}+ className="mt-2 text-muted-foreground"/>)}</div>@@ -1282,16 +1283,15 @@ const Quote = ({ data }: { data: QuoteData }) => {setSelectedLines={setSelectedLines}/>- {Object.keys(quote?.externalNotes ?? {}).length > 0 && (+ {!isRichTextEmpty(quote?.externalNotes as JSONContent) && (<div className="mt-6 mb-2"><Heading size="h4" className="mb-2"><Trans>Notes</Trans></Heading>- <div- className="prose dark:prose-invert text-muted-foreground"- dangerouslySetInnerHTML={{- __html: generateHTML(quote.externalNotes as JSONContent)- }}+ <RichTextView+ content={quote.externalNotes as JSONContent}+ empty={null}+ className="text-muted-foreground"/></div>)}diff --git a/packages/react/AGENTS.md b/packages/react/AGENTS.mdindex 22d0b6bf98..0a5d9c1c02 100644--- a/packages/react/AGENTS.md+++ b/packages/react/AGENTS.md@@ -47,7 +47,7 @@ import { Button, Card, HStack, VStack, IconButton, cn } from "@carbon/react";- **Links that prefetch**: `PrefetchLink` is a React Router `Link` that prefetches its destination when the pointer goes down on it. Use it instead of `<Link prefetch="intent">`, which prefetches on a 100 ms hover and so runs a page's loaders for every row the mouse passes over. The click reuses the prefetch only because `prefetchCacheMiddleware` (`@carbon/utils`, in each app's root `middleware`) gives a prefetch response a few seconds of private cache; without it both requests reach the server and the click waits behind the prefetch. `NavRailLink` and both apps' `Hyperlink` already use it- **Record outlet**: `RecordOutlet` is the `<Outlet>` of every route under `/x`. It remounts the page inside it when that page is shown for a different record (the params of the route in the outlet, not of a drawer below it), so nothing seeded from the previous record survives. A plain `<Outlet>` there fails the `no-bare-outlet` check- **Data**: `Table` (TanStack), chart components via sub-exports (`@carbon/react/Chart`)-- **Rich text**: `@carbon/react/Editor` and `@carbon/react/RichText` (wraps `@carbon/tiptap`)+- **Rich text**: `@carbon/react/Editor` and `@carbon/react/RichText` (wraps `@carbon/tiptap`). Read-only rich text is `RichTextView`. `generateHTML` returns `""` on the server and hydration keeps a server `dangerouslySetInnerHTML` as it is, so `__html: generateHTML(…)` on a page's first load stays empty; `RichTextView` sets the HTML once the page has hydrated- **Error boundary**: `@carbon/react/ErrorBoundary` — `RouteErrorBoundary` (exported as `ErrorBoundary` from a module layout so a failed loader shows inside the app shell; it shows the status code and, for a 4xx, the message the server threw — `routeErrorCopy` — so throw a `Response` whose body says what was wrong. A 5xx or thrown `Error` gets generic copy) and `RootErrorBoundary` (drop-in root `ErrorBoundary` for RR v7 that maps 404 / 503 (the maintenance screen) / other HTTP / thrown `Error` to a styled screen) plus its parts (`ErrorScreen`, `GlitchHeading`, `StatusReadout`, `MagneticLink`, `NoiseOverlay`). Both read a request that got no response (`isNetworkError`: a `TypeError` with one of the browsers' fetch-failure messages) as a lost connection, not a fault, and `useNetworkRetry` revalidates when the browser is back online or the tab is shown again, which clears the error. Wrap it in the app's `Document` and pass `env` so `window.env` is set (the client crashes hydration otherwise). Copy is intentionally hardcoded English, not i18n.- **Avatar**: `src` may be a URL or a generated-avatar value from `user.avatarUrl` (`dicebear:<style>:<seed>[:<rrggbb>]`; the styles and value helpers are in `@carbon/utils` `avatar.ts`). A generated value renders as a plain `<img>` of `generatedAvatarUrl(value)` (`utils/generatedAvatarImage.ts`, which `Avatar` imports instead of the renderer so no bundle that shows an avatar carries DiceBear) — `/file/avatar/:value?v=<GENERATED_AVATAR_RENDER_VERSION>` — so it is in the server-rendered HTML and needs no client JavaScript. Every app (ERP, MES, academy) serves that path with a one-line route re-exporting `generatedAvatarLoader` from `@carbon/react/GeneratedAvatar`: it draws the SVG on the server with DiceBear 10 and answers `Cache-Control: public, max-age=31536000, immutable`, so a refresh reads it from the browser cache. **Bump `GENERATED_AVATAR_RENDER_VERSION` whenever the same value would draw differently** (a DiceBear upgrade, a change to the rendering options), or browsers keep the old image. The avatar picker draws in the browser instead (`GeneratedAvatarPreview`, `useGeneratedAvatar`), because a color drag makes a new value per step; there the DiceBear core and each style's JSON load with `import()` (`STYLE_LOADERS`, typed `Record<GeneratedAvatarStyle, …>`), never with a `with: { type: "json" }` attribute (Vite passes it to the browser, which rejects the JSON Vite serves as JavaScript, and the picker stays grey); the server side instead bundles `@dicebear/styles` through `ssrNoExternal` in each app's `vite.config.ts`, because Node refuses a package's JSON without the attribute. `generatedAvatarClassName(style)` picks the image classes: line-art styles on white (`bg-white`) in both themes, color styles on `bg-muted`. A value's optional background goes to DiceBear as `backgroundColor`; on a dark one (`isDarkBackground`, WCAG contrast) the styles that draw lines straight onto the background (`INK_OPTIONS`) get white ink. The app `Avatar` wrappers turn a stored value into `src` with `avatarSrc` (`@carbon/utils`); a new user has no avatar (initials) until they choose one- **Announcement**: `AnnouncementBar` is the one-line bar both shells render above their page area for the deployment's announcement. It remembers a dismissal in localStorage per user and announcement id, and while shown sets `--announcement-height` on `<html>`; the ERP's `--content-inset` includes it, and a page sized from `100dvh` outside that variable must subtract itdiff --git a/packages/react/src/HTML.test.tsx b/packages/react/src/HTML.test.tsxindex 9ad39014b8..790449fffd 100644--- a/packages/react/src/HTML.test.tsx+++ b/packages/react/src/HTML.test.tsx@@ -4,8 +4,41 @@// @vitest-environment jsdom+import { act } from "react";+import type { Root } from "react-dom/client";+import { hydrateRoot } from "react-dom/client";import { describe, expect, it } from "vitest";-import { generateHTML, isRichTextEmpty } from "./HTML";+import { generateHTML, isRichTextEmpty, RichTextView } from "./HTML";++describe("RichTextView", () => {+ it("fills in the text when it hydrates the server's empty markup", () => {+ (+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }+ ).IS_REACT_ACT_ENVIRONMENT = true;+ const doc = {+ type: "doc",+ content: [+ { type: "paragraph", content: [{ type: "text", text: "Net 30" }] }+ ]+ };+ // generateHTML needs the DOM, so the server sends the element empty.+ const container = document.createElement("div");+ container.innerHTML = '<div class="prose dark:prose-invert"></div>';+ document.body.appendChild(container);++ let root: Root | undefined;+ act(() => {+ root = hydrateRoot(+ container,+ <RichTextView content={doc} empty={null} />+ );+ });++ expect(container.textContent).toBe("Net 30");+ act(() => root?.unmount());+ container.remove();+ });+});// A work instruction stored as a JSON string scalar crashed the MES operation// page: `"type" in "<text>"` throws. Strings are now read as documents.diff --git a/packages/react/src/HTML.tsx b/packages/react/src/HTML.tsxindex 58478bd122..fc7cfa186a 100644--- a/packages/react/src/HTML.tsx+++ b/packages/react/src/HTML.tsx@@ -12,6 +12,7 @@ import StarterKit from "@tiptap/starter-kit";import pkg from "dompurify";import type { ReactNode } from "react";import { defaultExtensions } from "./Editor/extensions";+import { useHydrated } from "./hooks";import { cn } from "./utils/cn";const { sanitize } = pkg;@@ -105,6 +106,10 @@ const RichTextView = ({empty: ReactNode;className?: string;}) => {+ // The server sends the body empty (`generateHTML` needs the DOM), and+ // hydration keeps a server `dangerouslySetInnerHTML` as it is, so the HTML+ // is set only once the page has hydrated.+ const hydrated = useHydrated();if (isRichTextEmpty(content)) {return (<p className="hidden text-sm text-muted-foreground max-md:block">@@ -116,7 +121,7 @@ const RichTextView = ({<divclassName={cn("prose dark:prose-invert", className)}dangerouslySetInnerHTML={{- __html: generateHTML(content as JSONContent)+ __html: hydrated ? generateHTML(content as JSONContent) : ""}}/>);