Skip to content

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.

feat(erp): phone redesign of record pages, reports and inventory quantities

aashu849350af5354
diff --git a/.ai/plans/2026-10-08-erp-phone-detail-redesign.md b/.ai/plans/2026-10-08-erp-phone-detail-redesign.md
new file mode 100644
index 0000000000..2f3575e318
--- /dev/null
+++ b/.ai/plans/2026-10-08-erp-phone-detail-redesign.md
@@ -0,0 +1,494 @@
+# ERP phone redesign of 12 screens — implementation plan
+
+**Spec:** `.ai/specs/2026-10-08-erp-phone-detail-redesign.md` (approved 2026-10-08)
+**Research:** `.ai/research/2026-10-08-erp-phone-redesign-mapping.md` (file:line for every screen)
+**Designs:** `local-docs/mobile-design/review-2026-10-08/index.html` (after-*.json)
+**Branch:** `feat/mobile-redesign`
+
+🛑 Never commit. The owner commits.
+🛑 Desktop must not change. Gate every change with `max-md:` / `md:hidden` classes or `useViewport().isPhone`.
+🛑 Adapt, don't add: no new data, no new features. Every action that exists today must stay reachable.
+🛑 Every new user-facing string uses Lingui (`useLingui().t` or `<Trans>`).
+🛑 If an assumption in a task is false, STOP and report. Do not improvise.
+
+Paths are relative to `apps/erp/app/` unless they start with `packages/` or `.ai/`.
+
+## Progress
+
+- [x] Task 1: One ⋯ per record on phones (S3)
+- [x] Task 2: Icon cell in the record action bar (S4)
+- [x] Task 3: Split button shows only its main action in the bar (S5)
+- [x] Task 4: Page items in the record app-bar ⋯ (S6)
+- [x] Task 5: Record tab setter (S7)
+- [x] Task 6: Files cards on phones (S8)
+- [x] Task 7: `emptyState` prop on `SortableList` (S9)
+- [x] Task 8: Trailing row action in phone lists (S10)
+- [x] Task 9: Extra items in the list toolbar ⋯ (S11)
+- [x] Task 10: Subtitle under the section switcher title (S12)
+- [x] Task 11: Detail page tops: app bar subtitle and hero subtitle (S1, S2)
+- [x] Task 12: Sales Order body
+- [x] Task 13: Purchase Order body
+- [x] Task 14: Quote body
+- [x] Task 15: Quotes list rows
+- [x] Task 16: Job body
+- [x] Task 17: Part body
+- [x] Task 18: Quantity detail
+- [x] Task 19: Storage Unit edit sheet
+- [x] Task 20: Picking List detail
+- [x] Task 21: Issue detail
+- [x] Task 22: Production and Purchasing Planning
+- [x] Task 23: Strings, typecheck, lint
+- [x] Task 24: Browser verification at 393 and 1440
+
+## Dependencies
+
+- Tasks 1–10 are independent of each other (shared parts). Run them in any order.
+- Task 11 needs nothing.
+- Tasks 12, 13, 16 need Tasks 1–3. Task 13 also needs Task 5. Tasks 16 and 17 need Tasks 4 and 7.
+- Tasks 12–14, 20 and 21 need Task 6 where they touch Files cards.
+- Task 22 needs Tasks 8, 9, 10.
+- Task 23 needs all code tasks. Task 24 needs Task 23.
+
+## Shared commands
+
+```bash
+# Typecheck (scoped; whole-repo typecheck runs out of memory)
+pnpm exec turbo run typecheck --filter=erp --filter=@carbon/react --filter=@carbon/printing
+# Expected: "Tasks: N successful, N total"
+# Lint the files you changed
+pnpm exec biome check --write <changed files>
+# Expected: no errors (pre-existing warnings are fine)
+```
+
+---
+
+## Task 1: One ⋯ per record on phones (S3)
+
+**Depends on:** none
+**Files:**
+- Modify: `components/Layout/RecordHeader.tsx` — `RecordPhoneChrome` (about `:166-247`)
+- Precedent: the current `RecordPhoneChrome` app-bar `DropdownMenu` (`:189-212`)
+
+**Steps:**
+1. Make the app-bar `DropdownMenu` controlled by the existing `useOverflowSheet` store: `open={open} onOpenChange={setOpen}`.
+2. Inside its `DropdownMenuContent`, keep "Copy ID" and `{menu}` first.
+3. If `hasOverflow` is true, add a `DropdownMenuSeparator` and then `<overflowSlot.Target className="flex flex-col [&>*]:w-full" />` after `{menu}`.
+4. Render the app-bar ⋯ when `menu || copyValue || hasOverflow` is true.
+5. In the `BottomBar`, delete the ⋯ `IconButton` that opened the overflow sheet.
+6. Delete the "Actions" `BottomSheet` that held `overflowSlot.Target`.
+7. Keep `closeOverflow` as the row `onSelect`. It now closes the app-bar menu, because the menu reads the same store.
+
+**Verify:**
+```bash
+pnpm exec turbo run typecheck --filter=erp
+# Expected: success
+```
+Manual: on a phone (393px), SO000025's app bar ⋯ lists Copy ID, the menu items, then the overflow actions. The bottom bar has no ⋯.
+
+**Out of scope:** desktop header row; what each header puts in `menu` or `overflow`.
+If an overflow action opens its own dropdown and that dropdown fails inside the menu sheet, STOP and report.
+
+## Task 2: Icon cell in the record action bar (S4)
+
+**Depends on:** none
+**Files:**
+- Modify: `packages/react/src/ActionPresentation.tsx` — add `iconOnly?: boolean` to the `bar` kind.
+- Modify: `packages/react/src/Button.tsx` — icon-only bar rendering (around the presentation block, about `:205-260`).
+- Modify: `components/Layout/RecordHeader.tsx` — a new `iconSlot` and `RecordAction slot="icon"`.
+- Precedent: `presentations` and `slots` maps in `RecordHeader.tsx:58-70`.
+
+**Steps:**
+1. In `ActionPresentation`, change the bar kind to `{ kind: "bar"; emphasis: "primary" | "secondary"; iconOnly?: boolean }`.
+2. In `Button`, if `presentation?.kind === "bar" && presentation.iconOnly`:
+ 1. Render with `isIcon`, `size="lg"`, variant `secondary`.
+ 2. Do not add `w-full`. Add `shrink-0`.
+ 3. Render `leftIcon` only. Put `children` in `<span className="sr-only">`. Do not render `rightIcon`.
+3. In `RecordHeader.tsx`, create `const iconSlot = createPortalSlot();`.
+4. Add `icon: { kind: "bar", emphasis: "secondary", iconOnly: true }` to `presentations` and `icon: iconSlot` to `slots`. Extend the `slot` prop type with `"icon"`.
+5. In the `BottomBar` row, render `<iconSlot.Target className="flex shrink-0 empty:hidden" />` before the primary target.
+6. Show the bar when the icon slot is filled too (`iconSlot.useFilled()`).
+
+**Verify:** typecheck (shared command). Expected: success.
+
+**Out of scope:** moving any action into the icon slot (Tasks 12–14 do that).
+
+## Task 3: Split button shows only its main action in the bar (S5)
+
+**Depends on:** none
+**Files:**
+- Modify: `packages/react/src/SplitButton.tsx` (`:40-125`)
+
+**Steps:**
+1. If `presentation?.kind === "bar"`, do not render the chevron `DropdownMenu`.
+2. Keep the main `Button` full width (`min-w-0 flex-1`) and drop `rounded-r-none` in that case.
+3. Do not change the `row` kind or desktop.
+
+**Verify:** typecheck. Manual in Tasks 13 and 16.
+
+**Out of scope:** where the dropdown items go (Tasks 13 and 16 add them to the ⋯).
+
+## Task 4: Page items in the record app-bar ⋯ (S6)
+
+**Depends on:** none
+**Files:**
+- Modify: `components/Layout/RecordHeader.tsx`
+- Precedent: `createValueSlot` in `components/Layout/Mobile/slots.tsx:66-97`; `recordTabsSlot` in `components/Layout/Panels.tsx:26`.
+
+**Steps:**
+1. Export `recordMenuSlot = createValueSlot<ReactNode>()` from `RecordHeader.tsx`.
+2. In `RecordPhoneChrome`, read `const pageMenu = recordMenuSlot.useValue();`.
+3. Render `{pageMenu}` after `{menu}` and before the overflow target, with a `DropdownMenuSeparator` between them.
+4. Count `pageMenu` in the condition that shows the app-bar ⋯.
+
+**Verify:** typecheck. Manual in Tasks 16 and 17.
+
+**Out of scope:** callers (Tasks 16, 17).
+
+## Task 5: Record tab setter (S7)
+
+**Depends on:** none
+**Files:**
+- Modify: `components/Layout/Panels.tsx` — `CompactRecordTabs` (`:114-196`)
+
+**Steps:**
+1. Export `RecordPanelContext = createContext<(panel: "content" | "explorer" | "properties") => void>(() => {})`.
+2. In `CompactRecordTabs`, wrap the panel body in `<RecordPanelContext.Provider value={setPanel}>`.
+3. Export a hook `useShowRecordPanel()` that returns the context value.
+
+**Verify:** typecheck.
+
+**Out of scope:** desktop panels.
+
+## Task 6: Files cards on phones (S8)
+
+**Depends on:** none
+**Files:**
+- Modify: `modules/sales/ui/Opportunity/OpportunityDocuments.tsx` — header New `:104-119` and `:414-437`, thead `:121-135`
+- Modify: `modules/purchasing/ui/SupplierInteraction/SupplierInteractionDocuments.tsx` — thead `:100-105`, New `:345`
+- Modify: `components/Documents.tsx` — New `:237-249`, thead `:253-266`
+- Precedent: `components/RecordDocuments.tsx:129` (thead hidden on phones when empty)
+
+**Steps:**
+1. Add `max-md:hidden` to the card-header "New" `File` button (or its `CardAction`) in each file.
+2. If the file list is empty, add `max-md:hidden` to the table header, as `RecordDocuments.tsx:129` does.
+3. Keep `FileDropzone`'s phone "Upload" button as the only upload control.
+
+**Verify:** typecheck. Manual: SO000025 Files card shows one "Upload" and no "Name Size Created" row.
+
+**Out of scope:** desktop Files cards; `RecordDocuments.tsx`.
+
+## Task 7: `emptyState` prop on `SortableList` (S9)
+
+**Depends on:** none
+**Files:**
+- Modify: `components/SortableList.tsx` (`:325-327` returns `<Empty />`)
+- Precedent: `components/Table/components/Compact/CompactEmpty.tsx`
+
+**Steps:**
+1. Add an optional prop `emptyState?: ReactNode`.
+2. If `items` is empty and `emptyState` is set, return `emptyState`. Otherwise return `<Empty />` as today.
+
+**Verify:** typecheck.
+
+**Out of scope:** `components/Empty.tsx` (about 49 users).
+
+## Task 8: Trailing row action in phone lists (S10)
+
+**Depends on:** none
+**Files:**
+- Modify: `components/Table/types.ts:48` — `mobile?: "P1" | "P2" | "P3" | "P4" | "action";`
+- Modify: `components/Table/components/Compact/resolveSlots.ts` — add `action?: Column<T, unknown>` to `CompactSlots`; set it to the first column with `meta.mobile === "action"`.
+- Modify: `components/Table/components/Compact/resolveSlots.test.ts` — one test: a column marked `action` resolves to `slots.action` and to no other slot.
+- Modify: `components/Table/components/Compact/CompactRow.tsx`
+
+**Steps:**
+1. Make the type and `resolveSlots` changes above.
+2. In `CompactRow`, render `renderCell(row, slots.action)` after the text column and before the expand button. Use `relative z-10 shrink-0 self-center [&_button]:h-11 [&_button]:min-w-11`.
+3. If `selection` is set, do not render the action cell.
+
+**Verify:**
+```bash
+pnpm --filter erp exec vitest run app/components/Table/components/Compact/resolveSlots.test.ts
+# Expected: all tests pass, including the new one
+```
+
+**Out of scope:** any table annotation (Task 22).
+
+## Task 9: Extra items in the list toolbar ⋯ (S11)
+
+**Depends on:** none
+**Files:**
+- Modify: `components/Table/Table.tsx` (props near `:170`, compact render near `:1109`)
+- Modify: `components/Table/components/Compact/CompactList.tsx`
+- Modify: `components/Table/components/Compact/CompactToolbar.tsx` (`:60-135`)
+
+**Steps:**
+1. Add `mobileMenuItems?: ReactNode` to `Table`. Pass it to `CompactList`, then to `CompactToolbar`.
+2. In `CompactToolbar`, include `mobileMenuItems` in `hasMenu`.
+3. Render `{mobileMenuItems}` first in the `DropdownMenuContent`, then a `DropdownMenuSeparator` if more items follow.
+
+**Verify:** typecheck.
+
+**Out of scope:** desktop toolbar.
+
+## Task 10: Subtitle under the section switcher title (S12)
+
+**Depends on:** none
+**Files:**
+- Modify: `components/Layout/Mobile/MobileAppBar.tsx` (`:79-104`)
+
+**Steps:**
+1. In the `canSwitch` branch, wrap the title button content in a column.
+2. Under `titleText`, render `subtitle` with the same classes the non-switch branch uses (`min-w-0 max-w-full truncate text-xs text-muted-foreground`).
+3. Keep the chevron beside the title line, not beside the subtitle.
+
+**Verify:** typecheck. Manual in Task 22.
+
+## Task 11: Detail page tops: app bar subtitle and hero subtitle (S1, S2)
+
+**Depends on:** none
+**Files and values** (table rows; header paths in the research file §Part A and §Part B):
+
+| Screen | Header file | Hero `subtitle` | Route that sets the app bar subtitle |
+|---|---|---|---|
+| Sales Order | `modules/sales/ui/SalesOrder/SalesOrderHeader.tsx` | customer name | `routes/x+/sales-order+/$orderId.tsx` → "Sales Order" |
+| Purchase Order | `modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx` | supplier name, then " · Rev N" when `revisionId > 0` | `routes/x+/purchase-order+/$orderId.tsx` → "Purchase Order" |
+| Quote | `modules/sales/ui/Quotes/QuoteHeader.tsx` | customer name, then " · Rev N" when `revisionId > 0` | `routes/x+/quote+/$quoteId.tsx` → "Quote" |
+| Job | `modules/production/ui/Jobs/JobHeader.tsx` | item readable ID + " · Qty N" | `routes/x+/job+/$jobId.tsx` → "Job" |
+| Part | `modules/items/ui/Parts/PartHeader.tsx` | part name | `routes/x+/part+/$itemId.tsx` → "Part" |
+| Quantity | `routes/x+/inventory+/quantities+/$itemId.tsx` (standalone `RecordHero`, precedent `InspectionView.tsx:506`) | item name | same route → "Quantities" |
+| Picking List | `modules/inventory/ui/PickingLists/PickingListHeader.tsx` | first distinct `pickingListLines[].job.jobId`, "+N" when more, then " · " + assignee full name | `routes/x+/picking-list+/$pickingListId.tsx` → "Picking List" |
+| Issue | `modules/quality/ui/Issue/IssueHeader.tsx` | `nonConformance.name` | `routes/x+/issue+/$id.tsx` → "Issue" |
+
+**Steps:**
+1. For each row, pass the hero value as `subtitle` to `RecordHeader`. Read names from the route data the header already uses.
+2. In each route, call `useSetAppBarOverride(useMemo(() => (isPhone ? { subtitle: t\`Sales Order\` } : null), [isPhone, t]))`. Precedent: `components/NewRecordPage.tsx:20`.
+3. Do not change any breadcrumb (`handle`).
+4. For the picking list assignee, read `assigneeUser.fullName`. If the assignee was just changed optimistically, look the name up with `usePeople()`.
+
+**Verify:** typecheck. Manual: SO000025 app bar reads "SO000025 / Sales Order"; the hero line shows the customer with an ellipsis.
+
+**Out of scope:** desktop header row (it never shows `subtitle`).
+
+## Task 12: Sales Order body
+
+**Depends on:** 1, 2, 6, 11
+**Files:**
+- Modify: `modules/sales/ui/SalesOrder/SalesOrderSummary.tsx` — `LineItems` (`:346-708`), totals (`:244-339`)
+- Modify: `modules/sales/ui/SalesOrder/SalesOrderHeader.tsx` — Preview `RecordAction` (`:391-415`)
+- Precedent for the phone row: `components/Layout/Mobile/SheetRow.tsx` (`SheetRowContent`)
+
+**Steps:**
+1. On phones, render each line as one row: line 1 part number (truncate) + line total (`shrink-0`), line 2 part name (muted, truncate), line 3 "{qty} × {unit price} {unit}".
+2. On phones, make the row a `Link` to `path.to.salesOrderLine(orderId, lineId)`. Hide the Edit link, the badges and the inline expand (`md:` only).
+3. In totals, on phones, show a "Shipping" row with the amount. Its tap calls the existing `onEditShippingCost`. Hide the "Add Shipping" link on phones.
+4. Change the Preview `RecordAction` to `slot="icon"`.
+5. Keep the card order: `OpportunityState`, summary, Notes, Files, Shipping, Payment.
+
+**Verify:** typecheck. Manual: AC 1, 4, 5 of the spec.
+
+**Out of scope:** desktop summary; line page route.
+
+## Task 13: Purchase Order body
+
+**Depends on:** 1, 2, 3, 5, 6, 11
+**Files:**
+- Modify: `modules/purchasing/ui/PurchaseOrder/PurchaseOrderSummary.tsx` — `LineItems` (`:53+`), badge (`:200-210`)
+- Modify: `modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx` — Preview (`:329-353`), Finalize split (`:355-385`)
+
+**Steps:**
+1. Apply Task 12 steps 1–2 with `path.to.purchaseOrderLine`.
+2. Remove the "1 ⇄" badge on phones.
+3. On phones, show the first 3 lines. If there are more, show a "See all {count}" button. It calls `useShowRecordPanel()("explorer")`.
+4. Change Preview to `slot="icon"`.
+5. If `isPhone`, add a `RecordAction slot="overflow"` Button "Mark as Planned" with the existing handler (`:203-208`). Do not render it on desktop.
+
+**Verify:** typecheck. Manual: AC 2, 6.
+
+## Task 14: Quote body
+
+**Depends on:** 1, 2, 6, 11
+**Files:**
+- Modify: `modules/sales/ui/Quotes/QuoteSummary.tsx` — rows `:160-275`
+- Modify: `modules/sales/ui/Quotes/QuoteHeader.tsx` — Preview `:197-238`, slots `:104-112`, Reopen `:136-155`
+- Modify: `modules/sales/ui/Quotes/QuotePaymentForm.tsx` (`:49-61`), `QuoteShipmentForm.tsx` (`:81-101`)
+
+**Steps:**
+1. On phones, restyle each row as in Task 12 step 1. Keep tap-to-expand and `LinePricingOptions`. Hide the Edit link and badges on phones.
+2. Change Preview to `slot="icon"`. Leave Share (status Sent) as it is.
+3. If `isPhone` and the status is Expired, add a primary `RecordAction` "Reopen" with the existing reopen handler. Keep the `menu` item.
+4. In both forms, if `isQuoteLocked` and on a phone, show one muted line: "Locked while the quote is {status}. Reopen it to edit."
+
+**Verify:** typecheck. Manual: Q000008 bar shows Preview icon + Reopen; tapping a line expands it.
+
+## Task 15: Quotes list rows
+
+**Depends on:** none
+**Files:**
+- Modify: `modules/sales/ui/Quotes/QuotesTable.tsx` — status cell `:117-145`, customer cell `:98-115`
+- Precedent: `QuoteStatus.tsx:19`; `packages/react/src/DateTime.tsx:48-52`
+
+**Steps:**
+1. In the status cell, for Draft: keep `BarProgress` with `max-md:hidden`. Add a `md:hidden` span with `<QuoteStatus status="Draft" />` and "{completedLines} of {lines} lines complete".
+2. In the customer cell, add a `md:hidden` span " · Exp. {date}" using `DateTime` with `dateOptions={{ month: "short", day: "numeric" }}`. Show it only when `expirationDate` is set.
+
+**Verify:** typecheck. Manual: AC 16.
+
+## Task 16: Job body
+
+**Depends on:** 1, 3, 4, 7, 11
+**Files:**
+- Modify: `modules/production/ui/Jobs/JobMakeMethodTools.tsx` (`:309-385`)
+- Modify: `modules/production/ui/Jobs/JobBillOfProcess.tsx` (`:1049-1078`), `JobBillOfMaterial.tsx` (`:559-586`)
+- Modify: `modules/production/ui/Jobs/JobEstimatesVsActuals.tsx` (`:311-329`)
+- Modify: `modules/production/ui/Jobs/JobHeader.tsx` — Pause `:393-441`, Release split `:443-469`
+- Precedent for the empty state: `components/Table/components/Compact/CompactEmpty.tsx`
+
+**Steps:**
+1. In `JobMakeMethodTools`, add `max-md:hidden` to the `Menubar`. Provide `recordMenuSlot.useProvide(...)` with `DropdownMenuItem`s for Get Method, Save Method, Configure and Item Master. Each item calls the same disclosure the Menubar button opens. Memoize the node.
+2. Pass `emptyState` to `SortableList` in BOP and BOM: icon tile, "No operations yet" / "No materials yet", one sentence, and the existing add action.
+3. In Estimates vs Actual, on phones, stack the title over a full-width `TabsList` (`max-md:flex-col max-md:items-stretch`).
+4. In `JobHeader`, if `isPhone` and the status is not Ready or In Progress, do not render the Pause action.
+5. If `isPhone`, add a `RecordAction slot="overflow"` "Mark as Planned" with the existing handler.
+
+**Verify:** typecheck. Manual: AC 7, 8.
+If `JobMakeMethodTools` mounts on `job+/$jobId.make.$methodId.tsx` too, the slot items show there as well. That is correct.
+
+## Task 17: Part body
+
+**Depends on:** 1, 4, 7, 11
+**Files:**
+- Modify: `modules/items/ui/Item/MakeMethodTools.tsx` (`:234-380`)
+- Modify: `routes/x+/part+/$itemId.details.tsx` (Bill of Process at `:337`)
+- Modify: `modules/items/ui/Item/ItemManufacturingForm.tsx` (`:96-103`)
+- Modify: `components/SortableList.tsx` only if rows clip (step 4)
+
+**Steps:**
+1. Apply Task 16 step 1 to `MakeMethodTools` (Get Method, Save Method, Item Master). Wrap "Item Master" in Lingui.
+2. On phones, render the version dropdown as a chip above Bill of Process. Extract the version control into `MakeMethodVersionSelect` in the same folder. Render it in the tools on desktop and above `BillOfProcess` on phones (`md:hidden`).
+3. In `ItemManufacturingForm`, on phones, make Save full width. Disable it until the form has touched fields. Precedent: `DefaultDisabledSubmit` (`packages/form/src/components/Submit.tsx:42-58`).
+4. Open ADCS-001 on a phone. If BOP/BOM row text clips, relax the `truncate` in `SortableList.tsx:120` to `max-md:whitespace-normal` for the title only. If nothing clips, skip this step.
+5. Pass `emptyState` to BOP and BOM as in Task 16 step 2.
+
+**Verify:** typecheck. Manual: AC 9.
+
+## Task 18: Quantity detail
+
+**Depends on:** 11
+**Files:**
+- Modify: `modules/inventory/ui/Inventory/InventoryDetails.tsx` (`:57-171`)
+- Modify: `modules/inventory/ui/Inventory/InventoryStorageUnits.tsx` (`:270-476`)
+- Modify: `modules/inventory/ui/Inventory/InventoryItemHeader.tsx` (`:47-52`)
+- Modify: `routes/x+/inventory+/quantities+/$itemId.details.tsx` (`:225-255`)
+- Modify: `components/Table/components/Compact/CompactToolbar.tsx` (duplicate ⋯ fix)
+- Precedent: tiles `routes/x+/sales+/_index.tsx:384`; rows `CompactRow.tsx` classes; empty line `CompactEmpty.tsx`
+
+**Steps:**
+1. Add `variant?: "quantity"` to `InventoryDetails` and `InventoryStorageUnits`. Pass it only from `$itemId.details.tsx`. Every step below applies only when `variant === "quantity"` and on phones.
+2. Grid: `max-md:grid-cols-2 max-md:gap-3`. Under PO and SO figures, add "↑ Incoming" / "↓ Outgoing". On the jobs tile, add "Supply / demand".
+3. Usage window: show a "Daily usage" label before the existing `DateSelect` chip.
+4. Move the external-link icon to the app-bar ⋯ as "Item Master" (`recordMenuSlot` from Task 4 is not mounted here; use `AppBarActions` with one `DropdownMenu`).
+5. Fix the duplicate ⋯: in `CompactToolbar`, do not fill `AppBarActions` while a `compactFocus` pane is shown. Read the state the `Resizable` `compactFocus` uses (`packages/react/src/Resizable.tsx:32-44`). If no readable state exists, STOP and report.
+6. Move "Update Inventory" to a `BottomBar` (`components/Layout/Mobile/ChromeSlots.tsx:38`).
+7. Render storage units as phone rows (unit, quantity, tracking ID, expiry). Keep the batch group toggle and the per-row ⋯. If there are no rows, show one line: "No storage unit holds this item."
+
+**Verify:** typecheck. Manual: AC 10, 11.
+
+## Task 19: Storage Unit edit sheet
+
+**Depends on:** none
+**Files:**
+- Modify: `modules/inventory/ui/StorageUnits/StorageUnitForm.tsx` (`:68-178`)
+- Modify: `packages/printing/src/ui/PrintButton.tsx` (`:30-127`) — add `label?: ReactNode` (default stays "Print")
+
+**Steps:**
+1. Apply every change only when `isEditing` and on phones.
+2. Add `max-md:h-[calc(100dvh-env(safe-area-inset-top)-12px)]` to `ModalDrawerContent`. Do not use `size="full"`.
+3. Render `Submit` in the header, left of the ×. Hide the footer Save and Cancel on phones.
+4. In the footer, render `PrintButton` full width with `label={t\`Print label\`}`.
+5. Replace the read-only `Location` with the read-only `InputBase` pattern at `:126-137`. Add `<Hidden name="locationId" />` and the helper text "Set when the unit was created".
+6. On phones, pass no `termId` to Parent Storage Unit and Work Center. Keep Storage Types' `termId`.
+
+**Verify:** typecheck. Manual: AC 12.
+
+## Task 20: Picking List detail
+
+**Depends on:** 1, 11
+**Files:**
+- Modify: `modules/inventory/ui/PickingLists/PickingListLines.tsx` (`:180-572`)
+- Modify: `modules/inventory/ui/PickingLists/PickingListHeader.tsx` (`:108-218`)
+- Modify: `components/Assignee.tsx` (`:115-205`) — controlled `open` / `onOpenChange` props
+- Precedent: overline header `components/Table/components/Compact/CompactList.tsx:295-302`
+
+**Steps:**
+1. On phones, replace `BarProgress` with an overline header: the job on the left, "{progress}% picked" on the right.
+2. On phones, drop the inner bordered box. Render each line as its own `Card`.
+3. Replace the quantity badge with "To pick {n} {unit}" and "Picked {n} {unit}". If `line.status === "Short"`, add a "Short" `Status` pill.
+4. Put Short and Pick on their own row as two `flex-1` `size="lg"` buttons. On phones Pick uses `variant="secondary"`. Apply the same to Scan and Unpick.
+5. In the header, change the Assignee action to `slot="overflow"` as a Button "Assign". It opens the `Assignee` picker through the new controlled `open` prop.
+
+**Verify:** typecheck. Manual: AC 13.
+
+## Task 21: Issue detail
+
+**Depends on:** 6, 11
+**Files:**
+- Modify: `components/ActionTasks/ActionTaskList.tsx` (`:94-135`), `ActionTaskAddModal.tsx` (`:64-73`)
+- Modify: `modules/quality/ui/Issue/ReviewersList.tsx` (`:56-187`)
+
+**Steps:**
+1. On phones, Actions: a `CardAction` "Add" button opens the existing add modal. Hide the dashed tile. If empty, show one line: "No actions yet."
+2. On phones, Approval Requirements: always render the card. Its header "Add" opens the empty-state modal while empty. With requirements, it opens the "Add Requirement" modal. Hide the dashed tile. If empty, show "No approval requirements yet."
+3. Do not add a properties card on Overview.
+
+**Verify:** typecheck. Manual: AC 14. Also open a Change Notice's Actions card on a phone; it must still work.
+
+## Task 22: Production and Purchasing Planning
+
+**Depends on:** 8, 9, 10
+**Files:**
+- Modify: `modules/production/ui/Planning/ProductionPlanningTable.tsx` (Order col `:487-525`, On Hand `:433-441`, toolbar `:587-607`)
+- Modify: `modules/purchasing/ui/Planning/PurchasingPlanningTable.tsx` (Order col `:563-600`, Supplier `:440-460`, toolbar `:661-685`)
+- Modify: `routes/x+/production+/planning.tsx`, `routes/x+/purchasing+/planning.tsx` (app bar subtitle)
+
+**Steps:**
+1. Add `meta: { mobile: "action" }` to each Order column.
+2. Pass `mobileMenuItems` with a `DropdownMenuItem` "Recalculate". It calls `mrpFetcher.submit({}, { method: "post", action: path.to.api.mrp(locationId) })`. Disable it while `mrpFetcher.state !== "idle"`.
+3. On phones, hide the Recalculate button in `primaryAction`. Add one `md:hidden` muted line: "MRP runs every 3 hours. To run it now, use ⋯ › Recalculate."
+4. In each route, set the app bar subtitle "Production" / "Purchasing" on phones (Task 11 pattern).
+5. Production: add `meta: { mobile: "P3", mobileLabel: true }` to On Hand.
+6. Purchasing: in the Supplier cell, add a `md:hidden` " · {onHand} on hand" after the supplier. Wrap "No Supplier" in Lingui.
+
+**Verify:** typecheck. Manual: AC 15.
+
+## Task 23: Strings, typecheck, lint
+
+**Depends on:** 1–22
+**Steps:**
+1. Run `pnpm lingui:extract && pnpm lingui:clean`.
+2. Run the shared typecheck. Expected: success.
+3. Run `pnpm exec biome check --write` on every changed file. Expected: no errors.
+4. Run `pnpm --filter erp exec vitest run app/components/Table/components/Compact/resolveSlots.test.ts`. Expected: pass.
+
+## Task 24: Browser verification at 393 and 1440
+
+**Depends on:** 23
+**Steps:**
+1. Log in with the `auth` skill (ERP `http://localhost:3000`, `[email protected]`).
+2. At 393×852, check every acceptance criterion 1–16 and 18 of the spec. Screenshot each screen into the session scratchpad.
+3. At 1440×900, open the 12 screens and compare with `local-docs/mobile-design/review-2026-10-08/shots/` desktop behaviour (AC 17). Desktop must look as before.
+4. Close the browser session.
+5. Write the results under "Run notes" below.
+
+## Run notes
+
+- Tasks 1–10 ran in the main session. Five agents started Tasks 11–22 in parallel. The owner stopped them because 4 parallel typechecks used all the RAM. The main session then finished and reviewed every task one group at a time, with one typecheck at the end.
+- Verify: one scoped typecheck (`erp`, `@carbon/react`, `@carbon/printing`) passes. `resolveSlots.test.ts` passes (5 tests). Biome is clean on every file this plan changed. `apps/erp/app/root.tsx` has 2 Biome errors, but that file had uncommitted changes before this plan and this plan does not touch it.
+- Browser at 393×852: all 12 screens load, and no screen scrolls sideways. Checked: one ⋯ on SO (Copy ID, menu, then Cancel / Ship / Invoice), the Preview icon cell, the SO line link, "See all 30" opening the Lines tab, the Quote Reopen primary, the Job Release-only bar, the Part version chip above Bill of Process, the quantity tiles and Update Inventory bar, the full-screen Storage Unit sheet, the Picking List buttons, the Issue cards, the planning Make / Order buttons, and the Quotes list text.
+- Browser at 1440×900: the 11 screens show their desktop layout as before.
+- Deviations:
+ 1. No commits (the owner commits).
+ 2. Task 18 step 5: `compactFocus` has no readable state. A value slot (`useHideListAppBarMenu` in `CompactToolbar.tsx`) keeps the list's ⋯ out of the quantity page's app bar.
+ 3. Added after the browser check: on phones the SO and PO summary card hides its repeated ID and truncates the customer / supplier name. The planning "Qty to Order" leaves the phone row, because the Make / Order button shows the same number.
+ 4. The planning "Make", "Order" and "Blocked" labels now use Lingui (they show on phone rows).
+- Not checked in the browser: saving the Storage Unit sheet, the Assign sheet, the Approval Requirement modals, the Part Save enable rule, and BOP / BOM row clipping with long names (ADCS-001 rows showed no clipping).
diff --git a/.ai/research/2026-10-08-erp-phone-redesign-mapping.md b/.ai/research/2026-10-08-erp-phone-redesign-mapping.md
new file mode 100644
index 0000000000..797998af41
--- /dev/null
+++ b/.ai/research/2026-10-08-erp-phone-redesign-mapping.md
@@ -0,0 +1,99 @@
+# ERP phone redesign — code mapping of the approved changes
+
+Source designs: `local-docs/mobile-design/review-2026-10-08/` (index.html, after-*.json, review.json).
+Read-only mapping on `feat/mobile-redesign` at 5c51803534. Paths relative to `apps/erp/app` unless they start with `packages/`. Nothing here was run in the app unless stated.
+
+## Part B — Quantity, Storage Unit, Picking List, Planning
+
+### Cross-cutting
+- **Trailing row action:** `CompactRow` has none (`components/Table/components/Compact/CompactRow.tsx:44-167`: checkbox, P1 + P2 trailing capped `max-w-[45%]`, P3, ≤2 pills, expand chevron, selection overlay `absolute inset-0` `:155-162`). `resolveSlots.ts:8` ignores Select/Actions/Expand. Adding one = new slot in `components/Table/types.ts:48` + `resolveSlots.ts` (+ test) + a cell in `CompactRow` raised `relative z-10`; hide it in selection mode. Shared but additive (opt-in per column).
+- **Selection mode + bulk bar:** exist. Opt in with `withSelectableRows` + `renderActions` (`Table.tsx:1109-1153` → `CompactList.tsx:164-189`, `:207-211`, bulk `BottomBar` with one "Actions" dropdown `:370-390`). Both planning tables already opt in (`ProductionPlanningTable.tsx:610,614`, `PurchasingPlanningTable.tsx:687,691`).
+- **Drawers:** every `DrawerContent` is a bottom sheet on phones (`packages/react/src/Drawer.tsx:94,192-248`); the grabber is visual only, no swipe code exists; 124 ERP files use it. `size="full"` also widens desktop right/left drawers (`Drawer.tsx:173-176`) — use a phone-only class instead.
+
+### Quantity detail (`/x/inventory/quantities/:itemId/details`)
+- Today: `routes/x+/inventory+/quantities+/$itemId.tsx:96-141` (app bar override, `ResizablePanel compactFocus`), `modules/inventory/ui/Inventory/InventoryItemHeader.tsx:31-58` (external link `:47-52`, `DetailsTopbar` → `CompactTabRow`), `InventoryDetails.tsx:57-171` (six cards `grid-cols-1 md:grid-cols-2` `:59`), `InventoryStorageUnits.tsx:347-476` (Update Inventory `:365-369`, Table `:372-475`, rows `:270-345`).
+- **Shared:** `InventoryDetails` / `InventoryStorageUnits` also render on part/material/tool/consumable `$itemId.inventory.tsx` tabs (e.g. `routes/x+/part+/$itemId.inventory.tsx:287`). Gate quantity-only changes with a prop.
+- Hero subtitle = item name: layout; `item.name` in loader (`:84-94`); `RecordHero` usable standalone (precedent `InspectionView.tsx:506`).
+- Tabs Details · Activity: already exist.
+- 2-col tiles: layout (`max-md:grid-cols-2`, precedent `routes/x+/sales+/_index.tsx:384`, `components/MetricCard.tsx`).
+- Incoming/Outgoing/Supply–demand words: copy; data exists (`InventoryDetails.tsx:107-159`).
+- "Daily usage: 30D ▾" chip: `DateSelect` already renders a chip on phones (`components/DateSelect.tsx:82-101`) but shows only the value; a prefix needs a label beside it or a new prop (shared with 6 dashboards).
+- External link → ⋯ › Item Master: **conflict** — the hidden list's `CompactToolbar` already portals a ⋯ (`InventoryTable.tsx:648-654`, `CompactToolbar.tsx:135`); a second `AppBarActions` stacks two ⋯ (`Mobile/slots.tsx:45-57`). Suppress the list's fill while a `compactFocus` pane is mounted, or merge.
+- Update Inventory → bottom bar: must be gated (`PartHeader` mounts `RecordPhoneChrome`, `modules/items/ui/Parts/PartHeader.tsx:92`).
+- Storage Units table → rows: no phone row component for non-TanStack data; keep batch groups (`toggleGroup`) and the per-row ⋯ (Update Quantity, Print Label). Empty today = empty `<Tbody>`.
+
+### Storage unit edit (`/x/inventory/storage-units/:id`)
+- Today: `routes/x+/inventory+/storage-units.$storageUnitId.tsx:99-127`, `modules/inventory/ui/StorageUnits/StorageUnitForm.tsx:68-178` (`ModalDrawer*`), footer `[Cancel][Print][Save]` `:150-173`. Shared with `storage-units.new.tsx:88` and the inline create modal `components/Form/StorageUnit.tsx:195`.
+- Full-screen sheet: phone-only class on `ModalDrawerContent` (`:76`).
+- Save in header: conflicts with the drawer × (`Drawer.tsx:236,258`, `max-md:pr-14`); × disappears only without `onOpenChange` (`Modal.tsx:24-40`).
+- Swipe-to-dismiss: **new behaviour**, none exists. Discard prompt already partly exists via `Submit`'s `useBlocker` (`packages/form/src/components/Submit.tsx:134-145`) — UNVERIFIED in app.
+- "Print label": `PrintButton` label hard-coded "Print" (`packages/printing/src/ui/PrintButton.tsx:125`).
+- Location lock + why: `label` typed `string`; reuse the form's read-only `InputBase` + `FormHelperText` pattern (`:126-137`) with `<Hidden name="locationId">`.
+- Remove ⓘ: pass `termId` only off phones (`LabelWithHelp` renders nothing without it); Storage Types has no helper text → loses all help on phones.
+
+### Picking list detail (`/x/picking-list/:id/details`)
+- Today: `routes/x+/picking-list+/$pickingListId.tsx:95-106`; `modules/inventory/ui/PickingLists/PickingListHeader.tsx:139-218` (menu Reopen + Delete; actions Assignee overflow, Start primary in Draft, Finish primary In Progress, Cancel overflow → second ⋯ in bar); `PickingListLines.tsx` (`PickingKitCard` `:180-233` with `BarProgress` `:217` and inner box `:218`; line `:366-572`; qty badge `:475-491`; Short/Pick `:553-571`).
+- Hero subtitle job · assignee: **derived data** — `pickingList` has no job column; jobs come from lines (`inventory.service.ts:2960-2972`); a list can span jobs. Assignee name via `assigneeUser(fullName)` (`:2898`) / `usePeople` for optimistic ids.
+- Short/Pick equal buttons, Pick secondary on phones: layout; tracked lines' Scan/Unpick (`:492-542`) need the same.
+- Tick bar → overline header "N% picked": layout (`progress` `:191-201`; style per `CompactList.tsx:295-302`).
+- Inner box removed, line cards: layout, local file.
+- Words for quantities + Short pill: copy; data exists.
+- Bar: Finish only primary; Assign/Start/Cancel/Reopen/Delete → app bar ⋯: `menu` also renders on desktop (`RecordHeader.tsx:334-346`) → needs phone-only items or a new slot; `Assignee` (`components/Assignee.tsx:115-205`) is a self-contained Popover with no controlled `open` → as a menu row needs a new prop or picker sheet. In Draft, Start is primary.
+
+### Production / Purchasing planning
+- Today: `routes/x+/production+/planning.tsx:97-120`, `routes/x+/purchasing+/planning.tsx`; tables `modules/production/ui/Planning/ProductionPlanningTable.tsx` (cols `:347-526`) and `modules/purchasing/ui/Planning/PurchasingPlanningTable.tsx` (cols `:386-600`); order drawers are bottom sheets.
+- Make N / Order N trailing button: **new CompactRow slot** (above); Order cells at Production `:487-525`, Purchasing `:563-600`.
+- Recalculate → app bar ⋯: **new plumbing** — `CompactToolbar` ⋯ only has Export/Import/Select (`:98-131`); add e.g. `mobileMenuItems` through `Table → CompactList → CompactToolbar`; disable while the MRP fetcher is busy.
+- Subtitle under "Material Planning": root screens render the section-switcher branch, which never renders `subtitle` (`components/Layout/Mobile/MobileAppBar.tsx:79-104`); additive shared change.
+- Totals collapsed: already exists.
+- On hand on the row: Production = annotation (`meta.mobile: "P3"`); Purchasing P3 is already Supplier and `resolveSlots` takes only the first P3 → needs a combined column or multi-P3 support.
+- Supplier / "No Supplier" pill: exists (avatar + name; "No Supplier" untranslated).
+- Bulk via Select: exists ("Actions" menu, not a direct button).
+
+## Part A — SO, PO, Quote, Quotes list, Job, Part, Issue
+
+### Shared mechanics
+- **Hero subtitle:** `RecordHeader` → `RecordHero` (`components/Layout/RecordHeader.tsx:306-310`, phone only). Set today only on PO/Quote, to the ID-with-revision when `revisionId > 0` (`PurchaseOrderHeader.tsx:316-320`, `QuoteHeader.tsx:185-187`) — **conflict**: a counterparty subtitle would drop the only phone place showing the revision. Names are in loader data (SO `customer` `sales-order+/$orderId.tsx:233`, PO `supplier` `purchase-order+/$orderId.tsx:600`, Quote `customer` `quote+/$quoteId.tsx:195`, Issue `nonConformance.name`).
+- **App bar subtitle ("Orders"):** parent breadcrumb via `deriveAppBar` (`components/Layout/Mobile/appBar.ts:68-74`) from `detailBreadcrumb` (`utils/handle.ts:41-50`; SO `$orderId.tsx:62-65`, PO `:88-91`, Quote `:54-57`, Job `:74-77`, Issue `:54-57`). Changing crumbs changes desktop; phone-only via `useSetAppBarOverride({ subtitle })` (`useAppBarOverride.ts`, `mergeAppBar` `appBar.ts:31-37`).
+- **Two ⋯ on phones:** `RecordPhoneChrome` (`RecordHeader.tsx:166-247`) renders the app-bar ⋯ (Copy ID + `menu`, `:189-212`) and a bottom-bar ⋯ opening an "Actions" sheet of `slot="overflow"` actions (`:219-244`). Removing the bar ⋯ is a shared change (25 `RecordHeader` users, 24 files with overflow). `menu` items are `DropdownMenuItem`s (MenuSheet on phones, `packages/react/src/Dropdown.tsx:263-270`); overflow actions are Buttons in "row" presentation — merging = mount `overflowSlot.Target` inside the app-bar menu (controlled close) or move items into `menu` behind `isPhone` (menu also renders on desktop `:334-346`).
+- **Preview icon cell:** new — bar presentation forces `w-full lg` Buttons (`packages/react/src/Button.tsx:221-238`), no icon-cell kind.
+- **SplitButton chevron in bar:** `packages/react/src/SplitButton.tsx:55-125`; only PO (Finalize/Mark as Planned) and Job (Release/Mark as Planned) put one in a `RecordAction`.
+- **Files cards:** `components/FileDropzone.tsx:77-93` already gives one phone Upload; the extra is each card's header "New": `OpportunityDocuments.tsx` (SO, Quote, Sales RFQ, Sales Invoice), `SupplierInteractionDocuments.tsx` (PO, Purchasing RFQ, Purchase Invoice, Supplier Quote), `components/Documents.tsx` (Issue, Gauge Calibration). Precedent hiding thead when empty: `components/RecordDocuments.tsx:129`.
+- **Empty state:** `components/Empty.tsx:10-27` ("Looks empty here"), ~49 users; BOP/BOM reach it via `components/SortableList.tsx:325-327` (Job, Item, Quote BOP/BOM). Reuse `CompactEmpty`; add an `emptyState` prop to `SortableList`.
+- **List slots:** `resolveSlots.ts:41-66` — P1 line 1, P2 line 1 trailing (static filter/`mobilePill` → pill on line 3, ≤2), P3 line 2 **first only**, P4/unset hidden; `mobileLabel` prefix (`CompactRow.tsx:13-28`); types `components/Table/types.ts:45-53`.
+- **Number steppers:** `packages/form/src/components/Number.tsx:106-115`, `NumberControlled.tsx:173-182`, styles `packages/react/src/Number.tsx:76-91` (phones get a deliberate 88px −/+ pair, 44pt each). No prop hides them; `size="sm"` also shrinks the input. Hiding contradicts the earlier deliberate phone stepper design.
+
+### Sales Order
+- Order today `routes/x+/sales-order+/$orderId.details.tsx:202-240`: OpportunityState → Summary → Notes → Files → Shipping → Payment. Tabs Overview/Lines/Properties (`Panels.tsx:114-196`).
+- Lines `SalesOrderSummary.tsx:346-708`: inline Edit link to `$orderId.$lineId.details.tsx` (`:429-438`); row tap toggles an inline tax/add-on breakdown + job list (`:409-411`, `:557-702`). Making tap navigate drops that breakdown and job links on phones. `SheetRowContent` (`Mobile/SheetRow.tsx`) is the nearest row.
+- Shipping row: Totals `:244-339`, Add/Edit Shipping → `onEditShippingCost` (`SalesOrderShipmentForm.tsx:78`).
+- Bar: Preview overflow (`SalesOrderHeader.tsx:391-415`), Confirm primary in Draft (`:284`, `:417-432`), Cancel overflow (`:434-453`), Ship/Invoice/Shipments/Invoices/RMAs by status (`:278-290`, `:455-644`); `menu` has Convert Lines to Jobs, Export CSV, Reopen, Delete (`:292-353`).
+
+### Purchase Order
+- Order `purchase-order+/$orderId.details.tsx:231-262`. Lines `PurchaseOrderSummary.tsx:53+` (Edit `:162`, toggle `:139`). The "1 ⇄" badge (`:200-210`) is meaningless: `purchaseOrderLines` has no `methodType` (`purchasing.service.ts:487-497`), always the Pull-from-Inventory icon.
+- "3 of N + See all → Lines tab": tab state is local `useState` in `CompactRecordTabs` (`Panels.tsx:124-126`) — needs a setter via context/slot.
+- Finalize is a `SplitButton` with Mark as Planned (`PurchaseOrderHeader.tsx:355-385`); Cancel Order `:656-675`.
+
+### Quote
+- Order `quote+/$quoteId.details.tsx:191-222`. Rows `QuoteSummary.tsx:160-275`; Edit untranslated (`:199-209`). **Row expand holds `LinePricingOptions` (`:255-265`, `:288+`), the quantity-break picker that drives totals** — tap-to-open would drop it on phones.
+- Bar: Preview overflow (`:197-238`), Share when Sent; Expired → Finalize/Won resolve to overflow, nothing primary (`:104-112`); Reopen only in `menu` (`:136-155`).
+- Locked cards: `QuotePaymentForm.tsx:49-61`, `QuoteShipmentForm.tsx:81-101` disable when `isQuoteLocked` (any status ≠ Draft, `sales.models.ts:1164-1166`); no locked-message component exists.
+
+### Quotes list
+- `modules/sales/ui/Quotes/QuotesTable.tsx`: quoteId P1, customer P3, status P2 pill; Draft renders `BarProgress` (`:124-130`). Data `lines`, `completedLines`, `expirationDate` loaded (`sales.service.ts:116`). Expiration on line 2 needs multi-P3 (shared, ~100 P3 uses) or a phone-only addition in the customer cell. `DateTime dateOptions` for "Sep 21".
+
+### Job
+- `job+/$jobId.details.tsx:259-345`. Method tools `JobMakeMethodTools.tsx:309-385` (Menubar: Get/Save Method, Configure, Item Master, Print; also `job+/$jobId.make.$methodId.tsx:158`). Moving to app-bar ⋯ needs a new value slot that `RecordPhoneChrome` renders after `menu`.
+- Empty BOP/BOM `JobBillOfProcess.tsx:1049-1078`, `JobBillOfMaterial.tsx:559-586` (via SortableList).
+- Estimates vs Actual `JobEstimatesVsActuals.tsx:311-329`: layout fix.
+- Bar `JobHeader.tsx`: Pause secondary (`:393-441`, disabled unless Ready/In Progress `:405-408` → disabled next to Release on Draft), Release SplitButton with Mark as Planned (`:443-469`), Complete/Cancel/SO link/Traveler overflow.
+
+### Part
+- `part+/$itemId.details.tsx:285-375`. `modules/items/ui/Item/MakeMethodTools.tsx:234-265` (Get/Save Method, Item Master untranslated `:262`), version dropdown `:267-~380`; shared with tool/service/part details and make routes (6). Version chip needs extracting the control or a slot above `BillOfProcess` (route `:337`).
+- Rows: shared `SortableList` item (`truncate` `:120`) — what clips on device UNVERIFIED.
+- Steppers: `ItemManufacturingForm.tsx:62-77`. Save footer `:96-103` (`Submit withBlocker={false}`); "enabled only while changed" = new; `Submit` reads `touchedFields` (`packages/form/src/components/Submit.tsx:79-80`); touched ≠ dirty.
+
+### Issue
+- `issue+/$id.details.tsx:153-245`. Actions card `components/ActionTasks/ActionTaskList.tsx:94-135`, dashed add tile `ActionTaskAddModal.tsx:64-73` (shared with Change Notices). Approval Requirements `ReviewersList.tsx`: empty → only a dashed tile opening a modal with an MRB checkbox (`:56-58`, `:179-187`); non-empty → card with "Add Requirement" opening a different modal (`:60-138`) — one header Add must pick one flow.
+- Properties already a tab (`issue+/$id.tsx:265`) → an Overview card would duplicate it.
+- Bar already matches (Start primary, Complete secondary when Registered; `IssueHeader.tsx:148-196`).
diff --git a/.ai/specs/2026-10-08-erp-phone-detail-redesign.md b/.ai/specs/2026-10-08-erp-phone-detail-redesign.md
new file mode 100644
index 0000000000..4e9809938e
--- /dev/null
+++ b/.ai/specs/2026-10-08-erp-phone-detail-redesign.md
@@ -0,0 +1,224 @@
+# ERP phone redesign: 12 screens that failed the phone review
+
+> Status: draft — waiting for owner approval
+> Author: Claude (with the branch owner)
+> Date: 2026-10-08
+> Branch: `feat/mobile-redesign`
+
+## TL;DR
+
+- 12 ERP screens scored 80 or less in the phone review. This spec builds the approved new versions.
+- Every detail page gets the same top: the ID and the record type in the app bar, then `RecordHero` with one muted line and the status, then the usual tab row.
+- Every record page gets one ⋯, in the app bar. The second ⋯ in the bottom action bar goes away.
+- Changes are phone only (below 768px). Desktop stays the same.
+- No new data, no schema change, no new feature. Layout, copy and a few shared phone parts only.
+
+Sources:
+- Approved designs: `local-docs/mobile-design/review-2026-10-08/index.html` (specs `after-*.json`, scores `review.json`).
+- Code mapping: `.ai/research/2026-10-08-erp-phone-redesign-mapping.md`.
+- Earlier phone chrome spec: `.ai/specs/2026-10-07-mobile-chrome-structure.md` (`RecordHeader`, slots).
+
+## Problem
+
+A phone review of 20 main ERP screens scored each one out of 100. 8 list screens passed. 12 screens failed:
+
+| Screen | Score | Main problems |
+|---|---|---|
+| Part detail | 55 | No identity at the top; clipped method button row |
+| Quantity detail | 56 | Six full-width number cards; empty Storage Units table has no message |
+| Sales Order detail | 59 | No customer at the top; clipped customer name; two ⋯ |
+| Purchase Order detail | 59 | Same as Sales Order; meaningless "1 ⇄" badge |
+| Job detail | 60 | Clipped method button row; "Looks empty here 👀" |
+| Quote detail | 61 | No customer at the top; no primary action when Expired |
+| Picking List detail | 69 | Unlabelled tick bar; Short and Pick crammed in a row |
+| Storage Unit edit | 73 | Half sheet; Save at the bottom under the keyboard |
+| Issue detail | 64 | Dashed add tiles; Files table header over "No files" |
+| Production Planning | 76 | No way to act on a row; Recalculate in the body |
+| Purchasing Planning | 77 | Same as Production Planning |
+| Quotes list | 79 | Bare progress bar; no expiry date |
+
+## Goals
+
+- Each of the 12 screens matches its approved design, with the changes in "Resolved questions".
+- The 8 detail pages share one top made of existing phone parts.
+- Every record page has exactly one ⋯ on phones.
+- Every action that a screen offers today stays reachable on phones.
+
+## Non-goals
+
+- Desktop layout or behaviour. Every change is behind `max-md:` or `useViewport().isPhone`.
+- New features, new data, new KPIs, schema changes.
+- A swipe-to-dismiss gesture for sheets.
+- Hiding the number field −/+ steppers.
+- The 8 screens that passed. Their review issues stay in the backlog.
+
+## Design
+
+### 1. Shared phone parts
+
+| # | Part | Change | Files | Reach |
+|---|---|---|---|---|
+| S1 | Record hero subtitle | Each detail header passes `subtitle` to `RecordHeader`. The value is per screen (table 2). | `*Header.tsx` | Phone only (hero renders only on phones) |
+| S2 | App bar subtitle | Each detail route sets the record type ("Sales Order", "Job") with `useSetAppBarOverride({ subtitle })`. Breadcrumbs do not change. | detail routes, `components/Layout/Mobile/useAppBarOverride.ts` | Phone only |
+| S3 | One ⋯ per record | `RecordPhoneChrome` drops the bottom-bar ⋯. The app-bar ⋯ shows Copy ID, then the header `menu`, then every `slot="overflow"` action. | `components/Layout/RecordHeader.tsx` | All 25 record headers |
+| S4 | Icon cell in the action bar | A new `RecordAction slot="icon"` renders one square secondary `IconButton` before the primary. Preview uses it. | `RecordHeader.tsx`, `packages/react/src/ActionPresentation.tsx` | Opt-in |
+| S5 | Split button in the bar | In the bar, a `SplitButton` shows only its main action. Its menu items move to the app-bar ⋯. | `packages/react/src/SplitButton.tsx`, PO and Job headers | PO, Job |
+| S6 | Page items in the app-bar ⋯ | A new value slot lets a child route add items to the record's app-bar ⋯. The method tools use it. | `RecordHeader.tsx`, slot module | Opt-in |
+| S7 | Record tab setter | `CompactRecordTabs` exposes a setter, so "See all N" can switch to the Lines tab. | `components/Layout/Panels.tsx` | Opt-in |
+| S8 | Files cards | On phones, hide the card-header "New" button, and hide the table header while the list is empty. The phone dropzone keeps its one "Upload" button. | `OpportunityDocuments.tsx`, `SupplierInteractionDocuments.tsx`, `components/Documents.tsx` | 10 record pages |
+| S9 | Neutral empty state in sorted lists | `SortableList` takes an `emptyState` prop. Job and Part BOP/BOM pass an icon, one sentence and the add action. Without the prop, nothing changes. | `components/SortableList.tsx` | Opt-in |
+| S10 | Trailing row action in phone lists | A new column meta `mobile: "action"` renders the cell as a trailing 44pt button. It hides in selection mode. | `components/Table/types.ts`, `resolveSlots.ts` (+ test), `CompactRow.tsx` | Opt-in |
+| S11 | Extra items in the list toolbar ⋯ | A new `mobileMenuItems` prop on `Table` adds items to the phone toolbar ⋯. | `Table.tsx`, `CompactList.tsx`, `CompactToolbar.tsx` | Opt-in |
+| S12 | Subtitle on root screens | `MobileAppBar` renders `subtitle` under the section switcher title too. | `components/Layout/Mobile/MobileAppBar.tsx` | Root screens that set a subtitle |
+
+### 2. Detail page tops
+
+Each top has 3 parts: the app bar (ID, record type, ⋯), then `RecordHero` (subtitle and status), then the tab row. Tab rows do not change.
+
+| Screen | App bar subtitle | Hero subtitle | Status | Tabs |
+|---|---|---|---|---|
+| Sales Order | Sales Order | customer name | `SalesStatus` badges | Overview · Lines · Properties |
+| Purchase Order | Purchase Order | supplier name, then " · Rev N" if revised | status badges | Overview · Lines · Properties |
+| Quote | Quote | customer name, then " · Rev N" if revised | `QuoteStatus` | Overview · Lines · Properties |
+| Job | Job | item readable ID · "Qty N" | `JobStatus` badges | Overview · Bill of Materials · Properties |
+| Part | Part | part name | lifecycle status (only when set) | the part's sub-page tabs |
+| Quantity | Quantities | item name | none | Details · Activity |
+| Picking List | Picking List | first job ID (+N if more jobs) · assignee name | `PickingListStatus` | none |
+| Issue | Issue | issue name | `IssueStatus` | Overview · Associations · Properties |
+
+SO, PO and Quote keep `OpportunityState` / `SupplierInteractionState` as the first Overview card, as today.
+
+### 3. Per-screen body changes
+
+**Sales Order**
+1. Overview order: state bar, summary (lines, totals), then Notes, Files, Shipping, Payment, as today.
+2. Phone line row: part number with the line total, then the part name, then "1 × $250.00 EA". No Edit link, no badges, no expand.
+3. A tap on the row opens the line page (`path.to.salesOrderLine`).
+4. In the totals, "Add Shipping" becomes a Shipping row. The row uses the existing `onEditShippingCost`.
+5. Action bar: Preview (icon cell), then the status primary (Confirm when Draft). Cancel and the other overflow actions go to the app-bar ⋯ (S3).
+
+**Purchase Order**
+1. Same template as Sales Order.
+2. Overview shows the first 3 lines and "See all N". "See all N" opens the Lines tab (S7).
+3. The "1 ⇄" badge goes. It always shows the same icon today (no `methodType` on `purchaseOrderLines`).
+4. Action bar: Preview (icon), Finalize. "Mark as Planned" moves to the app-bar ⋯ (S5).
+
+**Quote**
+1. Same template. The line row keeps its tap-to-expand, because the expand holds the quantity-break picker. Only the row look changes (no Edit link, no badges).
+2. If the quote is Expired, Reopen is the bar primary on phones. The ⋯ menu keeps Reopen for desktop.
+3. On phones, locked Payment and Shipping cards show one line: "Locked while the quote is {status}. Reopen it to edit."
+
+**Quotes list**
+1. Draft quotes: a Draft status pill and the text "N of M lines complete" replace the bar (phone only).
+2. Line 2: the customer, then "Exp. Sep 21" (phone-only text in the customer cell).
+
+**Job**
+1. Get Method, Save Method, Configure and Item Master move to the app-bar ⋯ (S6). The phone hides the method `Menubar`.
+2. Bill of Process and Bill of Material use the neutral empty state (S9): "No operations yet" / "No materials yet", one sentence, the add action.
+3. Estimates vs Actual: the title on its own line, then the Processes / Material tabs at full width.
+4. Action bar: Release is the primary. Pause shows only when the job is Ready or In Progress. "Mark as Planned" moves to the ⋯ (S5).
+
+**Part**
+1. Get Method, Save Method and Item Master move to the app-bar ⋯ (S6).
+2. The method version control renders as a chip above Bill of Process on phones.
+3. Bill of Process and Bill of Material rows show their full text. Execute checks the rows on a phone first and fixes only the clipped parts.
+4. The Manufacturing card Save is a full-width button. On phones it is disabled until a field in the card changes.
+5. Number fields keep their −/+ steppers.
+
+**Quantity detail** (changes gated so the part, material, tool and consumable inventory tabs stay the same)
+1. The six cards become a 2-column grid of tiles.
+2. Under the order figures: "↑ Incoming" and "↓ Outgoing". The jobs tile reads "Supply / demand".
+3. The usage window select shows as a chip with the label "Daily usage".
+4. The external-link icon moves to the app-bar ⋯ as "Item Master".
+5. "Update Inventory" moves to the bottom action bar.
+6. The Storage Units table becomes phone rows: unit, quantity, tracking ID, expiry. Batch groups and the per-row ⋯ stay. If no unit holds stock, one line says so.
+7. Fix: the hidden list's toolbar ⋯ must not add a second ⋯ to this page's app bar.
+
+**Storage Unit edit** (edit sheet only; the New sheet and the inline create modal stay the same)
+1. The sheet fills the screen on phones (a phone-only class, not `size="full"`).
+2. Save moves to the sheet header, left of the existing ×. The footer holds "Print label" as one full-width secondary button.
+3. The × and the overlay keep their close behaviour and the existing unsaved-changes prompt.
+4. The read-only Location field shows a lock and the line "Set when the unit was created".
+5. The ⓘ help icons go on phones where the field has help text under it (Parent, Work Center). Storage Types keeps its ⓘ, because it has no help text.
+
+**Picking List detail**
+1. The grey tick bar becomes an overline header: the job, then "N% picked" on the right.
+2. The inner bordered box goes. Each line is its own card at the full gutter width.
+3. Quantities use words: "To pick 4 EA", "Picked 0 LB". A shorted line shows a "Short" pill with an icon.
+4. Short and Pick are two equal 44pt buttons on their own row. Pick is secondary on phones. Tracked lines get the same treatment for Scan and Unpick.
+5. Action bar: the status primary only (Start when Draft, Finish when In Progress). Assign, Cancel, Reopen and Delete are in the app-bar ⋯ (S3). "Assign" opens the existing assignee picker in a sheet.
+
+**Issue detail**
+1. Files: S8.
+2. Actions and Approval Requirements are cards with one "Add" in the card header and a one-line empty sentence. The dashed tiles go on phones.
+3. While empty, the Approval Requirements "Add" opens today's empty-state modal. With requirements, it opens today's "Add Requirement" modal.
+4. Properties stay in the Properties tab. No Overview card.
+5. Action bar: no change (Start primary, Complete secondary when Registered).
+
+**Production and Purchasing Planning**
+1. Each phone row gets the desktop "Make N" / "Order N" button as a trailing action (S10). It opens the existing order sheet.
+2. Recalculate moves to the toolbar ⋯ (S11). It is disabled while MRP runs.
+3. One muted line under the location chip: "MRP runs every 3 hours. To run it now, use ⋯ › Recalculate."
+4. The app bar shows "Material Planning" with the subtitle "Production" or "Purchasing" (S12).
+5. Production rows show on hand on line 2. Purchasing rows show the supplier (or the red "No Supplier" pill), then on hand.
+6. Totals stay as the collapsed card. Bulk actions stay in ⋯ › Select, as today.
+
+## Design decisions
+
+| Decision | Choice | Why |
+|---|---|---|
+| Build the top from what parts? | `RecordHero` subtitle + status, existing tab row | Owner rejected new header styling; these parts already ship on phones |
+| Where the record type comes from on phones | `useSetAppBarOverride` per detail route | Changing breadcrumbs would change desktop |
+| Second ⋯ in the bar | Removed on all 25 records | Owner choice; one menu everywhere |
+| Preview button | New `slot="icon"` cell | Bar presentation forces full-width buttons today |
+| Split buttons in the bar | Main action only; menu items to ⋯ | The chevron is a second target in a 44pt bar |
+| Method tools on Job and Part | New value slot into the app-bar ⋯ | Tools live in a child route; the header owns the ⋯ |
+| PO "See all N" | Setter on `CompactRecordTabs` | Tab state is local today |
+| Files cards | Hide header New and empty table header on phones | The phone dropzone already gives one Upload; precedent `RecordDocuments.tsx:129` |
+| Empty BOP/BOM | `emptyState` prop on `SortableList` | `Empty` has about 49 users; a prop keeps the change opt-in |
+| Planning row action | New `mobile: "action"` slot | `CompactRow` has no trailing action; opt-in per column |
+| Recalculate | New `mobileMenuItems` on `Table` | A second `AppBarActions` would show two ⋯ |
+| Quotes list expiry | Phone-only text in the customer cell | `resolveSlots` takes only the first P3 column |
+| Purchasing on hand | Phone-only text after the supplier | Same P3 limit |
+| Quantity tiles and rows | Gated by a prop | The same components render on 4 item inventory tabs |
+| Storage Unit full screen | Phone-only class | `size="full"` widens desktop drawers |
+| Picking list subtitle | First job ID, "+N" if more | A list can span jobs; `pickingList` has no job column |
+| "Print label" text | New `label` prop on `PrintButton` | The label is hard-coded "Print" |
+
+## Acceptance criteria
+
+All checks run at 393×852 unless the row says 1440.
+
+1. On SO000025, the hero line reads "ZZ_Mobile_Audit_CustomerVeryLongNameNoSp Industrial…" with an ellipsis, and the app bar subtitle reads "Sales Order".
+2. On a revised PO, the hero line ends with " · Rev 1".
+3. Each of the 25 record pages shows one ⋯, in the app bar. Every action that the old bottom-bar ⋯ held is in it.
+4. On SO000025, the action bar shows a square Preview icon and Confirm. Preview opens the PDF menu.
+5. Tapping an SO or PO line opens its line page. Tapping a Quote line expands it and shows the quantity-break picker.
+6. On PO000019, Overview shows 3 lines and "See all 30". Tapping it selects the Lines tab.
+7. On J000022, the ⋯ holds Get Method, Save Method, Configure and Item Master. No method button row shows. BOP and BOM show "No operations yet" and "No materials yet" with an add button.
+8. On a Draft job, the bar shows only Release. On an In Progress job, Pause shows too.
+9. On ADCS-001, the version chip shows above Bill of Process. The Manufacturing Save is disabled until a field changes.
+10. On the ADCS-001 quantity page, 6 tiles form 2 columns, Update Inventory is in the bottom bar, and the app bar has one ⋯ with Item Master.
+11. On the ADCS-001 Part → Inventory tab, the tiles and the Storage Units table look as they do today.
+12. The Storage Unit edit sheet fills the screen, Save is in the header, and Print label is the only footer button. The New sheet looks as it does today.
+13. On PL000002, Short and Pick are two equal buttons. The header shows "N% picked". The bar shows only Finish.
+14. On NCR000006, Actions and Approval Requirements each show a card with "Add" in the header. No dashed tile shows.
+15. On both planning pages, each row has a "Make N" / "Order N" button that opens the order sheet. ⋯ holds Recalculate.
+16. On the Quotes list, Q000005 shows a Draft pill and "0 of 2 lines complete". Line 2 shows "Exp." and a date.
+17. At 1440×900, all 12 screens match their desktop screenshots from before this change.
+18. No screen scrolls sideways at 393px. Typecheck, Biome and `pnpm lingui:extract` pass.
+
+## Resolved questions
+
+- [x] How far should the ⋯ merge go? — **Answer:** every record page (25 headers).
+- [x] What does a tap on an SO, PO or Quote line do? — **Answer:** SO and PO open the line page. Quote keeps the expand for the quantity-break picker.
+- [x] Hide the Part number steppers? — **Answer:** no. Keep the phone −/+ steppers.
+- [x] How does the Storage Unit sheet close? — **Answer:** Save in the header, keep the ×. No swipe gesture.
+- [x] What does the PO / Quote hero line show when revised? — **Answer:** the name, then " · Rev N".
+- [x] Add an Issue properties card on Overview? — **Answer:** no. The Properties tab stays the only place.
+- [x] What does the single Approval Requirements "Add" open? — **Answer:** the same modal as today for each state.
+- [x] How does the Job bar read on a Draft job? — **Answer:** Release only. Pause shows when the job is Ready or In Progress.
+
+## Changelog
+
+- 2026-10-08: First draft after the owner approved the redesigned screens and answered 8 questions.
diff --git a/apps/erp/app/components/ActionTasks/ActionTaskAddModal.tsx b/apps/erp/app/components/ActionTasks/ActionTaskAddModal.tsx
index 5b3516e7cd..9c3a9f91d3 100644
--- a/apps/erp/app/components/ActionTasks/ActionTaskAddModal.tsx
+++ b/apps/erp/app/components/ActionTasks/ActionTaskAddModal.tsx
@@ -29,13 +29,16 @@ export function ActionTaskAddModal({
onAdd,
isSubmitting = false,
isDisabled = false,
- emptyMessage
+ emptyMessage,
+ trigger = "tile"
}: {
templates: ListItem[];
onAdd: (selectedIds: string[]) => void;
isSubmitting?: boolean;
isDisabled?: boolean;
emptyMessage?: string;
+ /** `button`: a compact "Add" for a card header (phones) instead of the dashed tile. */
+ trigger?: "tile" | "button";
}) {
const [isOpen, setIsOpen] = useState(false);
const [selectedIds, setSelectedIds] = useState<string[]>([]);
@@ -61,17 +64,28 @@ export function ActionTaskAddModal({
return (
<>
- <button
- type="button"
- className="flex items-center justify-start bg-card border-2 border-dashed border-background w-full hover:bg-background/80 rounded-lg px-10 py-6 text-muted-foreground hover:text-foreground gap-2 transition-colors duration-200 text-sm cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed"
- onClick={() => setIsOpen(true)}
- disabled={isDisabled}
- >
- <LuCirclePlus size={16} />
- <span>
- <Trans>Add Actions</Trans>
- </span>
- </button>
+ {trigger === "button" ? (
+ <Button
+ variant="secondary"
+ leftIcon={<LuCirclePlus />}
+ isDisabled={isDisabled}
+ onClick={() => setIsOpen(true)}
+ >
+ <Trans>Add</Trans>
+ </Button>
+ ) : (
+ <button
+ type="button"
+ className="flex items-center justify-start bg-card border-2 border-dashed border-background w-full hover:bg-background/80 rounded-lg px-10 py-6 text-muted-foreground hover:text-foreground gap-2 transition-colors duration-200 text-sm cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed"
+ onClick={() => setIsOpen(true)}
+ disabled={isDisabled}
+ >
+ <LuCirclePlus size={16} />
+ <span>
+ <Trans>Add Actions</Trans>
+ </span>
+ </button>
+ )}
<Modal
open={isOpen}
diff --git a/apps/erp/app/components/ActionTasks/ActionTaskList.tsx b/apps/erp/app/components/ActionTasks/ActionTaskList.tsx
index 9175aebaad..ac5d531d29 100644
--- a/apps/erp/app/components/ActionTasks/ActionTaskList.tsx
+++ b/apps/erp/app/components/ActionTasks/ActionTaskList.tsx
@@ -4,11 +4,13 @@
import {
Card,
+ CardAction,
CardContent,
CardHeader,
CardTitle,
HStack,
useDebounce,
+ useViewport,
VStack
} from "@carbon/react";
import { Trans } from "@lingui/react/macro";
@@ -56,6 +58,7 @@ export function ActionTaskList<T extends ActionTaskRow>({
title?: ReactNode;
}) {
const orderFetcher = useFetcher<{ success: boolean }>();
+ const { isPhone } = useViewport();
const [sortOrder, setSortOrder] = useState<string[]>(() =>
[...tasks]
@@ -97,7 +100,28 @@ export function ActionTaskList<T extends ActionTaskRow>({
<CardHeader>
<CardTitle>{title ?? <Trans>Actions</Trans>}</CardTitle>
</CardHeader>
- {tasks.length > 0 && <ActionTaskProgress tasks={tasks} />}
+ {isPhone ? (
+ // Phones: the add sits in the header; the progress bar keeps the
+ // space for the collapse button after it.
+ <HStack spacing={0} className="pr-14">
+ {tasks.length > 0 && (
+ <ActionTaskProgress tasks={tasks} className="pr-2" />
+ )}
+ {!isDisabled && onAdd && (
+ <CardAction className="px-0">
+ <ActionTaskAddModal
+ templates={templates ?? []}
+ onAdd={onAdd}
+ isSubmitting={isAddSubmitting}
+ emptyMessage={addEmptyMessage}
+ trigger="button"
+ />
+ </CardAction>
+ )}
+ </HStack>
+ ) : (
+ tasks.length > 0 && <ActionTaskProgress tasks={tasks} />
+ )}
</HStack>
<CardContent>
<VStack spacing={3}>
@@ -122,7 +146,13 @@ export function ActionTaskList<T extends ActionTaskRow>({
</Reorder.Group>
)}
- {!isDisabled && onAdd && (
+ {isPhone && tasks.length === 0 && (
+ <p className="text-sm text-muted-foreground">
+ <Trans>No actions yet.</Trans>
+ </p>
+ )}
+
+ {!isPhone && !isDisabled && onAdd && (
<ActionTaskAddModal
templates={templates ?? []}
onAdd={onAdd}
diff --git a/apps/erp/app/components/Assignee.tsx b/apps/erp/app/components/Assignee.tsx
index a052f3d9d7..20569c5703 100644
--- a/apps/erp/app/components/Assignee.tsx
+++ b/apps/erp/app/components/Assignee.tsx
@@ -43,6 +43,9 @@ export type AssigneeProps = Omit<
placeholder?: string;
variant?: AssigneeVariants;
onChange?: (selected: string) => void;
+ /** Controlled picker state. Omit both to let the trigger open it. */
+ open?: boolean;
+ onOpenChange?: (open: boolean) => void;
};
const Assign = forwardRef<HTMLButtonElement, AssigneeProps>(
@@ -56,13 +59,20 @@ const Assign = forwardRef<HTMLButtonElement, AssigneeProps>(
placeholder,
variant = "button",
onChange,
+ open: controlledOpen,
+ onOpenChange,
className,
...props
},
ref
) => {
const { t } = useLingui();
- const [open, setOpen] = useState(false);
+ const [uncontrolledOpen, setUncontrolledOpen] = useState(false);
+ const open = controlledOpen ?? uncontrolledOpen;
+ const setOpen = (next: boolean) => {
+ if (controlledOpen === undefined) setUncontrolledOpen(next);
+ onOpenChange?.(next);
+ };
const [people] = usePeople();
const fetcher = useFetcher<{}>();
const user = useUser();
diff --git a/apps/erp/app/components/Documents.tsx b/apps/erp/app/components/Documents.tsx
index 46d3f21db4..d14861010e 100644
--- a/apps/erp/app/components/Documents.tsx
+++ b/apps/erp/app/components/Documents.tsx
@@ -11,6 +11,7 @@ import {
CardContent,
CardHeader,
CardTitle,
+ cn,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
@@ -234,7 +235,7 @@ const Documents = ({
<Trans>Files</Trans>
</CardTitle>
</CardHeader>
- <CardAction>
+ <CardAction className="max-md:hidden">
<File
isDisabled={!canUpdate}
leftIcon={<LuUpload />}
@@ -251,7 +252,11 @@ const Documents = ({
</HStack>
<CardContent>
<Table>
- <Thead>
+ <Thead
+ className={cn(
+ allFiles.length === 0 && !modelUpload && "max-md:hidden"
+ )}
+ >
<Tr>
<Th>
<Trans>Name</Trans>
diff --git a/apps/erp/app/components/Layout/Mobile/MobileAppBar.tsx b/apps/erp/app/components/Layout/Mobile/MobileAppBar.tsx
index 3babaa431f..1478c9035a 100644
--- a/apps/erp/app/components/Layout/Mobile/MobileAppBar.tsx
+++ b/apps/erp/app/components/Layout/Mobile/MobileAppBar.tsx
@@ -81,10 +81,19 @@ export function MobileAppBar() {
type="button"
onClick={() => setSwitcherOpen(true)}
aria-haspopup="dialog"
- className="flex min-h-11 min-w-0 items-center gap-1 rounded-lg px-1 text-foreground outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50"
+ className="flex min-h-11 min-w-0 flex-col items-start justify-center rounded-lg px-1 text-left text-foreground outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50"
>
- {titleText}
- <LuChevronDown className="size-5 shrink-0 text-muted-foreground" />
+ <span className="flex min-w-0 max-w-full items-center gap-1">
+ {titleText}
+ <LuChevronDown className="size-5 shrink-0 text-muted-foreground" />
+ </span>
+ {/* A root screen with two siblings under one sidebar label
+ (Material Planning) names itself here. */}
+ {subtitle ? (
+ <span className="min-w-0 max-w-full truncate text-xs text-muted-foreground">
+ {subtitle}
+ </span>
+ ) : null}
</button>
) : (
<button
diff --git a/apps/erp/app/components/Layout/Mobile/MobileTabBar.tsx b/apps/erp/app/components/Layout/Mobile/MobileTabBar.tsx
index 1840f93fe7..203ece22bf 100644
--- a/apps/erp/app/components/Layout/Mobile/MobileTabBar.tsx
+++ b/apps/erp/app/components/Layout/Mobile/MobileTabBar.tsx
@@ -2,12 +2,11 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-import { cn } from "@carbon/react";
+import { cn, TabBar, TabBarItem } from "@carbon/react";
import { useLingui } from "@lingui/react/macro";
-import type { ReactNode } from "react";
import { useEffect, useState } from "react";
import { LuHouse, LuLayoutGrid, LuSearch, LuSquarePen } from "react-icons/lu";
-import { Link, useLocation } from "react-router";
+import { useLocation } from "react-router";
import { Avatar } from "~/components";
import { useUser } from "~/hooks";
import { useUIStore } from "~/stores/ui";
@@ -18,40 +17,6 @@ import { ModulesSheet } from "./ModulesSheet";
import { ProfileSheet } from "./ProfileSheet";
import { useAppBar } from "./useAppBar";
-const tabClassName =
- "flex min-h-11 min-w-0 flex-1 flex-col items-center justify-center gap-0.5 text-[10.5px] font-medium leading-none outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50";
-
-function Tab({
- icon,
- label,
- isActive
-}: {
- icon: ReactNode;
- label: string;
- isActive?: boolean;
-}) {
- return (
- <>
- <span
- className={cn(
- "flex size-6 items-center justify-center [&>svg]:size-5",
- isActive ? "text-foreground" : "text-muted-foreground"
- )}
- >
- {icon}
- </span>
- <span
- className={cn(
- "max-w-full truncate",
- isActive ? "text-foreground" : "text-muted-foreground"
- )}
- >
- {label}
- </span>
- </>
- );
-}
-
/**
* The compact tab bar: Home, Search, Create, Modules, Profile — each
* an existing desktop control. Shown on root screens only; a page's bottom
@@ -81,67 +46,43 @@ export function MobileTabBar() {
return (
<>
- <nav
- aria-label={t`Main`}
- className={cn(
- "md:hidden flex shrink-0 items-stretch border-t border-border bg-card/92 px-1 pt-1 pb-safe backdrop-blur",
- hidden && "hidden"
- )}
- >
- <Link
+ <TabBar aria-label={t`Main`} className={cn(hidden && "hidden")}>
+ <TabBarItem
to={path.to.authenticatedRoot}
- className={tabClassName}
- aria-current={isHome ? "page" : undefined}
- >
- <Tab icon={<LuHouse />} label={t`Home`} isActive={isHome} />
- </Link>
- <button
- type="button"
- className={tabClassName}
+ icon={<LuHouse />}
+ label={t`Home`}
+ isActive={isHome}
+ />
+ <TabBarItem
+ icon={<LuSearch />}
+ label={t`Search`}
onClick={openSearchModal}
- >
- <Tab icon={<LuSearch />} label={t`Search`} />
- </button>
- <button
- type="button"
- className={tabClassName}
+ />
+ <TabBarItem
+ icon={<LuSquarePen />}
+ label={t`Create`}
+ isActive={sheet === "create"}
onClick={() => setSheet("create")}
- >
- <Tab
- icon={<LuSquarePen />}
- label={t`Create`}
- isActive={sheet === "create"}
- />
- </button>
- <button
- type="button"
- className={tabClassName}
+ />
+ <TabBarItem
+ icon={<LuLayoutGrid />}
+ label={t`Modules`}
+ isActive={sheet === "modules"}
onClick={() => setSheet("modules")}
- >
- <Tab
- icon={<LuLayoutGrid />}
- label={t`Modules`}
- isActive={sheet === "modules"}
- />
- </button>
- <button
- type="button"
- className={tabClassName}
+ />
+ <TabBarItem
+ icon={
+ <Avatar
+ path={user.avatarUrl}
+ name={`${user.firstName} ${user.lastName}`}
+ size="xs"
+ />
+ }
+ label={t`Profile`}
+ isActive={sheet === "profile"}
onClick={() => setSheet("profile")}
- >
- <Tab
- icon={
- <Avatar
- path={user.avatarUrl}
- name={`${user.firstName} ${user.lastName}`}
- size="xs"
- />
- }
- label={t`Profile`}
- isActive={sheet === "profile"}
- />
- </button>
- </nav>
+ />
+ </TabBar>
<CreateSheet open={sheet === "create"} onOpenChange={setOpen("create")} />
<ModulesSheet
open={sheet === "modules"}
diff --git a/apps/erp/app/components/Layout/Mobile/useAppBar.ts b/apps/erp/app/components/Layout/Mobile/useAppBar.ts
index 823c54af36..e753e2f041 100644
--- a/apps/erp/app/components/Layout/Mobile/useAppBar.ts
+++ b/apps/erp/app/components/Layout/Mobile/useAppBar.ts
@@ -2,7 +2,11 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import type { MessageDescriptor } from "@lingui/core";
+import { useLingui } from "@lingui/react/macro";
+import { useMatches } from "react-router";
import { useUser } from "~/hooks";
+import type { Handle } from "~/utils/handle";
import { useCompactModuleSidebar } from "../Navigation/CollapsibleSidebar";
import { useBreadcrumbs } from "../Topbar/Breadcrumbs";
import { deriveAppBar, mergeAppBar } from "./appBar";
@@ -15,6 +19,8 @@ import { useAppBarOverride } from "./useAppBarOverride";
* title. Home shows the company name.
*/
export function useAppBar() {
+ const { i18n } = useLingui();
+ const matches = useMatches();
const crumbs = useBreadcrumbs();
const Sidebar = useCompactModuleSidebar();
const { company } = useUser();
@@ -24,10 +30,21 @@ export function useAppBar() {
hasModuleSidebar: Boolean(Sidebar),
moduleCrumbIndex: 0
});
+ // The deepest route that names its record type replaces the list crumb.
+ const subtitle = [...matches]
+ .reverse()
+ .find((m) => (m.handle as Handle | undefined)?.appBarSubtitle);
const state = mergeAppBar(
{
...derived,
- title: crumbs.length === 0 ? company?.name : derived.title
+ title: crumbs.length === 0 ? company?.name : derived.title,
+ ...(subtitle
+ ? {
+ subtitle: i18n._(
+ (subtitle.handle as Handle).appBarSubtitle as MessageDescriptor
+ )
+ }
+ : {})
},
override
);
diff --git a/apps/erp/app/components/Layout/Panels.tsx b/apps/erp/app/components/Layout/Panels.tsx
index cac57306c0..8bc0174680 100644
--- a/apps/erp/app/components/Layout/Panels.tsx
+++ b/apps/erp/app/components/Layout/Panels.tsx
@@ -106,6 +106,17 @@ interface ResizablePanelsProps {
/** True inside a compact record frame's tab panel (see CompactToolbar). */
export const RecordFrameContext = createContext(false);
+type RecordPanel = "content" | "explorer" | "properties";
+const RecordPanelContext = createContext<(panel: RecordPanel) => void>(
+ () => {}
+);
+
+/**
+ * Phones: switch the record frame's tab, e.g. "See all 30" opening Lines.
+ * A no-op outside a compact record frame.
+ */
+export const useShowRecordPanel = () => useContext(RecordPanelContext);
+
/**
* Phones: one sticky underline tab row instead of side panels: the record's
* content (or its sub-route tabs), the explorer and the properties. Content
@@ -121,9 +132,7 @@ function CompactRecordTabs({
const location = useOptimisticLocation();
const recordTabs = recordTabsSlot.useValue();
recordFrameSlot.useProvide(true);
- const [panel, setPanel] = useState<"content" | "explorer" | "properties">(
- "content"
- );
+ const [panel, setPanel] = useState<RecordPanel>("content");
// A tapped line (or any navigation) shows its content.
// biome-ignore lint/correctness/useExhaustiveDependencies: switch back on navigation only
@@ -184,11 +193,13 @@ function CompactRecordTabs({
)}
>
<RecordFrameContext.Provider value>
- {panel === "content"
- ? content
- : panel === "explorer"
- ? explorer
- : properties}
+ <RecordPanelContext.Provider value={setPanel}>
+ {panel === "content"
+ ? content
+ : panel === "explorer"
+ ? explorer
+ : properties}
+ </RecordPanelContext.Provider>
</RecordFrameContext.Provider>
</div>
</div>
diff --git a/apps/erp/app/components/Layout/RecordHeader.tsx b/apps/erp/app/components/Layout/RecordHeader.tsx
index 2370470e57..acdd93cb73 100644
--- a/apps/erp/app/components/Layout/RecordHeader.tsx
+++ b/apps/erp/app/components/Layout/RecordHeader.tsx
@@ -4,11 +4,6 @@
import {
ActionPresentationProvider,
- BottomSheet,
- BottomSheetBody,
- BottomSheetContent,
- BottomSheetHeader,
- BottomSheetTitle,
Copy,
cn,
copyToClipboard,
@@ -16,6 +11,7 @@ import {
DropdownMenuContent,
DropdownMenuIcon,
DropdownMenuItem,
+ DropdownMenuSeparator,
DropdownMenuTrigger,
Heading,
HStack,
@@ -42,14 +38,18 @@ import {
} from "./Mobile/ChromeSlots";
import { createPortalSlot } from "./Mobile/slots";
-/** Where record actions go on phones: the bottom bar's cells, the ⋯ sheet. */
+/**
+ * Where record actions go on phones: the bottom bar's cells (an icon cell,
+ * then the primary and secondary), and the app-bar ⋯.
+ */
+const iconSlot = createPortalSlot();
const primarySlot = createPortalSlot();
const secondarySlot = createPortalSlot();
const overflowSlot = createPortalSlot();
/** A card form's hero: DocumentHeader fills it, the page places it. */
export const recordHeroSlot = createPortalSlot();
-/** The ⋯ action sheet; one record frame shows at a time, like its slot. */
+/** The app-bar ⋯ menu; one record frame shows at a time, like its slot. */
const useOverflowSheet = create<{
open: boolean;
setOpen: (open: boolean) => void;
@@ -57,11 +57,13 @@ const useOverflowSheet = create<{
const closeOverflow = () => useOverflowSheet.getState().setOpen(false);
const presentations = {
+ icon: { kind: "bar", emphasis: "secondary", iconOnly: true },
primary: { kind: "bar", emphasis: "primary" },
secondary: { kind: "bar", emphasis: "secondary" },
overflow: { kind: "row", onSelect: closeOverflow }
} as const;
const slots = {
+ icon: iconSlot,
primary: primarySlot,
secondary: secondarySlot,
overflow: overflowSlot
@@ -69,28 +71,47 @@ const slots = {
/**
* A record header action. Desktop renders it in place; phones move it to
- * the bottom bar (`primary` filled, `secondary` outline) or the ⋯ sheet
- * (`overflow`), and its Button renders to match (see ActionPresentation).
+ * the bottom bar (`icon` a square outline cell, `primary` filled, `secondary`
+ * outline) or the app-bar ⋯ (`overflow`), and its Button renders to match
+ * (see ActionPresentation).
*/
export function RecordAction({
slot,
children
}: {
- slot: "primary" | "secondary" | "overflow";
+ slot: "icon" | "primary" | "secondary" | "overflow";
children: ReactNode;
}) {
const { isPhone } = useViewport();
if (!isPhone) return <>{children}</>;
const { Fill } = slots[slot];
+ const presentation = presentations[slot];
return (
<Fill>
- <ActionPresentationProvider value={presentations[slot]}>
+ <ActionPresentationProvider
+ value={
+ presentation.kind === "bar"
+ ? { ...presentation, overflow: renderOverflow }
+ : presentation
+ }
+ >
{children}
</ActionPresentationProvider>
</Fill>
);
}
+/** A bar action's extra buttons (a split button's items) as ⋯ menu rows. */
+function renderOverflow(buttons: ReactNode) {
+ return (
+ <overflowSlot.Fill>
+ <ActionPresentationProvider value={presentations.overflow}>
+ {buttons}
+ </ActionPresentationProvider>
+ </overflowSlot.Fill>
+ );
+}
+
/**
* Phones: the record's name, subtitle and status under the app bar. Kept
* mounted (hidden) when empty, so --header-height still resolves (to 0):
@@ -159,9 +180,9 @@ const cellClassName =
"flex min-w-0 flex-1 empty:hidden [&>*]:w-full [&>*]:min-w-0";
/**
- * Phones: the record's app-bar ⋯ (Copy ID and its menu) and the bottom
- * action bar with the ⋯ sheet that its RecordActions fill. Renders nothing
- * at md and above.
+ * Phones: the record's one ⋯, in the app bar (Copy ID, the header menu, then
+ * the overflow actions), and the bottom action bar its
+ * RecordActions fill. Renders nothing at md and above.
*/
export function RecordPhoneChrome({
menu,
@@ -172,6 +193,7 @@ export function RecordPhoneChrome({
}) {
const { t } = useLingui();
const { isPhone } = useViewport();
+ const hasIcon = iconSlot.useFilled();
const hasPrimary = primarySlot.useFilled();
const hasSecondary = secondarySlot.useFilled();
const hasOverflow = overflowSlot.useFilled();
@@ -184,11 +206,13 @@ export function RecordPhoneChrome({
}
};
+ const hasMenu = Boolean(menu || copyValue || hasOverflow);
+
return (
<>
- {menu || copyValue ? (
+ {hasMenu ? (
<AppBarActions>
- <DropdownMenu>
+ <DropdownMenu open={open} onOpenChange={setOpen}>
<DropdownMenuTrigger asChild>
<IconButton
className="order-last"
@@ -206,42 +230,28 @@ export function RecordPhoneChrome({
</DropdownMenuItem>
) : null}
{menu}
+ {hasOverflow ? (
+ <>
+ <DropdownMenuSeparator />
+ {/* Overflow actions render as menu rows here; choosing
+ one closes the menu (closeOverflow). */}
+ <overflowSlot.Target className="flex flex-col [&>*]:w-full" />
+ </>
+ ) : null}
</DropdownMenuContent>
</DropdownMenu>
</AppBarActions>
) : null}
- {hasPrimary || hasSecondary || hasOverflow ? (
+ {hasIcon || hasPrimary || hasSecondary ? (
<BottomBar>
<div className="flex items-center gap-2 border-t border-border bg-card px-4 pt-2 pb-safe-4 [&>*]:min-w-0">
+ <iconSlot.Target className="flex shrink-0 empty:hidden" />
<primarySlot.Target className={cellClassName} />
<secondarySlot.Target className={cellClassName} />
- {hasOverflow ? (
- <IconButton
- aria-label={t`More actions`}
- icon={<LuEllipsis />}
- variant="secondary"
- size="lg"
- className="ml-auto shrink-0"
- onClick={() => setOpen(true)}
- />
- ) : null}
</div>
</BottomBar>
) : null}
-
- <BottomSheet open={open} onOpenChange={setOpen}>
- <BottomSheetContent>
- <BottomSheetHeader>
- <BottomSheetTitle>
- <Trans>Actions</Trans>
- </BottomSheetTitle>
- </BottomSheetHeader>
- <BottomSheetBody>
- <overflowSlot.Target className="flex flex-col [&>*]:w-full" />
- </BottomSheetBody>
- </BottomSheetContent>
- </BottomSheet>
</>
);
}
diff --git a/apps/erp/app/components/SortableList.tsx b/apps/erp/app/components/SortableList.tsx
index feadf00824..5d31e51d46 100644
--- a/apps/erp/app/components/SortableList.tsx
+++ b/apps/erp/app/components/SortableList.tsx
@@ -290,6 +290,7 @@ interface SortableListProps<T extends Item> {
onReorder: (items: T[]) => void;
renderItem: (props: SortableItemRenderProps<T>) => React.ReactNode;
isReadOnly?: boolean;
+ emptyState?: React.ReactNode;
}
function SortableList<T extends Item>({
@@ -298,7 +299,8 @@ function SortableList<T extends Item>({
onToggleItem,
onReorder,
renderItem,
- isReadOnly = false
+ isReadOnly = false,
+ emptyState
}: SortableListProps<T>) {
if (items && Array.isArray(items) && items.length > 0) {
return (
@@ -323,7 +325,7 @@ function SortableList<T extends Item>({
</LayoutGroup>
);
} else {
- return <Empty />;
+ return <>{emptyState ?? <Empty />}</>;
}
}
diff --git a/apps/erp/app/components/SummaryLineRow.tsx b/apps/erp/app/components/SummaryLineRow.tsx
new file mode 100644
index 0000000000..4742b893bd
--- /dev/null
+++ b/apps/erp/app/components/SummaryLineRow.tsx
@@ -0,0 +1,67 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import type { ReactNode } from "react";
+import { Link } from "react-router";
+
+type SummaryLineRowProps = {
+ /** Line 1, leading: the part or line identity. */
+ title: ReactNode;
+ /** Line 1, trailing: the line total. */
+ value: ReactNode;
+ /** Line 2: the name or description. */
+ description?: ReactNode;
+ /** Line 3: quantity × unit price. */
+ meta?: ReactNode;
+ /** After the value, e.g. an expand chevron. */
+ trailing?: ReactNode;
+} & ({ to: string } | { onClick: () => void; expanded: boolean });
+
+const rowClassName =
+ "flex w-full min-w-0 flex-col gap-0.5 py-3 text-left active:bg-accent";
+
+/**
+ * Phones: one document line in a summary card (SO, PO, Quote). A link opens
+ * the line's page; a button expands the line in place.
+ */
+export function SummaryLineRow(props: SummaryLineRowProps) {
+ const content = (
+ <>
+ <span className="flex w-full min-w-0 items-baseline justify-between gap-3">
+ <span className="min-w-0 truncate font-medium text-foreground">
+ {props.title}
+ </span>
+ <span className="flex shrink-0 items-center gap-1 tabular-nums">
+ {props.value}
+ {props.trailing}
+ </span>
+ </span>
+ {props.description ? (
+ <span className="w-full min-w-0 truncate text-sm text-muted-foreground">
+ {props.description}
+ </span>
+ ) : null}
+ {props.meta ? (
+ <span className="text-sm text-muted-foreground tabular-nums">
+ {props.meta}
+ </span>
+ ) : null}
+ </>
+ );
+
+ return "to" in props ? (
+ <Link to={props.to} className={rowClassName}>
+ {content}
+ </Link>
+ ) : (
+ <button
+ type="button"
+ aria-expanded={props.expanded}
+ onClick={props.onClick}
+ className={rowClassName}
+ >
+ {content}
+ </button>
+ );
+}
diff --git a/apps/erp/app/components/Table/Table.tsx b/apps/erp/app/components/Table/Table.tsx
index 60527f1613..40d968dede 100644
--- a/apps/erp/app/components/Table/Table.tsx
+++ b/apps/erp/app/components/Table/Table.tsx
@@ -168,6 +168,8 @@ interface TableProps<T extends object> {
// `meta.mobile` priorities; "table" keeps the grid, scrolling sideways with
// a sticky first column (inline-editing grids, comparison tables).
mobileLayout?: "list" | "table";
+ /** Phones: extra items first in the list toolbar ⋯ (e.g. Recalculate). */
+ mobileMenuItems?: ReactNode;
}
type AggregateFunction = "sum" | "average" | "min" | "max" | "median" | "count";
@@ -318,7 +320,8 @@ const Table = <T extends object>({
renderExpandedRow,
canExpandRow,
groupRowsBy,
- mobileLayout = "list"
+ mobileLayout = "list",
+ mobileMenuItems
}: TableProps<T>) => {
const { t } = useLingui();
const tableContainerRef = useRef<HTMLDivElement>(null);
@@ -1123,6 +1126,7 @@ const Table = <T extends object>({
withSelectableRows={withSelectableRows}
headerActions={headerActions}
primaryAction={primaryAction}
+ mobileMenuItems={mobileMenuItems}
emptyState={emptyState}
isLoading={isLoading}
isTableEmpty={isTableEmpty}
diff --git a/apps/erp/app/components/Table/components/Compact/CompactEmpty.tsx b/apps/erp/app/components/Table/components/Compact/CompactEmpty.tsx
index 47474136c1..3f435bf489 100644
--- a/apps/erp/app/components/Table/components/Compact/CompactEmpty.tsx
+++ b/apps/erp/app/components/Table/components/Compact/CompactEmpty.tsx
@@ -2,7 +2,7 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-import { Button, Skeleton } from "@carbon/react";
+import { Button, cn, Skeleton } from "@carbon/react";
import { Trans } from "@lingui/react/macro";
import type { ReactNode } from "react";
import { LuInbox, LuSearchX } from "react-icons/lu";
@@ -19,23 +19,40 @@ function IconTile({ children }: { children: ReactNode }) {
/** A list with no records yet: neutral tile, title, the create action. */
export function CompactEmpty({
title,
- primaryAction
+ heading,
+ description,
+ icon = <LuInbox />,
+ primaryAction,
+ className
}: {
+ /** The records' name, for "No {title} yet". */
title?: string;
+ /** A full heading instead of "No {title} yet". */
+ heading?: ReactNode;
+ description?: ReactNode;
+ icon?: ReactNode;
primaryAction?: ReactNode;
+ className?: string;
}) {
return (
- <div className="flex flex-col items-center gap-3 px-6 py-16 text-center">
- <IconTile>
- <LuInbox />
- </IconTile>
+ <div
+ className={cn(
+ "flex flex-col items-center gap-3 px-6 py-16 text-center",
+ className
+ )}
+ >
+ <IconTile>{icon}</IconTile>
<h3 className="text-[17px] font-semibold text-foreground">
- {title ? (
- <Trans>No {title} yet</Trans>
- ) : (
- <Trans>Nothing here yet</Trans>
- )}
+ {heading ??
+ (title ? (
+ <Trans>No {title} yet</Trans>
+ ) : (
+ <Trans>Nothing here yet</Trans>
+ ))}
</h3>
+ {description ? (
+ <p className="text-sm text-muted-foreground">{description}</p>
+ ) : null}
{primaryAction ? (
<NewPlacementContext.Provider value="inline">
{/* Several actions (an HStack of buttons) stack full width, primary first. */}
diff --git a/apps/erp/app/components/Table/components/Compact/CompactList.tsx b/apps/erp/app/components/Table/components/Compact/CompactList.tsx
index fe9c7992b2..b89a5b52dc 100644
--- a/apps/erp/app/components/Table/components/Compact/CompactList.tsx
+++ b/apps/erp/app/components/Table/components/Compact/CompactList.tsx
@@ -7,6 +7,7 @@ import {
ContextMenu,
ContextMenuContent,
ContextMenuTrigger,
+ cn,
DropdownMenu,
DropdownMenuTrigger,
Menu
@@ -16,6 +17,7 @@ import { useNumberFormatter } from "@react-aria/i18n";
import type { Table } from "@tanstack/react-table";
import type { ReactNode } from "react";
import { Fragment, useEffect, useMemo, useState } from "react";
+import { LuChevronDown } from "react-icons/lu";
import { BottomBar } from "~/components/Layout/Mobile/ChromeSlots";
import { useSetAppBarOverride } from "~/components/Layout/Mobile/useAppBarOverride";
import { useUrlParams } from "~/hooks";
@@ -46,6 +48,8 @@ export type CompactListProps<T> = {
withSelectableRows: boolean;
headerActions?: ReactNode;
primaryAction?: ReactNode;
+ /** Extra items first in the toolbar ⋯. */
+ mobileMenuItems?: ReactNode;
emptyState?: ReactNode;
isLoading: boolean;
isTableEmpty: boolean;
@@ -86,6 +90,7 @@ export function CompactList<T>({
withSelectableRows,
headerActions,
primaryAction,
+ mobileMenuItems,
emptyState,
isLoading,
isTableEmpty,
@@ -202,6 +207,7 @@ export function CompactList<T>({
headerActions={headerActions}
csvExport={csvExport}
importCSV={importCSV}
+ menuItems={mobileMenuItems}
onSelect={
withSelectableRows && rows.length > 0 && !selecting
? () => setSelecting(true)
@@ -248,6 +254,12 @@ export function CompactList<T>({
<div className="flex min-h-full w-full min-w-0 flex-col bg-card">
{toolbar}
{primaryActionRow}
+ {totals.length > 0 ? (
+ <CompactTotals
+ totals={totals}
+ format={(value) => numberFormatter.format(value)}
+ />
+ ) : null}
<div className="flex flex-col border-t border-border">
{rows.slice(0, shown).map((row) => {
const rowExpandable =
@@ -317,29 +329,6 @@ export function CompactList<T>({
})}
</div>
- {totals.length > 0 ? (
- <div className="mx-4 mt-4 rounded-xl border border-border bg-card p-3">
- <div className="pb-1 text-xs font-medium uppercase tracking-[0.04em] text-muted-foreground">
- <Trans>Totals</Trans>
- </div>
- {totals.map((total) => (
- <div
- key={total.id}
- className="flex min-h-9 items-center justify-between gap-3 text-sm"
- >
- <span className="min-w-0 truncate text-muted-foreground">
- {total.label}
- </span>
- <span className="shrink-0 font-medium tabular-nums">
- {total.formatter
- ? total.formatter(total.value)
- : numberFormatter.format(total.value)}
- </span>
- </div>
- ))}
- </div>
- ) : null}
-
{offset > 0 || shown < total ? (
<div className="flex flex-col items-center gap-2 px-4 py-4">
{canLoadMore ? (
@@ -406,3 +395,70 @@ export function CompactList<T>({
</div>
);
}
+
+/**
+ * The table's footer totals, above the rows: collapsed to its first total so
+ * the list starts right under it, expanded on a tap.
+ */
+function CompactTotals({
+ totals,
+ format
+}: {
+ totals: CompactListProps<unknown>["totals"];
+ format: (value: number) => string;
+}) {
+ const [open, setOpen] = useState(false);
+ const formatTotal = (total: (typeof totals)[number]) =>
+ total.formatter ? total.formatter(total.value) : format(total.value);
+ const first = totals[0]!;
+
+ return (
+ <div className="mx-4 mb-2 rounded-xl border border-border bg-card">
+ <button
+ type="button"
+ aria-expanded={open}
+ onClick={() => setOpen((value) => !value)}
+ className="flex min-h-11 w-full items-center gap-3 rounded-xl px-3 text-left outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50"
+ >
+ <span className="shrink-0 text-xs font-medium uppercase tracking-[0.04em] text-muted-foreground">
+ <Trans>Totals</Trans>
+ </span>
+ {open ? (
+ <span className="flex-1" />
+ ) : (
+ <span className="flex min-w-0 flex-1 items-center justify-end gap-2 text-sm">
+ <span className="min-w-0 truncate text-muted-foreground">
+ {first.label}
+ </span>
+ <span className="shrink-0 font-medium tabular-nums">
+ {formatTotal(first)}
+ </span>
+ </span>
+ )}
+ <LuChevronDown
+ className={cn(
+ "size-4 shrink-0 text-muted-foreground transition-transform duration-200",
+ open && "rotate-180"
+ )}
+ />
+ </button>
+ {open ? (
+ <div className="border-t border-border px-3 py-1">
+ {totals.map((total) => (
+ <div
+ key={total.id}
+ className="flex min-h-9 items-center justify-between gap-3 text-sm"
+ >
+ <span className="min-w-0 truncate text-muted-foreground">
+ {total.label}
+ </span>
+ <span className="shrink-0 font-medium tabular-nums">
+ {formatTotal(total)}
+ </span>
+ </div>
+ ))}
+ </div>
+ ) : null}
+ </div>
+ );
+}
diff --git a/apps/erp/app/components/Table/components/Compact/CompactRow.tsx b/apps/erp/app/components/Table/components/Compact/CompactRow.tsx
index 784a8feb6c..fecc0a1a25 100644
--- a/apps/erp/app/components/Table/components/Compact/CompactRow.tsx
+++ b/apps/erp/app/components/Table/components/Compact/CompactRow.tsx
@@ -52,6 +52,8 @@ export function CompactRow<T>({
const { t } = useLingui();
const p2 = renderCell(row, slots.p2);
const p3 = renderCell(row, slots.p3);
+ // In selection mode a tap selects the row, so the row action hides.
+ const action = selection ? null : renderCell(row, slots.action);
const pills = slots.pills
.map((column) => ({ id: column.id, node: renderCell(row, column) }))
.filter((pill) => pill.node !== null);
@@ -138,6 +140,11 @@ export function CompactRow<T>({
</div>
) : null}
</div>
+ {action !== null ? (
+ <div className="relative z-10 shrink-0 self-center [&_button]:h-11 [&_button]:min-w-11">
+ {action}
+ </div>
+ ) : null}
{expansion ? (
<button
type="button"
diff --git a/apps/erp/app/components/Table/components/Compact/CompactToolbar.tsx b/apps/erp/app/components/Table/components/Compact/CompactToolbar.tsx
index 894c077fb8..243853a858 100644
--- a/apps/erp/app/components/Table/components/Compact/CompactToolbar.tsx
+++ b/apps/erp/app/components/Table/components/Compact/CompactToolbar.tsx
@@ -7,6 +7,7 @@ import {
DropdownMenuContent,
DropdownMenuIcon,
DropdownMenuItem,
+ DropdownMenuSeparator,
DropdownMenuTrigger,
IconButton
} from "@carbon/react";
@@ -23,6 +24,7 @@ import {
import { SearchFilter } from "~/components";
import { ImportCSVModal } from "~/components/ImportCSVModal";
import { AppBarActions } from "~/components/Layout/Mobile/ChromeSlots";
+import { createValueSlot } from "~/components/Layout/Mobile/slots";
import { RecordFrameContext } from "~/components/Layout/Panels";
import type { fieldMappings } from "~/modules/shared/imports.models";
import { type DownloadProps, useCsvDownload } from "../Download";
@@ -54,6 +56,8 @@ type CompactToolbarProps = {
csvExport?: DownloadProps;
importCSV?: { table: keyof typeof fieldMappings; label: string }[];
onSelect?: () => void;
+ /** Extra items first in the ⋯ (a page's own phone actions). */
+ menuItems?: ReactNode;
hideControls?: boolean;
};
@@ -63,6 +67,13 @@ type CompactToolbarProps = {
* ⋯ for Export CSV, Import and Select. Column and density controls stay on
* desktop.
*/
+/**
+ * Phones: a page shown over its list (a `compactFocus` detail pane) takes
+ * over the app bar; while it is mounted the hidden list's ⋯ stays out of it.
+ */
+const listMenuHiddenSlot = createValueSlot<true>();
+export const useHideListAppBarMenu = () => listMenuHiddenSlot.useProvide(true);
+
export function CompactToolbar({
title,
tableName,
@@ -76,6 +87,7 @@ export function CompactToolbar({
csvExport,
importCSV,
onSelect,
+ menuItems,
hideControls = false
}: CompactToolbarProps) {
const { t } = useLingui();
@@ -90,11 +102,13 @@ export function CompactToolbar({
filters.length > 0 || (withSort && Object.keys(sortKeyToLabel).length > 0);
const activeCount = urlFiltersParams.filter(Boolean).length;
const canExport = Boolean(csvExport?.data.length);
- const hasMenu = canExport || Boolean(importCSV?.length || onSelect);
+ const hasBuiltIns = canExport || Boolean(importCSV?.length || onSelect);
+ const hasMenu = hasBuiltIns || Boolean(menuItems);
// Inside a record frame the app bar ⋯ is the record's: the table's own
// ⋯ sits in its search row instead, so the bar never shows two.
const inRecord = useContext(RecordFrameContext);
+ const listMenuHidden = listMenuHiddenSlot.useValue() === true;
const menu = (
<DropdownMenu>
<DropdownMenuTrigger asChild>
@@ -108,6 +122,8 @@ export function CompactToolbar({
/>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
+ {menuItems}
+ {menuItems && hasBuiltIns ? <DropdownMenuSeparator /> : null}
{canExport ? (
<DropdownMenuItem onClick={exportCsv}>
<DropdownMenuIcon icon={<LuDownload />} />
@@ -132,7 +148,9 @@ export function CompactToolbar({
return (
<>
- {hasMenu && !inRecord ? <AppBarActions>{menu}</AppBarActions> : null}
+ {hasMenu && !inRecord && !listMenuHidden ? (
+ <AppBarActions>{menu}</AppBarActions>
+ ) : null}
{titleBadge ? (
<div className="shrink-0 flex items-center gap-2 bg-card px-4 pt-3">
diff --git a/apps/erp/app/components/Table/components/Compact/resolveSlots.test.ts b/apps/erp/app/components/Table/components/Compact/resolveSlots.test.ts
index 402b1f7018..b7b5367e64 100644
--- a/apps/erp/app/components/Table/components/Compact/resolveSlots.test.ts
+++ b/apps/erp/app/components/Table/components/Compact/resolveSlots.test.ts
@@ -36,6 +36,16 @@ describe("resolveSlots", () => {
expect(slots?.pills).toEqual([state]);
});
+ it("puts an action column in the action slot only", () => {
+ const id = col("id", { mobile: "P1" });
+ const order = col("order", { mobile: "action" });
+ const slots = resolveSlots([id, order]);
+ expect(slots?.action).toBe(order);
+ expect(slots?.p2).toBeUndefined();
+ expect(slots?.p3).toBeUndefined();
+ expect(slots?.pills).toEqual([]);
+ });
+
it("falls back to the first data column and warns", () => {
const warn = vi.spyOn(console, "warn").mockImplementation(() => undefined);
const name = col("name");
diff --git a/apps/erp/app/components/Table/components/Compact/resolveSlots.ts b/apps/erp/app/components/Table/components/Compact/resolveSlots.ts
index dd63a6f6de..01d728e0c3 100644
--- a/apps/erp/app/components/Table/components/Compact/resolveSlots.ts
+++ b/apps/erp/app/components/Table/components/Compact/resolveSlots.ts
@@ -18,6 +18,8 @@ export type CompactSlots<T> = {
p3?: Column<T, unknown>;
/** Line 3: status pills (enumerated P2 columns), at most two. */
pills: Column<T, unknown>[];
+ /** Trailing: the row's one action button. */
+ action?: Column<T, unknown>;
};
/**
@@ -42,7 +44,7 @@ export function resolveSlots<T>(
const data = columns.filter((c) => !STRUCTURAL_COLUMN_IDS.has(c.id));
if (data.length === 0) return null;
- const byPriority = (p: "P1" | "P2" | "P3") =>
+ const byPriority = (p: "P1" | "P2" | "P3" | "action") =>
data.filter((c) => c.columnDef.meta?.mobile === p);
let p1 = byPriority("P1")[0];
@@ -60,6 +62,7 @@ export function resolveSlots<T>(
const p2 = p2Columns.find((c) => !isStatusColumn(c));
const pills = p2Columns.filter(isStatusColumn).slice(0, MAX_PILLS);
const p3 = byPriority("P3").find((c) => c !== p1);
+ const action = byPriority("action").find((c) => c !== p1);
- return { p1, p2, p3, pills };
+ return { p1, p2, p3, pills, action };
}
diff --git a/apps/erp/app/components/Table/types.ts b/apps/erp/app/components/Table/types.ts
index da61c270b7..be11486990 100644
--- a/apps/erp/app/components/Table/types.ts
+++ b/apps/erp/app/components/Table/types.ts
@@ -44,8 +44,9 @@ declare module "@tanstack/react-table" {
sortBy?: string;
// Phone list priority: P1 = identity (line 1), P2 = trailing metric
// or status pill, P3 = context (line 2); P4 or unset = not in the row.
- // See Table/components/Compact/resolveSlots.ts.
- mobile?: "P1" | "P2" | "P3" | "P4";
+ // "action" = the row's one trailing button (e.g. "Make 90"), hidden in
+ // selection mode. See Table/components/Compact/resolveSlots.ts.
+ mobile?: "P1" | "P2" | "P3" | "P4" | "action";
/** Phones: show this P2 column as a status pill on line 3 (a status column without a static filter). */
mobilePill?: boolean;
/** Phones: lead this column's value with its (string) header, since a
diff --git a/apps/erp/app/modules/accounting/ui/FixedAssets/FixedAssetNotes.tsx b/apps/erp/app/modules/accounting/ui/FixedAssets/FixedAssetNotes.tsx
index a82b5fbd44..c958d192bd 100644
--- a/apps/erp/app/modules/accounting/ui/FixedAssets/FixedAssetNotes.tsx
+++ b/apps/erp/app/modules/accounting/ui/FixedAssets/FixedAssetNotes.tsx
@@ -9,11 +9,12 @@ import {
CardContent,
CardHeader,
CardTitle,
- generateHTML,
+ RichTextView,
useDebounce
} from "@carbon/react";
import { Editor } from "@carbon/react/Editor";
import { getLocalTimeZone, today } from "@internationalized/date";
+import { Trans } from "@lingui/react/macro";
import { useState } from "react";
import { useImageUpload, usePermissions, useUser } from "~/hooks";
@@ -64,11 +65,9 @@ const FixedAssetNotes = ({
}}
/>
) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(notes as JSONContent)
- }}
+ <RichTextView
+ content={notes as JSONContent}
+ empty={<Trans>No notes</Trans>}
/>
)}
</CardContent>
diff --git a/apps/erp/app/modules/accounting/ui/Reports/ColumnStepper.tsx b/apps/erp/app/modules/accounting/ui/Reports/ColumnStepper.tsx
new file mode 100644
index 0000000000..b666ec907d
--- /dev/null
+++ b/apps/erp/app/modules/accounting/ui/Reports/ColumnStepper.tsx
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import { IconButton } from "@carbon/react";
+import { useLingui } from "@lingui/react/macro";
+import type { ReactNode } from "react";
+import { useEffect, useState } from "react";
+import { LuChevronLeft, LuChevronRight } from "react-icons/lu";
+
+/**
+ * Phones: which one of a report's value columns shows. Starts on `initial`
+ * (default: the last, i.e. the latest period) and stays in range when the
+ * column count changes.
+ */
+export function useColumnStep(count: number, initial = count - 1) {
+ const [index, setIndex] = useState(Math.max(0, initial));
+ // A new period range or column set starts again on its default column.
+ // biome-ignore lint/correctness/useExhaustiveDependencies: reset per column count only
+ useEffect(() => {
+ setIndex(Math.max(0, initial));
+ }, [count]);
+ return [
+ Math.min(Math.max(0, index), Math.max(0, count - 1)),
+ setIndex
+ ] as const;
+}
+
+/**
+ * Phones: the report's column header, one column at a time, with ‹ › to step
+ * to the neighbouring column.
+ */
+export function ColumnStepper({
+ index,
+ count,
+ onChange,
+ label,
+ detail
+}: {
+ index: number;
+ count: number;
+ onChange: (index: number) => void;
+ label: ReactNode;
+ /** Under the label, e.g. "To Date". */
+ detail?: ReactNode;
+}) {
+ const { t } = useLingui();
+ return (
+ <div className="flex h-12 shrink-0 items-center gap-1 border-b border-border bg-card px-1">
+ <IconButton
+ aria-label={t`Previous column`}
+ variant="ghost"
+ size="lg"
+ icon={<LuChevronLeft />}
+ isDisabled={index <= 0}
+ onClick={() => onChange(index - 1)}
+ />
+ <div
+ aria-live="polite"
+ className="flex min-w-0 flex-1 flex-col items-center justify-center text-center"
+ >
+ <span className="truncate text-sm font-medium text-foreground">
+ {label}
+ </span>
+ {detail ? (
+ <span className="text-xs text-muted-foreground">{detail}</span>
+ ) : null}
+ </div>
+ {count > 1 ? (
+ <span className="sr-only">{t`Column ${index + 1} of ${count}`}</span>
+ ) : null}
+ <IconButton
+ aria-label={t`Next column`}
+ variant="ghost"
+ size="lg"
+ icon={<LuChevronRight />}
+ isDisabled={index >= count - 1}
+ onClick={() => onChange(index + 1)}
+ />
+ </div>
+ );
+}
diff --git a/apps/erp/app/modules/accounting/ui/Reports/ExecutivePnlSummary.tsx b/apps/erp/app/modules/accounting/ui/Reports/ExecutivePnlSummary.tsx
index d5430f9833..2e134e7502 100644
--- a/apps/erp/app/modules/accounting/ui/Reports/ExecutivePnlSummary.tsx
+++ b/apps/erp/app/modules/accounting/ui/Reports/ExecutivePnlSummary.tsx
@@ -12,12 +12,11 @@ import { useLocale } from "@react-aria/i18n";
import { memo, useEffect, useMemo, useRef } from "react";
import { useRealtime } from "~/hooks";
import type { ChartPeriodSeries } from "../../types";
+import { ColumnStepper, useColumnStep } from "./ColumnStepper";
import { computeExecutivePnl, type ExecutivePnlRowKey } from "./executivePnl";
import { getPeriodColumnLabel } from "./MultiPeriodStatementTree";
const ACCOUNT_COLUMN_WIDTH = 360;
-/** Phones: the pinned first column is capped at 150pt. */
-const COMPACT_ACCOUNT_COLUMN_WIDTH = 150;
const PERIOD_COLUMN_WIDTH = 128;
type ExecutivePnlSummaryProps = {
@@ -47,9 +46,13 @@ const ExecutivePnlSummary = memo(
}: ExecutivePnlSummaryProps) => {
const { t } = useLingui();
const { isPhone } = useViewport();
- const accountColumnWidth = isPhone
- ? COMPACT_ACCOUNT_COLUMN_WIDTH
- : ACCOUNT_COLUMN_WIDTH;
+ // Phones: one period at a time (the latest first), so the labels and
+ // margins get the width the other periods took.
+ const [periodIndex, setPeriodIndex] = useColumnStep(periods.length);
+ const visiblePeriods = isPhone
+ ? periods.slice(periodIndex, periodIndex + 1)
+ : periods;
+ const currentPeriod = periods[periodIndex];
const { locale } = useLocale();
useRealtime("journal");
const scrollRef = useRef<HTMLDivElement>(null);
@@ -99,20 +102,33 @@ const ExecutivePnlSummary = memo(
[locale]
);
- const rowWidth =
- accountColumnWidth + periods.length * PERIOD_COLUMN_WIDTH + 16;
+ const rowWidth = isPhone
+ ? undefined
+ : ACCOUNT_COLUMN_WIDTH + periods.length * PERIOD_COLUMN_WIDTH + 16;
return (
- <div className="flex h-[calc(100dvh-var(--header-height)-61px)] w-full flex-col">
+ <div className="flex h-[calc(100dvh-var(--header-height)-61px)] w-full flex-col max-md:h-auto max-md:min-h-0 max-md:flex-1">
+ {isPhone && currentPeriod ? (
+ <ColumnStepper
+ index={periodIndex}
+ count={periods.length}
+ onChange={setPeriodIndex}
+ label={getPeriodColumnLabel(currentPeriod, columns, locale)}
+ detail={currentPeriod.isPartial ? t`To Date` : undefined}
+ />
+ ) : null}
{/* Header viewport — scrollLeft is mirrored from the body below */}
- <div ref={headerRef} className="shrink-0 overflow-x-hidden">
+ <div
+ ref={headerRef}
+ className="shrink-0 overflow-x-hidden max-md:hidden"
+ >
<div
className="flex h-12 items-center border-b border-border bg-card pr-4 text-sm font-medium text-foreground/80"
style={{ minWidth: rowWidth }}
>
<div
className="sticky left-0 z-[2] flex h-full shrink-0 items-center bg-card px-4"
- style={{ width: accountColumnWidth }}
+ style={{ width: ACCOUNT_COLUMN_WIDTH }}
>
<Trans>Executive P&amp;L</Trans>
</div>
@@ -144,7 +160,7 @@ const ExecutivePnlSummary = memo(
<div
key={row.key}
className={cn(
- "flex h-9 items-center pr-4 text-sm",
+ "flex h-9 items-center pr-4 text-sm max-md:h-12",
row.isSubtotal && "font-semibold",
row.isSubtotal &&
!row.isBottomLine &&
@@ -158,15 +174,16 @@ const ExecutivePnlSummary = memo(
<div
className={cn(
"sticky left-0 z-[1] flex h-full shrink-0 items-center px-4",
+ "max-md:static max-md:min-w-0 max-md:flex-1",
row.isBottomLine ? "bg-muted/40" : "bg-card"
)}
- style={{ width: accountColumnWidth }}
+ style={isPhone ? undefined : { width: ACCOUNT_COLUMN_WIDTH }}
>
<span className="truncate">{labels[row.key]}</span>
</div>
{/* One cell per period bucket */}
- {periods.map((bucket) => {
+ {visiblePeriods.map((bucket) => {
const value = row.values[bucket.key] ?? 0;
const margin = row.margins?.[bucket.key];
return (
diff --git a/apps/erp/app/modules/accounting/ui/Reports/MultiPeriodStatementTree.tsx b/apps/erp/app/modules/accounting/ui/Reports/MultiPeriodStatementTree.tsx
index 0e49fab3ef..babce314cc 100644
--- a/apps/erp/app/modules/accounting/ui/Reports/MultiPeriodStatementTree.tsx
+++ b/apps/erp/app/modules/accounting/ui/Reports/MultiPeriodStatementTree.tsx
@@ -23,11 +23,10 @@ import { LevelLine, TreeView, useTree } from "~/components/TreeView";
import { useRealtime, useUrlParams } from "~/hooks";
import type { ChartPeriodSeries } from "../../types";
import { NET_INCOME_ACCOUNT_ID } from "../../types";
+import { ColumnStepper, useColumnStep } from "./ColumnStepper";
import { accountsToFlatTree, filterAccounts } from "./reportTree";
const ACCOUNT_COLUMN_WIDTH = 360;
-/** Phones: the pinned first column is capped at 150pt. */
-const COMPACT_ACCOUNT_COLUMN_WIDTH = 150;
const PERIOD_COLUMN_WIDTH = 128;
type MultiPeriodStatementTreeProps = {
@@ -89,9 +88,13 @@ const MultiPeriodStatementTree = memo(
}: MultiPeriodStatementTreeProps) => {
const { t } = useLingui();
const { isPhone } = useViewport();
- const accountColumnWidth = isPhone
- ? COMPACT_ACCOUNT_COLUMN_WIDTH
- : ACCOUNT_COLUMN_WIDTH;
+ // Phones: one period at a time (the latest first), so the account name
+ // gets the width the other periods took.
+ const [periodIndex, setPeriodIndex] = useColumnStep(periods.length);
+ const visiblePeriods = isPhone
+ ? periods.slice(periodIndex, periodIndex + 1)
+ : periods;
+ const currentPeriod = periods[periodIndex];
const { locale } = useLocale();
useRealtime("journal");
const navigate = useNavigate();
@@ -138,45 +141,61 @@ const MultiPeriodStatementTree = memo(
} = useTree<ChartPeriodSeries, undefined>({
tree,
parentRef,
- estimatedRowHeight: () => 36,
+ estimatedRowHeight: () => (isPhone ? 44 : 36),
isEager: true
});
- const rowWidth =
- accountColumnWidth + periods.length * PERIOD_COLUMN_WIDTH + 16;
+ const rowWidth = isPhone
+ ? undefined
+ : ACCOUNT_COLUMN_WIDTH + periods.length * PERIOD_COLUMN_WIDTH + 16;
return (
- <div className="flex h-[calc(100dvh-var(--header-height)-61px)] w-full flex-col">
- {/* Header viewport — scrollLeft is mirrored from the tree below */}
- <div ref={headerRef} className="shrink-0 overflow-x-hidden">
- <div
- className="flex h-12 items-center border-b border-border bg-card pr-4 text-sm font-medium text-foreground/80"
- style={{ minWidth: rowWidth }}
- >
- <div
- className="sticky left-0 z-[2] flex h-full shrink-0 items-center bg-card px-4"
- style={{ width: accountColumnWidth }}
- >
- <Trans>Account</Trans>
- </div>
- {periods.map((bucket) => (
+ // Phones: the filter rows differ in height, so the tree fills what is left.
+ <div className="flex h-[calc(100dvh-var(--header-height)-61px)] w-full flex-col max-md:h-auto max-md:min-h-0 max-md:flex-1">
+ {isPhone ? (
+ currentPeriod ? (
+ <ColumnStepper
+ index={periodIndex}
+ count={periods.length}
+ onChange={setPeriodIndex}
+ label={getPeriodColumnLabel(currentPeriod, columns, locale)}
+ detail={currentPeriod.isPartial ? t`To Date` : undefined}
+ />
+ ) : null
+ ) : (
+ <>
+ {/* Header viewport — scrollLeft is mirrored from the tree below */}
+ <div ref={headerRef} className="shrink-0 overflow-x-hidden">
<div
- key={bucket.key}
- className="flex shrink-0 flex-col items-end justify-center px-2 text-right"
- style={{ width: PERIOD_COLUMN_WIDTH }}
+ className="flex h-12 items-center border-b border-border bg-card pr-4 text-sm font-medium text-foreground/80"
+ style={{ minWidth: rowWidth }}
>
- <span className="whitespace-nowrap">
- {getPeriodColumnLabel(bucket, columns, locale)}
- </span>
- {bucket.isPartial && (
- <span className="text-xs font-normal text-muted-foreground">
- {t`To Date`}
- </span>
- )}
+ <div
+ className="sticky left-0 z-[2] flex h-full shrink-0 items-center bg-card px-4"
+ style={{ width: ACCOUNT_COLUMN_WIDTH }}
+ >
+ <Trans>Account</Trans>
+ </div>
+ {periods.map((bucket) => (
+ <div
+ key={bucket.key}
+ className="flex shrink-0 flex-col items-end justify-center px-2 text-right"
+ style={{ width: PERIOD_COLUMN_WIDTH }}
+ >
+ <span className="whitespace-nowrap">
+ {getPeriodColumnLabel(bucket, columns, locale)}
+ </span>
+ {bucket.isPartial && (
+ <span className="text-xs font-normal text-muted-foreground">
+ {t`To Date`}
+ </span>
+ )}
+ </div>
+ ))}
</div>
- ))}
- </div>
- </div>
+ </div>
+ </>
+ )}
<TreeView<ChartPeriodSeries>
tree={tree}
nodes={nodes}
@@ -197,7 +216,7 @@ const MultiPeriodStatementTree = memo(
return (
<div
className={cn(
- "flex h-8 cursor-pointer items-center pr-4 text-sm group/row",
+ "flex h-8 cursor-pointer items-center pr-4 text-sm group/row max-md:h-11",
state.selected
? "bg-muted hover:bg-accent"
: "bg-transparent hover:bg-accent",
@@ -217,11 +236,13 @@ const MultiPeriodStatementTree = memo(
<div
className={cn(
"sticky left-0 z-[1] flex h-full shrink-0 items-center overflow-hidden",
+ // Phones: no sideways scroll; the name takes the rest.
+ "max-md:static max-md:min-w-0 max-md:flex-1",
state.selected
? "bg-muted group-hover/row:bg-accent"
: "bg-card group-hover/row:bg-accent"
)}
- style={{ width: accountColumnWidth }}
+ style={isPhone ? undefined : { width: ACCOUNT_COLUMN_WIDTH }}
>
{/* Indentation lines */}
<div className="flex h-9 items-center">
@@ -281,7 +302,7 @@ const MultiPeriodStatementTree = memo(
</div>
{/* One cell per period bucket */}
- {periods.map((bucket) => {
+ {visiblePeriods.map((bucket) => {
const cell = account.periods?.[bucket.key];
// Translated: the Income Statement (netChange) must read the
// translated period delta; the Balance Sheet (balanceAtDate)
diff --git a/apps/erp/app/modules/accounting/ui/Reports/PivotControlBar.tsx b/apps/erp/app/modules/accounting/ui/Reports/PivotControlBar.tsx
index eb37016234..15a21db725 100644
--- a/apps/erp/app/modules/accounting/ui/Reports/PivotControlBar.tsx
+++ b/apps/erp/app/modules/accounting/ui/Reports/PivotControlBar.tsx
@@ -16,6 +16,7 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
HStack,
+ IconButton,
MENU_ITEM_SHORTCUTS,
Switch
} from "@carbon/react";
@@ -34,6 +35,7 @@ import {
} from "react-icons/lu";
import { PeriodSelector } from "~/components";
import { DimensionEntityTypeIcon } from "~/components/Icons";
+import { AppBarActions } from "~/components/Layout/Mobile/ChromeSlots";
import ConfirmDelete from "~/components/Modals/ConfirmDelete";
import { useUrlParams } from "~/hooks";
import { path } from "~/utils/path";
@@ -228,6 +230,62 @@ const PivotControlBar = ({
});
};
+ const viewMenu = (
+ <ActionMenu>
+ <DropdownMenuItem onClick={() => setSaveModalOpen(true)}>
+ <DropdownMenuIcon icon={<LuBookmarkPlus />} />
+ <Trans>Save view</Trans>
+ </DropdownMenuItem>
+ {activeView && activeView.createdBy === currentUserId && (
+ <DropdownMenuItem
+ shortcut={MENU_ITEM_SHORTCUTS.delete}
+ destructive
+ onClick={() => setDeleteModalOpen(true)}
+ >
+ <DropdownMenuIcon icon={<LuTrash2 />} />
+ <Trans>Delete view</Trans>
+ </DropdownMenuItem>
+ )}
+ {savedViews.length > 0 && (
+ <>
+ <DropdownMenuSeparator />
+ <DropdownMenuRadioGroup
+ value={activeViewId ?? ""}
+ onValueChange={onSelectView}
+ >
+ {privateViews.length > 0 && (
+ <>
+ <DropdownMenuLabel>
+ <Trans>Private</Trans>
+ </DropdownMenuLabel>
+ {privateViews.map((view) => (
+ <DropdownMenuRadioItem key={view.id} value={view.id}>
+ {view.name}
+ </DropdownMenuRadioItem>
+ ))}
+ </>
+ )}
+ {privateViews.length > 0 && companyViews.length > 0 && (
+ <DropdownMenuSeparator />
+ )}
+ {companyViews.length > 0 && (
+ <>
+ <DropdownMenuLabel>
+ <Trans>Company</Trans>
+ </DropdownMenuLabel>
+ {companyViews.map((view) => (
+ <DropdownMenuRadioItem key={view.id} value={view.id}>
+ {view.name}
+ </DropdownMenuRadioItem>
+ ))}
+ </>
+ )}
+ </DropdownMenuRadioGroup>
+ </>
+ )}
+ </ActionMenu>
+ );
+
return (
<div className="flex flex-wrap px-4 py-3 items-center gap-2 justify-between bg-card border-b border-border w-full max-md:gap-1 max-md:px-0 max-md:py-1.5">
{/* Phones: the scope controls form one sideways-scrolling
@@ -445,7 +503,7 @@ const PivotControlBar = ({
</Button>
)}
</HStack>
- <HStack className="gap-2 max-md:ml-auto max-md:px-4">
+ <HStack className="gap-2 max-md:hidden">
<Button
variant="secondary"
leftIcon={<LuDownload />}
@@ -453,60 +511,19 @@ const PivotControlBar = ({
>
{t`Download`}
</Button>
- <ActionMenu>
- <DropdownMenuItem onClick={() => setSaveModalOpen(true)}>
- <DropdownMenuIcon icon={<LuBookmarkPlus />} />
- <Trans>Save view</Trans>
- </DropdownMenuItem>
- {activeView && activeView.createdBy === currentUserId && (
- <DropdownMenuItem
- shortcut={MENU_ITEM_SHORTCUTS.delete}
- destructive
- onClick={() => setDeleteModalOpen(true)}
- >
- <DropdownMenuIcon icon={<LuTrash2 />} />
- <Trans>Delete view</Trans>
- </DropdownMenuItem>
- )}
- {savedViews.length > 0 && (
- <>
- <DropdownMenuSeparator />
- <DropdownMenuRadioGroup
- value={activeViewId ?? ""}
- onValueChange={onSelectView}
- >
- {privateViews.length > 0 && (
- <>
- <DropdownMenuLabel>
- <Trans>Private</Trans>
- </DropdownMenuLabel>
- {privateViews.map((view) => (
- <DropdownMenuRadioItem key={view.id} value={view.id}>
- {view.name}
- </DropdownMenuRadioItem>
- ))}
- </>
- )}
- {privateViews.length > 0 && companyViews.length > 0 && (
- <DropdownMenuSeparator />
- )}
- {companyViews.length > 0 && (
- <>
- <DropdownMenuLabel>
- <Trans>Company</Trans>
- </DropdownMenuLabel>
- {companyViews.map((view) => (
- <DropdownMenuRadioItem key={view.id} value={view.id}>
- {view.name}
- </DropdownMenuRadioItem>
- ))}
- </>
- )}
- </DropdownMenuRadioGroup>
- </>
- )}
- </ActionMenu>
+ {viewMenu}
</HStack>
+ {/* Phones: Download and the views menu sit in the app bar. */}
+ <AppBarActions>
+ <IconButton
+ aria-label={t`Download`}
+ variant="ghost"
+ size="lg"
+ icon={<LuDownload />}
+ onClick={onDownload}
+ />
+ {viewMenu}
+ </AppBarActions>
{saveModalOpen && (
<SaveViewModal
reportKey={reportKey}
diff --git a/apps/erp/app/modules/accounting/ui/Reports/PivotTree.tsx b/apps/erp/app/modules/accounting/ui/Reports/PivotTree.tsx
index 6557d73a00..6df277ef39 100644
--- a/apps/erp/app/modules/accounting/ui/Reports/PivotTree.tsx
+++ b/apps/erp/app/modules/accounting/ui/Reports/PivotTree.tsx
@@ -18,6 +18,7 @@ import { LevelLine, TreeView, useTree } from "~/components/TreeView";
import { useRealtime, useUrlParams } from "~/hooks";
import type { PivotMeasure, PivotState } from "../../accounting.models";
import type { DimensionPivot } from "../../types";
+import { ColumnStepper, useColumnStep } from "./ColumnStepper";
import type { PivotCellValue, PivotRowNode } from "./pivotData";
import {
applyPercentOfTotal,
@@ -29,8 +30,6 @@ import {
} from "./pivotData";
const ROW_COLUMN_WIDTH = 360;
-/** Phones: the pinned first column is capped at 150pt. */
-const COMPACT_ROW_COLUMN_WIDTH = 150;
const VALUE_COLUMN_WIDTH = 128;
/**
@@ -85,9 +84,7 @@ const PivotTree = memo(
({ pivot, state, columnLabels, onCellClick }: PivotTreeProps) => {
const { t } = useLingui();
const { isPhone } = useViewport();
- const rowColumnWidth = isPhone
- ? COMPACT_ROW_COLUMN_WIDTH
- : ROW_COLUMN_WIDTH;
+ const rowColumnWidth = ROW_COLUMN_WIDTH;
const { locale } = useLocale();
const [, setParams] = useUrlParams();
useRealtime("journal");
@@ -131,6 +128,17 @@ const PivotTree = memo(
);
const { flatTree, columnKeys, columnTotals, grandTotal } = pivotTree;
+ // Phones: one value column at a time; the last step is the row total,
+ // shown first.
+ const [columnIndex, setColumnIndex] = useColumnStep(columnKeys.length + 1);
+ const phoneColumnKey: string | null =
+ columnIndex < columnKeys.length
+ ? (columnKeys[columnIndex] ?? null)
+ : null;
+ const columnLabel = (columnKey: string) =>
+ columnKey === UNASSIGNED_COLUMN_KEY
+ ? t`Unassigned`
+ : (columnLabels[columnKey] ?? columnKey);
const percentFormatter = useMemo(
() =>
@@ -192,7 +200,7 @@ const PivotTree = memo(
} = useTree<PivotRowNode, undefined>({
tree: flatTree,
parentRef,
- estimatedRowHeight: () => 36,
+ estimatedRowHeight: () => (isPhone ? 44 : 36),
isEager: true
});
@@ -252,14 +260,27 @@ const PivotTree = memo(
}
return (
- <div className="flex h-[calc(100dvh-var(--header-height)-61px)] w-full flex-col">
+ <div className="flex h-[calc(100dvh-var(--header-height)-61px)] w-full flex-col max-md:h-auto max-md:min-h-0 max-md:flex-1">
{pivot.hasMore && (
<div className="shrink-0 border-b border-border bg-card px-4 py-1.5 text-xs text-muted-foreground">
<p>{t`Showing the top 1,000 groups by amount`}</p>
</div>
)}
+ {isPhone ? (
+ <ColumnStepper
+ index={columnIndex}
+ count={columnKeys.length + 1}
+ onChange={setColumnIndex}
+ label={
+ phoneColumnKey === null ? t`Total` : columnLabel(phoneColumnKey)
+ }
+ />
+ ) : null}
{/* Header viewport — scrollLeft is mirrored from the tree below */}
- <div ref={headerRef} className="shrink-0 overflow-x-hidden">
+ <div
+ ref={headerRef}
+ className="shrink-0 overflow-x-hidden max-md:hidden"
+ >
<div
className="relative flex h-12 items-center border-b border-border bg-card text-sm font-medium text-foreground/80"
style={{ minWidth: rowWidth }}
@@ -330,14 +351,78 @@ const PivotTree = memo(
virtualizer={virtualizer}
parentRef={parentRef}
scrollRef={scrollRef}
- parentClassName="flex-1 overflow-x-auto max-md:scroll-fade-x"
- contentMinWidth={rowWidth}
+ parentClassName="flex-1 overflow-x-auto"
+ contentMinWidth={isPhone ? undefined : rowWidth}
renderNode={({ node, state: nodeState }) => {
const row = node.data;
const percents = state.percentOfTotal
? applyPercentOfTotal(row.cells, columnTotals, state.measure)
: undefined;
+ if (isPhone) {
+ const isTotal = phoneColumnKey === null;
+ return (
+ <div
+ className={cn(
+ "flex h-11 cursor-pointer items-center pr-2 text-sm",
+ nodeState.selected ? "bg-muted" : "bg-transparent",
+ node.hasChildren && "font-semibold"
+ )}
+ onClick={() => {
+ selectNode(node.id, false);
+ if (node.hasChildren) toggleExpandNode(node.id);
+ }}
+ >
+ <div className="flex h-9 shrink-0 items-center">
+ {Array.from({ length: node.level }).map((_, index) => (
+ <LevelLine key={index} isSelected={nodeState.selected} />
+ ))}
+ <div className="flex h-9 w-5 items-center justify-center">
+ {node.hasChildren ? (
+ nodeState.expanded ? (
+ <LuChevronDown className="h-4 w-4 text-muted-foreground flex-shrink-0" />
+ ) : (
+ <LuChevronRight className="h-4 w-4 text-muted-foreground flex-shrink-0" />
+ )
+ ) : null}
+ </div>
+ </div>
+ <span
+ className={cn(
+ "min-w-0 flex-1 truncate pl-2 pr-2",
+ row.isUnassigned && "italic text-muted-foreground"
+ )}
+ >
+ {row.label}
+ </span>
+ <span
+ className={cn(
+ "shrink-0 px-2 text-right tabular-nums text-muted-foreground",
+ isTotal && "font-medium"
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+ onCellClick(
+ cellCoordinates(
+ row,
+ node.level,
+ phoneColumnKey,
+ isTotal
+ )
+ );
+ }}
+ >
+ {phoneColumnKey === null
+ ? formatRowTotal(row.total)
+ : formatCell(
+ row.cells[phoneColumnKey],
+ percents?.[phoneColumnKey]
+ )}
+ </span>
+ </div>
+ );
+ }
+
return (
<div
className={cn(
@@ -447,8 +532,38 @@ const PivotTree = memo(
);
}}
/>
+ {isPhone ? (
+ <div className="flex h-11 shrink-0 items-center justify-between gap-3 border-t border-border bg-card px-4 text-sm font-semibold">
+ <Trans>Total</Trans>
+ <span className="tabular-nums">
+ {phoneColumnKey === null
+ ? state.percentOfTotal
+ ? percentFormatter.format(grandTotalValue === 0 ? 0 : 1)
+ : formatMeasureValue(grandTotalValue, state.measure)
+ : state.percentOfTotal
+ ? percentFormatter.format(
+ getPivotMeasureValue(
+ columnTotals[phoneColumnKey],
+ state.measure
+ ) === 0
+ ? 0
+ : 1
+ )
+ : formatMeasureValue(
+ getPivotMeasureValue(
+ columnTotals[phoneColumnKey],
+ state.measure
+ ),
+ state.measure
+ )}
+ </span>
+ </div>
+ ) : null}
{/* Column totals footer — scrollLeft mirrored from the tree above */}
- <div ref={footerRef} className="shrink-0 overflow-x-hidden">
+ <div
+ ref={footerRef}
+ className="shrink-0 overflow-x-hidden max-md:hidden"
+ >
<div
className="relative flex h-9 items-center border-t border-border bg-card text-sm font-semibold"
style={{ minWidth: rowWidth }}
diff --git a/apps/erp/app/modules/accounting/ui/Reports/PurchasesControlBar.tsx b/apps/erp/app/modules/accounting/ui/Reports/PurchasesControlBar.tsx
index ab86a8438c..005985e70f 100644
--- a/apps/erp/app/modules/accounting/ui/Reports/PurchasesControlBar.tsx
+++ b/apps/erp/app/modules/accounting/ui/Reports/PurchasesControlBar.tsx
@@ -12,6 +12,7 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
HStack,
+ IconButton,
Switch
} from "@carbon/react";
import { Trans, useLingui } from "@lingui/react/macro";
@@ -26,6 +27,7 @@ import {
} from "react-icons/lu";
import { PeriodSelector } from "~/components";
import { DimensionEntityTypeIcon } from "~/components/Icons";
+import { AppBarActions } from "~/components/Layout/Mobile/ChromeSlots";
import { useUrlParams } from "~/hooks";
import type { PivotMeasure, PivotState } from "../../accounting.models";
import {
@@ -326,10 +328,20 @@ const PurchasesControlBar = ({
variant="secondary"
leftIcon={<LuDownload />}
onClick={onDownload}
- className="max-md:ml-auto max-md:mr-4"
+ className="max-md:hidden"
>
{t`Download`}
</Button>
+ {/* Phones: Download sits in the app bar, not on a row of its own. */}
+ <AppBarActions>
+ <IconButton
+ aria-label={t`Download`}
+ variant="ghost"
+ size="lg"
+ icon={<LuDownload />}
+ onClick={onDownload}
+ />
+ </AppBarActions>
</div>
);
};
diff --git a/apps/erp/app/modules/accounting/ui/Reports/ReportFilters.tsx b/apps/erp/app/modules/accounting/ui/Reports/ReportFilters.tsx
index 6492495238..d7b6d46ae1 100644
--- a/apps/erp/app/modules/accounting/ui/Reports/ReportFilters.tsx
+++ b/apps/erp/app/modules/accounting/ui/Reports/ReportFilters.tsx
@@ -10,6 +10,7 @@ import {
DropdownMenuRadioItem,
DropdownMenuTrigger,
HStack,
+ IconButton,
Input,
InputGroup,
InputLeftElement
@@ -24,6 +25,7 @@ import {
LuX
} from "react-icons/lu";
import { PeriodSelector } from "~/components";
+import { AppBarActions } from "~/components/Layout/Mobile/ChromeSlots";
import { useUrlParams } from "~/hooks";
import { financialReportColumns } from "../../accounting.models";
import CompanySelector from "./CompanySelector";
@@ -87,101 +89,119 @@ const ReportFilters = ({
};
return (
- <div className="flex px-4 py-3 items-center space-x-4 justify-between bg-card border-b border-border w-full max-md:flex-wrap max-md:gap-y-1 max-md:space-x-0 max-md:px-0 max-md:py-1.5">
- {/* Phones: search, company, period and columns form one
- sideways-scrolling chip row; Download sits on the line below. */}
- <HStack className="max-md:w-full max-md:flex-nowrap max-md:overflow-x-auto max-md:scrollbar-hide max-md:scroll-fade-x max-md:whitespace-nowrap max-md:px-4 max-md:py-1.5 max-md:[&>*]:shrink-0">
+ <div className="flex px-4 py-3 items-center space-x-4 justify-between bg-card border-b border-border w-full max-md:flex-col max-md:items-stretch max-md:space-x-0 max-md:px-0 max-md:py-0">
+ {/* Phones: search on its own row, then company, period and columns as
+ one sideways-scrolling chip row; Download moves to the app bar. */}
+ <div className="flex min-w-0 items-center gap-2 max-md:flex-col max-md:items-stretch max-md:gap-0">
{showSearch && (
- <InputGroup size="sm" className="w-64 max-md:w-48">
- <InputLeftElement>
- <LuSearch className="h-4 w-4 text-muted-foreground" />
- </InputLeftElement>
- <Input
- placeholder={t`Search accounts...`}
- value={search}
- onChange={(e) => onSearchChange?.(e.target.value)}
- />
- </InputGroup>
- )}
- <CompanySelector
- companies={companies}
- selectedCompanyIds={selectedCompanyIds}
- />
- <PeriodSelector
- variant={periodVariant}
- fiscalStartMonth={fiscalStartMonth}
- defaultPresetId={defaultPeriodId}
- />
- {showColumns && (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="secondary" leftIcon={<LuColumns3 />}>
- {columnLabels[columns]}
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="start">
- <DropdownMenuRadioGroup
- value={columns}
- onValueChange={(value) =>
- setParams({
- columns: value === "month" ? undefined : value
- })
- }
- >
- {financialReportColumns.map((granularity) => (
- <DropdownMenuRadioItem key={granularity} value={granularity}>
- {columnLabels[granularity]}
- </DropdownMenuRadioItem>
- ))}
- </DropdownMenuRadioGroup>
- </DropdownMenuContent>
- </DropdownMenu>
- )}
- {!isMultiCompany && isForeignCurrency && parentCurrency && (
- <Button
- variant={showTranslated ? "primary" : "secondary"}
- leftIcon={<LuLanguages />}
- onClick={() =>
- setParams({
- showTranslated: showTranslated ? undefined : "true"
- })
- }
- >
- Show in {parentCurrency}
- </Button>
+ <div className="max-md:px-4 max-md:pt-2">
+ <InputGroup size="sm" className="w-64 max-md:w-full">
+ <InputLeftElement>
+ <LuSearch className="h-4 w-4 text-muted-foreground" />
+ </InputLeftElement>
+ <Input
+ placeholder={t`Search accounts...`}
+ value={search}
+ onChange={(e) => onSearchChange?.(e.target.value)}
+ />
+ </InputGroup>
+ </div>
)}
- {isMultiCompany && parentCurrency && (
- <span className="text-sm text-muted-foreground">
- Showing in {parentCurrency}
- </span>
- )}
- {[...params.entries()].length > 0 && (
+ <HStack className="max-md:w-full max-md:flex-nowrap max-md:overflow-x-auto max-md:scrollbar-hide max-md:scroll-fade-x max-md:whitespace-nowrap max-md:px-4 max-md:py-2 max-md:[&>*]:shrink-0">
+ <CompanySelector
+ companies={companies}
+ selectedCompanyIds={selectedCompanyIds}
+ />
+ <PeriodSelector
+ variant={periodVariant}
+ fiscalStartMonth={fiscalStartMonth}
+ defaultPresetId={defaultPeriodId}
+ />
+ {showColumns && (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="secondary" leftIcon={<LuColumns3 />}>
+ {columnLabels[columns]}
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start">
+ <DropdownMenuRadioGroup
+ value={columns}
+ onValueChange={(value) =>
+ setParams({
+ columns: value === "month" ? undefined : value
+ })
+ }
+ >
+ {financialReportColumns.map((granularity) => (
+ <DropdownMenuRadioItem
+ key={granularity}
+ value={granularity}
+ >
+ {columnLabels[granularity]}
+ </DropdownMenuRadioItem>
+ ))}
+ </DropdownMenuRadioGroup>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )}
+ {!isMultiCompany && isForeignCurrency && parentCurrency && (
+ <Button
+ variant={showTranslated ? "primary" : "secondary"}
+ leftIcon={<LuLanguages />}
+ onClick={() =>
+ setParams({
+ showTranslated: showTranslated ? undefined : "true"
+ })
+ }
+ >
+ Show in {parentCurrency}
+ </Button>
+ )}
+ {isMultiCompany && parentCurrency && (
+ <span className="text-sm text-muted-foreground">
+ Showing in {parentCurrency}
+ </span>
+ )}
+ {[...params.entries()].length > 0 && (
+ <Button
+ variant="secondary"
+ rightIcon={<LuX />}
+ onClick={() =>
+ setParams({
+ companies: undefined,
+ startDate: undefined,
+ endDate: undefined,
+ columns: undefined,
+ showTranslated: undefined
+ })
+ }
+ >
+ {t`Reset`}
+ </Button>
+ )}
+ </HStack>
+ </div>
+ {onDownload && (
+ <>
<Button
variant="secondary"
- rightIcon={<LuX />}
- onClick={() =>
- setParams({
- companies: undefined,
- startDate: undefined,
- endDate: undefined,
- columns: undefined,
- showTranslated: undefined
- })
- }
+ leftIcon={<LuDownload />}
+ onClick={onDownload}
+ className="max-md:hidden"
>
- {t`Reset`}
+ {t`Download`}
</Button>
- )}
- </HStack>
- {onDownload && (
- <Button
- variant="secondary"
- leftIcon={<LuDownload />}
- onClick={onDownload}
- className="max-md:ml-auto max-md:mr-4"
- >
- {t`Download`}
- </Button>
+ <AppBarActions>
+ <IconButton
+ aria-label={t`Download`}
+ variant="ghost"
+ size="lg"
+ icon={<LuDownload />}
+ onClick={onDownload}
+ />
+ </AppBarActions>
+ </>
)}
</div>
);
diff --git a/apps/erp/app/modules/accounting/ui/Reports/TrialBalanceTree.tsx b/apps/erp/app/modules/accounting/ui/Reports/TrialBalanceTree.tsx
index e5a82cc705..01515d984f 100644
--- a/apps/erp/app/modules/accounting/ui/Reports/TrialBalanceTree.tsx
+++ b/apps/erp/app/modules/accounting/ui/Reports/TrialBalanceTree.tsx
@@ -15,6 +15,7 @@ import { useNavigate } from "react-router";
import { LevelLine, TreeView, useTree } from "~/components/TreeView";
import { useRealtime, useUrlParams } from "~/hooks";
import type { Chart } from "../../types";
+import { ColumnStepper, useColumnStep } from "./ColumnStepper";
import {
accountsToFlatTree,
filterAccounts,
@@ -61,6 +62,18 @@ const TrialBalanceTree = memo(
}: TrialBalanceTreeProps) => {
const { t } = useLingui();
const { isPhone } = useViewport();
+ // Phones: one value column at a time, starting on Ending.
+ const columnLabels = [
+ t`Beginning`,
+ t`Debits`,
+ t`Credits`,
+ t`Ending`,
+ ...(showTranslated
+ ? [t`Ending (${parentCurrency ?? "Translated"})`]
+ : []),
+ t`Ratio`
+ ];
+ const [columnIndex, setColumnIndex] = useColumnStep(columnLabels.length, 3);
useRealtime("journal");
const navigate = useNavigate();
const [params] = useUrlParams();
@@ -99,7 +112,7 @@ const TrialBalanceTree = memo(
} = useTree<TrialBalanceChart, undefined>({
tree,
parentRef,
- estimatedRowHeight: () => 36,
+ estimatedRowHeight: () => (isPhone ? 44 : 36),
isEager: true
});
@@ -107,36 +120,46 @@ const TrialBalanceTree = memo(
<ScrollArea
className={cn(
"h-[calc(100dvh-var(--header-height)-61px)] w-full",
- // Phones: the viewport also scrolls sideways, with an
- // edge fade, behind a sticky 150pt account column.
- "max-md:[&>[data-radix-scroll-area-viewport]]:!overflow-x-auto max-md:[&>[data-radix-scroll-area-viewport]]:scroll-fade-x"
+ // Phones: the tree fills what the filter rows leave.
+ "max-md:h-auto max-md:min-h-0 max-md:flex-1"
)}
>
- <div className="sticky top-0 z-10 flex h-11 items-center pr-4 text-sm font-medium text-foreground/80 border-b border-border bg-card max-md:w-max max-md:min-w-full">
- <div className="flex-1 px-4 max-md:sticky max-md:left-0 max-md:z-[2] max-md:w-[150px] max-md:flex-none max-md:truncate max-md:bg-card">
- <Trans>Account</Trans>
+ {isPhone ? (
+ <div className="sticky top-0 z-10">
+ <ColumnStepper
+ index={columnIndex}
+ count={columnLabels.length}
+ onChange={setColumnIndex}
+ label={columnLabels[columnIndex]}
+ />
</div>
- <span className="w-28 text-right px-2">
- <Trans>Beginning</Trans>
- </span>
- <span className="w-28 text-right px-2">
- <Trans>Debits</Trans>
- </span>
- <span className="w-28 text-right px-2">
- <Trans>Credits</Trans>
- </span>
- <span className="w-28 text-right px-2">
- <Trans>Ending</Trans>
- </span>
- {showTranslated && (
+ ) : (
+ <div className="sticky top-0 z-10 flex h-11 items-center pr-4 text-sm font-medium text-foreground/80 border-b border-border bg-card max-md:w-max max-md:min-w-full">
+ <div className="flex-1 px-4 max-md:sticky max-md:left-0 max-md:z-[2] max-md:w-[150px] max-md:flex-none max-md:truncate max-md:bg-card">
+ <Trans>Account</Trans>
+ </div>
<span className="w-28 text-right px-2">
- {t`Ending (${parentCurrency ?? "Translated"})`}
+ <Trans>Beginning</Trans>
</span>
- )}
- <span className="w-20 text-right px-2">
- <Trans>Ratio</Trans>
- </span>
- </div>
+ <span className="w-28 text-right px-2">
+ <Trans>Debits</Trans>
+ </span>
+ <span className="w-28 text-right px-2">
+ <Trans>Credits</Trans>
+ </span>
+ <span className="w-28 text-right px-2">
+ <Trans>Ending</Trans>
+ </span>
+ {showTranslated && (
+ <span className="w-28 text-right px-2">
+ {t`Ending (${parentCurrency ?? "Translated"})`}
+ </span>
+ )}
+ <span className="w-20 text-right px-2">
+ <Trans>Ratio</Trans>
+ </span>
+ </div>
+ )}
<TreeView<TrialBalanceChart>
tree={tree}
nodes={nodes}
@@ -144,12 +167,7 @@ const TrialBalanceTree = memo(
getNodeProps={getNodeProps}
virtualizer={virtualizer}
parentRef={parentRef}
- parentClassName={cn(
- "h-full",
- // The viewport is the sideways scroller, so sticky cells pin to it.
- "max-md:overflow-visible",
- showTranslated ? "max-md:min-w-[806px]" : "max-md:min-w-[694px]"
- )}
+ parentClassName="h-full"
renderNode={({ node, state }) => {
const account = node.data;
const isGroup = account.isGroup;
@@ -229,10 +247,50 @@ const TrialBalanceTree = memo(
</>
);
+ // Same order as the header; the translated cell only when shown.
+ const cellClass =
+ "w-28 text-right tabular-nums shrink-0 px-2 text-muted-foreground";
+ const valueCells = [
+ <span key="beginning" className={cellClass}>
+ {formatCurrency(beginningBalance)}
+ </span>,
+ <span key="debit" className={cellClass}>
+ {formatCurrency(debit)}
+ </span>,
+ <span key="credit" className={cellClass}>
+ {formatCurrency(credit)}
+ </span>,
+ <span
+ key="ending"
+ className={cn(
+ cellClass,
+ isDrillable &&
+ "group-hover/row:text-foreground group-hover/row:underline underline-offset-2 decoration-border"
+ )}
+ >
+ {formatCurrency(endingBalance)}
+ </span>,
+ ...(showTranslated
+ ? [
+ <span key="translated" className={cellClass}>
+ {account.translatedBalance != null
+ ? formatCurrency(account.translatedBalance)
+ : "-"}
+ </span>
+ ]
+ : []),
+ <span
+ key="ratio"
+ className="w-20 text-right tabular-nums shrink-0 px-2 text-muted-foreground"
+ >
+ {node.parentId ? formatPercent(ratio) : ""}
+ </span>
+ ];
+
return (
<div
className={cn(
- "flex h-8 cursor-pointer items-center overflow-hidden pr-4 text-sm group/row max-md:overflow-visible",
+ "flex h-8 cursor-pointer items-center overflow-hidden pr-4 text-sm group/row max-md:h-11",
state.selected
? "bg-muted hover:bg-accent"
: "bg-transparent hover:bg-accent",
@@ -247,62 +305,16 @@ const TrialBalanceTree = memo(
}
}}
>
- {/* Compact: one sticky cell, so the name stays beside the
- amounts while they scroll sideways. */}
+ {/* Phones: the name takes the width; one value shows. */}
{isPhone ? (
- <div
- className={cn(
- "sticky left-0 z-[1] flex h-full w-[150px] shrink-0 items-center overflow-hidden",
- state.selected
- ? "bg-muted group-hover/row:bg-accent"
- : "bg-card group-hover/row:bg-accent"
- )}
- >
+ <div className="flex h-full min-w-0 flex-1 items-center overflow-hidden">
{accountCell}
</div>
) : (
accountCell
)}
- {/* Beginning Balance */}
- <span className="w-28 text-right tabular-nums shrink-0 px-2 text-muted-foreground">
- {formatCurrency(beginningBalance)}
- </span>
-
- {/* Debits */}
- <span className="w-28 text-right tabular-nums shrink-0 px-2 text-muted-foreground">
- {formatCurrency(debit)}
- </span>
-
- {/* Credits */}
- <span className="w-28 text-right tabular-nums shrink-0 px-2 text-muted-foreground">
- {formatCurrency(credit)}
- </span>
-
- {/* Ending Balance */}
- <span
- className={cn(
- "w-28 text-right tabular-nums shrink-0 px-2 text-muted-foreground",
- isDrillable &&
- "group-hover/row:text-foreground group-hover/row:underline underline-offset-2 decoration-border"
- )}
- >
- {formatCurrency(endingBalance)}
- </span>
-
- {/* Translated Ending Balance */}
- {showTranslated && (
- <span className="w-28 text-right tabular-nums shrink-0 px-2 text-muted-foreground">
- {account.translatedBalance != null
- ? formatCurrency(account.translatedBalance)
- : "-"}
- </span>
- )}
-
- {/* Ratio */}
- <span className="w-20 text-right tabular-nums shrink-0 px-2 text-muted-foreground">
- {node.parentId ? formatPercent(ratio) : ""}
- </span>
+ {isPhone ? valueCells[columnIndex] : valueCells}
</div>
);
}}
diff --git a/apps/erp/app/modules/inventory/ui/Inventory/InventoryDetails.tsx b/apps/erp/app/modules/inventory/ui/Inventory/InventoryDetails.tsx
index 52be25cb43..73d5163cde 100644
--- a/apps/erp/app/modules/inventory/ui/Inventory/InventoryDetails.tsx
+++ b/apps/erp/app/modules/inventory/ui/Inventory/InventoryDetails.tsx
@@ -7,6 +7,7 @@ import {
CardContent,
CardHeader,
CardTitle,
+ cn,
VStack
} from "@carbon/react";
import { Trans } from "@lingui/react/macro";
@@ -35,6 +36,11 @@ type InventoryDetailsProps = {
pickMethod: z.infer<typeof pickMethodValidator>;
quantities: ItemQuantities | null;
storageUnits: { value: string; label: string }[];
+ /**
+ * The inventory quantities page. Phones show tiles and rows there; the
+ * item pages' inventory tabs stay as they are.
+ */
+ variant?: "quantity";
};
const InventoryDetails = ({
@@ -45,8 +51,10 @@ const InventoryDetails = ({
trackedEntityExpirations,
pickMethod,
quantities,
- storageUnits
+ storageUnits,
+ variant
}: InventoryDetailsProps) => {
+ const isQuantity = variant === "quantity";
const formatQuantity = useQuantityFormatter();
const [usageWindow, setUsageWindow] = useState<"30" | "90">("30");
const dailyUsage =
@@ -54,9 +62,44 @@ const InventoryDetails = ({
? (quantities?.usageLast30Days ?? 0)
: (quantities?.usageLast90Days ?? 0);
+ const renderUsageWindowSelect = (className?: string) => (
+ <DateSelect
+ className={className}
+ value={usageWindow}
+ onValueChange={(v) => {
+ if (v === "30" || v === "90") setUsageWindow(v);
+ }}
+ options={[
+ { value: "30", label: "30D" },
+ { value: "90", label: "90D" }
+ ]}
+ showCustom={false}
+ />
+ );
+
+ // Quantities page, phones: the figures as 2-column tiles (MetricCard sizes).
+ const valueClassName = cn(
+ "text-4xl font-medium tracking-tighter",
+ isQuantity &&
+ "max-md:truncate max-md:text-[26px] max-md:font-semibold max-md:tracking-tight max-md:tabular-nums"
+ );
+
return (
<VStack>
- <div className="w-full grid gap-2 grid-cols-1 md:grid-cols-2 lg:grid-cols-2">
+ {isQuantity ? (
+ <div className="flex items-center gap-2 md:hidden">
+ <span className="text-sm text-muted-foreground">
+ <Trans>Daily usage</Trans>
+ </span>
+ {renderUsageWindowSelect()}
+ </div>
+ ) : null}
+ <div
+ className={cn(
+ "w-full grid gap-2 grid-cols-1 md:grid-cols-2 lg:grid-cols-2",
+ isQuantity && "max-md:grid-cols-2 max-md:gap-3"
+ )}
+ >
<Card>
<CardHeader>
<CardTitle>
@@ -64,7 +107,7 @@ const InventoryDetails = ({
</CardTitle>
</CardHeader>
<CardContent>
- <h3 className="text-4xl font-medium tracking-tighter">
+ <h3 className={valueClassName}>
{formatQuantity(quantities?.quantityOnHand ?? 0)}
</h3>
</CardContent>
@@ -76,7 +119,7 @@ const InventoryDetails = ({
</CardTitle>
</CardHeader>
<CardContent>
- <h3 className="text-4xl font-medium tracking-tighter">
+ <h3 className={valueClassName}>
{formatQuantity(quantities?.daysRemaining ?? 0)}
</h3>
</CardContent>
@@ -86,22 +129,11 @@ const InventoryDetails = ({
<CardTitle>
<Trans>Daily Usage</Trans>
</CardTitle>
- <DateSelect
- value={usageWindow}
- onValueChange={(v) => {
- if (v === "30" || v === "90") setUsageWindow(v);
- }}
- options={[
- { value: "30", label: "30D" },
- { value: "90", label: "90D" }
- ]}
- showCustom={false}
- />
+ {/* Quantities page, phones: the select sits above the tiles. */}
+ {renderUsageWindowSelect(isQuantity ? "max-md:hidden" : undefined)}
</CardHeader>
<CardContent>
- <h3 className="text-4xl font-medium tracking-tighter">
- {formatQuantity(dailyUsage)}
- </h3>
+ <h3 className={valueClassName}>{formatQuantity(dailyUsage)}</h3>
</CardContent>
</Card>
<Card>
@@ -112,11 +144,17 @@ const InventoryDetails = ({
</CardHeader>
<CardContent>
<div className="flex justify-start items-center gap-1">
- <h3 className="text-4xl font-medium tracking-tighter">
+ <h3 className={valueClassName}>
{formatQuantity(quantities?.quantityOnPurchaseOrder ?? 0)}
</h3>
<LuMoveUp className="text-emerald-500 text-lg" />
</div>
+ {isQuantity ? (
+ <span className="flex items-center gap-1 text-xs text-muted-foreground md:hidden">
+ <LuMoveUp className="text-emerald-500" />
+ <Trans>Incoming</Trans>
+ </span>
+ ) : null}
</CardContent>
</Card>
<Card>
@@ -127,11 +165,17 @@ const InventoryDetails = ({
</CardHeader>
<CardContent>
<div className="flex justify-start items-center gap-1">
- <h3 className="text-4xl font-medium tracking-tighter">
+ <h3 className={valueClassName}>
{formatQuantity(quantities?.quantityOnSalesOrder ?? 0)}
</h3>
<LuMoveDown className="text-red-500 text-lg" />
</div>
+ {isQuantity ? (
+ <span className="flex items-center gap-1 text-xs text-muted-foreground md:hidden">
+ <LuMoveDown className="text-red-500" />
+ <Trans>Outgoing</Trans>
+ </span>
+ ) : null}
</CardContent>
</Card>
<Card>
@@ -143,18 +187,23 @@ const InventoryDetails = ({
<CardContent>
<div className="flex items-start justify-start gap-2">
<div className="flex justify-start items-center gap-1">
- <h3 className="text-4xl font-medium tracking-tighter">
+ <h3 className={valueClassName}>
{formatQuantity(quantities?.quantityOnProductionOrder ?? 0)}
</h3>
<LuMoveUp className="text-emerald-500 text-lg" />
</div>
<div className="flex justify-start items-center gap-1">
- <h3 className="text-4xl font-medium tracking-tighter">
+ <h3 className={valueClassName}>
{formatQuantity(quantities?.quantityOnProductionDemand ?? 0)}
</h3>
<LuMoveDown className="text-red-500 text-lg" />
</div>
</div>
+ {isQuantity ? (
+ <span className="text-xs text-muted-foreground md:hidden">
+ <Trans>Supply / demand</Trans>
+ </span>
+ ) : null}
</CardContent>
</Card>
</div>
@@ -166,6 +215,7 @@ const InventoryDetails = ({
trackedEntityExpirations={trackedEntityExpirations}
pickMethod={pickMethod}
storageUnits={storageUnits}
+ variant={variant}
/>
</VStack>
);
diff --git a/apps/erp/app/modules/inventory/ui/Inventory/InventoryItemHeader.tsx b/apps/erp/app/modules/inventory/ui/Inventory/InventoryItemHeader.tsx
index d84f9e2cb4..80678cb09e 100644
--- a/apps/erp/app/modules/inventory/ui/Inventory/InventoryItemHeader.tsx
+++ b/apps/erp/app/modules/inventory/ui/Inventory/InventoryItemHeader.tsx
@@ -2,10 +2,22 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-import { Button, VStack } from "@carbon/react";
-import { LuExternalLink, LuX } from "react-icons/lu";
+import {
+ Button,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuIcon,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ IconButton,
+ VStack
+} from "@carbon/react";
+import { Trans, useLingui } from "@lingui/react/macro";
+import { LuEllipsis, LuExternalLink, LuX } from "react-icons/lu";
import { Link, useNavigate, useParams } from "react-router";
import { DetailsTopbar } from "~/components/Layout";
+import { AppBarActions } from "~/components/Layout/Mobile/ChromeSlots";
+import { useHideListAppBarMenu } from "~/components/Table/components/Compact/CompactToolbar";
import { useUrlParams } from "~/hooks";
import { getLinkToItemDetails } from "~/modules/items/ui/Item/ItemForm";
import type { MethodItemType } from "~/modules/shared";
@@ -27,6 +39,11 @@ const InventoryItemHeader = ({
const [params] = useUrlParams();
const navigate = useNavigate();
+ const { t } = useLingui();
+
+ // Phones: this page owns the app bar ⋯ (the list behind it keeps out), and
+ // the link to the item's own page lives there.
+ useHideListAppBarMenu();
return (
<div>
@@ -46,7 +63,7 @@ const InventoryItemHeader = ({
<span className="max-md:hidden">{itemReadableId}</span>{" "}
<Link
to={getLinkToItemDetails(itemType, itemId)}
- className="ml-2 max-md:-mx-1.5 max-md:-my-3.5 max-md:p-3.5"
+ className="ml-2 max-md:hidden"
>
<LuExternalLink />
</Link>
@@ -54,6 +71,26 @@ const InventoryItemHeader = ({
<DetailsTopbar links={links} preserveParams />
</div>
</VStack>
+ <AppBarActions>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton
+ aria-label={t`More options`}
+ icon={<LuEllipsis />}
+ variant="ghost"
+ size="lg"
+ />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <DropdownMenuItem asChild>
+ <Link to={getLinkToItemDetails(itemType, itemId)}>
+ <DropdownMenuIcon icon={<LuExternalLink />} />
+ <Trans>Item Master</Trans>
+ </Link>
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </AppBarActions>
</div>
);
};
diff --git a/apps/erp/app/modules/inventory/ui/Inventory/InventoryStorageUnits.tsx b/apps/erp/app/modules/inventory/ui/Inventory/InventoryStorageUnits.tsx
index fac2c0c56e..0210ca48d3 100644
--- a/apps/erp/app/modules/inventory/ui/Inventory/InventoryStorageUnits.tsx
+++ b/apps/erp/app/modules/inventory/ui/Inventory/InventoryStorageUnits.tsx
@@ -19,6 +19,7 @@ import {
CardHeader,
CardTitle,
Copy,
+ cn,
DropdownMenu,
DropdownMenuContent,
DropdownMenuIcon,
@@ -40,6 +41,7 @@ import {
Tr,
toast,
useDisclosure,
+ useViewport,
VStack
} from "@carbon/react";
import { groupBy } from "@carbon/utils";
@@ -64,6 +66,7 @@ import { Input, Location, Select, TextArea } from "~/components/Form";
import ScrapReason from "~/components/Form/ScrapReason";
import StorageUnit from "~/components/Form/StorageUnit";
import { useUnitOfMeasure } from "~/components/Form/UnitOfMeasure";
+import { BottomBar } from "~/components/Layout/Mobile/ChromeSlots";
import { usePermissions, usePrinting } from "~/hooks";
import type {
ItemStorageUnitQuantities,
@@ -84,6 +87,8 @@ type InventoryStorageUnitsProps = {
} | null;
trackedEntityExpirations: Record<string, string | null>;
storageUnits: { value: string; label: string }[];
+ /** The inventory quantities page: phones show rows and a bottom bar. */
+ variant?: "quantity";
};
const InventoryStorageUnits = ({
@@ -93,10 +98,14 @@ const InventoryStorageUnits = ({
itemShelfLife,
trackedEntityExpirations,
pickMethod,
- storageUnits
+ storageUnits,
+ variant
}: InventoryStorageUnitsProps) => {
const permissions = usePermissions();
const { t } = useLingui();
+ const { isPhone } = useViewport();
+ const isQuantity = variant === "quantity";
+ const showPhoneRows = isQuantity && isPhone;
const adjustmentModal = useDisclosure();
const ruleViolations = useRuleViolations({
action: path.to.inventoryItemAdjustment(pickMethod.itemId),
@@ -156,6 +165,22 @@ const InventoryStorageUnits = ({
});
};
+ const summarizeGroup = (members: ItemStorageUnitQuantities[]) => {
+ // Batch quantities are decimals — clamp float noise on the sum.
+ const summedQuantity =
+ Math.round(members.reduce((sum, m) => sum + m.quantity, 0) * 1e6) / 1e6;
+ const expirations = members
+ .map((m) =>
+ m.trackedEntityId ? trackedEntityExpirations[m.trackedEntityId] : null
+ )
+ .filter((d): d is string => Boolean(d));
+ const earliestExpiration =
+ expirations.length > 0
+ ? expirations.reduce((min, d) => (d < min ? d : min))
+ : null;
+ return { summedQuantity, earliestExpiration };
+ };
+
const showExpirationColumn = useMemo(
() =>
visibleStorageUnitQuantities.some(
@@ -268,6 +293,41 @@ const InventoryStorageUnits = ({
setPendingPrintEntityId(null);
};
+ const renderRowMenu = (item: ItemStorageUnitQuantities) => (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton
+ aria-label={t`Actions`}
+ variant="ghost"
+ icon={<LuEllipsisVertical />}
+ />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent className="w-56">
+ <DropdownMenuItem
+ onClick={() =>
+ openAdjustmentModal(
+ item.storageUnitId,
+ item.trackedEntityId,
+ item.readableId,
+ item.quantity
+ )
+ }
+ >
+ <DropdownMenuIcon icon={<LuPencil />} />
+ <Trans>Update Quantity</Trans>
+ </DropdownMenuItem>
+ {item.trackedEntityId && (
+ <DropdownMenuItem
+ onClick={() => handlePrintLabel(item.trackedEntityId!)}
+ >
+ <DropdownMenuIcon icon={<LuPrinter />} />
+ <Trans>Print Label</Trans>
+ </DropdownMenuItem>
+ )}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+
const renderStorageUnitRow = (
item: ItemStorageUnitQuantities,
key: string
@@ -308,42 +368,131 @@ const InventoryStorageUnits = ({
</Td>
)}
<Td className="flex flex-shrink-0 justify-end items-center">
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <IconButton
- aria-label={t`Actions`}
- variant="ghost"
- icon={<LuEllipsisVertical />}
- />
- </DropdownMenuTrigger>
- <DropdownMenuContent className="w-56">
- <DropdownMenuItem
- onClick={() =>
- openAdjustmentModal(
- item.storageUnitId,
- item.trackedEntityId,
- item.readableId,
- item.quantity
- )
- }
- >
- <DropdownMenuIcon icon={<LuPencil />} />
- <Trans>Update Quantity</Trans>
- </DropdownMenuItem>
- {item.trackedEntityId && (
- <DropdownMenuItem
- onClick={() => handlePrintLabel(item.trackedEntityId!)}
- >
- <DropdownMenuIcon icon={<LuPrinter />} />
- <Trans>Print Label</Trans>
- </DropdownMenuItem>
- )}
- </DropdownMenuContent>
- </DropdownMenu>
+ {renderRowMenu(item)}
</Td>
</Tr>
);
+ const storageUnitLabel = (item: ItemStorageUnitQuantities) =>
+ storageUnits.find((s) => s.value === item.storageUnitId)?.label ||
+ item.storageUnitName ||
+ item.storageUnitId;
+
+ // Quantities page, phones: list rows (unit and quantity, then tracking ID
+ // and expiry) in place of the table, with the same per-row ⋯.
+ const phoneRowClassName =
+ "relative flex min-h-14 items-center gap-3 bg-card px-4 py-3 after:pointer-events-none after:absolute after:right-0 after:bottom-0 after:left-4 after:h-px after:bg-border last:after:hidden";
+
+ const renderPhoneRow = (
+ item: ItemStorageUnitQuantities,
+ key: string,
+ isGroupMember = false
+ ) => {
+ const expiration = item.trackedEntityId
+ ? trackedEntityExpirations[item.trackedEntityId]
+ : null;
+ return (
+ <div
+ key={key}
+ className={cn(phoneRowClassName, isGroupMember && "pl-12")}
+ >
+ <div className="flex min-w-0 flex-1 flex-col gap-1">
+ <div className="flex min-w-0 items-start gap-3">
+ <span className="min-w-0 flex-1 truncate text-[15px] font-medium text-foreground">
+ {storageUnitLabel(item)}
+ </span>
+ <span className="max-w-[45%] shrink-0 truncate text-right text-[15px] tabular-nums text-foreground">
+ {item.quantity}
+ </span>
+ </div>
+ {item.trackedEntityId ? (
+ <div className="flex min-w-0 items-center gap-1.5 text-[13px] text-muted-foreground">
+ {item.readableId ? (
+ <span className="min-w-0 truncate">{item.readableId}</span>
+ ) : null}
+ <Copy
+ icon={<LuQrCode />}
+ text={item.trackedEntityId}
+ withTextInTooltip
+ />
+ {expiration ? (
+ <span className="shrink-0">
+ <Trans>
+ Expires <DateTime value={expiration} variant="date" />
+ </Trans>
+ </span>
+ ) : null}
+ </div>
+ ) : null}
+ </div>
+ <div className="shrink-0 [&_button]:size-11">{renderRowMenu(item)}</div>
+ </div>
+ );
+ };
+
+ const phoneRows =
+ storageUnitGroups.length === 0 ? (
+ <p className="px-4 py-3 text-sm text-muted-foreground">
+ <Trans>No storage unit holds this item.</Trans>
+ </p>
+ ) : (
+ <div className="flex flex-col">
+ {storageUnitGroups.map((group) => {
+ if (group.members.length === 1) {
+ return renderPhoneRow(group.members[0], group.key);
+ }
+ const isExpanded = expandedGroupKeys.has(group.key);
+ const first = group.members[0];
+ const { summedQuantity, earliestExpiration } = summarizeGroup(
+ group.members
+ );
+ return (
+ <Fragment key={group.key}>
+ <div className={cn(phoneRowClassName, "pl-1")}>
+ <IconButton
+ aria-label={isExpanded ? t`Collapse` : t`Expand`}
+ variant="ghost"
+ className="size-11 shrink-0"
+ icon={isExpanded ? <LuChevronDown /> : <LuChevronRight />}
+ onClick={() => toggleGroup(group.key)}
+ />
+ <div className="flex min-w-0 flex-1 flex-col gap-1">
+ <div className="flex min-w-0 items-start gap-3">
+ <span className="min-w-0 flex-1 truncate text-[15px] font-medium text-foreground">
+ {storageUnitLabel(first)}
+ </span>
+ <span className="max-w-[45%] shrink-0 truncate text-right text-[15px] tabular-nums text-foreground">
+ {summedQuantity}
+ </span>
+ </div>
+ <div className="flex min-w-0 items-center gap-1.5 text-[13px] text-muted-foreground">
+ {first.readableId ? (
+ <span className="min-w-0 truncate">
+ {first.readableId}
+ </span>
+ ) : null}
+ <span className="shrink-0">×{group.members.length}</span>
+ {earliestExpiration ? (
+ <span className="shrink-0">
+ <Trans>
+ Expires{" "}
+ <DateTime value={earliestExpiration} variant="date" />
+ </Trans>
+ </span>
+ ) : null}
+ </div>
+ </div>
+ </div>
+ {isExpanded &&
+ group.members.map((item, index) =>
+ renderPhoneRow(item, `${group.key}:${index}`, true)
+ )}
+ </Fragment>
+ );
+ })}
+ </div>
+ );
+
return (
<>
<Card className="w-full">
@@ -362,119 +511,128 @@ const InventoryStorageUnits = ({
</HStack>
</CardTitle>
</CardHeader>
- <CardAction>
+ {/* Quantities page, phones: the action is in the bottom bar. */}
+ <CardAction className={isQuantity ? "max-md:hidden" : undefined}>
<Button onClick={() => openAdjustmentModal()}>
<Trans>Update Inventory</Trans>
</Button>
</CardAction>
</HStack>
- <CardContent>
- <Table className="table-fixed">
- <Thead>
- <Tr>
- <Th>
- <Trans>Storage Unit</Trans>
- </Th>
-
- <Th>
- <Trans>Quantity</Trans>
- </Th>
- <Th>
- <Trans>Tracking ID</Trans>
- </Th>
- {showExpirationColumn && (
+ <CardContent
+ className={showPhoneRows ? "overflow-hidden max-md:p-0" : undefined}
+ >
+ {showPhoneRows ? (
+ phoneRows
+ ) : (
+ <Table className="table-fixed">
+ <Thead>
+ <Tr>
<Th>
- <Trans>Expiration Date</Trans>
+ <Trans>Storage Unit</Trans>
</Th>
- )}
- <Th className="flex flex-shrink-0 justify-end" />
- </Tr>
- </Thead>
- <Tbody>
- {storageUnitGroups.map((group) => {
- if (group.members.length === 1) {
- return renderStorageUnitRow(group.members[0], group.key);
- }
- const isExpanded = expandedGroupKeys.has(group.key);
- const first = group.members[0];
- // Batch quantities are decimals — clamp float noise on the sum.
- const summedQuantity =
- Math.round(
- group.members.reduce((sum, m) => sum + m.quantity, 0) * 1e6
- ) / 1e6;
- const expirations = group.members
- .map((m) =>
- m.trackedEntityId
- ? trackedEntityExpirations[m.trackedEntityId]
- : null
- )
- .filter((d): d is string => Boolean(d));
- const earliestExpiration =
- expirations.length > 0
- ? expirations.reduce((min, d) => (d < min ? d : min))
- : null;
- return (
- <Fragment key={group.key}>
- <Tr>
- <Td>
- <HStack className="gap-1">
- <IconButton
- aria-label={isExpanded ? t`Collapse` : t`Expand`}
- variant="ghost"
- icon={
- isExpanded ? (
- <LuChevronDown />
- ) : (
- <LuChevronRight />
- )
- }
- onClick={() => toggleGroup(group.key)}
- />
- <span>
- {storageUnits.find(
- (s) => s.value === first.storageUnitId
- )?.label ||
- first.storageUnitName ||
- first.storageUnitId}
- </span>
- </HStack>
- </Td>
- <Td>
- <span>{summedQuantity}</span>
- </Td>
- <Td>
- <HStack>
- {first.readableId && <span>{first.readableId}</span>}
- <span className="text-xs text-muted-foreground">
- ×{group.members.length}
- </span>
- </HStack>
- </Td>
- {showExpirationColumn && (
+
+ <Th>
+ <Trans>Quantity</Trans>
+ </Th>
+ <Th>
+ <Trans>Tracking ID</Trans>
+ </Th>
+ {showExpirationColumn && (
+ <Th>
+ <Trans>Expiration Date</Trans>
+ </Th>
+ )}
+ <Th className="flex flex-shrink-0 justify-end" />
+ </Tr>
+ </Thead>
+ <Tbody>
+ {storageUnitGroups.map((group) => {
+ if (group.members.length === 1) {
+ return renderStorageUnitRow(group.members[0], group.key);
+ }
+ const isExpanded = expandedGroupKeys.has(group.key);
+ const first = group.members[0];
+ const { summedQuantity, earliestExpiration } = summarizeGroup(
+ group.members
+ );
+ return (
+ <Fragment key={group.key}>
+ <Tr>
<Td>
- {earliestExpiration && (
+ <HStack className="gap-1">
+ <IconButton
+ aria-label={isExpanded ? t`Collapse` : t`Expand`}
+ variant="ghost"
+ icon={
+ isExpanded ? (
+ <LuChevronDown />
+ ) : (
+ <LuChevronRight />
+ )
+ }
+ onClick={() => toggleGroup(group.key)}
+ />
<span>
- <DateTime
- value={earliestExpiration}
- variant="date"
- />
+ {storageUnits.find(
+ (s) => s.value === first.storageUnitId
+ )?.label ||
+ first.storageUnitName ||
+ first.storageUnitId}
</span>
- )}
+ </HStack>
</Td>
- )}
- <Td className="flex flex-shrink-0 justify-end items-center" />
- </Tr>
- {isExpanded &&
- group.members.map((item, index) =>
- renderStorageUnitRow(item, `${group.key}:${index}`)
- )}
- </Fragment>
- );
- })}
- </Tbody>
- </Table>
+ <Td>
+ <span>{summedQuantity}</span>
+ </Td>
+ <Td>
+ <HStack>
+ {first.readableId && (
+ <span>{first.readableId}</span>
+ )}
+ <span className="text-xs text-muted-foreground">
+ ×{group.members.length}
+ </span>
+ </HStack>
+ </Td>
+ {showExpirationColumn && (
+ <Td>
+ {earliestExpiration && (
+ <span>
+ <DateTime
+ value={earliestExpiration}
+ variant="date"
+ />
+ </span>
+ )}
+ </Td>
+ )}
+ <Td className="flex flex-shrink-0 justify-end items-center" />
+ </Tr>
+ {isExpanded &&
+ group.members.map((item, index) =>
+ renderStorageUnitRow(item, `${group.key}:${index}`)
+ )}
+ </Fragment>
+ );
+ })}
+ </Tbody>
+ </Table>
+ )}
</CardContent>
</Card>
+ {isQuantity ? (
+ <BottomBar>
+ <div className="flex items-center gap-2 border-t border-border bg-card px-4 pt-2 pb-safe-4">
+ <Button
+ size="lg"
+ className="w-full"
+ onClick={() => openAdjustmentModal()}
+ >
+ <Trans>Update Inventory</Trans>
+ </Button>
+ </div>
+ </BottomBar>
+ ) : null}
{adjustmentModal.isOpen && (
<Modal
open
diff --git a/apps/erp/app/modules/inventory/ui/PickingLists/PickingListHeader.tsx b/apps/erp/app/modules/inventory/ui/PickingLists/PickingListHeader.tsx
index babd2d236b..a89f389054 100644
--- a/apps/erp/app/modules/inventory/ui/PickingLists/PickingListHeader.tsx
+++ b/apps/erp/app/modules/inventory/ui/PickingLists/PickingListHeader.tsx
@@ -15,7 +15,8 @@ import {
ModalHeader,
ModalOverlay,
ModalTitle,
- useDisclosure
+ useDisclosure,
+ useViewport
} from "@carbon/react";
import { Trans, useLingui } from "@lingui/react/macro";
import { useEffect, useState } from "react";
@@ -25,7 +26,8 @@ import {
LuCircleStop,
LuLoaderCircle,
LuTrash,
- LuTriangleAlert
+ LuTriangleAlert,
+ LuUser
} from "react-icons/lu";
import { useFetcher, useParams } from "react-router";
import Assignee, { useOptimisticAssignment } from "~/components/Assignee";
@@ -38,6 +40,7 @@ import type {
UnresolvedPickingListLine
} from "~/modules/inventory";
import { isPickingListLocked } from "~/modules/inventory";
+import { usePeople } from "~/stores";
import { path } from "~/utils/path";
import PickingListStatus from "./PickingListStatus";
@@ -62,8 +65,11 @@ const PickingListHeader = () => {
const status = pickingList.status;
const { t } = useLingui();
+ const { isPhone } = useViewport();
const permissions = usePermissions();
const deleteModal = useDisclosure();
+ const [people] = usePeople();
+ const [isAssigneeOpen, setIsAssigneeOpen] = useState(false);
const statusFetcher = useFetcher<{
needsAcknowledgement?: boolean;
unresolvedLines?: UnresolvedPickingListLine[];
@@ -94,6 +100,26 @@ const PickingListHeader = () => {
optimisticAssignment !== undefined
? optimisticAssignment
: pickingList.assignee;
+ const canAssign =
+ permissions.can("update", "inventory") && permissions.is("employee");
+
+ // Phones: the hero line. The list has no job column, so the jobs come
+ // from its lines: the first one, then "+N" for the others.
+ const jobIds = Array.from(
+ new Set(
+ (routeData.pickingListLines ?? [])
+ .map((line) => line.job?.jobId)
+ .filter((jobId): jobId is string => Boolean(jobId))
+ )
+ );
+ const jobLabel =
+ jobIds.length > 1 ? `${jobIds[0]} +${jobIds.length - 1}` : jobIds[0];
+ const assigneeName =
+ optimisticAssignment !== undefined
+ ? people.find((person) => person.id === optimisticAssignment)?.name
+ : pickingList.assigneeUser?.fullName;
+ const subtitle =
+ [jobLabel, assigneeName].filter(Boolean).join(" · ") || undefined;
const submitStatus = (next: string, acknowledged?: boolean) => {
if (acknowledged !== true) setAcknowledgeLines(null);
@@ -143,16 +169,29 @@ const PickingListHeader = () => {
copyValue={pickingList.pickingListId ?? ""}
menu={menuItems}
status={statusBadge}
+ subtitle={subtitle}
actions={
<>
<RecordAction slot="overflow">
- <Assignee
- size="md"
- id={pickingListId}
- value={assignee ?? ""}
- table="pickingList"
- isReadOnly={!permissions.can("update", "inventory")}
- />
+ {isPhone ? (
+ <Button
+ type="button"
+ variant="secondary"
+ leftIcon={<LuUser />}
+ isDisabled={!canAssign}
+ onClick={() => setIsAssigneeOpen(true)}
+ >
+ <Trans>Assign</Trans>
+ </Button>
+ ) : (
+ <Assignee
+ size="md"
+ id={pickingListId}
+ value={assignee ?? ""}
+ table="pickingList"
+ isReadOnly={!permissions.can("update", "inventory")}
+ />
+ )}
</RecordAction>
<RecordAction slot={status === "Draft" ? "primary" : "overflow"}>
<Button
@@ -217,6 +256,22 @@ const PickingListHeader = () => {
}
/>
+ {/* Phones: the ⋯ "Assign" row opens the picker as a sheet; its own
+ trigger stays hidden. */}
+ {isPhone && (
+ <div className="hidden">
+ <Assignee
+ size="md"
+ id={pickingListId}
+ value={assignee ?? ""}
+ table="pickingList"
+ isReadOnly={!permissions.can("update", "inventory")}
+ open={isAssigneeOpen}
+ onOpenChange={setIsAssigneeOpen}
+ />
+ </div>
+ )}
+
{acknowledgeLines && (
<Modal
open
diff --git a/apps/erp/app/modules/inventory/ui/PickingLists/PickingListLines.tsx b/apps/erp/app/modules/inventory/ui/PickingLists/PickingListLines.tsx
index 5073876594..a6426b9362 100644
--- a/apps/erp/app/modules/inventory/ui/PickingLists/PickingListLines.tsx
+++ b/apps/erp/app/modules/inventory/ui/PickingLists/PickingListLines.tsx
@@ -24,11 +24,13 @@ import {
DropdownMenuTrigger,
HStack,
Skeleton,
+ Status,
Tooltip,
TooltipContent,
TooltipTrigger,
TrackedEntityPicker,
toast,
+ useViewport,
VStack
} from "@carbon/react";
import { Trans, useLingui } from "@lingui/react/macro";
@@ -199,6 +201,38 @@ function PickingKitCard({
0
);
const progress = totalToPick > 0 ? (totalPicked / totalToPick) * 100 : 0;
+ const { t } = useLingui();
+ const { isPhone } = useViewport();
+
+ // Phones: an overline header for the kit, then each line as its own card.
+ if (isPhone) {
+ const percent = Math.round(progress);
+ return (
+ <section className="flex w-full flex-col gap-3">
+ <div className="flex items-center justify-between gap-3 px-1 text-xs font-medium uppercase tracking-[0.04em] text-muted-foreground">
+ <div className="min-w-0 truncate normal-case tracking-normal">
+ {kit.jobReadableId ?? t`Unknown Job`}
+ {kit.operationName ? ` · ${kit.operationName}` : ""}
+ {kit.workCenterName ? ` · ${kit.workCenterName}` : ""}
+ </div>
+ <span className="shrink-0 tabular-nums">
+ <Trans>{percent}% picked</Trans>
+ </span>
+ </div>
+ {kit.lines.map((line) => (
+ <Card key={line.id} className="bg-card">
+ <PickingListLineItem
+ line={line}
+ pickingListId={pickingListId}
+ isLast
+ isLocked={isLocked}
+ recommendations={recommendations}
+ />
+ </Card>
+ ))}
+ </section>
+ );
+ }
return (
<Card>
@@ -247,6 +281,7 @@ function PickingListLineItem({
}) {
const permissions = usePermissions();
const { t } = useLingui();
+ const { isPhone } = useViewport();
const [items] = useItems();
const fetcher = useFetcher<{ success: boolean; message?: string }>();
const isPending = fetcher.state !== "idle";
@@ -363,6 +398,118 @@ function PickingListLineItem({
});
};
+ const quantityBadge = isTracked ? (
+ <Badge
+ variant={isPicked ? "green" : quantityPicked > 0 ? "orange" : "red"}
+ className="text-base tabular-nums"
+ >
+ {quantityPicked}/{quantityToPick}
+ {unitSuffix}
+ </Badge>
+ ) : (
+ <Badge
+ variant={isPicked ? "green" : isShort ? "orange" : "red"}
+ className="text-base tabular-nums"
+ >
+ {isShort ? quantityPicked : quantityToPick}
+ {unitSuffix}
+ </Badge>
+ );
+
+ // Phones: the line's buttons share their own row as equal 44pt halves.
+ const phoneButton = isPhone
+ ? { size: "lg" as const, className: "flex-1" }
+ : {};
+ const phoneButtonRow = isPhone ? "w-full gap-2 space-x-0" : undefined;
+
+ const actions = isLocked ? null : isTracked ? (
+ <HStack spacing={1} className={phoneButtonRow}>
+ {pickedLots.length === 1 ? (
+ <Button
+ variant="secondary"
+ leftIcon={<LuUndo2 />}
+ isDisabled={!canPick || isPending}
+ onClick={() => unpickTracked(pickedLots[0].trackedEntityId)}
+ {...phoneButton}
+ >
+ {pickedLots[0].trackedEntity?.readableId ? (
+ <Trans>Unpick {pickedLots[0].trackedEntity.readableId}</Trans>
+ ) : (
+ <Trans>Unpick</Trans>
+ )}
+ </Button>
+ ) : pickedLots.length > 1 ? (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ variant="secondary"
+ leftIcon={<LuUndo2 />}
+ rightIcon={<LuChevronDown />}
+ isDisabled={!canPick || isPending}
+ {...phoneButton}
+ >
+ <Trans>Unpick</Trans>
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ {pickedLots.map((lot) => (
+ <DropdownMenuItem
+ key={lot.trackedEntityId}
+ onClick={() => unpickTracked(lot.trackedEntityId)}
+ >
+ <DropdownMenuIcon icon={<LuUndo2 />} />
+ {lot.trackedEntity?.readableId ?? lot.trackedEntityId}
+ </DropdownMenuItem>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ ) : null}
+ {!isPicked && (
+ <Button
+ variant="secondary"
+ leftIcon={<LuQrCode />}
+ isDisabled={!canPick || isPending}
+ onClick={openPicker}
+ {...phoneButton}
+ >
+ <Trans>Scan</Trans>
+ </Button>
+ )}
+ </HStack>
+ ) : isPicked ? (
+ <Button
+ variant="secondary"
+ leftIcon={<LuUndo2 />}
+ isDisabled={!canPick || isPending}
+ isLoading={isPending}
+ onClick={() => pick(0)}
+ {...phoneButton}
+ >
+ <Trans>Unpick</Trans>
+ </Button>
+ ) : (
+ <HStack spacing={1} className={phoneButtonRow}>
+ <Button
+ variant="secondary"
+ isDisabled={!canPick || isPending}
+ onClick={() => setShortOpen(true)}
+ {...phoneButton}
+ >
+ <Trans>Short</Trans>
+ </Button>
+ <Button
+ variant={isPhone ? "secondary" : undefined}
+ leftIcon={<LuCirclePlus />}
+ isDisabled={!canPick || isPending}
+ isLoading={isPending}
+ onClick={() => pick(quantityToPick)}
+ {...phoneButton}
+ >
+ <Trans>Pick</Trans>
+ </Button>
+ </HStack>
+ );
+
return (
<div
className={cn(
@@ -408,6 +555,11 @@ function PickingListLineItem({
<RecommendedLots resolve={recommendations} lineId={line.id} />
)}
</VStack>
+ {isPhone && isShort && (
+ <Status color="orange" disableTooltip className="ml-auto shrink-0">
+ <Trans>Short</Trans>
+ </Status>
+ )}
</HStack>
<HStack
@@ -472,104 +624,21 @@ function PickingListLineItem({
</TooltipContent>
</Tooltip>
)}
- {isTracked ? (
- <Badge
- variant={isPicked ? "green" : quantityPicked > 0 ? "orange" : "red"}
- className="text-base tabular-nums"
- >
- {quantityPicked}/{quantityToPick}
- {unitSuffix}
- </Badge>
- ) : (
- <Badge
- variant={isPicked ? "green" : isShort ? "orange" : "red"}
- className="text-base tabular-nums"
- >
- {isShort ? quantityPicked : quantityToPick}
- {unitSuffix}
- </Badge>
- )}
- {isLocked ? null : isTracked ? (
- <HStack spacing={1}>
- {pickedLots.length === 1 ? (
- <Button
- variant="secondary"
- leftIcon={<LuUndo2 />}
- isDisabled={!canPick || isPending}
- onClick={() => unpickTracked(pickedLots[0].trackedEntityId)}
- >
- {pickedLots[0].trackedEntity?.readableId ? (
- <Trans>Unpick {pickedLots[0].trackedEntity.readableId}</Trans>
- ) : (
- <Trans>Unpick</Trans>
- )}
- </Button>
- ) : pickedLots.length > 1 ? (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button
- variant="secondary"
- leftIcon={<LuUndo2 />}
- rightIcon={<LuChevronDown />}
- isDisabled={!canPick || isPending}
- >
- <Trans>Unpick</Trans>
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- {pickedLots.map((lot) => (
- <DropdownMenuItem
- key={lot.trackedEntityId}
- onClick={() => unpickTracked(lot.trackedEntityId)}
- >
- <DropdownMenuIcon icon={<LuUndo2 />} />
- {lot.trackedEntity?.readableId ?? lot.trackedEntityId}
- </DropdownMenuItem>
- ))}
- </DropdownMenuContent>
- </DropdownMenu>
- ) : null}
- {!isPicked && (
- <Button
- variant="secondary"
- leftIcon={<LuQrCode />}
- isDisabled={!canPick || isPending}
- onClick={openPicker}
- >
- <Trans>Scan</Trans>
- </Button>
+ {isPhone ? (
+ <span className="ml-auto inline-flex items-center gap-1.5 text-sm text-muted-foreground">
+ {isTracked || isPicked || isShort ? (
+ <Trans>Picked</Trans>
+ ) : (
+ <Trans>To pick</Trans>
)}
- </HStack>
- ) : isPicked ? (
- <Button
- variant="secondary"
- leftIcon={<LuUndo2 />}
- isDisabled={!canPick || isPending}
- isLoading={isPending}
- onClick={() => pick(0)}
- >
- <Trans>Unpick</Trans>
- </Button>
+ {quantityBadge}
+ </span>
) : (
- <HStack spacing={1}>
- <Button
- variant="secondary"
- isDisabled={!canPick || isPending}
- onClick={() => setShortOpen(true)}
- >
- <Trans>Short</Trans>
- </Button>
- <Button
- leftIcon={<LuCirclePlus />}
- isDisabled={!canPick || isPending}
- isLoading={isPending}
- onClick={() => pick(quantityToPick)}
- >
- <Trans>Pick</Trans>
- </Button>
- </HStack>
+ quantityBadge
)}
+ {isPhone ? null : actions}
</HStack>
+ {isPhone && actions ? <div className="flex w-full">{actions}</div> : null}
{shortOpen && (
<ShortPickModal
diff --git a/apps/erp/app/modules/inventory/ui/PickingLists/PickingListNotes.tsx b/apps/erp/app/modules/inventory/ui/PickingLists/PickingListNotes.tsx
index 19f6b87acd..e3cde13adc 100644
--- a/apps/erp/app/modules/inventory/ui/PickingLists/PickingListNotes.tsx
+++ b/apps/erp/app/modules/inventory/ui/PickingLists/PickingListNotes.tsx
@@ -9,7 +9,7 @@ import {
CardContent,
CardHeader,
CardTitle,
- generateHTML,
+ RichTextView,
useDebounce
} from "@carbon/react";
import { Editor } from "@carbon/react/Editor";
@@ -67,11 +67,9 @@ const PickingListNotes = ({
}}
/>
) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(notes as JSONContent)
- }}
+ <RichTextView
+ content={notes as JSONContent}
+ empty={<Trans>No notes</Trans>}
/>
)}
</CardContent>
diff --git a/apps/erp/app/modules/inventory/ui/Shipments/ShipmentNotes.tsx b/apps/erp/app/modules/inventory/ui/Shipments/ShipmentNotes.tsx
index 4895a58c10..ec959d4a49 100644
--- a/apps/erp/app/modules/inventory/ui/Shipments/ShipmentNotes.tsx
+++ b/apps/erp/app/modules/inventory/ui/Shipments/ShipmentNotes.tsx
@@ -10,8 +10,8 @@ import {
CardContent,
CardHeader,
CardTitle,
- generateHTML,
HStack,
+ RichTextView,
Tabs,
TabsContent,
TabsList,
@@ -111,11 +111,9 @@ const ShipmentNotes = ({
}}
/>
) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(internalNotes as JSONContent)
- }}
+ <RichTextView
+ content={internalNotes as JSONContent}
+ empty={<Trans>No internal notes</Trans>}
/>
)}
</TabsContent>
@@ -130,11 +128,9 @@ const ShipmentNotes = ({
}}
/>
) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(externalNotes as JSONContent)
- }}
+ <RichTextView
+ content={externalNotes as JSONContent}
+ empty={<Trans>No external notes</Trans>}
/>
)}
</TabsContent>
diff --git a/apps/erp/app/modules/inventory/ui/StockTransfers/StockTransferNotes.tsx b/apps/erp/app/modules/inventory/ui/StockTransfers/StockTransferNotes.tsx
index dbb7fa5e2a..4b12624ac1 100644
--- a/apps/erp/app/modules/inventory/ui/StockTransfers/StockTransferNotes.tsx
+++ b/apps/erp/app/modules/inventory/ui/StockTransfers/StockTransferNotes.tsx
@@ -9,7 +9,7 @@ import {
CardContent,
CardHeader,
CardTitle,
- generateHTML,
+ RichTextView,
useDebounce
} from "@carbon/react";
import { Editor } from "@carbon/react/Editor";
@@ -67,11 +67,9 @@ const ShipmentNotes = ({
}}
/>
) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(notes as JSONContent)
- }}
+ <RichTextView
+ content={notes as JSONContent}
+ empty={<Trans>No notes</Trans>}
/>
)}
</CardContent>
diff --git a/apps/erp/app/modules/inventory/ui/StorageUnits/StorageUnitForm.tsx b/apps/erp/app/modules/inventory/ui/StorageUnits/StorageUnitForm.tsx
index e60501d178..6b17ac3a41 100644
--- a/apps/erp/app/modules/inventory/ui/StorageUnits/StorageUnitForm.tsx
+++ b/apps/erp/app/modules/inventory/ui/StorageUnits/StorageUnitForm.tsx
@@ -10,6 +10,8 @@ import {
FormLabel,
HStack,
Input as InputBase,
+ InputGroup,
+ InputLeftElement,
ModalDrawer,
ModalDrawerBody,
ModalDrawerContent,
@@ -17,9 +19,11 @@ import {
ModalDrawerHeader,
ModalDrawerProvider,
ModalDrawerTitle,
+ useViewport,
VStack
} from "@carbon/react";
import { Trans, useLingui } from "@lingui/react/macro";
+import { LuLock } from "react-icons/lu";
import { useFetcher } from "react-router";
import type { z } from "zod";
import { PrintButton } from "~/components";
@@ -31,6 +35,7 @@ import {
Submit,
WorkCenter
} from "~/components/Form";
+import { useLocations } from "~/components/Form/Location";
import { usePermissions } from "~/hooks";
import { storageUnitValidator } from "~/modules/inventory";
import { path } from "~/utils/path";
@@ -65,6 +70,36 @@ const StorageUnitForm = ({
? !permissions.can("update", "parts")
: !permissions.can("create", "parts");
+ // Phones, edit only: a full-screen sheet with Save in its header. The New
+ // sheet and the inline create modal stay as they are.
+ const { isPhone } = useViewport();
+ const isPhoneEdit = isEditing && isPhone;
+ const locations = useLocations();
+ const locationName =
+ locations.find((l) => l.value === initialValues.locationId)?.label ?? "";
+
+ const saveButton = (
+ <Submit isDisabled={isDisabled}>
+ <Trans>Save</Trans>
+ </Submit>
+ );
+ const printButton =
+ isEditing && initialValues.id ? (
+ <PrintButton
+ sourceDocument="StorageUnit"
+ sourceDocumentId={initialValues.id}
+ locationId={locationId || undefined}
+ context="inventory"
+ fileRoutes={{
+ pdf: (id: string, opts?: { labelSize?: string }) =>
+ path.to.file.storageUnitLabelsPdf(id, opts),
+ zpl: (id: string, opts?: { labelSize?: string }) =>
+ path.to.file.storageUnitLabelsZpl(id, opts)
+ }}
+ label={isPhoneEdit ? t`Print label` : undefined}
+ />
+ ) : null;
+
return (
<ModalDrawerProvider type={type}>
<ModalDrawer
@@ -73,7 +108,13 @@ const StorageUnitForm = ({
if (!open) onClose?.();
}}
>
- <ModalDrawerContent>
+ <ModalDrawerContent
+ className={
+ isPhoneEdit
+ ? "max-md:h-[calc(100dvh-env(safe-area-inset-top)-12px)]"
+ : undefined
+ }
+ >
<ValidatedForm
validator={storageUnitValidator}
method="post"
@@ -91,10 +132,20 @@ const StorageUnitForm = ({
}}
className="flex flex-col h-full"
>
- <ModalDrawerHeader>
+ <ModalDrawerHeader
+ className={
+ isPhoneEdit
+ ? "max-md:flex-row max-md:items-center max-md:justify-between max-md:gap-3"
+ : undefined
+ }
+ >
<ModalDrawerTitle>
{isEditing ? t`Edit Storage Unit` : t`New Storage Unit`}
</ModalDrawerTitle>
+ {/* Last in the row, so it sits left of the sheet's × */}
+ {isPhoneEdit ? (
+ <div className="order-last shrink-0">{saveButton}</div>
+ ) : null}
</ModalDrawerHeader>
<ModalDrawerBody>
<Hidden name="id" />
@@ -102,15 +153,37 @@ const StorageUnitForm = ({
<VStack spacing={4}>
<Input name="name" label={t`Name`} />
- <Location
- isReadOnly={isEditing}
- name="locationId"
- label={t`Location`}
- />
+ {isPhoneEdit ? (
+ <FormControl>
+ <FormLabel htmlFor="locationId-readonly">
+ {t`Location`}
+ </FormLabel>
+ <Hidden name="locationId" />
+ <InputGroup>
+ <InputLeftElement>
+ <LuLock className="size-4 text-muted-foreground" />
+ </InputLeftElement>
+ <InputBase
+ id="locationId-readonly"
+ value={locationName}
+ isReadOnly
+ className="text-muted-foreground"
+ />
+ </InputGroup>
+ <FormHelperText>{t`Set when the unit was created`}</FormHelperText>
+ </FormControl>
+ ) : (
+ <Location
+ isReadOnly={isEditing}
+ name="locationId"
+ label={t`Location`}
+ />
+ )}
<StorageUnitParentSelect
name="parentId"
label={t`Parent Storage Unit`}
- termId="storage-unit-parent"
+ // Phones: the helper text under the field explains it.
+ termId={isPhoneEdit ? undefined : "storage-unit-parent"}
locationId={locationId}
isOptional
helperText={t`Must be in the same location`}
@@ -139,7 +212,9 @@ const StorageUnitForm = ({
<WorkCenter
name="workCenterId"
label={t`Work Center`}
- termId="storage-unit-work-center"
+ termId={
+ isPhoneEdit ? undefined : "storage-unit-work-center"
+ }
locationId={locationId}
isOptional
helperText={t`Assigns this storage unit to a work center (lineside)`}
@@ -148,28 +223,18 @@ const StorageUnitForm = ({
</VStack>
</ModalDrawerBody>
<ModalDrawerFooter>
- <HStack>
- <Submit isDisabled={isDisabled}>
- <Trans>Save</Trans>
- </Submit>
- <Button size="md" variant="solid" onClick={onClose}>
- <Trans>Cancel</Trans>
- </Button>
- {isEditing && initialValues.id && (
- <PrintButton
- sourceDocument="StorageUnit"
- sourceDocumentId={initialValues.id}
- locationId={locationId || undefined}
- context="inventory"
- fileRoutes={{
- pdf: (id: string, opts?: { labelSize?: string }) =>
- path.to.file.storageUnitLabelsPdf(id, opts),
- zpl: (id: string, opts?: { labelSize?: string }) =>
- path.to.file.storageUnitLabelsZpl(id, opts)
- }}
- />
- )}
- </HStack>
+ {isPhoneEdit ? (
+ // Save is in the header; × and the overlay close the sheet.
+ <div className="w-full [&>button]:w-full">{printButton}</div>
+ ) : (
+ <HStack>
+ {saveButton}
+ <Button size="md" variant="solid" onClick={onClose}>
+ <Trans>Cancel</Trans>
+ </Button>
+ {printButton}
+ </HStack>
+ )}
</ModalDrawerFooter>
</ValidatedForm>
</ModalDrawerContent>
diff --git a/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx b/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
index bb865e882a..238a135ebf 100644
--- a/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
+++ b/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
@@ -29,6 +29,7 @@ import {
toast,
useDisclosure,
useThrottle,
+ useViewport,
VStack
} from "@carbon/react";
import { getItemById, getItemReadableId } from "@carbon/utils";
@@ -47,6 +48,7 @@ import {
LuGitPullRequestCreate,
LuGitPullRequestCreateArrow,
LuLock,
+ LuPackage,
LuRedoDot,
LuSquareFunction,
LuTruck
@@ -91,6 +93,7 @@ import {
SortableListItemPanel,
SortableListItemToggle
} from "~/components/SortableList";
+import { CompactEmpty } from "~/components/Table/components/Compact/CompactEmpty";
import { usePermissions, useUrlParams, useUser } from "~/hooks";
import type {
MethodItemType,
@@ -195,6 +198,7 @@ const BillOfMaterial = ({
revisionStatus,
releaseControl
});
+ const { isPhone } = useViewport();
const isReadOnly =
permissions.can("update", "parts") === false ||
makeMethod.status !== "Draft" ||
@@ -549,6 +553,25 @@ const BillOfMaterial = ({
<ReleaseLockAlert isLocked={isReleaseLocked} className="mb-4" />
)}
<SortableList
+ emptyState={
+ isPhone ? (
+ <CompactEmpty
+ className="py-10"
+ icon={<LuPackage />}
+ heading={<Trans>No materials yet</Trans>}
+ description={<Trans>Add the materials this item uses.</Trans>}
+ primaryAction={
+ <Button
+ variant="secondary"
+ isDisabled={isReadOnly}
+ onClick={onAddItem}
+ >
+ <Trans>Add Item</Trans>
+ </Button>
+ }
+ />
+ ) : undefined
+ }
isReadOnly={isReadOnly}
items={materials}
onReorder={onReorder}
diff --git a/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx b/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
index c0f91df766..e2a240a5b8 100644
--- a/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
+++ b/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
@@ -43,6 +43,7 @@ import {
useDebounce,
useDisclosure,
useThrottle,
+ useViewport,
VStack
} from "@carbon/react";
import { Editor } from "@carbon/react/Editor";
@@ -71,7 +72,8 @@ import {
LuMaximize2,
LuMinimize2,
LuSquareFunction,
- LuTriangleAlert
+ LuTriangleAlert,
+ LuWorkflow
} from "react-icons/lu";
import {
useFetcher,
@@ -128,6 +130,7 @@ import {
SortableListItemToggle
} from "~/components/SortableList";
import { StepLinkEditor } from "~/components/StepLinkEditor";
+import { CompactEmpty } from "~/components/Table/components/Compact/CompactEmpty";
import {
useCurrencyDecimals,
useImageUpload,
@@ -269,6 +272,7 @@ const BillOfProcess = ({
revisionStatus,
releaseControl
});
+ const { isPhone } = useViewport();
const isReadOnly =
permissions.can("update", "parts") === false ||
makeMethod.status !== "Draft" ||
@@ -891,6 +895,27 @@ const BillOfProcess = ({
<ReleaseLockAlert isLocked={isReleaseLocked} className="mb-4" />
)}
<SortableList
+ emptyState={
+ isPhone ? (
+ <CompactEmpty
+ className="py-10"
+ icon={<LuWorkflow />}
+ heading={<Trans>No operations yet</Trans>}
+ description={
+ <Trans>Add the operations that make this item.</Trans>
+ }
+ primaryAction={
+ <Button
+ variant="secondary"
+ isDisabled={isReadOnly || selectedItemId !== null}
+ onClick={onAddItem}
+ >
+ <Trans>Add Operation</Trans>
+ </Button>
+ }
+ />
+ ) : undefined
+ }
isReadOnly={isReadOnly}
items={items}
onReorder={onReorder}
diff --git a/apps/erp/app/modules/items/ui/Item/ItemManufacturingForm.tsx b/apps/erp/app/modules/items/ui/Item/ItemManufacturingForm.tsx
index 163a7f1993..ccc4cc9691 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemManufacturingForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemManufacturingForm.tsx
@@ -2,13 +2,14 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-import { ValidatedForm } from "@carbon/form";
+import { useFormState, ValidatedForm } from "@carbon/form";
import {
Card,
CardContent,
CardFooter,
CardHeader,
- CardTitle
+ CardTitle,
+ useViewport
} from "@carbon/react";
import { INPUT_FORMAT } from "@carbon/utils";
import { Trans, useLingui } from "@lingui/react/macro";
@@ -94,16 +95,32 @@ const ItemManufacturingForm = ({
</div>
</CardContent>
<CardFooter className="flex justify-between">
- <Submit
- withBlocker={false}
+ <ManufacturingSubmit
isDisabled={!permissions.can("update", "parts")}
- >
- <Trans>Save</Trans>
- </Submit>
+ />
</CardFooter>
</ValidatedForm>
</Card>
);
};
+/**
+ * The card's Save. Phones: full width, and disabled until a field in the
+ * card changes (precedent: DefaultDisabledSubmit).
+ */
+function ManufacturingSubmit({ isDisabled }: { isDisabled: boolean }) {
+ const { isPhone } = useViewport();
+ const { touchedFields } = useFormState();
+ const isTouched = Object.keys(touchedFields).length > 0;
+ return (
+ <Submit
+ withBlocker={false}
+ isDisabled={isDisabled || (isPhone && !isTouched)}
+ className="max-md:w-full"
+ >
+ <Trans>Save</Trans>
+ </Submit>
+ );
+}
+
export default ItemManufacturingForm;
diff --git a/apps/erp/app/modules/items/ui/Item/ItemNotes.tsx b/apps/erp/app/modules/items/ui/Item/ItemNotes.tsx
index 7e21ae9587..d64f652bd1 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemNotes.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemNotes.tsx
@@ -9,7 +9,7 @@ import {
CardContent,
CardHeader,
CardTitle,
- generateHTML,
+ RichTextView,
useDebounce
} from "@carbon/react";
import { Editor } from "@carbon/react/Editor";
@@ -74,11 +74,9 @@ const ItemNotes = ({
}}
/>
) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(notes as JSONContent)
- }}
+ <RichTextView
+ content={notes as JSONContent}
+ empty={<Trans>No notes</Trans>}
/>
)}
</CardContent>
diff --git a/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx b/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx
index 92d4b3f4d1..3b3933f0bb 100644
--- a/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx
+++ b/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx
@@ -59,6 +59,8 @@ import {
} from "react-icons/lu";
import { Link, useParams } from "react-router";
import { Hidden, Item, useConfigurableItems } from "~/components/Form";
+import { createPortalSlot } from "~/components/Layout/Mobile/slots";
+import { RecordAction } from "~/components/Layout/RecordHeader";
import { Confirm } from "~/components/Modals";
import { usePermissions, useUser } from "~/hooks";
import type { ItemType } from "~/modules/shared";
@@ -82,13 +84,23 @@ type MakeMethodToolsProps = {
type: ItemType;
makeMethods: MakeMethod[];
currentMethodId?: string;
+ /**
+ * Phones: show the version control where the page places
+ * `methodVersionSlot.Target` (above Bill of Process) instead of in the
+ * tools row.
+ */
+ versionInSlot?: boolean;
};
+/** Phones: where a page shows the method version control (see versionInSlot). */
+export const methodVersionSlot = createPortalSlot();
+
const MakeMethodTools = ({
itemId,
makeMethods,
type,
- currentMethodId
+ currentMethodId,
+ versionInSlot = false
}: MakeMethodToolsProps) => {
const permissions = usePermissions();
const { t } = useLingui();
@@ -230,165 +242,184 @@ const MakeMethodTools = ({
}
};
+ const versionMenu = (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="ghost" rightIcon={<LuChevronDown />}>
+ <div className="flex items-center gap-2">
+ <Badge variant="outline">V{activeMethod.version}</Badge>
+ <MakeMethodVersionStatus status={activeMethod.status} />
+ </div>
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ {makeMethods && makeMethods.length > 0 && (
+ <>
+ {makeMethods
+ .sort((a, b) => b.version - a.version)
+ .map((makeMethod) => {
+ const isCurrent = makeMethod.id === activeMethodId;
+
+ return (
+ <DropdownMenuSub key={makeMethod.id}>
+ <DropdownMenuSubTrigger>
+ <Link
+ to={getPathToMakeMethod(type, itemId, makeMethod.id)}
+ className="flex items-center justify-between gap-4"
+ >
+ <div className="flex items-center gap-2">
+ <LuCheck className={cn(!isCurrent && "opacity-0")} />
+ <span>Version {makeMethod.version}</span>
+ </div>
+ <MakeMethodVersionStatus
+ status={makeMethod.status}
+ isActive={
+ makeMethod.status === "Active" ||
+ makeMethods.length === 1
+ }
+ />
+ </Link>
+ </DropdownMenuSubTrigger>
+ <DropdownMenuPortal>
+ <DropdownMenuSubContent>
+ <ItemChangeNoticeLock
+ changeNotices={openChangeNotices}
+ isLocked={isChangeNoticeLocked}
+ >
+ <DropdownMenuItem
+ shortcut={MENU_ITEM_SHORTCUTS.duplicate}
+ disabled={isChangeNoticeLocked}
+ onClick={() => {
+ flushSync(() => {
+ setSelectedVersion(makeMethod);
+ });
+ newVersionModal.onOpen();
+ }}
+ >
+ <DropdownMenuIcon icon={<LuCopy />} />
+ Duplicate Version
+ </DropdownMenuItem>
+ </ItemChangeNoticeLock>
+
+ {/* <DropdownMenuItem
+ destructive
+ disabled={
+ makeMethod.status === "Active" ||
+ !permissions.can("delete", "parts")
+ }
+ >
+ <DropdownMenuIcon icon={<LuTrash />} />
+ Delete Version
+ </DropdownMenuItem> */}
+ <DropdownMenuSeparator />
+ <ItemChangeNoticeLock
+ changeNotices={openChangeNotices}
+ isLocked={isChangeNoticeLocked}
+ >
+ <DropdownMenuItem
+ disabled={
+ makeMethod.status === "Active" ||
+ isChangeNoticeLocked
+ }
+ onClick={() => {
+ flushSync(() => {
+ setSelectedVersion(makeMethod);
+ });
+ activeMethodModal.onOpen();
+ }}
+ >
+ <DropdownMenuIcon icon={<LuStar />} />
+ Set as Active Version
+ </DropdownMenuItem>
+ </ItemChangeNoticeLock>
+ </DropdownMenuSubContent>
+ </DropdownMenuPortal>
+ </DropdownMenuSub>
+ );
+ })}
+ <DropdownMenuSeparator />
+ {permissions.can("create", "production") && (
+ <ItemChangeNoticeLock
+ changeNotices={openChangeNotices}
+ isLocked={isChangeNoticeLocked}
+ >
+ <DropdownMenuItem
+ disabled={isChangeNoticeLocked}
+ onClick={newVersionModal.onOpen}
+ >
+ <DropdownMenuIcon icon={<LuCirclePlus />} />
+ New Version
+ </DropdownMenuItem>
+ </ItemChangeNoticeLock>
+ )}
+ {canCreateChangeNotice && (
+ <DropdownMenuItem onClick={changeNoticeModal.onOpen}>
+ <DropdownMenuIcon icon={<LuGitPullRequestArrow />} />
+ <Trans>New Change Notice</Trans>
+ </DropdownMenuItem>
+ )}
+ </>
+ )}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+
return (
<Fragment key={itemId}>
- <Menubar>
+ {versionInSlot ? (
+ <methodVersionSlot.Fill>{versionMenu}</methodVersionSlot.Fill>
+ ) : null}
+ <Menubar className={cn(versionInSlot && "max-md:hidden")}>
<HStack className="w-full justify-between">
<HStack spacing={0}>
- <MenubarItem
- isLoading={isGetMethodLoading}
- isDisabled={
- !permissions.can("update", "parts") ||
- isGetMethodLoading ||
- activeMethod.status !== "Draft" // Can only overwrite Draft versions
- }
- leftIcon={<LuGitBranch />}
- onClick={getMethodModal.onOpen}
- >
- <Trans>Get Method</Trans>
- </MenubarItem>
- <MenubarItem
- isDisabled={
- !permissions.can("update", "parts") || isSaveMethodLoading
- }
- isLoading={isSaveMethodLoading}
- leftIcon={<LuGitMerge />}
- onClick={saveMethodModal.onOpen}
- >
- <Trans>Save Method</Trans>
- </MenubarItem>
- {itemLink && (
- <MenubarItem leftIcon={<LuGitFork />} asChild>
- <PrefetchLink to={itemLink}>Item Master</PrefetchLink>
+ <RecordAction slot="overflow">
+ <MenubarItem
+ className="rounded-md"
+ isLoading={isGetMethodLoading}
+ isDisabled={
+ !permissions.can("update", "parts") ||
+ isGetMethodLoading ||
+ activeMethod.status !== "Draft" // Can only overwrite Draft versions
+ }
+ leftIcon={<LuGitBranch />}
+ onClick={getMethodModal.onOpen}
+ >
+ <Trans>Get Method</Trans>
</MenubarItem>
+ </RecordAction>
+ <RecordAction slot="overflow">
+ <MenubarItem
+ className="rounded-md"
+ isDisabled={
+ !permissions.can("update", "parts") || isSaveMethodLoading
+ }
+ isLoading={isSaveMethodLoading}
+ leftIcon={<LuGitMerge />}
+ onClick={saveMethodModal.onOpen}
+ >
+ <Trans>Save Method</Trans>
+ </MenubarItem>
+ </RecordAction>
+ {itemLink && (
+ <RecordAction slot="overflow">
+ <MenubarItem
+ className="rounded-md"
+ leftIcon={<LuGitFork />}
+ asChild
+ >
+ <PrefetchLink to={itemLink}>
+ <Trans>Item Master</Trans>
+ </PrefetchLink>
+ </MenubarItem>
+ </RecordAction>
)}
</HStack>
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="ghost" rightIcon={<LuChevronDown />}>
- <div className="flex items-center gap-2">
- <Badge variant="outline">V{activeMethod.version}</Badge>
- <MakeMethodVersionStatus status={activeMethod.status} />
- </div>
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- {makeMethods && makeMethods.length > 0 && (
- <>
- {makeMethods
- .sort((a, b) => b.version - a.version)
- .map((makeMethod) => {
- const isCurrent = makeMethod.id === activeMethodId;
-
- return (
- <DropdownMenuSub key={makeMethod.id}>
- <DropdownMenuSubTrigger>
- <Link
- to={getPathToMakeMethod(
- type,
- itemId,
- makeMethod.id
- )}
- className="flex items-center justify-between gap-4"
- >
- <div className="flex items-center gap-2">
- <LuCheck
- className={cn(!isCurrent && "opacity-0")}
- />
- <span>Version {makeMethod.version}</span>
- </div>
- <MakeMethodVersionStatus
- status={makeMethod.status}
- isActive={
- makeMethod.status === "Active" ||
- makeMethods.length === 1
- }
- />
- </Link>
- </DropdownMenuSubTrigger>
- <DropdownMenuPortal>
- <DropdownMenuSubContent>
- <ItemChangeNoticeLock
- changeNotices={openChangeNotices}
- isLocked={isChangeNoticeLocked}
- >
- <DropdownMenuItem
- shortcut={MENU_ITEM_SHORTCUTS.duplicate}
- disabled={isChangeNoticeLocked}
- onClick={() => {
- flushSync(() => {
- setSelectedVersion(makeMethod);
- });
- newVersionModal.onOpen();
- }}
- >
- <DropdownMenuIcon icon={<LuCopy />} />
- Duplicate Version
- </DropdownMenuItem>
- </ItemChangeNoticeLock>
-
- {/* <DropdownMenuItem
- destructive
- disabled={
- makeMethod.status === "Active" ||
- !permissions.can("delete", "parts")
- }
- >
- <DropdownMenuIcon icon={<LuTrash />} />
- Delete Version
- </DropdownMenuItem> */}
- <DropdownMenuSeparator />
- <ItemChangeNoticeLock
- changeNotices={openChangeNotices}
- isLocked={isChangeNoticeLocked}
- >
- <DropdownMenuItem
- disabled={
- makeMethod.status === "Active" ||
- isChangeNoticeLocked
- }
- onClick={() => {
- flushSync(() => {
- setSelectedVersion(makeMethod);
- });
- activeMethodModal.onOpen();
- }}
- >
- <DropdownMenuIcon icon={<LuStar />} />
- Set as Active Version
- </DropdownMenuItem>
- </ItemChangeNoticeLock>
- </DropdownMenuSubContent>
- </DropdownMenuPortal>
- </DropdownMenuSub>
- );
- })}
- <DropdownMenuSeparator />
- {permissions.can("create", "production") && (
- <ItemChangeNoticeLock
- changeNotices={openChangeNotices}
- isLocked={isChangeNoticeLocked}
- >
- <DropdownMenuItem
- disabled={isChangeNoticeLocked}
- onClick={newVersionModal.onOpen}
- >
- <DropdownMenuIcon icon={<LuCirclePlus />} />
- New Version
- </DropdownMenuItem>
- </ItemChangeNoticeLock>
- )}
- {canCreateChangeNotice && (
- <DropdownMenuItem onClick={changeNoticeModal.onOpen}>
- <DropdownMenuIcon icon={<LuGitPullRequestArrow />} />
- <Trans>New Change Notice</Trans>
- </DropdownMenuItem>
- )}
- </>
- )}
- </DropdownMenuContent>
- </DropdownMenu>
+ {versionInSlot ? (
+ <div className="max-md:hidden">{versionMenu}</div>
+ ) : (
+ versionMenu
+ )}
</HStack>
</Menubar>
diff --git a/apps/erp/app/modules/items/ui/Parts/PartHeader.tsx b/apps/erp/app/modules/items/ui/Parts/PartHeader.tsx
index edb41a33ab..cfe6559c89 100644
--- a/apps/erp/app/modules/items/ui/Parts/PartHeader.tsx
+++ b/apps/erp/app/modules/items/ui/Parts/PartHeader.tsx
@@ -95,6 +95,7 @@ const PartHeader = () => {
copyValue={routeData?.partSummary?.readableIdWithRevision ?? ""}
menu={menuItems}
status={statusPill}
+ subtitle={routeData?.partSummary?.name}
aside={<DetailsTopbar links={links} />}
/>
{deleteModal.isOpen && (
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx b/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
index 8e1951861d..b4ec5c2ad9 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
@@ -28,6 +28,7 @@ import {
toast,
useDebounce,
useDisclosure,
+ useViewport,
VStack
} from "@carbon/react";
import { getItemReadableId, INPUT_FORMAT } from "@carbon/utils";
@@ -44,6 +45,7 @@ import {
LuGitPullRequest,
LuGitPullRequestCreate,
LuGitPullRequestCreateArrow,
+ LuPackage,
LuRedoDot
} from "react-icons/lu";
import { Link, useFetcher, useFetchers, useParams } from "react-router";
@@ -77,6 +79,7 @@ import {
SortableListItemPanel,
SortableListItemToggle
} from "~/components/SortableList";
+import { CompactEmpty } from "~/components/Table/components/Compact/CompactEmpty";
import {
useCurrencyDecimals,
usePermissions,
@@ -307,6 +310,7 @@ const JobBillOfMaterial = ({
const permissions = usePermissions();
const addItemButtonRef = useRef<HTMLButtonElement>(null);
+ const { isPhone } = useViewport();
const [selectedItemId, setSelectedItemId] = useState<string | null>(null);
const [temporaryItems, setTemporaryItems] = useState<TemporaryItems>({});
@@ -583,6 +587,27 @@ const JobBillOfMaterial = ({
onToggleItem={onToggleItem}
onRemoveItem={onRemoveItem}
renderItem={renderListItem}
+ emptyState={
+ isPhone ? (
+ <CompactEmpty
+ className="py-10"
+ icon={<LuPackage />}
+ heading={<Trans>No materials yet</Trans>}
+ description={<Trans>Add the materials this job uses.</Trans>}
+ primaryAction={
+ <Button
+ variant="secondary"
+ isDisabled={
+ isDisabled || !permissions.can("update", "production")
+ }
+ onClick={onAddItem}
+ >
+ <Trans>Add Item</Trans>
+ </Button>
+ }
+ />
+ ) : undefined
+ }
/>
</CardContent>
</Card>
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx b/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
index d658ba360d..4f0b20fe76 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
@@ -53,6 +53,7 @@ import {
useDebounce,
useDisclosure,
useMount,
+ useViewport,
VStack
} from "@carbon/react";
import { Editor } from "@carbon/react/Editor";
@@ -87,7 +88,8 @@ import {
LuRefreshCcw,
LuSend,
LuShieldX,
- LuTriangleAlert
+ LuTriangleAlert,
+ LuWorkflow
} from "react-icons/lu";
import {
Link,
@@ -141,6 +143,7 @@ import {
SortableListItemToggle
} from "~/components/SortableList";
import { StepLinkEditor } from "~/components/StepLinkEditor";
+import { CompactEmpty } from "~/components/Table/components/Compact/CompactEmpty";
import {
useCurrencyDecimals,
useImageUpload,
@@ -740,6 +743,7 @@ const JobBillOfProcess = ({
const [isLoading, setIsLoading] = useState(false);
const [hasMore, setHasMore] = useState(true);
const addOperationButtonRef = useRef<HTMLButtonElement>(null);
+ const { isPhone } = useViewport();
useChangedRows<Database["public"]["Tables"]["productionEvent"]["Row"]>({
companyId,
@@ -1076,6 +1080,31 @@ const JobBillOfProcess = ({
onToggleItem={onToggleItem}
onRemoveItem={onRemoveItem}
renderItem={renderListItem}
+ emptyState={
+ isPhone ? (
+ <CompactEmpty
+ className="py-10"
+ icon={<LuWorkflow />}
+ heading={<Trans>No operations yet</Trans>}
+ description={
+ <Trans>Add the operations that make this item.</Trans>
+ }
+ primaryAction={
+ <Button
+ variant="secondary"
+ isDisabled={
+ !permissions.can("update", "production") ||
+ selectedItemId !== null ||
+ isDisabled
+ }
+ onClick={onAddItem}
+ >
+ <Trans>Add Operation</Trans>
+ </Button>
+ }
+ />
+ ) : undefined
+ }
/>
</CardContent>
</Card>
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobEstimatesVsActuals.tsx b/apps/erp/app/modules/production/ui/Jobs/JobEstimatesVsActuals.tsx
index 7e528bd7f3..8631e82c44 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobEstimatesVsActuals.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobEstimatesVsActuals.tsx
@@ -310,14 +310,14 @@ const JobEstimatesVsActuals = ({
return (
<Tabs defaultValue="processes" className="w-full">
<Card>
- <HStack className="justify-between items-start">
+ <HStack className="justify-between items-start max-md:flex-col max-md:items-stretch max-md:space-x-0">
<CardHeader>
<CardTitle>
<Trans>Estimates vs Actual</Trans>
</CardTitle>
</CardHeader>
<CardAction className="flex flex-col gap-2">
- <TabsList className="grid grid-cols-2">
+ <TabsList className="grid grid-cols-2 max-md:w-full">
<TabsTrigger value="processes">
<Trans>Processes</Trans>
</TabsTrigger>
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx b/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx
index e8e1b8b0bb..f4407a4481 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx
@@ -31,6 +31,7 @@ import {
Status,
useDisclosure,
useMount,
+ useViewport,
VStack
} from "@carbon/react";
import { formatDate } from "@carbon/utils";
@@ -119,6 +120,7 @@ const JobHeader = () => {
}
};
const permissions = usePermissions();
+ const { isPhone } = useViewport();
const { jobId } = useParams();
if (!jobId) throw new Error("jobId not found");
@@ -300,6 +302,16 @@ const JobHeader = () => {
</>
);
+ // Phones: the hero line under the app bar, "item · Qty N".
+ const jobQuantity = routeData?.job?.quantity;
+ const heroSubtitle =
+ [
+ routeData?.job?.itemReadableIdWithRevision,
+ jobQuantity != null ? t`Qty ${jobQuantity}` : null
+ ]
+ .filter(Boolean)
+ .join(" · ") || undefined;
+
return (
<>
<RecordHeader
@@ -308,6 +320,7 @@ const JobHeader = () => {
copyValue={routeData?.job?.jobId ?? ""}
menu={menuItems}
status={statusBadges}
+ subtitle={heroSubtitle}
onToggleExplorer={toggleExplorer}
onToggleProperties={toggleProperties}
actions={
@@ -391,30 +404,34 @@ const JobHeader = () => {
</RecordAction>
{status !== "Paused" ? (
- <RecordAction slot="secondary">
- <statusFetcher.Form
- method="post"
- action={path.to.jobStatus(jobId)}
- >
- <input type="hidden" name="status" value="Paused" />
- <Button
- isLoading={
- statusFetcher.state !== "idle" &&
- statusFetcher.formData?.get("status") === "Paused"
- }
- isDisabled={
- !["Ready", "In Progress"].includes(status ?? "") ||
- statusFetcher.state !== "idle" ||
- !permissions.can("update", "production")
- }
- leftIcon={<LuCirclePause />}
- type="submit"
- variant="secondary"
+ // Phones: Pause shows only while it can act (Ready or In Progress).
+ isPhone &&
+ !["Ready", "In Progress"].includes(status ?? "") ? null : (
+ <RecordAction slot="secondary">
+ <statusFetcher.Form
+ method="post"
+ action={path.to.jobStatus(jobId)}
>
- <Trans>Pause</Trans>
- </Button>
- </statusFetcher.Form>
- </RecordAction>
+ <input type="hidden" name="status" value="Paused" />
+ <Button
+ isLoading={
+ statusFetcher.state !== "idle" &&
+ statusFetcher.formData?.get("status") === "Paused"
+ }
+ isDisabled={
+ !["Ready", "In Progress"].includes(status ?? "") ||
+ statusFetcher.state !== "idle" ||
+ !permissions.can("update", "production")
+ }
+ leftIcon={<LuCirclePause />}
+ type="submit"
+ variant="secondary"
+ >
+ <Trans>Pause</Trans>
+ </Button>
+ </statusFetcher.Form>
+ </RecordAction>
+ )
) : (
<RecordAction slot="secondary">
<statusFetcher.Form
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx b/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx
index 00181af12d..43497e32f6 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx
@@ -59,6 +59,7 @@ import {
Submit,
useConfigurableItems
} from "~/components/Form";
+import { RecordAction } from "~/components/Layout/RecordHeader";
import type { Tree } from "~/components/TreeView";
import { usePermissions, useRouteData, useUser } from "~/hooks";
import {
@@ -306,28 +307,45 @@ const JobMakeMethodTools = ({ makeMethod }: { makeMethod?: JobMakeMethod }) => {
}
});
+ const canUseTools =
+ permissions.can("update", "production") && (isJobMethod || isJobMakeMethod);
+ const hasPrintLabel = Boolean(
+ makeMethod &&
+ (makeMethod.requiresSerialTracking || makeMethod.requiresBatchTracking)
+ );
+ const openGetMethod = () => {
+ // The modal's Item picker opens empty — clear any versions loaded on a
+ // previous open so the two can't disagree.
+ setSourceMakeMethods([]);
+ setSelectedSourceVersion(null);
+ getMethodModal.onOpen();
+ };
+ const openConfigure = () => {
+ setSelectedConfigureItemId(routeData?.job?.itemId ?? null);
+ configureSelectModal.onOpen();
+ };
+ const canConfigure = configurableItemIds.length > 0 && isJobMethod;
+
return (
<Fragment key={jobId}>
- {permissions.can("update", "production") &&
- (isJobMethod || isJobMakeMethod) && (
- <Menubar>
- <HStack className="w-full justify-start">
- <HStack spacing={0}>
+ {canUseTools && (
+ <Menubar className={cn(!hasPrintLabel && "max-md:hidden")}>
+ <HStack className="w-full justify-start">
+ <HStack spacing={0}>
+ <RecordAction slot="overflow">
<MenubarItem
+ className="rounded-md"
isLoading={isGetMethodLoading}
isDisabled={isDisabled || isGetMethodLoading}
leftIcon={<LuGitBranch />}
- onClick={() => {
- // The modal's Item picker opens empty — clear any versions
- // loaded on a previous open so the two can't disagree.
- setSourceMakeMethods([]);
- setSelectedSourceVersion(null);
- getMethodModal.onOpen();
- }}
+ onClick={openGetMethod}
>
<Trans>Get Method</Trans>
</MenubarItem>
+ </RecordAction>
+ <RecordAction slot="overflow">
<MenubarItem
+ className="rounded-md"
isDisabled={
!permissions.can("update", "parts") || isSaveMethodLoading
}
@@ -337,9 +355,12 @@ const JobMakeMethodTools = ({ makeMethod }: { makeMethod?: JobMakeMethod }) => {
>
<Trans>Save Method</Trans>
</MenubarItem>
+ </RecordAction>
- {configurableItemIds.length > 0 && isJobMethod && (
+ {canConfigure && (
+ <RecordAction slot="overflow">
<MenubarItem
+ className="rounded-md"
leftIcon={<LuSettings />}
isDisabled={
isDisabled ||
@@ -347,42 +368,42 @@ const JobMakeMethodTools = ({ makeMethod }: { makeMethod?: JobMakeMethod }) => {
isConfigureLoading
}
isLoading={isConfigureLoading}
- onClick={() => {
- setSelectedConfigureItemId(
- routeData?.job?.itemId ?? null
- );
- configureSelectModal.onOpen();
- }}
+ onClick={openConfigure}
>
<Trans>Configure</Trans>
</MenubarItem>
- )}
- {itemLink && (
- <MenubarItem leftIcon={<LuGitFork />} asChild>
+ </RecordAction>
+ )}
+ {itemLink && (
+ <RecordAction slot="overflow">
+ <MenubarItem
+ className="rounded-md"
+ leftIcon={<LuGitFork />}
+ asChild
+ >
<PrefetchLink to={itemLink}>
<Trans>Item Master</Trans>
</PrefetchLink>
</MenubarItem>
- )}
- {makeMethod &&
- (makeMethod.requiresSerialTracking ||
- makeMethod.requiresBatchTracking) && (
- <PrintButton
- sourceDocument="Operation"
- sourceDocumentId={makeMethod.id}
- locationId={routeData?.job?.locationId ?? undefined}
- context="workCenter"
- variant="ghost"
- fileRoutes={{
- pdf: path.to.file.operationLabelsPdf,
- zpl: path.to.file.operationLabelsZpl
- }}
- />
- )}
- </HStack>
+ </RecordAction>
+ )}
+ {hasPrintLabel && makeMethod && (
+ <PrintButton
+ sourceDocument="Operation"
+ sourceDocumentId={makeMethod.id}
+ locationId={routeData?.job?.locationId ?? undefined}
+ context="workCenter"
+ variant="ghost"
+ fileRoutes={{
+ pdf: path.to.file.operationLabelsPdf,
+ zpl: path.to.file.operationLabelsZpl
+ }}
+ />
+ )}
</HStack>
- </Menubar>
- )}
+ </HStack>
+ </Menubar>
+ )}
<Modal
open={getMethodModal.isOpen}
onOpenChange={(open) => {
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobNotes.tsx b/apps/erp/app/modules/production/ui/Jobs/JobNotes.tsx
index d3e0ce264c..f2b56aaeec 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobNotes.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobNotes.tsx
@@ -9,7 +9,7 @@ import {
CardContent,
CardHeader,
CardTitle,
- generateHTML,
+ RichTextView,
useDebounce
} from "@carbon/react";
import { Editor } from "@carbon/react/Editor";
@@ -76,11 +76,9 @@ const JobNotes = ({
}}
/>
) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(notes as JSONContent)
- }}
+ <RichTextView
+ content={notes as JSONContent}
+ empty={<Trans>No notes</Trans>}
/>
)}
</CardContent>
diff --git a/apps/erp/app/modules/production/ui/Planning/ProductionPlanningTable.tsx b/apps/erp/app/modules/production/ui/Planning/ProductionPlanningTable.tsx
index df045b43ae..ba57e4a552 100644
--- a/apps/erp/app/modules/production/ui/Planning/ProductionPlanningTable.tsx
+++ b/apps/erp/app/modules/production/ui/Planning/ProductionPlanningTable.tsx
@@ -435,6 +435,8 @@ const ProductionPlanningTable = ({
header: t`On Hand`,
cell: ({ row }) => numberFormatter.format(row.original.quantityOnHand),
meta: {
+ mobile: "P3",
+ mobileLabel: true,
icon: <LuBlocks />,
renderTotal: true
}
@@ -451,8 +453,8 @@ const ProductionPlanningTable = ({
);
},
meta: {
- mobile: "P2",
- mobileLabel: true,
+ // Phones: the row's "Make N" button already shows this quantity.
+ mobile: "P4",
icon: <LuCirclePlay />
}
},
@@ -509,18 +511,23 @@ const ProductionPlanningTable = ({
}}
>
{isBlocked ? (
- "Blocked"
+ <Trans>Blocked</Trans>
) : hasOrders ? (
<HStack>
<PulsingDot />
- <span>Make {orderQuantity}</span>
+ <span>
+ <Trans>Make {orderQuantity}</Trans>
+ </span>
</HStack>
) : (
- "Make"
+ <Trans>Make</Trans>
)}
</Button>
</div>
);
+ },
+ meta: {
+ mobile: "action"
}
}
];
@@ -584,7 +591,11 @@ const ProductionPlanningTable = ({
window.location.href = getLocationPath(selected);
}}
/>
- <mrpFetcher.Form method="post" action={path.to.api.mrp(locationId)}>
+ <mrpFetcher.Form
+ method="post"
+ action={path.to.api.mrp(locationId)}
+ className="max-md:hidden"
+ >
<Tooltip>
<TooltipTrigger asChild>
<Button
@@ -605,8 +616,27 @@ const ProductionPlanningTable = ({
</TooltipContent>
</Tooltip>
</mrpFetcher.Form>
+ <p className="basis-full text-xs text-muted-foreground md:hidden">
+ <Trans>
+ MRP runs every 3 hours. To run it now, use ⋯ › Recalculate.
+ </Trans>
+ </p>
</div>
}
+ mobileMenuItems={
+ <DropdownMenuItem
+ disabled={mrpFetcher.state !== "idle"}
+ onSelect={() =>
+ mrpFetcher.submit(
+ {},
+ { method: "post", action: path.to.api.mrp(locationId) }
+ )
+ }
+ >
+ <DropdownMenuIcon icon={<LuCirclePlay />} />
+ <Trans>Recalculate</Trans>
+ </DropdownMenuItem>
+ }
renderActions={renderActions}
title={t`Material Planning`}
table="production-planning"
diff --git a/apps/erp/app/modules/purchasing/ui/Planning/PurchasingPlanningTable.tsx b/apps/erp/app/modules/purchasing/ui/Planning/PurchasingPlanningTable.tsx
index 4bfc7692b3..c885650c92 100644
--- a/apps/erp/app/modules/purchasing/ui/Planning/PurchasingPlanningTable.tsx
+++ b/apps/erp/app/modules/purchasing/ui/Planning/PurchasingPlanningTable.tsx
@@ -442,9 +442,23 @@ const PlanningTable = memo(
header: t`Supplier`,
cell: ({ row }) => {
const supplierId = suppliersMap[row.original.id];
- if (!supplierId) return <Status color="red">No Supplier</Status>;
+ const onHand = numberFormatter.format(row.original.quantityOnHand);
- return <SupplierAvatar supplierId={supplierId} />;
+ // Phones: on hand follows the supplier on the row's second line.
+ return (
+ <div className="contents max-md:flex max-md:min-w-0 max-md:items-center max-md:gap-1.5">
+ {supplierId ? (
+ <SupplierAvatar supplierId={supplierId} />
+ ) : (
+ <Status color="red">
+ <Trans>No Supplier</Trans>
+ </Status>
+ )}
+ <span className="shrink-0 md:hidden">
+ · <Trans>{onHand} on hand</Trans>
+ </span>
+ </div>
+ );
},
meta: {
mobile: "P3",
@@ -528,7 +542,8 @@ const PlanningTable = memo(
);
},
meta: {
- mobile: "P2",
+ // Phones: the row's "Order N" button already shows this quantity.
+ mobile: "P4",
icon: <LuCirclePlay />
}
},
@@ -585,18 +600,23 @@ const PlanningTable = memo(
}}
>
{isBlocked ? (
- "Blocked"
+ <Trans>Blocked</Trans>
) : hasOrders ? (
<HStack>
<PulsingDot />
- <span>Order {orderQuantity}</span>
+ <span>
+ <Trans>Order {orderQuantity}</Trans>
+ </span>
</HStack>
) : (
- "Order"
+ <Trans>Order</Trans>
)}
</Button>
</div>
);
+ },
+ meta: {
+ mobile: "action"
}
}
];
@@ -663,6 +683,7 @@ const PlanningTable = memo(
<mrpFetcher.Form
method="post"
action={path.to.api.mrp(locationId)}
+ className="max-md:hidden"
>
<Tooltip>
<TooltipTrigger asChild>
@@ -677,13 +698,34 @@ const PlanningTable = memo(
</Button>
</TooltipTrigger>
<TooltipContent>
- MRP runs automatically every 3 hours, but you can run it
- manually here.
+ <Trans>
+ MRP runs automatically every 3 hours, but you can run it
+ manually here.
+ </Trans>
</TooltipContent>
</Tooltip>
</mrpFetcher.Form>
+ <p className="basis-full text-xs text-muted-foreground md:hidden">
+ <Trans>
+ MRP runs every 3 hours. To run it now, use ⋯ › Recalculate.
+ </Trans>
+ </p>
</div>
}
+ mobileMenuItems={
+ <DropdownMenuItem
+ disabled={mrpFetcher.state !== "idle"}
+ onSelect={() =>
+ mrpFetcher.submit(
+ {},
+ { method: "post", action: path.to.api.mrp(locationId) }
+ )
+ }
+ >
+ <DropdownMenuIcon icon={<LuCirclePlay />} />
+ <Trans>Recalculate</Trans>
+ </DropdownMenuItem>
+ }
renderActions={renderActions}
title={t`Material Planning`}
table="planning"
diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx
index e451f9696b..7448f3fb2a 100644
--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx
+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx
@@ -113,7 +113,7 @@ const PurchaseOrderHeader = () => {
canReopen: boolean;
canDelete: boolean;
defaultCc: string[];
- supplier: { status: string | null } | null;
+ supplier: { status: string | null; name: string | null } | null;
resolvedAttachments: Promise<ResolvedAttachmentItem[]>;
}>(path.to.purchaseOrder(orderId));
const resolvedAttachments = useResolved(
@@ -200,6 +200,10 @@ const PurchaseOrderHeader = () => {
[routeData?.lines]
);
+ const isMarkAsPlannedDisabled =
+ !["Draft"].includes(routeData?.purchaseOrder?.status ?? "") ||
+ routeData?.lines.length === 0 ||
+ !isSupplierApproved;
const markAsPlanned = () => {
statusFetcher.submit(
{ status: "Planned" },
@@ -301,23 +305,25 @@ const PurchaseOrderHeader = () => {
)}
</>
);
- // The ID with its revision; phones show it under the app bar title,
- // which names the record without the revision.
+ // The ID with its revision (desktop title).
const titleNode = (
<span className="flex items-center gap-0">
<span>{routeData?.purchaseOrder?.purchaseOrderId}</span>
<RevisionSuffix revisionId={routeData?.purchaseOrder?.revisionId} />
</span>
);
+ // Phones: the supplier under the hero, then the revision the app bar
+ // title (the ID alone) does not show.
+ const revisionId = routeData?.purchaseOrder?.revisionId ?? 0;
+ const heroSubtitle =
+ [routeData?.supplier?.name, revisionId > 0 ? t`Rev ${revisionId}` : null]
+ .filter(Boolean)
+ .join(" · ") || undefined;
return (
<>
<RecordHeader
title={titleNode}
- subtitle={
- (routeData?.purchaseOrder?.revisionId ?? 0) > 0
- ? titleNode
- : undefined
- }
+ subtitle={heroSubtitle}
titleTo={path.to.purchaseOrderDetails(orderId)}
copyValue={getPurchaseOrderDisplayId(routeData?.purchaseOrder)}
menu={menuItems}
@@ -326,7 +332,7 @@ const PurchaseOrderHeader = () => {
onToggleProperties={toggleProperties}
actions={
<>
- <RecordAction slot="overflow">
+ <RecordAction slot="icon">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
@@ -371,12 +377,7 @@ const PurchaseOrderHeader = () => {
label: t`Mark as Planned`,
icon: <LuCheckCheck />,
onClick: markAsPlanned,
- disabled:
- !["Draft"].includes(
- routeData?.purchaseOrder?.status ?? ""
- ) ||
- routeData?.lines.length === 0 ||
- !isSupplierApproved
+ disabled: isMarkAsPlannedDisabled
}
]}
>
diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSummary.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSummary.tsx
index 0b33a4bfc4..e051fd4e7e 100644
--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSummary.tsx
+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSummary.tsx
@@ -10,6 +10,7 @@ import {
CardDescription,
CardHeader,
CardTitle,
+ cn,
Heading,
HStack,
Table,
@@ -17,10 +18,11 @@ import {
Td,
Tr,
TruncatedTooltipText,
+ useViewport,
VStack
} from "@carbon/react";
import { getItemReadableId } from "@carbon/utils";
-import { Trans } from "@lingui/react/macro";
+import { Trans, useLingui } from "@lingui/react/macro";
import { useLocale } from "@react-aria/i18n";
import { motion } from "motion/react";
import { useState } from "react";
@@ -34,6 +36,8 @@ import {
} from "~/components";
import { useAccounts } from "~/components/Form/Account";
import { useUnitOfMeasure } from "~/components/Form/UnitOfMeasure";
+import { useShowRecordPanel } from "~/components/Layout/Panels";
+import { SummaryLineRow } from "~/components/SummaryLineRow";
import {
useCurrencyFormatter,
usePercentFormatter,
@@ -65,6 +69,9 @@ const LineItems = ({
lines: PurchaseOrderLine[];
shouldConvertCurrency: boolean;
}) => {
+ const { t } = useLingui();
+ const { isPhone } = useViewport();
+ const showRecordPanel = useShowRecordPanel();
const [items] = useItems();
const accounts = useAccounts();
const { orderId } = useParams();
@@ -80,9 +87,20 @@ const LineItems = ({
);
};
+ // Phones: the first lines as rows that open the line page; the Lines tab
+ // lists them all.
+ const phoneLineLimit = 3;
+ const shownLines = isPhone ? lines.slice(0, phoneLineLimit) : lines;
+
return (
- <VStack spacing={8} className="w-full overflow-hidden">
- {lines.map((line) => {
+ <VStack
+ spacing={8}
+ className={cn(
+ "w-full overflow-hidden",
+ isPhone && "space-y-0 divide-y divide-border"
+ )}
+ >
+ {shownLines.map((line) => {
if (!line.id) return null;
const isGlAccount = line.purchaseOrderLineType === "G/L Account";
@@ -111,6 +129,29 @@ const LineItems = ({
supplierLineTotal +
(line.supplierTaxAmount ?? 0) +
(line.supplierShippingCost ?? 0);
+ const unitOfMeasureLabel = unitOfMeasures.find(
+ (uom) => uom.value === line.purchaseUnitOfMeasureCode
+ )?.label;
+
+ // Phones: one row that opens the line page (its Edit link, the
+ // badges and the breakdown stay on desktop).
+ if (isPhone) {
+ return (
+ <SummaryLineRow
+ key={line.id}
+ to={path.to.purchaseOrderLine(orderId, line.id)}
+ title={itemReadableId}
+ value={formatter.format(total)}
+ description={lineDescription}
+ meta={
+ <>
+ {line.purchaseQuantity} ×{" "}
+ {formatter.format(line.unitPrice ?? 0)} {unitOfMeasureLabel}
+ </>
+ }
+ />
+ );
+ }
return (
<motion.div
@@ -409,6 +450,17 @@ const LineItems = ({
</motion.div>
);
})}
+ {isPhone && lines.length > phoneLineLimit ? (
+ <div className="w-full pt-3">
+ <Button
+ variant="secondary"
+ className="w-full"
+ onClick={() => showRecordPanel("explorer")}
+ >
+ {t`See all ${lines.length}`}
+ </Button>
+ </div>
+ ) : null}
</VStack>
);
};
@@ -487,8 +539,8 @@ const PurchaseOrderSummary = ({
return (
<Card>
<CardHeader>
- <HStack className="justify-between items-center">
- <div className="flex flex-col gap-1">
+ <HStack className="justify-between items-center max-md:min-w-0">
+ <div className="flex flex-col gap-1 max-md:hidden">
<CardTitle className="flex items-center gap-0">
<span>{routeData?.purchaseOrder.purchaseOrderId}</span>
<RevisionSuffix
@@ -499,7 +551,7 @@ const PurchaseOrderSummary = ({
<Trans>Purchase Order</Trans>
</CardDescription>
</div>
- <div className="flex flex-col gap-1 items-end">
+ <div className="flex flex-col gap-1 items-end max-md:w-full max-md:min-w-0 max-md:items-start max-md:[&>*]:max-w-full max-md:[&_span]:truncate">
<SupplierAvatar
supplierId={routeData?.purchaseOrder.supplierId ?? null}
/>
diff --git a/apps/erp/app/modules/purchasing/ui/SupplierInteraction/SupplierInteractionDocuments.tsx b/apps/erp/app/modules/purchasing/ui/SupplierInteraction/SupplierInteractionDocuments.tsx
index aab0eec4b4..7c6a56b5b3 100644
--- a/apps/erp/app/modules/purchasing/ui/SupplierInteraction/SupplierInteractionDocuments.tsx
+++ b/apps/erp/app/modules/purchasing/ui/SupplierInteraction/SupplierInteractionDocuments.tsx
@@ -11,6 +11,7 @@ import {
CardContent,
CardHeader,
CardTitle,
+ cn,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
@@ -85,7 +86,7 @@ const SupplierInteractionDocuments = ({
<Trans>Files</Trans>
</CardTitle>
</CardHeader>
- <CardAction>
+ <CardAction className="max-md:hidden">
{!isReadOnly && (
<SupplierInteractionDocumentForm
interactionId={interactionId}
@@ -97,7 +98,7 @@ const SupplierInteractionDocuments = ({
</HStack>
<CardContent>
<Table>
- <Thead>
+ <Thead className={cn(attachments.length === 0 && "max-md:hidden")}>
<Tr>
<Th>Name</Th>
<Th>Size</Th>
diff --git a/apps/erp/app/modules/purchasing/ui/SupplierInteraction/SupplierInteractionLineNotes.tsx b/apps/erp/app/modules/purchasing/ui/SupplierInteraction/SupplierInteractionLineNotes.tsx
index cdbacdd138..d049888bae 100644
--- a/apps/erp/app/modules/purchasing/ui/SupplierInteraction/SupplierInteractionLineNotes.tsx
+++ b/apps/erp/app/modules/purchasing/ui/SupplierInteraction/SupplierInteractionLineNotes.tsx
@@ -11,8 +11,8 @@ import {
CardDescription,
CardHeader,
CardTitle,
- generateHTML,
HStack,
+ RichTextView,
Tabs,
TabsContent,
TabsList,
@@ -134,11 +134,9 @@ const SupplierInteractionLineNotes = ({
}}
/>
) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(internalNotes as JSONContent)
- }}
+ <RichTextView
+ content={internalNotes as JSONContent}
+ empty={<Trans>No internal notes</Trans>}
/>
)}
</TabsContent>
@@ -158,11 +156,9 @@ const SupplierInteractionLineNotes = ({
}}
/>
) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(externalNotes as JSONContent)
- }}
+ <RichTextView
+ content={externalNotes as JSONContent}
+ empty={<Trans>No external notes</Trans>}
/>
)}
</TabsContent>
diff --git a/apps/erp/app/modules/purchasing/ui/SupplierInteraction/SupplierInteractionNotes.tsx b/apps/erp/app/modules/purchasing/ui/SupplierInteraction/SupplierInteractionNotes.tsx
index c3a6cf2bd0..902cc8227a 100644
--- a/apps/erp/app/modules/purchasing/ui/SupplierInteraction/SupplierInteractionNotes.tsx
+++ b/apps/erp/app/modules/purchasing/ui/SupplierInteraction/SupplierInteractionNotes.tsx
@@ -10,8 +10,8 @@ import {
CardContent,
CardHeader,
CardTitle,
- generateHTML,
HStack,
+ RichTextView,
Tabs,
TabsContent,
TabsList,
@@ -123,11 +123,9 @@ const SupplierInteractionNotes = ({
}}
/>
) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(internalNotes as JSONContent)
- }}
+ <RichTextView
+ content={internalNotes as JSONContent}
+ empty={<Trans>No internal notes</Trans>}
/>
)}
</TabsContent>
@@ -143,11 +141,9 @@ const SupplierInteractionNotes = ({
}}
/>
) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(externalNotes as JSONContent)
- }}
+ <RichTextView
+ content={externalNotes as JSONContent}
+ empty={<Trans>No external notes</Trans>}
/>
)}
</TabsContent>
diff --git a/apps/erp/app/modules/quality/ui/Issue/IssueHeader.tsx b/apps/erp/app/modules/quality/ui/Issue/IssueHeader.tsx
index 1b1ef39f30..45553badfe 100644
--- a/apps/erp/app/modules/quality/ui/Issue/IssueHeader.tsx
+++ b/apps/erp/app/modules/quality/ui/Issue/IssueHeader.tsx
@@ -104,6 +104,7 @@ const IssueHeader = () => {
copyValue={routeData?.nonConformance?.nonConformanceId ?? ""}
menu={menuItems}
status={statusBadge}
+ subtitle={routeData?.nonConformance?.name}
actions={
<>
<RecordAction slot="overflow">
diff --git a/apps/erp/app/modules/quality/ui/Issue/ReviewersList.tsx b/apps/erp/app/modules/quality/ui/Issue/ReviewersList.tsx
index ee5056ce36..5ce5ba42cf 100644
--- a/apps/erp/app/modules/quality/ui/Issue/ReviewersList.tsx
+++ b/apps/erp/app/modules/quality/ui/Issue/ReviewersList.tsx
@@ -7,6 +7,7 @@ import { useAction } from "@carbon/query";
import {
Button,
Card,
+ CardAction,
CardContent,
CardHeader,
CardTitle,
@@ -20,6 +21,7 @@ import {
ModalOverlay,
ModalTitle,
useDisclosure,
+ useViewport,
VStack
} from "@carbon/react";
import { Trans, useLingui } from "@lingui/react/macro";
@@ -42,6 +44,7 @@ export function ReviewersList({
isDisabled: boolean;
}) {
const disclosure = useDisclosure();
+ const { isPhone } = useViewport();
const { t } = useLingui();
const fetcher = useAction<typeof reviewAction>({
@@ -54,7 +57,28 @@ export function ReviewersList({
});
const submitted = useRef(false);
if (reviewers.length === 0) {
- return <NewApprovalRequirement isDisabled={isDisabled} />;
+ if (!isPhone) return <NewApprovalRequirement isDisabled={isDisabled} />;
+ // Phones: always a card. Its header "Add" opens the same modal as the
+ // desktop tile.
+ return (
+ <Card className="w-full" isCollapsible>
+ <HStack className="justify-between w-full">
+ <CardHeader>
+ <CardTitle className="flex items-center gap-2">
+ <Trans>Approval Requirements</Trans>
+ </CardTitle>
+ </CardHeader>
+ <CardAction className="px-0 pr-14">
+ <NewApprovalRequirement isDisabled={isDisabled} trigger="button" />
+ </CardAction>
+ </HStack>
+ <CardContent>
+ <p className="text-sm text-muted-foreground">
+ <Trans>No approval requirements yet.</Trans>
+ </p>
+ </CardContent>
+ </Card>
+ );
}
return (
@@ -65,7 +89,22 @@ export function ReviewersList({
<Trans>Approval Requirements</Trans>
</CardTitle>
</CardHeader>
- <TaskProgress tasks={reviewers} />
+ {isPhone ? (
+ <HStack spacing={0} className="pr-14">
+ <TaskProgress tasks={reviewers} className="pr-2" />
+ <CardAction className="px-0">
+ <Button
+ variant="secondary"
+ leftIcon={<LuCirclePlus />}
+ onClick={disclosure.onOpen}
+ >
+ <Trans>Add</Trans>
+ </Button>
+ </CardAction>
+ </HStack>
+ ) : (
+ <TaskProgress tasks={reviewers} />
+ )}
</HStack>
<CardContent>
<VStack spacing={3}>
@@ -122,7 +161,7 @@ export function ReviewersList({
</ModalContent>
</Modal>
)}
- <HStack>
+ <HStack className="max-md:hidden">
{disclosure.isOpen ? (
<Button variant="secondary" onClick={disclosure.onClose}>
<Trans>Cancel</Trans>
@@ -139,7 +178,14 @@ export function ReviewersList({
);
}
-function NewApprovalRequirement({ isDisabled }: { isDisabled: boolean }) {
+function NewApprovalRequirement({
+ isDisabled,
+ trigger = "tile"
+}: {
+ isDisabled: boolean;
+ /** `button`: a compact "Add" for a card header (phones) instead of the dashed tile. */
+ trigger?: "tile" | "button";
+}) {
const { id } = useParams();
if (!id) throw new Error("id not found");
@@ -178,13 +224,24 @@ function NewApprovalRequirement({ isDisabled }: { isDisabled: boolean }) {
return (
<>
- <button
- className="flex items-center justify-start bg-card border-2 border-dashed border-background w-full hover:bg-background/80 rounded-lg px-10 py-6 text-muted-foreground hover:text-foreground gap-2 transition-colors duration-200 text-sm cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed"
- onClick={() => setIsOpen(true)}
- disabled={isDisabled}
- >
- <LuCirclePlus size={16} /> <span>Add Approval Requirement</span>
- </button>
+ {trigger === "button" ? (
+ <Button
+ variant="secondary"
+ leftIcon={<LuCirclePlus />}
+ isDisabled={isDisabled}
+ onClick={() => setIsOpen(true)}
+ >
+ <Trans>Add</Trans>
+ </Button>
+ ) : (
+ <button
+ className="flex items-center justify-start bg-card border-2 border-dashed border-background w-full hover:bg-background/80 rounded-lg px-10 py-6 text-muted-foreground hover:text-foreground gap-2 transition-colors duration-200 text-sm cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed"
+ onClick={() => setIsOpen(true)}
+ disabled={isDisabled}
+ >
+ <LuCirclePlus size={16} /> <span>Add Approval Requirement</span>
+ </button>
+ )}
<Modal
open={isOpen}
diff --git a/apps/erp/app/modules/resources/ui/Maintenance/MaintenanceDispatchNotes.tsx b/apps/erp/app/modules/resources/ui/Maintenance/MaintenanceDispatchNotes.tsx
index b2b51552ac..dc95c115ed 100644
--- a/apps/erp/app/modules/resources/ui/Maintenance/MaintenanceDispatchNotes.tsx
+++ b/apps/erp/app/modules/resources/ui/Maintenance/MaintenanceDispatchNotes.tsx
@@ -21,10 +21,10 @@ import {
DropdownMenuItem,
DropdownMenuTrigger,
File,
- generateHTML,
HStack,
IconButton,
MENU_ITEM_SHORTCUTS,
+ RichTextView,
Skeleton,
Table,
Tbody,
@@ -110,11 +110,9 @@ export function MaintenanceDispatchNotes({
}}
/>
) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(content as JSONContent)
- }}
+ <RichTextView
+ content={content as JSONContent}
+ empty={<Trans>No notes</Trans>}
/>
)}
</CardContent>
diff --git a/apps/erp/app/modules/sales/ui/Opportunity/OpportunityDocuments.tsx b/apps/erp/app/modules/sales/ui/Opportunity/OpportunityDocuments.tsx
index 7e45ca59ff..20b2b27fb3 100644
--- a/apps/erp/app/modules/sales/ui/Opportunity/OpportunityDocuments.tsx
+++ b/apps/erp/app/modules/sales/ui/Opportunity/OpportunityDocuments.tsx
@@ -12,6 +12,7 @@ import {
CardContent,
CardHeader,
CardTitle,
+ cn,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
@@ -107,7 +108,7 @@ const OpportunityDocuments = ({
<Trans>Files</Trans>
</CardTitle>
</CardHeader>
- <CardAction>
+ <CardAction className="max-md:hidden">
{!isReadOnlyProp && (
<OpportunityDocumentForm
opportunityId={opportunity.id}
@@ -119,7 +120,11 @@ const OpportunityDocuments = ({
</HStack>
<CardContent>
<Table>
- <Thead>
+ <Thead
+ className={cn(
+ attachmentsToRender.length === 0 && "max-md:hidden"
+ )}
+ >
<Tr>
<Th>
<Trans>Name</Trans>
diff --git a/apps/erp/app/modules/sales/ui/Opportunity/OpportunityLineNotes.tsx b/apps/erp/app/modules/sales/ui/Opportunity/OpportunityLineNotes.tsx
index ccccc612c7..c34463b8c5 100644
--- a/apps/erp/app/modules/sales/ui/Opportunity/OpportunityLineNotes.tsx
+++ b/apps/erp/app/modules/sales/ui/Opportunity/OpportunityLineNotes.tsx
@@ -11,8 +11,8 @@ import {
CardDescription,
CardHeader,
CardTitle,
- generateHTML,
HStack,
+ RichTextView,
Tabs,
TabsContent,
TabsList,
@@ -129,11 +129,9 @@ const OpportunityLineNotes = ({
}}
/>
) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(internalNotes as JSONContent)
- }}
+ <RichTextView
+ content={internalNotes as JSONContent}
+ empty={<Trans>No internal notes</Trans>}
/>
)}
</TabsContent>
@@ -148,11 +146,9 @@ const OpportunityLineNotes = ({
}}
/>
) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(externalNotes as JSONContent)
- }}
+ <RichTextView
+ content={externalNotes as JSONContent}
+ empty={<Trans>No external notes</Trans>}
/>
)}
</TabsContent>
diff --git a/apps/erp/app/modules/sales/ui/Opportunity/OpportunityNotes.tsx b/apps/erp/app/modules/sales/ui/Opportunity/OpportunityNotes.tsx
index a31bffc6d6..5ddf6eb935 100644
--- a/apps/erp/app/modules/sales/ui/Opportunity/OpportunityNotes.tsx
+++ b/apps/erp/app/modules/sales/ui/Opportunity/OpportunityNotes.tsx
@@ -11,8 +11,8 @@ import {
CardDescription,
CardHeader,
CardTitle,
- generateHTML,
HStack,
+ RichTextView,
Tabs,
TabsContent,
TabsList,
@@ -124,11 +124,9 @@ const OpportunityNotes = ({
}}
/>
) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(internalNotes as JSONContent)
- }}
+ <RichTextView
+ content={internalNotes as JSONContent}
+ empty={<Trans>No internal notes</Trans>}
/>
)}
</TabsContent>
@@ -143,11 +141,9 @@ const OpportunityNotes = ({
}}
/>
) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(externalNotes as JSONContent)
- }}
+ <RichTextView
+ content={externalNotes as JSONContent}
+ empty={<Trans>No external notes</Trans>}
/>
)}
</TabsContent>
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteHeader.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteHeader.tsx
index 08a5c95c8b..6fb47bb45e 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteHeader.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteHeader.tsx
@@ -24,7 +24,8 @@ import {
ModalHeader,
ModalTitle,
toast,
- useDisclosure
+ useDisclosure,
+ useViewport
} from "@carbon/react";
import { Trans, useLingui } from "@lingui/react/macro";
import { useEffect, useState } from "react";
@@ -77,6 +78,7 @@ const QuoteHeader = () => {
quote: Quotation;
lines: QuotationLine[];
opportunity: Opportunity;
+ customer: { name: string | null } | null;
prices: QuotationPrice[];
shipment: QuotationShipment;
}>(path.to.quote(quoteId));
@@ -111,6 +113,22 @@ const QuoteHeader = () => {
const wonSlot = isWinnable ? "primary" : "overflow";
const lostSlot =
routeData?.quote?.status === "Sent" ? "secondary" : "overflow";
+ const isExpired = routeData?.quote?.status === "Expired";
+ const { isPhone } = useViewport();
+ const isReopenDisabled =
+ isDraft ||
+ (routeData?.opportunity?.salesOrders.length ?? 0) > 0 ||
+ statusFetcher.state !== "idle" ||
+ !permissions.can("update", "sales");
+ const reopen = () => {
+ statusFetcher.submit(
+ { status: "Draft" },
+ {
+ method: "post",
+ action: path.to.quoteStatus(quoteId)
+ }
+ );
+ };
const menuItems = (
<>
{auditLogTrigger}
@@ -134,23 +152,7 @@ const QuoteHeader = () => {
<DropdownMenuIcon icon={<LuGitBranchPlus />} />
<Trans>Create Quote Revision</Trans>
</DropdownMenuItem>
- <DropdownMenuItem
- disabled={
- isDraft ||
- (routeData?.opportunity?.salesOrders.length ?? 0) > 0 ||
- statusFetcher.state !== "idle" ||
- !permissions.can("update", "sales")
- }
- onClick={() => {
- statusFetcher.submit(
- { status: "Draft" },
- {
- method: "post",
- action: path.to.quoteStatus(quoteId)
- }
- );
- }}
- >
+ <DropdownMenuItem disabled={isReopenDisabled} onClick={reopen}>
<DropdownMenuIcon icon={<LuLoaderCircle />} />
<Trans>Reopen</Trans>
</DropdownMenuItem>
@@ -170,21 +172,25 @@ const QuoteHeader = () => {
</>
);
const statusBadge = <QuoteStatus status={routeData?.quote?.status} />;
- // The ID with its revision; phones show it under the app bar title,
- // which names the record without the revision.
+ // The ID with its revision (desktop title).
const titleNode = (
<span className="flex items-center gap-0">
<span>{routeData?.quote?.quoteId}</span>
<RevisionSuffix revisionId={routeData?.quote?.revisionId} />
</span>
);
+ // Phones: the customer under the hero, then the revision the app bar
+ // title (the ID alone) does not show.
+ const revisionId = routeData?.quote?.revisionId ?? 0;
+ const heroSubtitle =
+ [routeData?.customer?.name, revisionId > 0 ? t`Rev ${revisionId}` : null]
+ .filter(Boolean)
+ .join(" · ") || undefined;
return (
<>
<RecordHeader
title={titleNode}
- subtitle={
- (routeData?.quote?.revisionId ?? 0) > 0 ? titleNode : undefined
- }
+ subtitle={heroSubtitle}
titleTo={path.to.quoteDetails(quoteId)}
copyValue={getQuoteDisplayId(routeData?.quote)}
menu={menuItems}
@@ -205,7 +211,7 @@ const QuoteHeader = () => {
</Button>
</RecordAction>
) : (
- <RecordAction slot="overflow">
+ <RecordAction slot="icon">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
@@ -329,6 +335,24 @@ const QuoteHeader = () => {
</statusFetcher.Form>
</RecordAction>
)}
+
+ {/* Phones: an Expired quote has no other step, so Reopen (also
+ in the ⋯ menu) leads the action bar. */}
+ {isPhone && isExpired && (
+ <RecordAction slot="primary">
+ <Button
+ leftIcon={<LuLoaderCircle />}
+ isDisabled={isReopenDisabled}
+ isLoading={
+ statusFetcher.state !== "idle" &&
+ statusFetcher.formData?.get("status") === "Draft"
+ }
+ onClick={reopen}
+ >
+ <Trans>Reopen</Trans>
+ </Button>
+ </RecordAction>
+ )}
</>
}
/>
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricingOptions.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricingOptions.tsx
new file mode 100644
index 0000000000..da632eab96
--- /dev/null
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricingOptions.tsx
@@ -0,0 +1,459 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import {
+ RadioGroup,
+ RadioGroupItem,
+ Table,
+ Tbody,
+ Td,
+ Th,
+ Thead,
+ Tr,
+ VStack
+} from "@carbon/react";
+import { Trans } from "@lingui/react/macro";
+import type { Dispatch, SetStateAction } from "react";
+import { useState } from "react";
+import { useParams } from "react-router";
+import { MotionMoney } from "~/components";
+import {
+ useCurrencyDecimals,
+ usePercentFormatter,
+ useRouteData
+} from "~/hooks";
+import { path } from "~/utils/path";
+import type {
+ Quotation,
+ QuotationLine,
+ QuotationPrice,
+ SalesOrderLine
+} from "../../types";
+
+export type SelectedLine = {
+ quantity: number;
+ netUnitPrice: number;
+ convertedNetUnitPrice: number;
+ addOn: number;
+ convertedAddOn: number;
+ taxableAddOn: number;
+ convertedTaxableAddOn: number;
+ leadTime: number;
+ shippingCost: number;
+ convertedShippingCost: number;
+ taxPercent: number;
+ discountPercent: number;
+ unitPrice: number;
+ convertedUnitPrice: number;
+};
+
+export const deselectedLine: SelectedLine = {
+ addOn: 0,
+ convertedAddOn: 0,
+ taxableAddOn: 0,
+ convertedTaxableAddOn: 0,
+ netUnitPrice: 0,
+ convertedNetUnitPrice: 0,
+ quantity: 0,
+ leadTime: 0,
+ shippingCost: 0,
+ convertedShippingCost: 0,
+ taxPercent: 0,
+ discountPercent: 0,
+ unitPrice: 0,
+ convertedUnitPrice: 0
+};
+
+/** A quote line's total for the chosen quantity: price, add-ons, shipping, tax. */
+export function getQuoteLineTotal(line: SelectedLine) {
+ const net = (line.convertedNetUnitPrice ?? 0) * (line.quantity ?? 0);
+ return (
+ net +
+ (line.convertedAddOn ?? 0) +
+ (line.convertedShippingCost ?? 0) +
+ (net +
+ (line.convertedTaxableAddOn ?? 0) +
+ (line.convertedShippingCost ?? 0)) *
+ (line.taxPercent ?? 0)
+ );
+}
+
+type LinePricingOptionsProps = {
+ line: QuotationLine;
+ options: QuotationPrice[];
+ quoteCurrency: string;
+ shouldConvertCurrency: boolean;
+ quoteExchangeRate: number;
+ locale: string;
+ formatter: Intl.NumberFormat;
+ selectedLine: SelectedLine;
+ setSelectedLines: Dispatch<SetStateAction<Record<string, SelectedLine>>>;
+};
+
+export const LinePricingOptions = ({
+ line,
+ options,
+ quoteCurrency,
+ shouldConvertCurrency,
+ quoteExchangeRate,
+ locale,
+ formatter,
+ selectedLine,
+ setSelectedLines
+}: LinePricingOptionsProps) => {
+ // Settlement money at the document currency's configured decimals.
+ const currencyDecimals = useCurrencyDecimals(quoteCurrency);
+ const percentFormatter = usePercentFormatter();
+ const { quoteId } = useParams();
+ if (!quoteId) throw new Error("Could not find quote id");
+ const routeData = useRouteData<{
+ quote: Quotation;
+ salesOrderLines: SalesOrderLine[];
+ }>(path.to.quote(quoteId));
+
+ const [selectedValue, setSelectedValue] = useState<string | null>(
+ selectedLine?.quantity?.toString() ?? null
+ );
+
+ const additionalChargesByQuantity =
+ line.quantity?.reduce(
+ (acc, quantity) => {
+ const charges = Object.values(line.additionalCharges ?? {}).reduce(
+ (chargeAcc, charge) => {
+ const amount = charge.amounts?.[quantity];
+ return chargeAcc + amount;
+ },
+ 0
+ );
+ acc[quantity] = charges;
+ return acc;
+ },
+ { 0: 0 } as Record<number, number>
+ ) ?? {};
+
+ const convertedAdditionalChargesByQuantity = Object.entries(
+ additionalChargesByQuantity
+ ).reduce<Record<number, number>>(
+ (acc, [quantity, amount]) => {
+ acc[Number(quantity)] = amount * quoteExchangeRate;
+ return acc;
+ },
+ { 0: 0 }
+ );
+
+ const taxableAdditionalChargesByQuantity =
+ line.quantity?.reduce(
+ (acc, quantity) => {
+ const charges = Object.values(line.additionalCharges ?? {}).reduce(
+ (chargeAcc, charge) => {
+ if (charge.taxable === false) return chargeAcc;
+ const amount = charge.amounts?.[quantity];
+ return chargeAcc + amount;
+ },
+ 0
+ );
+ acc[quantity] = charges;
+ return acc;
+ },
+ { 0: 0 } as Record<number, number>
+ ) ?? {};
+
+ const convertedTaxableAdditionalChargesByQuantity = Object.entries(
+ taxableAdditionalChargesByQuantity
+ ).reduce<Record<number, number>>(
+ (acc, [quantity, amount]) => {
+ acc[Number(quantity)] = amount * quoteExchangeRate;
+ return acc;
+ },
+ { 0: 0 }
+ );
+
+ const additionalCharges: { name: string; amount: number }[] = [];
+ if (selectedLine.convertedShippingCost) {
+ additionalCharges.push({
+ name: "Shipping",
+ amount: selectedLine.convertedShippingCost
+ });
+ }
+ Object.entries(line.additionalCharges ?? {}).forEach(([name, charge]) => {
+ additionalCharges.push({
+ name: charge.description,
+ amount: charge.amounts?.[selectedLine.quantity] * quoteExchangeRate
+ });
+ });
+
+ const hasAnyShipping = options.some(
+ (option) => (option.convertedShippingCost ?? 0) > 0
+ );
+ const hasAnyFees = options.some(
+ (option) => (convertedAdditionalChargesByQuantity[option.quantity] ?? 0) > 0
+ );
+
+ return (
+ <VStack spacing={4}>
+ <RadioGroup
+ className="w-full"
+ value={selectedValue ?? undefined}
+ disabled={["Ordered", "Partial", "Expired", "Cancelled"].includes(
+ routeData?.quote.status ?? ""
+ )}
+ onValueChange={(value) => {
+ const selectedOption =
+ value === "0"
+ ? deselectedLine
+ : options.find((opt) => opt.quantity.toString() === value);
+
+ if (selectedOption) {
+ setSelectedLines((prev) => ({
+ ...prev,
+ [line.id!]: {
+ quantity: selectedOption.quantity,
+ netUnitPrice: selectedOption.netUnitPrice ?? 0,
+ convertedNetUnitPrice:
+ selectedOption.convertedNetUnitPrice ?? 0,
+ addOn:
+ additionalChargesByQuantity[selectedOption.quantity] || 0,
+ convertedAddOn:
+ convertedAdditionalChargesByQuantity[
+ selectedOption.quantity
+ ] || 0,
+ taxableAddOn:
+ taxableAdditionalChargesByQuantity[selectedOption.quantity] ||
+ 0,
+ convertedTaxableAddOn:
+ convertedTaxableAdditionalChargesByQuantity[
+ selectedOption.quantity
+ ] || 0,
+ leadTime: selectedOption.leadTime,
+ shippingCost: selectedOption.shippingCost ?? 0,
+ convertedShippingCost:
+ selectedOption.convertedShippingCost ?? 0,
+ taxPercent: line.taxPercent ?? 0,
+ discountPercent: selectedOption.discountPercent ?? 0,
+ unitPrice: selectedOption.unitPrice ?? 0,
+ convertedUnitPrice: selectedOption.convertedUnitPrice ?? 0
+ }
+ }));
+ setSelectedValue(value);
+ }
+ }}
+ >
+ <Table>
+ <Thead>
+ <Tr>
+ <Th />
+ <Th>
+ <Trans>Quantity</Trans>
+ </Th>
+ <Th>
+ <Trans>Unit Price</Trans>
+ </Th>
+ <Th>
+ <Trans>Discount</Trans>
+ </Th>
+ {hasAnyShipping && (
+ <Th>
+ <Trans>Shipping</Trans>
+ </Th>
+ )}
+ {hasAnyFees && (
+ <Th>
+ <Trans>Fees</Trans>
+ </Th>
+ )}
+ <Th>
+ <Trans>Lead Time</Trans>
+ </Th>
+ <Th>
+ <Trans>Subtotal</Trans>
+ </Th>
+ </Tr>
+ </Thead>
+ <Tbody>
+ {!Array.isArray(options) || options.length === 0 ? (
+ <Tr>
+ <Td
+ colSpan={5 + (hasAnyShipping ? 1 : 0) + (hasAnyFees ? 1 : 0)}
+ className="text-center py-8"
+ >
+ No pricing options found
+ </Td>
+ </Tr>
+ ) : (
+ options.map(
+ (option, index) =>
+ (line?.quantity?.includes(option.quantity) ||
+ option.quantity === 0) && (
+ <Tr key={index}>
+ <Td>
+ <RadioGroupItem
+ value={option.quantity.toString()}
+ id={`${line.id}:${option.quantity.toString()}`}
+ />
+ <label
+ htmlFor={`${line.id}:${option.quantity.toString()}`}
+ className="sr-only"
+ >
+ {option.quantity}
+ </label>
+ </Td>
+ <Td>{option.quantity}</Td>
+ <Td>
+ {formatter.format(option.convertedUnitPrice ?? 0)}
+ </Td>
+ <Td>
+ {option.discountPercent > 0
+ ? percentFormatter.format(option.discountPercent)
+ : "-"}
+ </Td>
+ {hasAnyShipping && (
+ <Td>
+ {(option.convertedShippingCost ?? 0) > 0
+ ? formatter.format(
+ option.convertedShippingCost ?? 0
+ )
+ : "-"}
+ </Td>
+ )}
+ {hasAnyFees && (
+ <Td>
+ {(convertedAdditionalChargesByQuantity[
+ option.quantity
+ ] ?? 0) > 0
+ ? formatter.format(
+ convertedAdditionalChargesByQuantity[
+ option.quantity
+ ]
+ )
+ : "-"}
+ </Td>
+ )}
+ <Td>
+ {new Intl.NumberFormat(locale, {
+ style: "unit",
+ unit: "day"
+ }).format(option.leadTime)}
+ </Td>
+ <Td>
+ {formatter.format(
+ (option.convertedNetUnitPrice ?? 0) *
+ option.quantity +
+ convertedAdditionalChargesByQuantity[
+ option.quantity
+ ] +
+ (option.convertedShippingCost ?? 0)
+ )}
+ </Td>
+ </Tr>
+ )
+ )
+ )}
+ </Tbody>
+ </Table>
+ </RadioGroup>
+
+ {selectedLine.quantity !== 0 && (
+ <div className="w-full">
+ <Table>
+ <Tbody>
+ <Tr key="extended-price" className="border-b border-border">
+ <Td>
+ <Trans>Extended Price</Trans>
+ </Td>
+ <Td className="text-right">
+ <MotionMoney
+ value={
+ (selectedLine.convertedUnitPrice ?? 0) *
+ selectedLine.quantity
+ }
+ currency={quoteCurrency}
+ decimalPlaces={currencyDecimals}
+ />
+ </Td>
+ </Tr>
+
+ {selectedLine.discountPercent > 0 && (
+ <Tr key="discount" className="border-b border-border">
+ <Td>
+ Discount (
+ {percentFormatter.format(selectedLine.discountPercent)})
+ </Td>
+ <Td className="text-right">
+ -
+ <MotionMoney
+ value={
+ (selectedLine.convertedUnitPrice ?? 0) *
+ selectedLine.quantity *
+ selectedLine.discountPercent
+ }
+ currency={quoteCurrency}
+ decimalPlaces={currencyDecimals}
+ />
+ </Td>
+ </Tr>
+ )}
+
+ {additionalCharges.length > 0 &&
+ additionalCharges.map((charge) => (
+ <Tr
+ key={charge.name}
+ className={
+ additionalCharges[additionalCharges.length - 1] === charge
+ ? "border-b border-border"
+ : ""
+ }
+ >
+ <Td>{charge.name}</Td>
+ <Td className="text-right">
+ <MotionMoney
+ value={charge.amount}
+ currency={quoteCurrency}
+ decimalPlaces={currencyDecimals}
+ />
+ </Td>
+ </Tr>
+ ))}
+
+ <Tr key="subtotal">
+ <Td>
+ <Trans>Subtotal</Trans>
+ </Td>
+ <Td className="text-right">
+ <MotionMoney
+ value={getQuoteLineTotal(selectedLine)}
+ currency={quoteCurrency}
+ decimalPlaces={currencyDecimals}
+ />
+ </Td>
+ </Tr>
+
+ <Tr key="total" className="font-bold">
+ <Td>
+ <Trans>Total</Trans>
+ </Td>
+ <Td className="text-right">
+ <MotionMoney
+ value={
+ (selectedLine.convertedNetUnitPrice ?? 0) *
+ selectedLine.quantity +
+ (selectedLine.convertedAddOn ?? 0) +
+ (selectedLine.convertedShippingCost ?? 0) +
+ ((selectedLine.convertedNetUnitPrice ?? 0) *
+ selectedLine.quantity +
+ (selectedLine.convertedTaxableAddOn ?? 0) +
+ (selectedLine.convertedShippingCost ?? 0)) *
+ (selectedLine.taxPercent ?? 0)
+ }
+ currency={quoteCurrency}
+ decimalPlaces={currencyDecimals}
+ />
+ </Td>
+ </Tr>
+ </Tbody>
+ </Table>
+ </div>
+ )}
+ </VStack>
+ );
+};
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuotePaymentForm.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuotePaymentForm.tsx
index e7ed03940c..336b4d996a 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuotePaymentForm.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuotePaymentForm.tsx
@@ -9,7 +9,8 @@ import {
CardFooter,
CardHeader,
CardTitle,
- HStack
+ HStack,
+ useViewport
} from "@carbon/react";
import { Trans, useLingui } from "@lingui/react/macro";
import { useState } from "react";
@@ -48,6 +49,8 @@ const QuotePaymentForm = ({ initialValues }: QuotePaymentFormProps) => {
const isLocked = isQuoteLocked(routeData?.quote?.status);
const isEditable = !isLocked;
+ const { isPhone } = useViewport();
+ const quoteStatus = routeData?.quote?.status ?? "";
const isDisabled = !isEditable || !permissions.can("update", "sales");
return (
@@ -64,6 +67,13 @@ const QuotePaymentForm = ({ initialValues }: QuotePaymentFormProps) => {
<CardTitle>
<Trans>Payment</Trans>
</CardTitle>
+ {isPhone && isLocked ? (
+ <p className="text-sm text-muted-foreground">
+ <Trans>
+ Locked while the quote is {quoteStatus}. Reopen it to edit.
+ </Trans>
+ </p>
+ ) : null}
</CardHeader>
<CardContent>
<Hidden name="id" />
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteShipmentForm.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteShipmentForm.tsx
index 439a961255..14f6c018e0 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteShipmentForm.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteShipmentForm.tsx
@@ -8,7 +8,8 @@ import {
CardContent,
CardFooter,
CardHeader,
- CardTitle
+ CardTitle,
+ useViewport
} from "@carbon/react";
import { INPUT_FORMAT } from "@carbon/utils";
import { Trans, useLingui } from "@lingui/react/macro";
@@ -80,6 +81,8 @@ const QuoteShipmentForm = forwardRef<
const isLocked = isQuoteLocked(routeData?.quote?.status);
const isEditable = !isLocked;
+ const { isPhone } = useViewport();
+ const quoteStatus = routeData?.quote?.status ?? "";
const { company } = useUser();
const currencyDecimals = useCurrencyDecimals(company?.baseCurrencyCode);
@@ -104,6 +107,13 @@ const QuoteShipmentForm = forwardRef<
<CardTitle>
<Trans>Shipping</Trans>
</CardTitle>
+ {isPhone && isLocked ? (
+ <p className="text-sm text-muted-foreground">
+ <Trans>
+ Locked while the quote is {quoteStatus}. Reopen it to edit.
+ </Trans>
+ </p>
+ ) : null}
</CardHeader>
<CardContent>
<Hidden name="id" />
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteSummary.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteSummary.tsx
index 25013d49e0..161fb3b7f4 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteSummary.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteSummary.tsx
@@ -9,17 +9,11 @@ import {
CardDescription,
CardHeader,
CardTitle,
+ cn,
Heading,
HStack,
- RadioGroup,
- RadioGroupItem,
- Table,
- Tbody,
- Td,
- Th,
- Thead,
- Tr,
TruncatedTooltipText,
+ useViewport,
VStack
} from "@carbon/react";
import { Trans } from "@lingui/react/macro";
@@ -35,10 +29,10 @@ import {
MotionMoney,
RevisionSuffix
} from "~/components";
+import { SummaryLineRow } from "~/components/SummaryLineRow";
import {
useCurrencyDecimals,
useCurrencyFormatter,
- usePercentFormatter,
useRouteData,
useUser
} from "~/hooks";
@@ -51,40 +45,12 @@ import type {
QuotationShipment,
SalesOrderLine
} from "../../types";
-
-type SelectedLine = {
- quantity: number;
- netUnitPrice: number;
- convertedNetUnitPrice: number;
- addOn: number;
- convertedAddOn: number;
- taxableAddOn: number;
- convertedTaxableAddOn: number;
- leadTime: number;
- shippingCost: number;
- convertedShippingCost: number;
- taxPercent: number;
- discountPercent: number;
- unitPrice: number;
- convertedUnitPrice: number;
-};
-
-const deselectedLine: SelectedLine = {
- addOn: 0,
- convertedAddOn: 0,
- taxableAddOn: 0,
- convertedTaxableAddOn: 0,
- netUnitPrice: 0,
- convertedNetUnitPrice: 0,
- quantity: 0,
- leadTime: 0,
- shippingCost: 0,
- convertedShippingCost: 0,
- taxPercent: 0,
- discountPercent: 0,
- unitPrice: 0,
- convertedUnitPrice: 0
-};
+import {
+ deselectedLine,
+ getQuoteLineTotal,
+ LinePricingOptions,
+ type SelectedLine
+} from "./QuoteLinePricingOptions";
const LineItems = ({
currencyCode,
@@ -102,6 +68,7 @@ const LineItems = ({
// Settlement money at the document currency's configured decimals.
const currencyDecimals = useCurrencyDecimals(currencyCode);
const { company } = useUser();
+ const { isPhone } = useViewport();
const { quoteId } = useParams();
if (!quoteId) throw new Error("Could not find quote id");
const routeData = useRouteData<{
@@ -156,7 +123,13 @@ const LineItems = ({
routeData?.quote.currencyCode !== company?.baseCurrencyCode;
return (
- <VStack spacing={8} className="w-full overflow-hidden tracking-tight">
+ <VStack
+ spacing={8}
+ className={cn(
+ "w-full overflow-hidden tracking-tight",
+ isPhone && "space-y-0 divide-y divide-border"
+ )}
+ >
{routeData?.lines?.map((line) => {
const prices = pricingByLine[line.id!];
@@ -165,6 +138,75 @@ const LineItems = ({
}
const selectedLine = selectedLines[line.id] || deselectedLine;
+ const lineTotal = getQuoteLineTotal(selectedLine);
+ // The quantity-break picker: a tap on the line opens it.
+ const pricingOptions = (
+ <motion.div
+ initial="collapsed"
+ animate={openItems.includes(line.id) ? "open" : "collapsed"}
+ variants={{
+ open: { opacity: 1, height: "auto", marginTop: 16 },
+ collapsed: { opacity: 0, height: 0, marginTop: 0 }
+ }}
+ transition={{ duration: 0.3 }}
+ className="w-full overflow-hidden"
+ >
+ <LinePricingOptions
+ formatter={formatter}
+ line={line}
+ options={pricingByLine[line.id!]}
+ quoteCurrency={routeData?.quote.currencyCode ?? "USD"}
+ quoteExchangeRate={routeData?.quote.exchangeRate ?? 1}
+ shouldConvertCurrency={shouldConvertCurrency}
+ locale={locale}
+ selectedLine={selectedLine}
+ setSelectedLines={setSelectedLines}
+ />
+ </motion.div>
+ );
+
+ // Phones: a text row (no image or Edit link); the line page opens
+ // from the Lines tab.
+ if (isPhone) {
+ return (
+ <div key={line.id} className="w-full">
+ <SummaryLineRow
+ expanded={openItems.includes(line.id)}
+ onClick={() => toggleOpen(line.id!)}
+ title={line.itemReadableId}
+ value={
+ <MotionMoney
+ value={lineTotal}
+ currency={currencyCode}
+ decimalPlaces={currencyDecimals}
+ />
+ }
+ trailing={
+ <motion.span
+ className="self-center text-muted-foreground"
+ animate={{ rotate: openItems.includes(line.id) ? 90 : 0 }}
+ transition={{ duration: 0.3 }}
+ >
+ <LuChevronRight className="size-4" />
+ </motion.span>
+ }
+ description={line.description}
+ meta={
+ selectedLine.quantity > 0 ? (
+ <>
+ {selectedLine.quantity} ×{" "}
+ {formatter.format(
+ selectedLine.convertedNetUnitPrice ?? 0
+ )}{" "}
+ {line.unitOfMeasureCode}
+ </>
+ ) : null
+ }
+ />
+ {pricingOptions}
+ </div>
+ );
+ }
return (
<motion.div
@@ -210,17 +252,7 @@ const LineItems = ({
</HStack>
<HStack spacing={4}>
<MotionMoney
- value={
- (selectedLine.convertedNetUnitPrice ?? 0) *
- (selectedLine.quantity ?? 0) +
- (selectedLine.convertedAddOn ?? 0) +
- (selectedLine.convertedShippingCost ?? 0) +
- ((selectedLine.convertedNetUnitPrice ?? 0) *
- (selectedLine.quantity ?? 0) +
- (selectedLine.convertedTaxableAddOn ?? 0) +
- (selectedLine.convertedShippingCost ?? 0)) *
- (selectedLine.taxPercent ?? 0)
- }
+ value={lineTotal}
currency={currencyCode}
decimalPlaces={currencyDecimals}
/>
@@ -244,28 +276,7 @@ const LineItems = ({
</VStack>
</HStack>
- <motion.div
- initial="collapsed"
- animate={openItems.includes(line.id) ? "open" : "collapsed"}
- variants={{
- open: { opacity: 1, height: "auto", marginTop: 16 },
- collapsed: { opacity: 0, height: 0, marginTop: 0 }
- }}
- transition={{ duration: 0.3 }}
- className="w-full overflow-hidden"
- >
- <LinePricingOptions
- formatter={formatter}
- line={line}
- options={pricingByLine[line.id!]}
- quoteCurrency={routeData?.quote.currencyCode ?? "USD"}
- quoteExchangeRate={routeData?.quote.exchangeRate ?? 1}
- shouldConvertCurrency={shouldConvertCurrency}
- locale={locale}
- selectedLine={selectedLine}
- setSelectedLines={setSelectedLines}
- />
- </motion.div>
+ {pricingOptions}
</motion.div>
);
})}
@@ -273,409 +284,6 @@ const LineItems = ({
);
};
-type LinePricingOptionsProps = {
- line: QuotationLine;
- options: QuotationPrice[];
- quoteCurrency: string;
- shouldConvertCurrency: boolean;
- quoteExchangeRate: number;
- locale: string;
- formatter: Intl.NumberFormat;
- selectedLine: SelectedLine;
- setSelectedLines: Dispatch<SetStateAction<Record<string, SelectedLine>>>;
-};
-
-const LinePricingOptions = ({
- line,
- options,
- quoteCurrency,
- shouldConvertCurrency,
- quoteExchangeRate,
- locale,
- formatter,
- selectedLine,
- setSelectedLines
-}: LinePricingOptionsProps) => {
- // Settlement money at the document currency's configured decimals.
- const currencyDecimals = useCurrencyDecimals(quoteCurrency);
- const percentFormatter = usePercentFormatter();
- const { quoteId } = useParams();
- if (!quoteId) throw new Error("Could not find quote id");
- const routeData = useRouteData<{
- quote: Quotation;
- salesOrderLines: SalesOrderLine[];
- }>(path.to.quote(quoteId));
-
- const [selectedValue, setSelectedValue] = useState<string | null>(
- selectedLine?.quantity?.toString() ?? null
- );
-
- const additionalChargesByQuantity =
- line.quantity?.reduce(
- (acc, quantity) => {
- const charges = Object.values(line.additionalCharges ?? {}).reduce(
- (chargeAcc, charge) => {
- const amount = charge.amounts?.[quantity];
- return chargeAcc + amount;
- },
- 0
- );
- acc[quantity] = charges;
- return acc;
- },
- { 0: 0 } as Record<number, number>
- ) ?? {};
-
- const convertedAdditionalChargesByQuantity = Object.entries(
- additionalChargesByQuantity
- ).reduce<Record<number, number>>(
- (acc, [quantity, amount]) => {
- acc[Number(quantity)] = amount * quoteExchangeRate;
- return acc;
- },
- { 0: 0 }
- );
-
- const taxableAdditionalChargesByQuantity =
- line.quantity?.reduce(
- (acc, quantity) => {
- const charges = Object.values(line.additionalCharges ?? {}).reduce(
- (chargeAcc, charge) => {
- if (charge.taxable === false) return chargeAcc;
- const amount = charge.amounts?.[quantity];
- return chargeAcc + amount;
- },
- 0
- );
- acc[quantity] = charges;
- return acc;
- },
- { 0: 0 } as Record<number, number>
- ) ?? {};
-
- const convertedTaxableAdditionalChargesByQuantity = Object.entries(
- taxableAdditionalChargesByQuantity
- ).reduce<Record<number, number>>(
- (acc, [quantity, amount]) => {
- acc[Number(quantity)] = amount * quoteExchangeRate;
- return acc;
- },
- { 0: 0 }
- );
-
- const additionalCharges: { name: string; amount: number }[] = [];
- if (selectedLine.convertedShippingCost) {
- additionalCharges.push({
- name: "Shipping",
- amount: selectedLine.convertedShippingCost
- });
- }
- Object.entries(line.additionalCharges ?? {}).forEach(([name, charge]) => {
- additionalCharges.push({
- name: charge.description,
- amount: charge.amounts?.[selectedLine.quantity] * quoteExchangeRate
- });
- });
-
- const hasAnyShipping = options.some(
- (option) => (option.convertedShippingCost ?? 0) > 0
- );
- const hasAnyFees = options.some(
- (option) => (convertedAdditionalChargesByQuantity[option.quantity] ?? 0) > 0
- );
-
- return (
- <VStack spacing={4}>
- <RadioGroup
- className="w-full"
- value={selectedValue ?? undefined}
- disabled={["Ordered", "Partial", "Expired", "Cancelled"].includes(
- routeData?.quote.status ?? ""
- )}
- onValueChange={(value) => {
- const selectedOption =
- value === "0"
- ? deselectedLine
- : options.find((opt) => opt.quantity.toString() === value);
-
- if (selectedOption) {
- setSelectedLines((prev) => ({
- ...prev,
- [line.id!]: {
- quantity: selectedOption.quantity,
- netUnitPrice: selectedOption.netUnitPrice ?? 0,
- convertedNetUnitPrice:
- selectedOption.convertedNetUnitPrice ?? 0,
- addOn:
- additionalChargesByQuantity[selectedOption.quantity] || 0,
- convertedAddOn:
- convertedAdditionalChargesByQuantity[
- selectedOption.quantity
- ] || 0,
- taxableAddOn:
- taxableAdditionalChargesByQuantity[selectedOption.quantity] ||
- 0,
- convertedTaxableAddOn:
- convertedTaxableAdditionalChargesByQuantity[
- selectedOption.quantity
- ] || 0,
- leadTime: selectedOption.leadTime,
- shippingCost: selectedOption.shippingCost ?? 0,
- convertedShippingCost:
- selectedOption.convertedShippingCost ?? 0,
- taxPercent: line.taxPercent ?? 0,
- discountPercent: selectedOption.discountPercent ?? 0,
- unitPrice: selectedOption.unitPrice ?? 0,
- convertedUnitPrice: selectedOption.convertedUnitPrice ?? 0
- }
- }));
- setSelectedValue(value);
- }
- }}
- >
- <Table>
- <Thead>
- <Tr>
- <Th />
- <Th>
- <Trans>Quantity</Trans>
- </Th>
- <Th>
- <Trans>Unit Price</Trans>
- </Th>
- <Th>
- <Trans>Discount</Trans>
- </Th>
- {hasAnyShipping && (
- <Th>
- <Trans>Shipping</Trans>
- </Th>
- )}
- {hasAnyFees && (
- <Th>
- <Trans>Fees</Trans>
- </Th>
- )}
- <Th>
- <Trans>Lead Time</Trans>
- </Th>
- <Th>
- <Trans>Subtotal</Trans>
- </Th>
- </Tr>
- </Thead>
- <Tbody>
- {!Array.isArray(options) || options.length === 0 ? (
- <Tr>
- <Td
- colSpan={5 + (hasAnyShipping ? 1 : 0) + (hasAnyFees ? 1 : 0)}
- className="text-center py-8"
- >
- No pricing options found
- </Td>
- </Tr>
- ) : (
- options.map(
- (option, index) =>
- (line?.quantity?.includes(option.quantity) ||
- option.quantity === 0) && (
- <Tr key={index}>
- <Td>
- <RadioGroupItem
- value={option.quantity.toString()}
- id={`${line.id}:${option.quantity.toString()}`}
- />
- <label
- htmlFor={`${line.id}:${option.quantity.toString()}`}
- className="sr-only"
- >
- {option.quantity}
- </label>
- </Td>
- <Td>{option.quantity}</Td>
- <Td>
- {formatter.format(option.convertedUnitPrice ?? 0)}
- </Td>
- <Td>
- {option.discountPercent > 0
- ? percentFormatter.format(option.discountPercent)
- : "-"}
- </Td>
- {hasAnyShipping && (
- <Td>
- {(option.convertedShippingCost ?? 0) > 0
- ? formatter.format(
- option.convertedShippingCost ?? 0
- )
- : "-"}
- </Td>
- )}
- {hasAnyFees && (
- <Td>
- {(convertedAdditionalChargesByQuantity[
- option.quantity
- ] ?? 0) > 0
- ? formatter.format(
- convertedAdditionalChargesByQuantity[
- option.quantity
- ]
- )
- : "-"}
- </Td>
- )}
- <Td>
- {new Intl.NumberFormat(locale, {
- style: "unit",
- unit: "day"
- }).format(option.leadTime)}
- </Td>
- <Td>
- {formatter.format(
- (option.convertedNetUnitPrice ?? 0) *
- option.quantity +
- convertedAdditionalChargesByQuantity[
- option.quantity
- ] +
- (option.convertedShippingCost ?? 0)
- )}
- </Td>
- </Tr>
- )
- )
- )}
- </Tbody>
- </Table>
- </RadioGroup>
-
- {selectedLine.quantity !== 0 && (
- <div className="w-full">
- <Table>
- <Tbody>
- <Tr key="extended-price" className="border-b border-border">
- <Td>
- <Trans>Extended Price</Trans>
- </Td>
- <Td className="text-right">
- <MotionMoney
- value={
- (selectedLine.convertedUnitPrice ?? 0) *
- selectedLine.quantity
- }
- currency={quoteCurrency}
- decimalPlaces={currencyDecimals}
- />
- </Td>
- </Tr>
-
- {selectedLine.discountPercent > 0 && (
- <Tr key="discount" className="border-b border-border">
- <Td>
- Discount (
- {percentFormatter.format(selectedLine.discountPercent)})
- </Td>
- <Td className="text-right">
- -
- <MotionMoney
- value={
- (selectedLine.convertedUnitPrice ?? 0) *
- selectedLine.quantity *
- selectedLine.discountPercent
- }
- currency={quoteCurrency}
- decimalPlaces={currencyDecimals}
- />
- </Td>
- </Tr>
- )}
-
- {additionalCharges.length > 0 &&
- additionalCharges.map((charge) => (
- <Tr
- key={charge.name}
- className={
- additionalCharges[additionalCharges.length - 1] === charge
- ? "border-b border-border"
- : ""
- }
- >
- <Td>{charge.name}</Td>
- <Td className="text-right">
- <MotionMoney
- value={charge.amount}
- currency={quoteCurrency}
- decimalPlaces={currencyDecimals}
- />
- </Td>
- </Tr>
- ))}
-
- <Tr key="subtotal">
- <Td>
- <Trans>Subtotal</Trans>
- </Td>
- <Td className="text-right">
- <MotionMoney
- value={
- (selectedLine.convertedNetUnitPrice ?? 0) *
- selectedLine.quantity +
- (selectedLine.convertedAddOn ?? 0) +
- (selectedLine.convertedShippingCost ?? 0)
- }
- currency={quoteCurrency}
- decimalPlaces={currencyDecimals}
- />
- </Td>
- </Tr>
-
- <Tr key="tax" className="border-b border-border">
- <Td>
- Tax ({percentFormatter.format(selectedLine.taxPercent)})
- </Td>
- <Td className="text-right">
- <MotionMoney
- value={
- ((selectedLine.convertedNetUnitPrice ?? 0) *
- selectedLine.quantity +
- (selectedLine.convertedTaxableAddOn ?? 0) +
- (selectedLine.convertedShippingCost ?? 0)) *
- (selectedLine.taxPercent ?? 0)
- }
- currency={quoteCurrency}
- decimalPlaces={currencyDecimals}
- />
- </Td>
- </Tr>
-
- <Tr key="total" className="font-bold">
- <Td>
- <Trans>Total</Trans>
- </Td>
- <Td className="text-right">
- <MotionMoney
- value={
- (selectedLine.convertedNetUnitPrice ?? 0) *
- selectedLine.quantity +
- (selectedLine.convertedAddOn ?? 0) +
- (selectedLine.convertedShippingCost ?? 0) +
- ((selectedLine.convertedNetUnitPrice ?? 0) *
- selectedLine.quantity +
- (selectedLine.convertedTaxableAddOn ?? 0) +
- (selectedLine.convertedShippingCost ?? 0)) *
- (selectedLine.taxPercent ?? 0)
- }
- currency={quoteCurrency}
- decimalPlaces={currencyDecimals}
- />
- </Td>
- </Tr>
- </Tbody>
- </Table>
- </div>
- )}
- </VStack>
- );
-};
-
const QuoteSummary = ({
onEditShippingCost
}: {
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuotesTable.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuotesTable.tsx
index 19cb748f9e..95ed2abf31 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuotesTable.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuotesTable.tsx
@@ -99,7 +99,23 @@ const QuotesTable = memo(({ data, count }: QuotesTableProps) => {
id: "customerId",
header: t`Customer`,
cell: ({ row }) => (
- <CustomerAvatar customerId={row.original.customerId} />
+ // Phones: the expiry date follows the customer on line 2.
+ <div className="contents max-md:flex max-md:min-w-0 max-md:items-center max-md:gap-1">
+ <CustomerAvatar customerId={row.original.customerId} />
+ {row.original.expirationDate ? (
+ <span className="shrink-0 whitespace-nowrap md:hidden">
+ ·{" "}
+ <Trans>
+ Exp.{" "}
+ <DateTime
+ value={row.original.expirationDate}
+ variant="date"
+ dateOptions={{ month: "short", day: "numeric" }}
+ />
+ </Trans>
+ </span>
+ ) : null}
+ </div>
),
meta: {
mobile: "P3",
@@ -122,11 +138,20 @@ const QuotesTable = memo(({ data, count }: QuotesTableProps) => {
const lines = row.original.lines ?? 0;
const completedLines = row.original.completedLines ?? 0;
return status === "Draft" ? (
- <BarProgress
- className="max-md:w-24"
- gradient
- progress={lines === 0 ? 0 : (completedLines / lines) * 100}
- />
+ <>
+ <BarProgress
+ className="max-md:hidden"
+ gradient
+ progress={lines === 0 ? 0 : (completedLines / lines) * 100}
+ />
+ {/* Phones: the status and the count in words, not a bare bar. */}
+ <span className="flex min-w-0 items-center gap-1.5 md:hidden">
+ <QuoteStatus status="Draft" />
+ <span className="truncate text-xs text-muted-foreground">
+ {t`${completedLines} of ${lines} lines complete`}
+ </span>
+ </span>
+ </>
) : (
<QuoteStatus status={status} />
);
diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx
index 78ad7c7ac4..5acc6b1793 100644
--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx
@@ -202,6 +202,7 @@ const SalesOrderHeader = () => {
salesOrder: SalesOrder;
lines: SalesOrderLine[];
opportunity: Opportunity;
+ customer: { name: string | null } | null;
relatedItems: Promise<{
jobs: Job[];
shipments: Shipment[];
@@ -384,11 +385,12 @@ const SalesOrderHeader = () => {
copyValue={routeData?.salesOrder?.salesOrderId ?? ""}
menu={menuItems}
status={statusBadges}
+ subtitle={routeData?.customer?.name ?? undefined}
onToggleExplorer={toggleExplorer}
onToggleProperties={toggleProperties}
actions={
<>
- <RecordAction slot="overflow">
+ <RecordAction slot="icon">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderSummary.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderSummary.tsx
index fab933b9ea..75e27daf1b 100644
--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderSummary.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderSummary.tsx
@@ -2,6 +2,7 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { getSalesOrderLineTotal } from "@carbon/documents/utils";
import {
Badge,
Button,
@@ -23,6 +24,7 @@ import {
Tr,
TruncatedTooltipText,
useDisclosure,
+ useViewport,
VStack
} from "@carbon/react";
import type { SalesOrderForProductionCheck } from "@carbon/utils";
@@ -53,6 +55,7 @@ import {
MotionMoney
} from "~/components";
import { Confirm } from "~/components/Modals";
+import { SummaryLineRow } from "~/components/SummaryLineRow";
import {
useCurrencyDecimals,
useCurrencyFormatter,
@@ -79,6 +82,7 @@ const SalesOrderSummary = ({
onEditShippingCost: () => void;
}) => {
const { t } = useLingui();
+ const { isPhone } = useViewport();
const { orderId } = useParams();
if (!orderId) throw new Error("Could not find orderId");
@@ -194,11 +198,11 @@ const SalesOrderSummary = ({
)}
<Card>
<CardHeader>
- <HStack className="justify-between items-center">
- <div className="flex flex-col gap-1">
+ <HStack className="justify-between items-center max-md:min-w-0">
+ <div className="flex flex-col gap-1 max-md:hidden">
<CardTitle>{routeData?.salesOrder.salesOrderId}</CardTitle>
</div>
- <div className="flex flex-col gap-1 items-end">
+ <div className="flex flex-col gap-1 items-end max-md:w-full max-md:min-w-0 max-md:items-start max-md:[&>*]:max-w-full max-md:[&_span]:truncate">
<CustomerAvatar
customerId={routeData?.salesOrder.customerId ?? null}
/>
@@ -262,39 +266,63 @@ const SalesOrderSummary = ({
decimalPlaces={currencyDecimals}
/>
</HStack>
- <HStack className="justify-between text-sm text-muted-foreground w-full">
- {convertedShippingCost > 0 ? (
- <>
- <VStack spacing={0}>
- <span>
- <Trans>Shipping:</Trans>
- </span>
- <Button
- variant="link"
- size="sm"
- className="text-muted-foreground"
- onClick={onEditShippingCost}
- >
- <Trans>Edit Shipping</Trans>
- </Button>
- </VStack>
- <MotionMoney
- value={convertedShippingCost}
- currency={routeData?.salesOrder?.currencyCode ?? "USD"}
- decimalPlaces={currencyDecimals}
- />
- </>
- ) : isEditable ? (
- <Button
- variant="link"
- size="sm"
- className="text-primary"
+ {isPhone ? (
+ // Phones: one tappable Shipping row in place of the Add / Edit
+ // Shipping links.
+ convertedShippingCost > 0 || isEditable ? (
+ <button
+ type="button"
+ className="flex min-h-11 w-full items-center justify-between text-sm text-muted-foreground"
onClick={onEditShippingCost}
>
- <Trans>Add Shipping</Trans>
- </Button>
- ) : null}
- </HStack>
+ <span>
+ <Trans>Shipping:</Trans>
+ </span>
+ <span className="flex items-center gap-1">
+ <MotionMoney
+ value={convertedShippingCost}
+ currency={routeData?.salesOrder?.currencyCode ?? "USD"}
+ decimalPlaces={currencyDecimals}
+ />
+ <LuChevronRight className="size-4" />
+ </span>
+ </button>
+ ) : null
+ ) : (
+ <HStack className="justify-between text-sm text-muted-foreground w-full">
+ {convertedShippingCost > 0 ? (
+ <>
+ <VStack spacing={0}>
+ <span>
+ <Trans>Shipping:</Trans>
+ </span>
+ <Button
+ variant="link"
+ size="sm"
+ className="text-muted-foreground"
+ onClick={onEditShippingCost}
+ >
+ <Trans>Edit Shipping</Trans>
+ </Button>
+ </VStack>
+ <MotionMoney
+ value={convertedShippingCost}
+ currency={routeData?.salesOrder?.currencyCode ?? "USD"}
+ decimalPlaces={currencyDecimals}
+ />
+ </>
+ ) : isEditable ? (
+ <Button
+ variant="link"
+ size="sm"
+ className="text-primary"
+ onClick={onEditShippingCost}
+ >
+ <Trans>Add Shipping</Trans>
+ </Button>
+ ) : null}
+ </HStack>
+ )}
<HStack className="justify-between text-xl font-semibold w-full">
<span>
<Trans>Total:</Trans>
@@ -359,6 +387,8 @@ function LineItems({
const { orderId } = useParams();
if (!orderId) throw new Error("Could not find orderId");
+ const { t } = useLingui();
+ const { isPhone } = useViewport();
const percentFormatter = usePercentFormatter();
// Settlement money at the document currency's configured decimals.
const currencyDecimals = useCurrencyDecimals(currencyCode);
@@ -371,6 +401,42 @@ function LineItems({
);
};
+ // Phones: one row per line that opens the line page (its Edit link, the
+ // badges and the breakdown stay on desktop).
+ if (isPhone) {
+ return (
+ <div className="flex w-full flex-col divide-y divide-border">
+ {lines.map((line) =>
+ line.id ? (
+ <SummaryLineRow
+ key={line.id}
+ to={path.to.salesOrderLine(orderId, line.id)}
+ title={
+ line.salesOrderLineType === "Fixed Asset"
+ ? line.assetReadableId || t`Fixed Asset`
+ : line.itemReadableId
+ }
+ value={
+ <MotionMoney
+ value={getSalesOrderLineTotal(line)}
+ currency={currencyCode}
+ decimalPlaces={currencyDecimals}
+ />
+ }
+ description={line.description}
+ meta={
+ <>
+ {line.saleQuantity} × {formatter.format(line.unitPrice ?? 0)}{" "}
+ {line.unitOfMeasureCode}
+ </>
+ }
+ />
+ ) : null
+ )}
+ </div>
+ );
+ }
+
return (
<VStack spacing={8} className="w-full overflow-hidden">
{lines.map((line) => {
@@ -450,14 +516,7 @@ function LineItems({
>
<HStack spacing={4}>
<MotionMoney
- value={
- ((line?.convertedUnitPrice ?? 0) *
- (line?.saleQuantity ?? 0) +
- (line?.convertedAddOnCost ?? 0) +
- (line?.convertedShippingCost ?? 0)) *
- (1 + (line?.taxPercent ?? 0)) +
- (line?.convertedNonTaxableAddOnCost ?? 0)
- }
+ value={getSalesOrderLineTotal(line)}
currency={currencyCode}
decimalPlaces={currencyDecimals}
/>
@@ -662,14 +721,7 @@ function LineItems({
<Td>Total</Td>
<Td className="text-right">
<MotionMoney
- value={
- ((line.convertedUnitPrice ?? 0) *
- (line.saleQuantity ?? 0) +
- (line.convertedAddOnCost ?? 0) +
- (line.convertedShippingCost ?? 0)) *
- (1 + (line.taxPercent ?? 0)) +
- (line.convertedNonTaxableAddOnCost ?? 0)
- }
+ value={getSalesOrderLineTotal(line)}
currency={currencyCode}
decimalPlaces={currencyDecimals}
/>
diff --git a/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.details.tsx b/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.details.tsx
index 6c2dedde5b..61dec5d32f 100644
--- a/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.details.tsx
+++ b/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.details.tsx
@@ -250,6 +250,7 @@ export default function ItemInventoryRoute() {
}}
quantities={quantities}
storageUnits={storageUnits.options}
+ variant="quantity"
/>
</VStack>
);
diff --git a/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.tsx b/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.tsx
index 953b082989..521e748a5a 100644
--- a/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.tsx
+++ b/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.tsx
@@ -13,6 +13,7 @@ import {
VStack
} from "@carbon/react";
import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { useLingui } from "@lingui/react/macro";
import { useMemo } from "react";
import type {
LoaderFunctionArgs,
@@ -20,6 +21,7 @@ import type {
} from "react-router";
import { Outlet, useLoaderData } from "react-router";
import { useSetAppBarOverride } from "~/components/Layout/Mobile";
+import { RecordHero } from "~/components/Layout/RecordHeader";
import { useUrlParams } from "~/hooks";
import InventoryItemHeader from "~/modules/inventory/ui/Inventory/InventoryItemHeader";
import { getItem, getPickMethod, upsertPickMethod } from "~/modules/items";
@@ -96,23 +98,26 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
export default function ItemInventoryRoute() {
const { item } = useLoaderData<typeof loader>();
+ const { t } = useLingui();
const { isPhone } = useViewport();
const [params] = useUrlParams();
const itemReadableId = item.readableIdWithRevision ?? item.readableId;
const backTo = `${path.to.inventory}?${params.toString()}`;
// Phones show this detail as its own screen: the item ID is the app bar
- // title and Back returns to the list (the panel's ✕ and ID are hidden).
+ // title, "Quantities" its subtitle, and Back returns to the list (the
+ // panel's ✕ and ID are hidden).
const appBarOverride = useMemo(
() =>
isPhone
? {
kind: "pushed" as const,
title: itemReadableId,
+ subtitle: t`Quantities`,
backTo
}
: null,
- [isPhone, itemReadableId, backTo]
+ [isPhone, itemReadableId, backTo, t]
);
useSetAppBarOverride(appBarOverride);
@@ -127,6 +132,7 @@ export default function ItemInventoryRoute() {
compactFocus
>
<ScrollArea className="h-[calc(100dvh-var(--topbar-height)-var(--content-inset))]">
+ <RecordHero subtitle={item.name} />
<InventoryItemHeader
itemReadableId={itemReadableId}
// @ts-expect-error
diff --git a/apps/erp/app/routes/x+/issue+/$id.tsx b/apps/erp/app/routes/x+/issue+/$id.tsx
index 63a2107e76..de8e24fdfc 100644
--- a/apps/erp/app/routes/x+/issue+/$id.tsx
+++ b/apps/erp/app/routes/x+/issue+/$id.tsx
@@ -42,6 +42,7 @@ import { path } from "~/utils/path";
const logger = getLogger("erp", "issue-detail");
export const handle: Handle = {
+ appBarSubtitle: msg`Issue`,
realtime: [
{ table: "nonConformance", column: "id", param: "id" },
{
diff --git a/apps/erp/app/routes/x+/job+/$jobId.tsx b/apps/erp/app/routes/x+/job+/$jobId.tsx
index b5eedb304f..baede00742 100644
--- a/apps/erp/app/routes/x+/job+/$jobId.tsx
+++ b/apps/erp/app/routes/x+/job+/$jobId.tsx
@@ -71,6 +71,7 @@ async function getJobOrderStatus(
}
export const handle: Handle = {
+ appBarSubtitle: msg`Job`,
breadcrumb: detailBreadcrumb(
{ breadcrumb: msg`Jobs`, to: path.to.jobs },
(data) => data?.job?.jobId
diff --git a/apps/erp/app/routes/x+/part+/$itemId.details.tsx b/apps/erp/app/routes/x+/part+/$itemId.details.tsx
index ec848f2d4e..8fe656ea5f 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.details.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.details.tsx
@@ -51,6 +51,7 @@ import {
MakeMethodTools
} from "~/modules/items/ui/Item";
import ItemManufacturingForm from "~/modules/items/ui/Item/ItemManufacturingForm";
+import { methodVersionSlot } from "~/modules/items/ui/Item/MakeMethodTools";
import { ConfigurationParametersForm } from "~/modules/items/ui/Parts";
import type { MethodItemType, MethodType } from "~/modules/shared";
import { getTagsList } from "~/modules/shared";
@@ -293,6 +294,7 @@ export default function PartDetailsRoute() {
makeMethods={makeMethods?.data ?? []}
type="Part"
currentMethodId={methodData.makeMethod.id}
+ versionInSlot
/>
)}
</Await>
@@ -334,6 +336,8 @@ export default function PartDetailsRoute() {
partData.partSummary?.replenishmentSystem ?? ""
) && (
<>
+ {/* Phones: the method version chip, right above the method. */}
+ <methodVersionSlot.Target className="flex md:hidden [&_button]:h-9 [&_button]:rounded-full [&_button]:border [&_button]:border-border [&_button]:bg-card [&_button]:px-3" />
<BillOfProcess
key={`bop:${itemId}`}
makeMethod={methodData.makeMethod}
diff --git a/apps/erp/app/routes/x+/part+/$itemId.tsx b/apps/erp/app/routes/x+/part+/$itemId.tsx
index a4b3e53ec8..d7acf9c1d0 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.tsx
@@ -64,6 +64,7 @@ import { detailBreadcrumb, type Handle } from "~/utils/handle";
import { path } from "~/utils/path";
export const handle: Handle = {
+ appBarSubtitle: msg`Part`,
breadcrumb: detailBreadcrumb(
{ breadcrumb: msg`Parts`, to: path.to.parts },
(data) => data?.partSummary?.readableIdWithRevision
diff --git a/apps/erp/app/routes/x+/picking-list+/$pickingListId.tsx b/apps/erp/app/routes/x+/picking-list+/$pickingListId.tsx
index f9368664a5..8058d8d057 100644
--- a/apps/erp/app/routes/x+/picking-list+/$pickingListId.tsx
+++ b/apps/erp/app/routes/x+/picking-list+/$pickingListId.tsx
@@ -23,6 +23,7 @@ import { detailBreadcrumb, type Handle } from "~/utils/handle";
import { path } from "~/utils/path";
export const handle: Handle = {
+ appBarSubtitle: msg`Picking List`,
realtime: [
{ table: "pickingList", column: "id", param: "pickingListId" },
{
diff --git a/apps/erp/app/routes/x+/production+/planning.tsx b/apps/erp/app/routes/x+/production+/planning.tsx
index 62a6658414..17675dbc94 100644
--- a/apps/erp/app/routes/x+/production+/planning.tsx
+++ b/apps/erp/app/routes/x+/production+/planning.tsx
@@ -26,6 +26,7 @@ import { getGenericQueryFilters } from "~/utils/query";
const WEEKS_TO_PLAN = 12 * 4;
export const handle: Handle = {
+ appBarSubtitle: msg`Production`,
realtime: ["job"],
breadcrumb: msg`Material Planning`,
to: path.to.productionPlanning
diff --git a/apps/erp/app/routes/x+/purchase-order+/$orderId.tsx b/apps/erp/app/routes/x+/purchase-order+/$orderId.tsx
index e303ebc011..67fbf31466 100644
--- a/apps/erp/app/routes/x+/purchase-order+/$orderId.tsx
+++ b/apps/erp/app/routes/x+/purchase-order+/$orderId.tsx
@@ -65,6 +65,7 @@ import { stripSpecialCharacters } from "~/utils/string";
const logger = getLogger("erp", "purchase-order");
export const handle: Handle = {
+ appBarSubtitle: msg`Purchase Order`,
realtime: [
{ table: "purchaseOrder", column: "id", param: "orderId" },
{ table: "purchaseOrderLine", column: "purchaseOrderId", param: "orderId" },
diff --git a/apps/erp/app/routes/x+/purchasing+/planning.tsx b/apps/erp/app/routes/x+/purchasing+/planning.tsx
index 20591bdc8a..f0477b67f2 100644
--- a/apps/erp/app/routes/x+/purchasing+/planning.tsx
+++ b/apps/erp/app/routes/x+/purchasing+/planning.tsx
@@ -26,6 +26,7 @@ import { getGenericQueryFilters } from "~/utils/query";
const WEEKS_TO_PLAN = 12 * 4;
export const handle: Handle = {
+ appBarSubtitle: msg`Purchasing`,
breadcrumb: msg`Material Planning`,
to: path.to.purchasingPlanning
};
diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.tsx
index 67b3abd964..1cc9c13de8 100644
--- a/apps/erp/app/routes/x+/quote+/$quoteId.tsx
+++ b/apps/erp/app/routes/x+/quote+/$quoteId.tsx
@@ -44,6 +44,7 @@ import { detailBreadcrumb, type Handle } from "~/utils/handle";
import { path } from "~/utils/path";
export const handle: Handle = {
+ appBarSubtitle: msg`Quote`,
realtime: [
{ table: "quote", column: "id", param: "quoteId" },
{ table: "quoteLine", column: "quoteId", param: "quoteId" },
diff --git a/apps/erp/app/routes/x+/sales-order+/$orderId.tsx b/apps/erp/app/routes/x+/sales-order+/$orderId.tsx
index 400d54c315..6562e7379a 100644
--- a/apps/erp/app/routes/x+/sales-order+/$orderId.tsx
+++ b/apps/erp/app/routes/x+/sales-order+/$orderId.tsx
@@ -37,6 +37,7 @@ import { detailBreadcrumb, type Handle } from "~/utils/handle";
import { path } from "~/utils/path";
export const handle: Handle = {
+ appBarSubtitle: msg`Sales Order`,
realtime: [
{ table: "salesOrder", column: "id", param: "orderId" },
{ table: "salesOrderLine", column: "salesOrderId", param: "orderId" },
diff --git a/apps/erp/app/utils/handle.ts b/apps/erp/app/utils/handle.ts
index b8b37c8ab3..ce215249f6 100644
--- a/apps/erp/app/utils/handle.ts
+++ b/apps/erp/app/utils/handle.ts
@@ -23,6 +23,9 @@ export type Handle = {
// Phones only: the section switcher for a route that is a module section
// but has no desktop sidebar (desktop is unchanged). Makes it a root screen.
compactSidebar?: ComponentType;
+ // Phones only: the app bar's subtitle under a record's ID ("Sales Order"),
+ // in place of the list crumb. Child routes (a line page) inherit it.
+ appBarSubtitle?: MessageDescriptor;
};
// A breadcrumb label may be plain text/markup or a Lingui MessageDescriptor